erdbpro 3.4.7-rc.38 → 3.4.7-rc.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/dist/assets/{AdminRoute-L67IOqL6.js → AdminRoute-DtQxECkH.js} +2 -2
- package/dist/assets/{Combination-iUqModQP.js → Combination-B64hrXA_.js} +1 -1
- package/dist/assets/{DataViewerModeToolbar-DpuUUpxH.js → DataViewerModeToolbar-AoTGrF0s.js} +1 -1
- package/dist/assets/{DbClientEditorRoute-DLLxQwb9.js → DbClientEditorRoute-BQsu2RPO.js} +1 -1
- package/dist/assets/{DiagramEditorRoute-CLADDbwI.js → DiagramEditorRoute-gB1Tnc1O.js} +1 -1
- package/dist/assets/{DrawingEditorRoute-Cx5d1LPX.js → DrawingEditorRoute-DI8POPT9.js} +2 -2
- package/dist/assets/{DrawingsView-8Bqqa1-H.js → DrawingsView-BB6j7wOc.js} +8 -8
- package/dist/assets/{ERDComments-DyRF9m2d.js → ERDComments-Cv72iUGw.js} +1 -1
- package/dist/assets/{FlowchartEditorRoute-Ddyctcrx.js → FlowchartEditorRoute-8E8F3Oi5.js} +1 -1
- package/dist/assets/{JumpToNode-D2cXYgdt.js → JumpToNode-DfTDRDCJ.js} +1 -1
- package/dist/assets/{LibraryRoute-Cu8kc4Uq.js → LibraryRoute-Dyzti-IB.js} +1 -1
- package/dist/assets/{NoteEditorRoute-BwHXTyYF.js → NoteEditorRoute-DbAY2OPi.js} +2 -2
- package/dist/assets/{NotesView-BetVH6gU.js → NotesView-BwYUJH_1.js} +1 -1
- package/dist/assets/{TeamInventoryRoute-DsDOchEM.js → TeamInventoryRoute-uTpVstiC.js} +1 -1
- package/dist/assets/{TeamManagementRoute-DjVvQqbb.js → TeamManagementRoute-wh96POof.js} +1 -1
- package/dist/assets/{TrashView-B46B8eek.js → TrashView-evH7nlfT.js} +1 -1
- package/dist/assets/{UserManagementRoute-BAENUAIi.js → UserManagementRoute-HIUP43af.js} +1 -1
- package/dist/assets/{WorkspaceProvider-BL3c_IQs.js → WorkspaceProvider-Cu8H8gxv.js} +3 -3
- package/dist/assets/{abnfDiagram-VCTEODGH-C1SbyaoV.js → abnfDiagram-VCTEODGH-OYk5XLVx.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-DXTKuxgk.js → ar-SA-G6X2FPQ2-DQvsVuH2.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-Bx8OMXT_.js → architectureDiagram-5GKGNRK7-VFYzzmKj.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-BW6VlK4o.js → az-AZ-76LH7QW2-D5ZD3h7-.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-BHynx4yd.js → bg-BG-XCXSNQG7-D6uoADq-.js} +1 -1
- package/dist/assets/{blockDiagram-I7D4REHJ-CmEZJjDT.js → blockDiagram-I7D4REHJ-ByoqqNwj.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-Dnho7u-A.js → bn-BD-2XOGV67Q-BYxuUXjL.js} +1 -1
- package/dist/assets/{c4Diagram-7LVT6UL2-X_-DQ7YR.js → c4Diagram-7LVT6UL2-BYQQeJkh.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-C6ZTyYKK.js → ca-ES-6MX7JW3Y-pMCVv-1Y.js} +1 -1
- package/dist/assets/channel-BrMac4y8.js +1 -0
- package/dist/assets/{chunk-4HAMMTFA-DVdpRLD2.js → chunk-4HAMMTFA-XhQXdgG_.js} +1 -1
- package/dist/assets/{chunk-75Z2AOVW-Clyl_xti.js → chunk-75Z2AOVW-Bh3l3zXM.js} +1 -1
- package/dist/assets/{chunk-DU6HZSFF-uQ3t8yma.js → chunk-DU6HZSFF-MR_SZWjM.js} +1 -1
- package/dist/assets/{chunk-EIO257PC-DFQieNuw.js → chunk-EIO257PC-BxPlG5lK.js} +1 -1
- package/dist/assets/{chunk-F27PBJKO-BtUwenj9.js → chunk-F27PBJKO-CmXI9imp.js} +1 -1
- package/dist/assets/{chunk-GMAD6QVW-BlI2nozc.js → chunk-GMAD6QVW-AOjEZQs5.js} +1 -1
- package/dist/assets/{chunk-GVQU2GXP-qK26anC1.js → chunk-GVQU2GXP-CY_RE5vu.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-BRUgasvo.js → chunk-IMKFNOWR-DaDFYwvW.js} +1 -1
- package/dist/assets/{chunk-L3NEJ4N5-B1y4590G.js → chunk-L3NEJ4N5-CFIvUVH-.js} +1 -1
- package/dist/assets/{chunk-OSK3NFVY-D-8X8m4U.js → chunk-OSK3NFVY-D74Yr7yM.js} +1 -1
- package/dist/assets/{chunk-P2QGCYS3-B0rXDK0H.js → chunk-P2QGCYS3-C7qDAi-K.js} +1 -1
- package/dist/assets/{chunk-POPQ4Y6H-D-wITa7K.js → chunk-POPQ4Y6H-C1vqOSuv.js} +1 -1
- package/dist/assets/{chunk-PWAF6VOD-BBD8aKGr.js → chunk-PWAF6VOD-2d3rPdGs.js} +1 -1
- package/dist/assets/{chunk-SHT3W25Y-lJyxUoWh.js → chunk-SHT3W25Y-B1R9SpdT.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-Y1NKseog.js → chunk-SVP7TREG-CUL24AKX.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-DqTd8JtV.js → chunk-TICWLB2K-D8rRyBEQ.js} +1 -1
- package/dist/assets/classDiagram-ZZMXUADV-DaWBRIph.js +1 -0
- package/dist/assets/classDiagram-v2-VYDZK3BY-DaWBRIph.js +1 -0
- package/dist/assets/{cs-CZ-2BRQDIVT-UL7Vn9Od.js → cs-CZ-2BRQDIVT-Cm-lfrEP.js} +1 -1
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-QJTTKoig.js → cynefinDiagram-5FMLGOSQ-BdtiF9pz.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-o4BtjkOA.js → da-DK-5WZEPLOC-CDhmeA76.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-Bk9T4arA.js → dagre-GXQ25YYZ-5gBsov7e.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-CH_LvzGM.js → de-DE-XR44H4JA-BA4YkX5J.js} +1 -1
- package/dist/assets/{diagram-S7CK7UJ4-j3I1PwaP.js → diagram-S7CK7UJ4-BaTJU1t6.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-DZsD2kIt.js → diagram-UQ7AKVKN-B4EjYw7M.js} +1 -1
- package/dist/assets/{diagram-VSXAHHWV-B1lMcVGH.js → diagram-VSXAHHWV-XefB_T0d.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-D8QndCJd.js → diagram-VX7I27RA-nbRPxWbZ.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-BYUgI434.js → diagram-Z3DM3KII-DtYz5Z_y.js} +1 -1
- package/dist/assets/{dist-fxh7uRnt.js → dist-Sd9sH_HT.js} +4 -4
- package/dist/assets/{ebnfDiagram-PWID7BFC-BRvUNi0Z.js → ebnfDiagram-PWID7BFC-XiSVVQd3.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-CiA0IvM3.js → el-GR-BZB4AONW-BTuLrbLA.js} +1 -1
- package/dist/assets/{en-B4ZKOASM-I9zfRWkC.js → en-B4ZKOASM-NalYYwE4.js} +1 -1
- package/dist/assets/{erDiagram-RLTQ6QDP-Dwz05Xtp.js → erDiagram-RLTQ6QDP-0n8JGdjH.js} +1 -1
- package/dist/assets/{erdActions-dUkJOxuT.js → erdActions-CFvkilVV.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-VPxI7ekn.js → es-ES-U4NZUMDT-C1QYKZv8.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-DwxQOWem.js → eu-ES-A7QVB2H4-B_PLAvoa.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-DEu8yW9P.js → fa-IR-HGAKTJCU-Di8kDwIE.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-D8tky5VF.js → fi-FI-Z5N7JZ37-BLDebQyy.js} +1 -1
- package/dist/assets/flowDiagram-HODETNUW-Cqn82-7I.js +1 -0
- package/dist/assets/{fr-FR-RHASNOE6-Duorn7my.js → fr-FR-RHASNOE6-Dwqv87rS.js} +1 -1
- package/dist/assets/{ganttDiagram-EL5Y4UJY-BOwdu5uF.js → ganttDiagram-EL5Y4UJY-BB96mGjl.js} +1 -1
- package/dist/assets/{gitGraphDiagram-WWUBYQGX-LWA7S7nk.js → gitGraphDiagram-WWUBYQGX-DNXhkh4h.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-CBpOp7z3.js → gl-ES-HMX3MZ6V-C9qvbwyk.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-NmzaNmp2.js → he-IL-6SHJWFNN-DuQ8Wyh1.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-Ds8ZSHBS.js → hi-IN-IWLTKZ5I-BLrBNzEM.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-6OaH_dxH.js → hu-HU-A5ZG7DT2-BGJ1HbjF.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-9_z4IM-b.js → id-ID-SAP4L64H-0fHaABpq.js} +1 -1
- package/dist/assets/{image-GAAHSSAO-Dc29oJpA.js → image-GAAHSSAO-BZnl0I1S.js} +1 -1
- package/dist/assets/{index-DYlhlMY7.js → index-C_WsbRA2.js} +4 -4
- package/dist/assets/{infoDiagram-27XIBGKW-DlklBpDt.js → infoDiagram-27XIBGKW-CXwVDwBa.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-BoeBzFTG.js → ishikawaDiagram-5VMMS53U-CrVU7vYt.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-BsDa5xtN.js → it-IT-JPQ66NNP-bKkX2qV9.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-BHlQFrgc.js → ja-JP-DBVTYXUO-DS1fvl8w.js} +1 -1
- package/dist/assets/{journeyDiagram-3NMN7TZE-BMdqz0rj.js → journeyDiagram-3NMN7TZE-BO04hpk9.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-CU4_6GSP.js → kaa-6HZHGXH3-DmCRAfHD.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-D4S42s0t.js → kab-KAB-ZGHBKWFO-C-LYCWJn.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-Dt1ef1J2.js → kanban-definition-UXKFOSKX-CUJkzEdo.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-CrbUHXYX.js → kk-KZ-P5N5QNE5-DerNDQrj.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-D1hsKAL8.js → km-KH-HSX4SM5Z-BfknLya1.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-CN8GUvDK.js → ko-KR-MTYHY66A-JmVCxxwB.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-DXt5Y0Rt.js → ku-TR-6OUDTVRD-B-gz8UPk.js} +1 -1
- package/dist/assets/{line-Cr63L6Zg.js → line-SVQeKbQl.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-B_KQFd1O.js → lt-LT-XHIRWOB4-Dp-_q2vZ.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-CrdbTTnU.js → lv-LV-5QDEKY6T-Dti3k2Lh.js} +1 -1
- package/dist/assets/{mindmap-definition-YA3MSWOX-DZgySv83.js → mindmap-definition-YA3MSWOX-BCdfcub0.js} +1 -1
- package/dist/assets/{mr-IN-CRQNXWMA-BR0AS_ED.js → mr-IN-CRQNXWMA-C4_WRwuI.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-CEszpLgR.js → my-MM-5M5IBNSE-MCQC4RZS.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-Bs44UBnp.js → nb-NO-T6EIAALU-qfzJrjbf.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-DIJu-Nwo.js → nl-NL-IS3SIHDZ--g7lvpdz.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-DQSw2Yy9.js → nn-NO-6E72VCQL-DUbsVZ2Y.js} +1 -1
- package/dist/assets/{note-importer-m3w8q3mT.js → note-importer-NTFD3Pan.js} +2 -2
- package/dist/assets/{oc-FR-POXYY2M6-Cbtr0HbP.js → oc-FR-POXYY2M6-SZNeV9_6.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-t4cRbVKE.js → pa-IN-N4M65BXN-shvKvmrJ.js} +1 -1
- package/dist/assets/{pegDiagram-XKGWAZYB-UOYSX3Xk.js → pegDiagram-XKGWAZYB-BhQVKeOo.js} +1 -1
- package/dist/assets/percentages-BXMCSKIN-CZbJzcX-.js +1 -0
- package/dist/assets/{pieDiagram-E7YTZNPT-CvKWgtgi.js → pieDiagram-E7YTZNPT-DDqUKq9a.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-BMeS3W0t.js → pl-PL-T2D74RX3-BviLqpHS.js} +1 -1
- package/dist/assets/{popover-0VFLdeui.js → popover-Bc3z69TT.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-DUMmETxp.js → pt-BR-5N22H2LF-DJsCWm-b.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-JxIW8Ji7.js → pt-PT-UZXXM6DQ-CmQ4hpVn.js} +1 -1
- package/dist/assets/{quadrantDiagram-AXDQQJYC-BEDJh1XX.js → quadrantDiagram-AXDQQJYC-BiGKp6Rp.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-C9sg1bna.js → railroadDiagram-O6MQD6OU-jDUnlCLp.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-CsJla7Yz.js → requirementDiagram-BXWQKSXE-apmKL4qG.js} +1 -1
- package/dist/assets/{ro-RO-JPDTUUEW-3krlr3l7.js → ro-RO-JPDTUUEW-DJ8n_0wI.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-B6wN7m6V.js → ru-RU-B4JR7IUQ-DtEg5LST.js} +1 -1
- package/dist/assets/{sankeyDiagram-P5KCCOFB-yFafENY-.js → sankeyDiagram-P5KCCOFB-BuWXIq2f.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-Be25mT8h.js → sequenceDiagram-WJ2MYXX4-BUDHMOf8.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-BD5ScUHE.js → si-LK-N5RQ5JYF-mUId1TWs.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-DjcvOPwX.js → sk-SK-C5VTKIMK-B77On-x4.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-DZsfaqar.js → sl-SI-NN7IZMDC-BWPngwa_.js} +1 -1
- package/dist/assets/{stateDiagram-D77RDMKH-DolWnDim.js → stateDiagram-D77RDMKH-Dd18BLUv.js} +1 -1
- package/dist/assets/stateDiagram-v2-MP3YSRHH-B2uktPB-.js +1 -0
- package/dist/assets/subset-shared.chunk-CW4vyRWX.js +1 -0
- package/dist/assets/{subset-worker.chunk-QsPJBLvF.js → subset-worker.chunk-CqFyfj_A.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-CnkVnN78.js → sv-SE-XGPEYMSR-BDRAx--p.js} +1 -1
- package/dist/assets/{swimlanes-42K2YHIH-Dlxe9WGR.js → swimlanes-42K2YHIH-DsGd62qg.js} +1 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-jXzta_IJ.js +8 -0
- package/dist/assets/{ta-IN-2NMHFXQM-BXLAV2S0.js → ta-IN-2NMHFXQM-YxR9MkA0.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-D2qtDZEy.js → th-TH-HPSO5L25-BpSxLSMH.js} +1 -1
- package/dist/assets/{timeline-definition-24CTP7MA-Dg2_Mirv.js → timeline-definition-24CTP7MA-CR3Ldy_I.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-YtPdahf7.js → tr-TR-DEFEU3FU-DDEGtbba.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-D-9RLKgK.js → uk-UA-QMV73CPH-DOwew-Od.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-Bwrsg7HH.js → vennDiagram-4TSXK5OY-CHde0TBS.js} +1 -1
- package/dist/assets/{vi-VN-M7AON7JQ-C_nYbh70.js → vi-VN-M7AON7JQ-DGh6WUVG.js} +1 -1
- package/dist/assets/{w3c-keyname-CHvXxlOf.js → w3c-keyname-BULLf9RX.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-DOXy3X4F.js → wardleyDiagram-VM6X3IG4-oGQjcb8A.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-aAKPSq9A.js → xychartDiagram-S5SC5T6Z-B24pZiG7.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-D2imuHUX.js → zh-CN-LNUGB5OW-C6tkWab-.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-DVrSj6sN.js → zh-HK-E62DVLB3-B4BiFtic.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-Ccp0vvfR.js → zh-TW-RAJ6MFWO-C1tdVaPx.js} +1 -1
- package/dist/index.html +6 -6
- package/dist-server/index.js +125 -125
- package/package.json +1 -1
- package/dist/assets/channel-DFXCQ8Cg.js +0 -1
- package/dist/assets/classDiagram-ZZMXUADV-pR7dbBVE.js +0 -1
- package/dist/assets/classDiagram-v2-VYDZK3BY-pR7dbBVE.js +0 -1
- package/dist/assets/flowDiagram-HODETNUW-PvIvZYxI.js +0 -1
- package/dist/assets/percentages-BXMCSKIN-Br1vB5jq.js +0 -1
- package/dist/assets/stateDiagram-v2-MP3YSRHH-cRTgNiJ3.js +0 -1
- package/dist/assets/subset-shared.chunk-CqONSGFV.js +0 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-CdrGMf5p.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/event-DtFyPu7u.js","assets/core-DNaw6KYU.js","assets/app-Dwb58oCT.js","assets/image-DXXwzuA0.js","assets/dist-js-CoMyUP6l.js","assets/rolldown-runtime-BCiCTKAo.js","assets/api-m1FDJyHM.js","assets/preload-helper-BLdHbfdN.js","assets/NoteEditorRoute-
|
|
2
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./rolldown-runtime-BCiCTKAo.js";import{n as o,t as s}from"./jsx-runtime-Cl3nUQcN.js";import{a as c,i as l,l as u,n as d,r as f,t as p}from"./dist-B2tJVU7c.js";import{a as m,c as h,d as g,f as _,i as v,l as y,n as b,o as x,s as S,t as C,u as w}from"./chunk-BV7QT456-B3UxAK3W.js";import{A as T,B as E,C as D,D as O,G as k,I as A,J as j,L as M,P as N,R as P,U as F,V as I,W as L,X as R,Z as ee,_ as te,a as ne,at as re,c as ie,ct as z,d as ae,et as oe,f as se,ft as ce,g as le,h as ue,it as de,j as B,k as fe,l as pe,m as me,n as he,nt as ge,o as _e,p as ve,pt as V,q as ye,r as be,rt as xe,s as Se,u as Ce,v as we,x as Te,z as Ee}from"./note-importer-m3w8q3mT.js";import{a as De,at as Oe,f as ke,g as Ae,h as je,i as Me,it as Ne,l as Pe,m as Fe,ot as Ie,p as Le,r as Re,s as ze,t as H,u as Be}from"./button-BoRKNt3a.js";import{$t as Ve,B as He,Bt as Ue,H as We,Ht as Ge,Kt as Ke,Lt as qe,R as Je,Rt as Ye,S as Xe,St as Ze,Ut as Qe,V as $e,Vt as et,Wt as tt,_ as nt,a as rt,b as it,c as at,en as ot,g as st,gn as ct,h as lt,l as ut,lt as dt,m as ft,n as pt,o as mt,p as ht,pt as gt,qt as _t,s as vt,u as yt,ut as bt,v as xt,x as St,y as Ct,zt as wt}from"./useOpenInteractionType-8RZuPnpG.js";import{a as Tt,i as Et,n as Dt,o as Ot,r as kt,s as At,t as jt}from"./useField-BVrxe_qk.js";import{a as Mt,c as Nt,d as Pt,f as Ft,i as It,l as Lt,n as Rt,o as zt,p as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"./popover-0VFLdeui.js";import{T as Gt,a as Kt,c as qt,d as Jt,i as Yt,l as Xt,m as Zt,n as Qt,o as $t,r as en,s as tn,t as nn,u as rn}from"./dropdown-menu-rZKTxsXp.js";import{t as an}from"./check-CkCHT6D9.js";import{r as on}from"./getPseudoElementBounds-Dgxi_dXc.js";import{a as sn,i as cn,r as ln,t as un}from"./CompositeList-fgcZ0MvU.js";import{$ as dn,B as fn,Ct as pn,D as mn,F as hn,H as gn,I as _n,K as vn,L as yn,O as bn,P as xn,Q as Sn,R as Cn,Tt as wn,U as Tn,V as En,W as Dn,X as On,Z as kn,at as An,bt as jn,ct as Mn,dt as Nn,et as Pn,ft as Fn,ht as In,it as Ln,k as Rn,lt as zn,mt as Bn,nt as Vn,pt as Hn,r as Un,rt as Wn,st as Gn,t as Kn,tt as qn,ut as Jn,wt as Yn,xt as Xn,yt as Zn,z as Qn}from"./ERDComments-DyRF9m2d.js";import{n as $n,t as er}from"./link-2-BrX-3vw2.js";import{C as tr,S as nr,T as rr,_ as ir,b as ar,c as or,g as sr,h as cr,i as lr,l as ur,n as dr,r as fr,t as pr,v as mr,w as hr,x as gr,y as _r}from"./w3c-keyname-CHvXxlOf.js";import{t as vr}from"./chevron-left-CB01oDjc.js";import{a as yr,d as br,i as xr,n as Sr,o as Cr,r as wr,s as Tr,t as Er}from"./select-pQS-1nhx.js";import{n as Dr,r as Or,t as kr}from"./ConfirmModal-DJuZVQTe.js";import{n as Ar,r as jr,t as Mr}from"./pen-tool-DmvCCYqc.js";import{t as Nr}from"./ellipsis-BGAMAt1v.js";import{a as Pr,i as Fr,n as Ir,o as Lr,r as Rr,t as zr}from"./field-n9pl0vBs.js";import{t as Br}from"./hard-drive-CrTpFIk_.js";import{t as Vr}from"./message-square-D0gsxj3O.js";import{t as Hr}from"./refresh-cw-B1eEBXCn.js";import{a as Ur,c as Wr,d as Gr,f as Kr,i as qr,l as Jr,n as Yr,o as Xr,r as Zr,s as Qr,t as $r,u as ei}from"./dialog-C2aDTmOl.js";import{t as ti}from"./sparkles-DxlLz1gp.js";import{t as ni}from"./trash-2-DPFpHyly.js";import{C as ri,_ as ii,a as ai,b as oi,c as si,g as ci,i as li,l as ui,n as di,o as fi,p as pi,r as mi,s as hi,t as gi,u as _i,v as vi,y as yi}from"./alert-dialog-WL8sXxIT.js";import{t as bi}from"./preload-helper-BLdHbfdN.js";import{a as xi,c as Si,i as Ci,n as wi,o as Ti,s as Ei,t as Di}from"./api-m1FDJyHM.js";import{t as Oi}from"./input-D_eLLMB7.js";import{t as ki}from"./useCompositeItem-DuwIR47L.js";import{i as Ai,n as ji}from"./fileOwnership-DvxzSccE.js";import{C as Mi,D as Ni,E as Pi,I as Fi,L as Ii,S as Li,T as Ri,_ as zi,a as Bi,b as Vi,c as Hi,g as Ui,h as Wi,l as Gi,n as Ki,r as qi,s as Ji,t as Yi,v as Xi,w as Zi,x as Qi,y as $i}from"./WorkspaceProvider-BL3c_IQs.js";import{t as ea}from"./localPersistence-CGAJ2Ky5.js";import{n as ta,t as na}from"./useAuth-ekcrHcTV.js";import{i as ra}from"./core-DNaw6KYU.js";import{n as ia,t as aa}from"./WorkspaceContext-CitlpD55.js";import{t as oa}from"./label-CNlirj1C.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var sa=a((e=>{var t=u();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))(),U=r(o(),1),ca=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},la=U.createContext(void 0),ua={setTheme:e=>{},themes:[]},da=()=>U.useContext(la)??ua;U.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return U.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${ca.toString()})(${u})`}})});var fa=ze(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),pa=ze(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ma=ze(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),ha=ze(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),ga=ze(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),_a=ze(`badge-alert`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),va=ze(`book-text`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]),ya=ze(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ba=ze(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),xa=ze(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Sa=ze(`calculator`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`,key:`x4nwl0`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`,key:`wjye3r`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]),Ca=ze(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),wa=ze(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Ta=ze(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Ea=ze(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Da=ze(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),Oa=ze(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ka=ze(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Aa=ze(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ja=ze(`clock-3`,[[`path`,{d:`M12 6v6h4`,key:`135r8i`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ma=ze(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Na=ze(`cloud-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193`,key:`yfwify`}],[`path`,{d:`M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07`,key:`jlfiyv`}]]),Pa=ze(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Fa=ze(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ia=ze(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),La=ze(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ra=ze(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),za=ze(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ba=ze(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Va=ze(`file-box`,[[`path`,{d:`M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`16lz6z`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z`,key:`99pj1s`}],[`path`,{d:`M7 17v5`,key:`1yj1jh`}],[`path`,{d:`M11.7 14.2 7 17l-4.7-2.8`,key:`1yk8tc`}]]),Ha=ze(`file-code`,[[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}]]),Ua=ze(`file-down`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),Wa=ze(`file-json`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Ga=ze(`file-pen`,[[`path`,{d:`M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5`,key:`1couwa`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`1y4qbx`}]]),Ka=ze(`file-type-2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M2 13v-1h6v1`,key:`1dh9dg`}],[`path`,{d:`M5 12v6`,key:`150t9c`}],[`path`,{d:`M4 18h2`,key:`1xrofg`}]]),qa=ze(`file-type`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M9 13v-1h6v1`,key:`1bb014`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`M11 18h2`,key:`12mj7e`}]]),Ja=ze(`file`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Ya=ze(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),Xa=ze(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),Za=ze(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Qa=ze(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),$a=ze(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),eo=ze(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),to=ze(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),no=ze(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ro=ze(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),io=ze(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),ao=ze(`heart`,[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]),oo=ze(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),so=ze(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),co=ze(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),lo=ze(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),uo=ze(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),fo=ze(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),po=ze(`layout-panel-left`,[[`rect`,{width:`7`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`2obqm`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),mo=ze(`library`,[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]),ho=ze(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),go=ze(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),_o=ze(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),vo=ze(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),yo=ze(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),bo=ze(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),xo=ze(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),So=ze(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Co=ze(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),wo=ze(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),To=ze(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Eo=ze(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Do=ze(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Oo=ze(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),ko=ze(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Ao=ze(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),jo=ze(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Mo=ze(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),No=ze(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Po=ze(`rotate-ccw-key`,[[`path`,{d:`m14.5 9.5 1 1`,key:`159eiq`}],[`path`,{d:`m15.5 8.5-4 4`,key:`iirg3q`}],[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.74 9.74 0 0 0-6.74 2.74L3 8`,key:`g2jlw`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`circle`,{cx:`10`,cy:`14`,r:`2`,key:`1239so`}]]),Fo=ze(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Io=ze(`server-cog`,[[`path`,{d:`m10.852 14.772-.383.923`,key:`11vil6`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`,key:`1v3clb`}],[`path`,{d:`m13.148 9.228.383-.923`,key:`t2zzyc`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`,key:`1bxfiv`}],[`path`,{d:`m14.772 10.852.923-.383`,key:`k9m8cz`}],[`path`,{d:`m14.772 13.148.923.383`,key:`1xvhww`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`,key:`tn8das`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`,key:`1g2pve`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M6 6h.01`,key:`1utrut`}],[`path`,{d:`m9.228 10.852-.923-.383`,key:`1wtb30`}],[`path`,{d:`m9.228 13.148-.923.383`,key:`1a830x`}]]),Lo=ze(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ro=ze(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),zo=ze(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Bo=ze(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Vo=ze(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ho=ze(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Uo=ze(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Wo=ze(`sticky-note`,[[`path`,{d:`M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z`,key:`qazsjp`}],[`path`,{d:`M15 3v4a2 2 0 0 0 2 2h4`,key:`40519r`}]]),Go=ze(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ko=ze(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),qo=ze(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Jo=ze(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Yo=ze(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),Xo=ze(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Zo=ze(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),Qo=ze(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),$o=ze(`users-round`,[[`path`,{d:`M18 21a8 8 0 0 0-16 0`,key:`3ypg7q`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`,key:`10s06x`}]]),es=ze(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),ts=ze(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),ns=ze(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),W=s(),rs=({...e})=>{let{theme:t=`system`}=da();return(0,W.jsx)(p,{theme:t,className:`toaster group`,richColors:!0,icons:{success:(0,W.jsx)(wn,{className:`size-4`}),info:(0,W.jsx)(Dr,{className:`size-4`}),warning:(0,W.jsx)(ri,{className:`size-4`}),error:(0,W.jsx)(Do,{className:`size-4`}),loading:(0,W.jsx)(vo,{className:`size-4 animate-spin`})},style:{"--border-radius":`var(--radius)`},toastOptions:{classNames:{toast:`cn-toast`}},...e})},is=U.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,W.jsx)(`div`,{ref:r,"data-slot":`card`,"data-size":t,className:c(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n}));is.displayName=`Card`;var as=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-header`,className:c(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t}));as.displayName=`CardHeader`;var os=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-title`,className:c(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t}));os.displayName=`CardTitle`;var ss=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-description`,className:c(`text-sm text-muted-foreground`,e),...t}));ss.displayName=`CardDescription`;var cs=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-action`,className:c(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t}));cs.displayName=`CardAction`;var ls=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-content`,className:c(`px-4 group-data-[size=sm]/card:px-3`,e),...t}));ls.displayName=`CardContent`;var us=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-footer`,className:c(`flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3`,e),...t}));us.displayName=`CardFooter`;var ds=U.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});function fs(e=!1){let t=U.useContext(ds);if(!t&&!e)throw Error(Ne(86));return t}var ps=U.createContext({disabled:!1});function ms(){return U.useContext(ps)}var hs=U.createContext(void 0);function gs(e=!0){let t=U.useContext(hs);if(t===void 0&&!e)throw Error(Ne(3));return t}function _s({configured:e,loginUrl:t,onLogin:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e=new URL(window.location.href);i(e.searchParams.get(`sso_link`)===`required`);let t=e.searchParams.get(`error`);t&&(d.error(t),e.searchParams.delete(`error`),window.history.replaceState({},document.title,`${e.pathname}${e.search}`))},[]);let l=()=>{i(!1),o(``);let e=new URL(window.location.href);e.searchParams.delete(`sso_link`),window.history.replaceState({},document.title,`${e.pathname}${e.search}`)};return(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(is,{className:`w-full max-w-sm`,children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(os,{children:r?`Link your existing Cloud account`:`Sign in to ERD Builder Pro Cloud`}),(0,W.jsx)(ss,{children:r?`This verified SSO email already belongs to a Cloud account. Enter that account's current password to confirm ownership.`:`Your account and subscription are managed by ERDBPro SaaS.`})]}),(0,W.jsx)(ls,{children:r?(0,W.jsx)(`form`,{onSubmit:async e=>{e.preventDefault(),c(!0);try{let e=await wi(`/api/sso/link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:a})}),t=await e.json();if(!e.ok){d.error(t.error||`Unable to link the existing Cloud account`);return}l(),n(t.user),d.success(`Existing Cloud account linked successfully`)}catch{d.error(`Unable to link the existing Cloud account`)}finally{c(!1)}},children:(0,W.jsxs)(Rr,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`sso-link-password`,children:`Current Cloud password`}),(0,W.jsx)(Oi,{id:`sso-link-password`,type:`password`,autoComplete:`current-password`,required:!0,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(Ir,{children:`Your ERDBPro SaaS password is not requested here.`})]}),(0,W.jsxs)(zr,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(H,{type:`submit`,disabled:s,className:`w-full`,children:s?`Verifying account...`:`Verify and link account`}),(0,W.jsx)(H,{type:`button`,variant:`outline`,className:`w-full`,onClick:l,children:`Cancel`})]})]})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(H,{className:`w-full`,disabled:!e,onClick:()=>window.location.assign(`${xi()}${t}`),children:[(0,W.jsx)(bo,{"data-icon":`inline-start`}),`Continue with ERDBPro SSO`]}),!e&&(0,W.jsx)(`p`,{className:`mt-3 text-center text-sm text-destructive`,children:`SSO configuration is incomplete.`})]})})]})})}function vs({onLogin:e,onGuestLogin:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(`password`),[E,D]=(0,U.useState)(!0),[O,k]=(0,U.useState)(`/api/sso/login`);(0,U.useEffect)(()=>{wi(`/api/auth-config`,{cache:`no-store`}).then(e=>e.json()).then(e=>{x(e.guest_mode!==!1),C(e.needs_setup===!0||e.needsSetup===!0),T((e.auth_mode??e.authMode)===`sso`?`sso`:`password`),D((e.sso_configured??e.ssoConfigured)!==!1),k(e.sso_login_url??e.ssoLoginUrl??`/api/sso/login`)}).catch(()=>C(!1))},[]);let A=Ei(),j=Ti()===`cli`,M=(0,U.useRef)(!0),N=(0,U.useRef)(0);if((0,U.useEffect)(()=>{if(!A)return;let t=!1;return(async()=>{for(;!t&&M.current;){try{let n=await wi(`/api/me`);if(n.ok){let r=await n.json();if(r.authenticated&&!t){r.token&&Si(r.token),e(r.user);return}}else if(n.status===503){let e=await n.json().catch(()=>({}));if(e.db_error&&!t){y(e.message||`Database initialization failed. Check logs for details.`);return}}}catch{}if(N.current++,N.current>=20&&!t){y(j?`Unable to connect to the CLI backend server. Check ~/.erdbpro/logs/ for server logs.`:`Unable to connect to the desktop backend server. Check the application logs.`);return}t||await new Promise(e=>setTimeout(e,1e3))}})(),()=>{t=!0}},[j,A,e]),A)return v?(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(`div`,{className:`max-w-md w-full rounded-lg border border-red-800 bg-red-950/40 p-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(`span`,{className:`text-red-400 text-lg`,children:`⚠️`}),(0,W.jsx)(`h2`,{className:`text-red-300 font-semibold`,children:`Startup Error`})]}),(0,W.jsx)(`p`,{className:`text-red-200/80 text-sm mb-4`,children:v}),(0,W.jsxs)(`div`,{className:`text-xs text-red-300/60 space-y-1`,children:[(0,W.jsxs)(`p`,{children:[`Log file: `,(0,W.jsx)(`code`,{className:`text-red-200/80`,children:j?`~/.erdbpro/logs/server-*.err.log`:`~/Library/Logs/com.erdbuilderpro.app/server-startup.log`})]}),(0,W.jsx)(`p`,{children:j?`Try restarting the CLI. If the issue persists, inspect the latest server error log.`:`Try restarting the app. If the issue persists, ensure Node.js is installed.`})]})]})}):(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,W.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connecting...`})]})});if(S===null)return(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6`,children:(0,W.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent`})});let P=S;return w===`sso`?(0,W.jsx)(_s,{configured:E,loginUrl:O,onLogin:e}):(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsx)(`div`,{className:`w-full max-w-sm`,children:(0,W.jsx)(`div`,{className:c(`flex flex-col gap-6`),children:(0,W.jsxs)(is,{children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(os,{children:P?`Create administrator account`:`Login to your account`}),(0,W.jsx)(ss,{children:P?`Set the first administrator email and password for this Self-host installation.`:`Enter your email below to login to your account`})]}),(0,W.jsx)(ls,{children:(0,W.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),P&&o!==l)d.error(`Passwords do not match`);else{_(!0);try{let t=await wi(P?`/api/setup`:`/api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(P?{name:n,email:i,password:o,confirmPassword:l}:{email:i,password:o})});if(t.ok){let n=await t.json();n.token&&Si(n.token),e(n.user),d.success(P?`Administrator account created!`:`Welcome back!`)}else{let e=await t.json();d.error(e.error||`Login failed`)}}catch(e){console.error(`Login error:`,e);let t=e instanceof Error?e.message:`An unexpected error occurred`;d.error(t)}finally{_(!1)}}},children:(0,W.jsxs)(Rr,{children:[P&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`name`,children:`Name`}),(0,W.jsx)(Oi,{id:`name`,type:`text`,placeholder:`Enter administrator name`,required:!0,value:n,onChange:e=>r(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`email`,children:`Email`}),(0,W.jsx)(Oi,{id:`email`,type:`email`,placeholder:`m@example.com`,required:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.jsx)(Fr,{htmlFor:`password`,children:`Password`})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`password`,type:f?`text`:`password`,placeholder:P?`Create a password`:`Enter your password`,required:!0,value:o,onChange:e=>s(e.target.value),className:`pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground focus:outline-none cursor-pointer`,"aria-label":f?`Hide password`:`Show password`,children:f?(0,W.jsx)(Lr,{className:`h-4 w-4`}):(0,W.jsx)(Ba,{className:`h-4 w-4`})})]})]}),P&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`confirm-password`,children:`Confirm Password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`confirm-password`,type:m?`text`:`password`,placeholder:`Re-enter your password`,required:!0,value:l,onChange:e=>u(e.target.value),className:`pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground focus:outline-none cursor-pointer`,"aria-label":m?`Hide confirm password`:`Show confirm password`,children:m?(0,W.jsx)(Lr,{className:`h-4 w-4`}):(0,W.jsx)(Ba,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(zr,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(H,{type:`submit`,disabled:g,className:`w-full`,children:g?P?`Creating account...`:`Logging in...`:P?`Create administrator`:`Login`}),b&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative my-2`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`span`,{className:`w-full border-t`})}),(0,W.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,W.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`Or`})})]}),(0,W.jsx)(H,{type:`button`,variant:`outline`,className:`w-full`,onClick:()=>{t?.(),d.success(`Welcome! You're in Guest Mode.`)},children:`Try as Guest (Local Mode)`})]}),P&&(0,W.jsx)(Ir,{className:`text-center`,children:`This setup is available only once for the empty database.`})]})]})})})]})})})})}var ys=(0,U.createContext)({});function bs(e){let t=(0,U.useRef)(null);return t.current===null&&(t.current=e()),t.current}var xs=(0,U.createContext)(null),Ss=(0,U.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`}),Cs=class extends U.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){let e=this.props.sizeRef.current;e.height=t.offsetHeight||0,e.width=t.offsetWidth||0,e.top=t.offsetTop,e.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function ws({children:e,isPresent:t}){let n=(0,U.useId)(),r=(0,U.useRef)(null),i=(0,U.useRef)({width:0,height:0,top:0,left:0}),{nonce:a}=(0,U.useContext)(Ss);return(0,U.useInsertionEffect)(()=>{let{width:e,height:o,top:s,left:c}=i.current;if(t||!r.current||!e||!o)return;r.current.dataset.motionPopId=n;let l=document.createElement(`style`);return a&&(l.nonce=a),document.head.appendChild(l),l.sheet&&l.sheet.insertRule(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/event-DtFyPu7u.js","assets/core-DNaw6KYU.js","assets/app-Dwb58oCT.js","assets/image-DXXwzuA0.js","assets/dist-js-CoMyUP6l.js","assets/rolldown-runtime-BCiCTKAo.js","assets/api-m1FDJyHM.js","assets/preload-helper-BLdHbfdN.js","assets/NoteEditorRoute-DbAY2OPi.js","assets/jsx-runtime-Cl3nUQcN.js","assets/chunk-BV7QT456-B3UxAK3W.js","assets/button-BoRKNt3a.js","assets/dist-B2tJVU7c.js","assets/WorkspaceProvider-Cu8H8gxv.js","assets/note-importer-NTFD3Pan.js","assets/src-C_gRsKqw.js","assets/value-CHmTzbgv.js","assets/image-compression-su-JvgYP.js","assets/fileOwnership-DvxzSccE.js","assets/localPersistence-CGAJ2Ky5.js","assets/useAuth-ekcrHcTV.js","assets/diagramVersioning-nI3XgdaM.js","assets/WorkspaceContext-CitlpD55.js","assets/DiagramEditorRoute-gB1Tnc1O.js","assets/pen-tool-DmvCCYqc.js","assets/DataViewerModeToolbar-AoTGrF0s.js","assets/useField-BVrxe_qk.js","assets/useOpenInteractionType-8RZuPnpG.js","assets/popover-Bc3z69TT.js","assets/dropdown-menu-rZKTxsXp.js","assets/check-CkCHT6D9.js","assets/getPseudoElementBounds-Dgxi_dXc.js","assets/CompositeList-fgcZ0MvU.js","assets/useCompositeItem-DuwIR47L.js","assets/ERDComments-Cv72iUGw.js","assets/select-pQS-1nhx.js","assets/ConfirmModal-DJuZVQTe.js","assets/alert-dialog-WL8sXxIT.js","assets/ellipsis-BGAMAt1v.js","assets/dialog-C2aDTmOl.js","assets/trash-2-DPFpHyly.js","assets/w3c-keyname-BULLf9RX.js","assets/input-D_eLLMB7.js","assets/chevron-left-CB01oDjc.js","assets/erdActions-CFvkilVV.js","assets/field-n9pl0vBs.js","assets/redo-2-pHmjKxwl.js","assets/message-square-D0gsxj3O.js","assets/refresh-cw-B1eEBXCn.js","assets/sparkles-DxlLz1gp.js","assets/undo-2-Lua5EZG-.js","assets/label-CNlirj1C.js","assets/JumpToNode-DfTDRDCJ.js","assets/JumpToNode-CHpVij2M.css","assets/FlowchartEditorRoute-8E8F3Oi5.js","assets/move-B7unHbzE.js","assets/DrawingEditorRoute-DI8POPT9.js","assets/image-BL95x2v1.js","assets/DbClientEditorRoute-BQsu2RPO.js","assets/TeamManagementRoute-wh96POof.js","assets/user-x-DvhsEMZL.js","assets/TeamInventoryRoute-uTpVstiC.js","assets/LibraryRoute-Dyzti-IB.js","assets/file-image-B0FVtvx-.js","assets/UserManagementRoute-HIUP43af.js","assets/user-cog-DHNnqUNW.js","assets/AdminRoute-DtQxECkH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./rolldown-runtime-BCiCTKAo.js";import{n as o,t as s}from"./jsx-runtime-Cl3nUQcN.js";import{a as c,i as l,l as u,n as d,r as f,t as p}from"./dist-B2tJVU7c.js";import{a as m,c as h,d as g,f as _,i as v,l as y,n as b,o as x,s as S,t as C,u as w}from"./chunk-BV7QT456-B3UxAK3W.js";import{A as T,B as E,C as D,D as O,G as k,I as A,J as j,L as M,P as N,R as P,U as F,V as I,W as L,X as R,Z as ee,_ as te,a as ne,at as re,c as ie,ct as z,d as ae,et as oe,f as se,ft as ce,g as le,h as ue,it as de,j as B,k as fe,l as pe,m as me,n as he,nt as ge,o as _e,p as ve,pt as V,q as ye,r as be,rt as xe,s as Se,u as Ce,v as we,x as Te,z as Ee}from"./note-importer-NTFD3Pan.js";import{a as De,at as Oe,f as ke,g as Ae,h as je,i as Me,it as Ne,l as Pe,m as Fe,ot as Ie,p as Le,r as Re,s as ze,t as H,u as Be}from"./button-BoRKNt3a.js";import{$t as Ve,B as He,Bt as Ue,H as We,Ht as Ge,Kt as Ke,Lt as qe,R as Je,Rt as Ye,S as Xe,St as Ze,Ut as Qe,V as $e,Vt as et,Wt as tt,_ as nt,a as rt,b as it,c as at,en as ot,g as st,gn as ct,h as lt,l as ut,lt as dt,m as ft,n as pt,o as mt,p as ht,pt as gt,qt as _t,s as vt,u as yt,ut as bt,v as xt,x as St,y as Ct,zt as wt}from"./useOpenInteractionType-8RZuPnpG.js";import{a as Tt,i as Et,n as Dt,o as Ot,r as kt,s as At,t as jt}from"./useField-BVrxe_qk.js";import{a as Mt,c as Nt,d as Pt,f as Ft,i as It,l as Lt,n as Rt,o as zt,p as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"./popover-Bc3z69TT.js";import{T as Gt,a as Kt,c as qt,d as Jt,i as Yt,l as Xt,m as Zt,n as Qt,o as $t,r as en,s as tn,t as nn,u as rn}from"./dropdown-menu-rZKTxsXp.js";import{t as an}from"./check-CkCHT6D9.js";import{r as on}from"./getPseudoElementBounds-Dgxi_dXc.js";import{a as sn,i as cn,r as ln,t as un}from"./CompositeList-fgcZ0MvU.js";import{$ as dn,B as fn,Ct as pn,D as mn,F as hn,H as gn,I as _n,K as vn,L as yn,O as bn,P as xn,Q as Sn,R as Cn,Tt as wn,U as Tn,V as En,W as Dn,X as On,Z as kn,at as An,bt as jn,ct as Mn,dt as Nn,et as Pn,ft as Fn,ht as In,it as Ln,k as Rn,lt as zn,mt as Bn,nt as Vn,pt as Hn,r as Un,rt as Wn,st as Gn,t as Kn,tt as qn,ut as Jn,wt as Yn,xt as Xn,yt as Zn,z as Qn}from"./ERDComments-Cv72iUGw.js";import{n as $n,t as er}from"./link-2-BrX-3vw2.js";import{C as tr,S as nr,T as rr,_ as ir,b as ar,c as or,g as sr,h as cr,i as lr,l as ur,n as dr,r as fr,t as pr,v as mr,w as hr,x as gr,y as _r}from"./w3c-keyname-BULLf9RX.js";import{t as vr}from"./chevron-left-CB01oDjc.js";import{a as yr,d as br,i as xr,n as Sr,o as Cr,r as wr,s as Tr,t as Er}from"./select-pQS-1nhx.js";import{n as Dr,r as Or,t as kr}from"./ConfirmModal-DJuZVQTe.js";import{n as Ar,r as jr,t as Mr}from"./pen-tool-DmvCCYqc.js";import{t as Nr}from"./ellipsis-BGAMAt1v.js";import{a as Pr,i as Fr,n as Ir,o as Lr,r as Rr,t as zr}from"./field-n9pl0vBs.js";import{t as Br}from"./hard-drive-CrTpFIk_.js";import{t as Vr}from"./message-square-D0gsxj3O.js";import{t as Hr}from"./refresh-cw-B1eEBXCn.js";import{a as Ur,c as Wr,d as Gr,f as Kr,i as qr,l as Jr,n as Yr,o as Xr,r as Zr,s as Qr,t as $r,u as ei}from"./dialog-C2aDTmOl.js";import{t as ti}from"./sparkles-DxlLz1gp.js";import{t as ni}from"./trash-2-DPFpHyly.js";import{C as ri,_ as ii,a as ai,b as oi,c as si,g as ci,i as li,l as ui,n as di,o as fi,p as pi,r as mi,s as hi,t as gi,u as _i,v as vi,y as yi}from"./alert-dialog-WL8sXxIT.js";import{t as bi}from"./preload-helper-BLdHbfdN.js";import{a as xi,c as Si,i as Ci,n as wi,o as Ti,s as Ei,t as Di}from"./api-m1FDJyHM.js";import{t as Oi}from"./input-D_eLLMB7.js";import{t as ki}from"./useCompositeItem-DuwIR47L.js";import{i as Ai,n as ji}from"./fileOwnership-DvxzSccE.js";import{C as Mi,D as Ni,E as Pi,I as Fi,L as Ii,S as Li,T as Ri,_ as zi,a as Bi,b as Vi,c as Hi,g as Ui,h as Wi,l as Gi,n as Ki,r as qi,s as Ji,t as Yi,v as Xi,w as Zi,x as Qi,y as $i}from"./WorkspaceProvider-Cu8H8gxv.js";import{t as ea}from"./localPersistence-CGAJ2Ky5.js";import{n as ta,t as na}from"./useAuth-ekcrHcTV.js";import{i as ra}from"./core-DNaw6KYU.js";import{n as ia,t as aa}from"./WorkspaceContext-CitlpD55.js";import{t as oa}from"./label-CNlirj1C.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var sa=a((e=>{var t=u();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))(),U=r(o(),1),ca=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},la=U.createContext(void 0),ua={setTheme:e=>{},themes:[]},da=()=>U.useContext(la)??ua;U.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return U.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${ca.toString()})(${u})`}})});var fa=ze(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),pa=ze(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ma=ze(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),ha=ze(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),ga=ze(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),_a=ze(`badge-alert`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),va=ze(`book-text`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]),ya=ze(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ba=ze(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),xa=ze(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Sa=ze(`calculator`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`,key:`x4nwl0`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`,key:`wjye3r`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]),Ca=ze(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),wa=ze(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Ta=ze(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Ea=ze(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Da=ze(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),Oa=ze(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ka=ze(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Aa=ze(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ja=ze(`clock-3`,[[`path`,{d:`M12 6v6h4`,key:`135r8i`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ma=ze(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Na=ze(`cloud-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193`,key:`yfwify`}],[`path`,{d:`M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07`,key:`jlfiyv`}]]),Pa=ze(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Fa=ze(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ia=ze(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),La=ze(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ra=ze(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),za=ze(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ba=ze(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Va=ze(`file-box`,[[`path`,{d:`M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`16lz6z`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z`,key:`99pj1s`}],[`path`,{d:`M7 17v5`,key:`1yj1jh`}],[`path`,{d:`M11.7 14.2 7 17l-4.7-2.8`,key:`1yk8tc`}]]),Ha=ze(`file-code`,[[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}]]),Ua=ze(`file-down`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),Wa=ze(`file-json`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Ga=ze(`file-pen`,[[`path`,{d:`M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5`,key:`1couwa`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`1y4qbx`}]]),Ka=ze(`file-type-2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M2 13v-1h6v1`,key:`1dh9dg`}],[`path`,{d:`M5 12v6`,key:`150t9c`}],[`path`,{d:`M4 18h2`,key:`1xrofg`}]]),qa=ze(`file-type`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M9 13v-1h6v1`,key:`1bb014`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`M11 18h2`,key:`12mj7e`}]]),Ja=ze(`file`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Ya=ze(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),Xa=ze(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),Za=ze(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Qa=ze(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),$a=ze(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),eo=ze(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),to=ze(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),no=ze(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ro=ze(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),io=ze(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),ao=ze(`heart`,[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]),oo=ze(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),so=ze(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),co=ze(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),lo=ze(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),uo=ze(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),fo=ze(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),po=ze(`layout-panel-left`,[[`rect`,{width:`7`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`2obqm`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),mo=ze(`library`,[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]),ho=ze(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),go=ze(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),_o=ze(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),vo=ze(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),yo=ze(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),bo=ze(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),xo=ze(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),So=ze(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Co=ze(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),wo=ze(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),To=ze(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Eo=ze(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Do=ze(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Oo=ze(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),ko=ze(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Ao=ze(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),jo=ze(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Mo=ze(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),No=ze(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Po=ze(`rotate-ccw-key`,[[`path`,{d:`m14.5 9.5 1 1`,key:`159eiq`}],[`path`,{d:`m15.5 8.5-4 4`,key:`iirg3q`}],[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.74 9.74 0 0 0-6.74 2.74L3 8`,key:`g2jlw`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`circle`,{cx:`10`,cy:`14`,r:`2`,key:`1239so`}]]),Fo=ze(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Io=ze(`server-cog`,[[`path`,{d:`m10.852 14.772-.383.923`,key:`11vil6`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`,key:`1v3clb`}],[`path`,{d:`m13.148 9.228.383-.923`,key:`t2zzyc`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`,key:`1bxfiv`}],[`path`,{d:`m14.772 10.852.923-.383`,key:`k9m8cz`}],[`path`,{d:`m14.772 13.148.923.383`,key:`1xvhww`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`,key:`tn8das`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`,key:`1g2pve`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M6 6h.01`,key:`1utrut`}],[`path`,{d:`m9.228 10.852-.923-.383`,key:`1wtb30`}],[`path`,{d:`m9.228 13.148-.923.383`,key:`1a830x`}]]),Lo=ze(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ro=ze(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),zo=ze(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Bo=ze(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Vo=ze(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ho=ze(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Uo=ze(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Wo=ze(`sticky-note`,[[`path`,{d:`M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z`,key:`qazsjp`}],[`path`,{d:`M15 3v4a2 2 0 0 0 2 2h4`,key:`40519r`}]]),Go=ze(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ko=ze(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),qo=ze(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Jo=ze(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Yo=ze(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),Xo=ze(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Zo=ze(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),Qo=ze(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),$o=ze(`users-round`,[[`path`,{d:`M18 21a8 8 0 0 0-16 0`,key:`3ypg7q`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`,key:`10s06x`}]]),es=ze(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),ts=ze(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),ns=ze(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),W=s(),rs=({...e})=>{let{theme:t=`system`}=da();return(0,W.jsx)(p,{theme:t,className:`toaster group`,richColors:!0,icons:{success:(0,W.jsx)(wn,{className:`size-4`}),info:(0,W.jsx)(Dr,{className:`size-4`}),warning:(0,W.jsx)(ri,{className:`size-4`}),error:(0,W.jsx)(Do,{className:`size-4`}),loading:(0,W.jsx)(vo,{className:`size-4 animate-spin`})},style:{"--border-radius":`var(--radius)`},toastOptions:{classNames:{toast:`cn-toast`}},...e})},is=U.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,W.jsx)(`div`,{ref:r,"data-slot":`card`,"data-size":t,className:c(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n}));is.displayName=`Card`;var as=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-header`,className:c(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t}));as.displayName=`CardHeader`;var os=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-title`,className:c(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t}));os.displayName=`CardTitle`;var ss=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-description`,className:c(`text-sm text-muted-foreground`,e),...t}));ss.displayName=`CardDescription`;var cs=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-action`,className:c(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t}));cs.displayName=`CardAction`;var ls=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-content`,className:c(`px-4 group-data-[size=sm]/card:px-3`,e),...t}));ls.displayName=`CardContent`;var us=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,"data-slot":`card-footer`,className:c(`flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3`,e),...t}));us.displayName=`CardFooter`;var ds=U.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});function fs(e=!1){let t=U.useContext(ds);if(!t&&!e)throw Error(Ne(86));return t}var ps=U.createContext({disabled:!1});function ms(){return U.useContext(ps)}var hs=U.createContext(void 0);function gs(e=!0){let t=U.useContext(hs);if(t===void 0&&!e)throw Error(Ne(3));return t}function _s({configured:e,loginUrl:t,onLogin:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e=new URL(window.location.href);i(e.searchParams.get(`sso_link`)===`required`);let t=e.searchParams.get(`error`);t&&(d.error(t),e.searchParams.delete(`error`),window.history.replaceState({},document.title,`${e.pathname}${e.search}`))},[]);let l=()=>{i(!1),o(``);let e=new URL(window.location.href);e.searchParams.delete(`sso_link`),window.history.replaceState({},document.title,`${e.pathname}${e.search}`)};return(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(is,{className:`w-full max-w-sm`,children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(os,{children:r?`Link your existing Cloud account`:`Sign in to ERD Builder Pro Cloud`}),(0,W.jsx)(ss,{children:r?`This verified SSO email already belongs to a Cloud account. Enter that account's current password to confirm ownership.`:`Your account and subscription are managed by ERDBPro SaaS.`})]}),(0,W.jsx)(ls,{children:r?(0,W.jsx)(`form`,{onSubmit:async e=>{e.preventDefault(),c(!0);try{let e=await wi(`/api/sso/link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:a})}),t=await e.json();if(!e.ok){d.error(t.error||`Unable to link the existing Cloud account`);return}l(),n(t.user),d.success(`Existing Cloud account linked successfully`)}catch{d.error(`Unable to link the existing Cloud account`)}finally{c(!1)}},children:(0,W.jsxs)(Rr,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`sso-link-password`,children:`Current Cloud password`}),(0,W.jsx)(Oi,{id:`sso-link-password`,type:`password`,autoComplete:`current-password`,required:!0,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(Ir,{children:`Your ERDBPro SaaS password is not requested here.`})]}),(0,W.jsxs)(zr,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(H,{type:`submit`,disabled:s,className:`w-full`,children:s?`Verifying account...`:`Verify and link account`}),(0,W.jsx)(H,{type:`button`,variant:`outline`,className:`w-full`,onClick:l,children:`Cancel`})]})]})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(H,{className:`w-full`,disabled:!e,onClick:()=>window.location.assign(`${xi()}${t}`),children:[(0,W.jsx)(bo,{"data-icon":`inline-start`}),`Continue with ERDBPro SSO`]}),!e&&(0,W.jsx)(`p`,{className:`mt-3 text-center text-sm text-destructive`,children:`SSO configuration is incomplete.`})]})})]})})}function vs({onLogin:e,onGuestLogin:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(`password`),[E,D]=(0,U.useState)(!0),[O,k]=(0,U.useState)(`/api/sso/login`);(0,U.useEffect)(()=>{wi(`/api/auth-config`,{cache:`no-store`}).then(e=>e.json()).then(e=>{x(e.guest_mode!==!1),C(e.needs_setup===!0||e.needsSetup===!0),T((e.auth_mode??e.authMode)===`sso`?`sso`:`password`),D((e.sso_configured??e.ssoConfigured)!==!1),k(e.sso_login_url??e.ssoLoginUrl??`/api/sso/login`)}).catch(()=>C(!1))},[]);let A=Ei(),j=Ti()===`cli`,M=(0,U.useRef)(!0),N=(0,U.useRef)(0);if((0,U.useEffect)(()=>{if(!A)return;let t=!1;return(async()=>{for(;!t&&M.current;){try{let n=await wi(`/api/me`);if(n.ok){let r=await n.json();if(r.authenticated&&!t){r.token&&Si(r.token),e(r.user);return}}else if(n.status===503){let e=await n.json().catch(()=>({}));if(e.db_error&&!t){y(e.message||`Database initialization failed. Check logs for details.`);return}}}catch{}if(N.current++,N.current>=20&&!t){y(j?`Unable to connect to the CLI backend server. Check ~/.erdbpro/logs/ for server logs.`:`Unable to connect to the desktop backend server. Check the application logs.`);return}t||await new Promise(e=>setTimeout(e,1e3))}})(),()=>{t=!0}},[j,A,e]),A)return v?(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(`div`,{className:`max-w-md w-full rounded-lg border border-red-800 bg-red-950/40 p-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(`span`,{className:`text-red-400 text-lg`,children:`⚠️`}),(0,W.jsx)(`h2`,{className:`text-red-300 font-semibold`,children:`Startup Error`})]}),(0,W.jsx)(`p`,{className:`text-red-200/80 text-sm mb-4`,children:v}),(0,W.jsxs)(`div`,{className:`text-xs text-red-300/60 space-y-1`,children:[(0,W.jsxs)(`p`,{children:[`Log file: `,(0,W.jsx)(`code`,{className:`text-red-200/80`,children:j?`~/.erdbpro/logs/server-*.err.log`:`~/Library/Logs/com.erdbuilderpro.app/server-startup.log`})]}),(0,W.jsx)(`p`,{children:j?`Try restarting the CLI. If the issue persists, inspect the latest server error log.`:`Try restarting the app. If the issue persists, ensure Node.js is installed.`})]})]})}):(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,W.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connecting...`})]})});if(S===null)return(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6`,children:(0,W.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent`})});let P=S;return w===`sso`?(0,W.jsx)(_s,{configured:E,loginUrl:O,onLogin:e}):(0,W.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center p-6 md:p-10`,children:(0,W.jsx)(`div`,{className:`w-full max-w-sm`,children:(0,W.jsx)(`div`,{className:c(`flex flex-col gap-6`),children:(0,W.jsxs)(is,{children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(os,{children:P?`Create administrator account`:`Login to your account`}),(0,W.jsx)(ss,{children:P?`Set the first administrator email and password for this Self-host installation.`:`Enter your email below to login to your account`})]}),(0,W.jsx)(ls,{children:(0,W.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),P&&o!==l)d.error(`Passwords do not match`);else{_(!0);try{let t=await wi(P?`/api/setup`:`/api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(P?{name:n,email:i,password:o,confirmPassword:l}:{email:i,password:o})});if(t.ok){let n=await t.json();n.token&&Si(n.token),e(n.user),d.success(P?`Administrator account created!`:`Welcome back!`)}else{let e=await t.json();d.error(e.error||`Login failed`)}}catch(e){console.error(`Login error:`,e);let t=e instanceof Error?e.message:`An unexpected error occurred`;d.error(t)}finally{_(!1)}}},children:(0,W.jsxs)(Rr,{children:[P&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`name`,children:`Name`}),(0,W.jsx)(Oi,{id:`name`,type:`text`,placeholder:`Enter administrator name`,required:!0,value:n,onChange:e=>r(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`email`,children:`Email`}),(0,W.jsx)(Oi,{id:`email`,type:`email`,placeholder:`m@example.com`,required:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.jsx)(Fr,{htmlFor:`password`,children:`Password`})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`password`,type:f?`text`:`password`,placeholder:P?`Create a password`:`Enter your password`,required:!0,value:o,onChange:e=>s(e.target.value),className:`pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground focus:outline-none cursor-pointer`,"aria-label":f?`Hide password`:`Show password`,children:f?(0,W.jsx)(Lr,{className:`h-4 w-4`}):(0,W.jsx)(Ba,{className:`h-4 w-4`})})]})]}),P&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`confirm-password`,children:`Confirm Password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`confirm-password`,type:m?`text`:`password`,placeholder:`Re-enter your password`,required:!0,value:l,onChange:e=>u(e.target.value),className:`pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground focus:outline-none cursor-pointer`,"aria-label":m?`Hide confirm password`:`Show confirm password`,children:m?(0,W.jsx)(Lr,{className:`h-4 w-4`}):(0,W.jsx)(Ba,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(zr,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(H,{type:`submit`,disabled:g,className:`w-full`,children:g?P?`Creating account...`:`Logging in...`:P?`Create administrator`:`Login`}),b&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative my-2`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`span`,{className:`w-full border-t`})}),(0,W.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,W.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`Or`})})]}),(0,W.jsx)(H,{type:`button`,variant:`outline`,className:`w-full`,onClick:()=>{t?.(),d.success(`Welcome! You're in Guest Mode.`)},children:`Try as Guest (Local Mode)`})]}),P&&(0,W.jsx)(Ir,{className:`text-center`,children:`This setup is available only once for the empty database.`})]})]})})})]})})})})}var ys=(0,U.createContext)({});function bs(e){let t=(0,U.useRef)(null);return t.current===null&&(t.current=e()),t.current}var xs=(0,U.createContext)(null),Ss=(0,U.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`}),Cs=class extends U.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){let e=this.props.sizeRef.current;e.height=t.offsetHeight||0,e.width=t.offsetWidth||0,e.top=t.offsetTop,e.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}};function ws({children:e,isPresent:t}){let n=(0,U.useId)(),r=(0,U.useRef)(null),i=(0,U.useRef)({width:0,height:0,top:0,left:0}),{nonce:a}=(0,U.useContext)(Ss);return(0,U.useInsertionEffect)(()=>{let{width:e,height:o,top:s,left:c}=i.current;if(t||!r.current||!e||!o)return;r.current.dataset.motionPopId=n;let l=document.createElement(`style`);return a&&(l.nonce=a),document.head.appendChild(l),l.sheet&&l.sheet.insertRule(`
|
|
3
3
|
[data-motion-pop-id="${n}"] {
|
|
4
4
|
position: absolute !important;
|
|
5
5
|
width: ${e}px !important;
|
|
@@ -45,7 +45,7 @@ import{a as e,i as t,n,o as r,r as i,t as a}from"./rolldown-runtime-BCiCTKAo.js"
|
|
|
45
45
|
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Pce(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Hv.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Ele(){return{exit:{taskListCheckValueChecked:Gv,taskListCheckValueUnchecked:Gv,paragraph:Ole}}}function Dle(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:kle}}}function Gv(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Ole(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function kle(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Hv.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Ale(){return[rce(),wce(),Oce(),yle(),Ele()]}function jle(e){return{extensions:[ice(),Tce(e),kce(),Tle(e),Dle()]}}function Mle(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}var Kv={}.hasOwnProperty;function Nle(e){let t={},n=-1;for(;++n<e.length;)Ple(t,e[n]);return t}function Ple(e,t){let n;for(n in t){let r=(Kv.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Kv.call(r,a)||(r[a]=[]);let e=i[a];Fle(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Fle(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Mle(e,0,0,r)}var qv=Qv(/[A-Za-z]/),Jv=Qv(/[\dA-Za-z]/);function Ile(e){return e!==null&&(e<32||e===127)}function Yv(e){return e!==null&&(e<0||e===32)}var Xv=Qv(/\p{P}|\p{S}/u),Zv=Qv(/\s/);function Qv(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Lle={tokenize:Ule,partial:!0},$v={tokenize:Wle,partial:!0},ey={tokenize:Gle,partial:!0},ty={tokenize:Kle,partial:!0},Rle={tokenize:qle,partial:!0},ny={name:`wwwAutolink`,tokenize:Vle,previous:sy},ry={name:`protocolAutolink`,tokenize:Hle,previous:cy},iy={name:`emailAutolink`,tokenize:Ble,previous:ly},ay={};function zle(){return{text:ay}}for(var oy=48;oy<123;)ay[oy]=iy,oy++,oy===58?oy=65:oy===91&&(oy=97);ay[43]=iy,ay[45]=iy,ay[46]=iy,ay[95]=iy,ay[72]=[iy,ry],ay[104]=[iy,ry],ay[87]=[iy,ny],ay[119]=[iy,ny];function Ble(e,t,n){let r=this,i,a;return o;function o(t){return!uy(t)||!ly.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return uy(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Rle,u,l)(t):t===45||t===95||Jv(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&qv(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Vle(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!sy.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Lle,e.attempt($v,e.attempt(ey,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Hle(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&cy.call(r,r.previous)&&!dy(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(qv(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ile(t)||Yv(t)||Zv(t)||Xv(t)?n(t):e.attempt($v,e.attempt(ey,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Ule(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Wle(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(ty,c,s)(t):t===null||Yv(t)||Zv(t)||t!==45&&Xv(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Gle(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(ty,t,a)(o):o===null||Yv(o)||Zv(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Kle(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Yv(o)||Zv(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Yv(e)||Zv(e)?t(e):r(e)}function a(e){return qv(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):qv(t)?(e.consume(t),o):n(t)}}function qle(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Jv(e)?n(e):t(e)}}function sy(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Yv(e)}function cy(e){return!qv(e)}function ly(e){return!(e===47||uy(e))}function uy(e){return e===43||e===45||e===46||e===95||Jv(e)}function dy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function Jle(e){return e!==null&&e<-2}function fy(e){return e!==null&&(e<0||e===32)}function py(e){return e===-2||e===-1||e===32}function my(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return py(r)?(e.enter(n),s(r)):t(r)}function s(r){return py(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Yle={partial:!0,tokenize:Xle};function Xle(e,t,n){return r;function r(t){return py(t)?my(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Jle(e)?t(e):n(e)}}function hy(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Zle={tokenize:aue,partial:!0};function Qle(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:nue,continuation:{tokenize:rue},exit:iue}},text:{91:{name:`gfmFootnoteCall`,tokenize:tue},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:$le,resolveTo:eue}}}}function $le(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=hy(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function eue(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function tue(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||fy(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(hy(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return fy(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function nue(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||fy(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=hy(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return fy(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),my(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function rue(e,t,n){return e.check(Yle,t,e.attempt(Zle,t,n))}function iue(e){e.exit(`gfmFootnoteDefinition`)}function aue(e,t,n){let r=this;return my(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function gy(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function oue(e){return e!==null&&(e<0||e===32)}var sue=_y(/\p{P}|\p{S}/u),cue=_y(/\s/);function _y(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function vy(e){if(e===null||oue(e)||cue(e))return 1;if(sue(e))return 2}function lue(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}function uue(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&gy(o,o.length,0,lue(s,e.slice(r+1,n),t)),gy(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),gy(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=vy(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=vy(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function yy(e){return e!==null&&e<-2}function by(e){return e!==null&&(e<0||e===32)}function xy(e){return e===-2||e===-1||e===32}function Sy(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return xy(r)?(e.enter(n),s(r)):t(r)}function s(r){return xy(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var due=class{constructor(){this.map=[]}add(e,t,n){fue(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function fue(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function pue(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function mue(){return{flow:{null:{name:`table`,tokenize:hue,resolveAll:gue}}}}function hue(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):yy(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):xy(t)?Sy(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||by(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,xy(t)?Sy(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return xy(t)?Sy(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||yy(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return xy(t)?Sy(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||yy(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||yy(n)?(e.exit(`tableRow`),t(n)):xy(n)?Sy(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||by(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function gue(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new due;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(wy(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Cy(f,t,o,i,n,d)):(o[0]=o[1],d=Cy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&wy(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=pue(t.events,n))}return e}function Cy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ty(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ty(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ty(t.events,n[2]),a=Ty(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ty(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function wy(e,t,n,r,i){let a=[],o=Ty(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ty(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function _ue(e){return e!==null&&e<-2}function vue(e){return e!==null&&(e<0||e===32)}function Ey(e){return e===-2||e===-1||e===32}function yue(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Ey(r)?(e.enter(n),s(r)):t(r)}function s(r){return Ey(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bue={name:`tasklistCheck`,tokenize:Sue};function xue(){return{text:{91:bue}}}function Sue(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return vue(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return _ue(r)?t(r):Ey(r)?e.check({tokenize:Cue},t,n)(r):n(r)}}function Cue(e,t,n){return yue(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function wue(e){return Nle([zle(),Qle(),uue(e),mue(),xue()])}var Tue={};function Dy(e){let t=this,n=e||Tue,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(wue(n)),a.push(Ale()),o.push(jle(n))}var Oy=`hadziqmtqn/erd-builder-pro`,Eue=5;function Due(e){if(!e)return 1;let t=e.match(/page=(\d+)>;\s*rel="last"/);return t?parseInt(t[1],10):1}function Oue(){let[e,t]=(0,U.useState)([]),[n,r]=(0,U.useState)(!0),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(null),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(1),[p,m]=(0,U.useState)(1),h=(0,U.useRef)(null),g=async e=>{e===1?r(!0):a(!0);try{let n=await fetch(`https://api.github.com/repos/${Oy}/releases?per_page=${Eue}&page=${e}`);if(!n.ok)throw Error(`Failed to fetch releases`);let r=await n.json();t(r),m(Due(n.headers.get(`Link`)))}catch(e){s(e instanceof Error?e.message:`Unknown error`)}finally{r(!1),a(!1)}};(0,U.useEffect)(()=>{g(1)},[]),(0,U.useEffect)(()=>{g(d),h.current?.scrollTo({top:0,behavior:`smooth`})},[d]);let _=d===1?e.findIndex(e=>!e.prerelease):-1;return n&&e.length===0?(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center space-y-4`,children:[(0,W.jsx)(vo,{className:`w-8 h-8 text-primary animate-spin`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground animate-pulse`,children:`Fetching latest updates...`})]}):o?(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center space-y-4 p-8 text-center`,children:[(0,W.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center`,children:(0,W.jsx)(tr,{className:`w-6 h-6 text-destructive`})}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-bold text-lg`,children:`Gagal memuat Changelog`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-xs`,children:o})]}),(0,W.jsx)(H,{onClick:()=>window.location.reload(),variant:`outline`,children:`Coba Lagi`})]}):(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col h-full overflow-hidden bg-background`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b bg-muted/20`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`h2`,{className:`text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,W.jsx)(oo,{className:`w-6 h-6 text-primary`}),`What's New`]}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Lacak pembaruan dan perubahan terbaru pada ERD Builder Pro.`})]}),(0,W.jsxs)(H,{variant:`outline`,size:`sm`,render:(0,W.jsx)(`a`,{href:`https://github.com/${Oy}/releases`,target:`_blank`,rel:`noreferrer`}),children:[(0,W.jsx)(za,{className:`w-4 h-4 mr-2`}),`GitHub Releases`]})]}),(0,W.jsx)(`div`,{ref:h,className:`flex-1 overflow-y-auto px-6 py-8`,children:(0,W.jsxs)(`div`,{className:`max-w-3xl mx-auto relative pl-8 space-y-12`,children:[(0,W.jsx)(`div`,{className:`absolute left-[15px] top-2 bottom-0 w-px bg-border`}),(0,W.jsx)(Ms,{mode:`popLayout`,children:e.map((e,t)=>(0,W.jsxs)(xp.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:t*.1},className:`relative`,children:[(0,W.jsx)(`div`,{className:c(`absolute -left-[32px] top-1.5 size-8 rounded-full border-4 border-background flex items-center justify-center transition-colors`,t===_&&_!==-1?`bg-primary shadow-[0_0_15px_rgba(var(--primary),0.5)]`:e.prerelease?`bg-amber-500/20 border-amber-500/30`:`bg-muted`),children:t===_&&_!==-1?(0,W.jsx)(ti,{className:`w-4 h-4 text-primary-foreground`}):e.prerelease?(0,W.jsx)(Ko,{className:`w-3 h-3 text-amber-400`}):(0,W.jsx)(Ko,{className:`w-3 h-3 text-muted-foreground`})}),(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsxs)(tm,{variant:e.prerelease?`secondary`:`default`,className:`font-mono text-xs px-2 pointer-events-none`,children:[`v`,e.tag_name.replace(`v`,``)]}),e.prerelease&&(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-400 border-amber-500/30`,children:`Pre-release`}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,W.jsx)(hr,{className:`w-3 h-3`}),lr(new Date(e.published_at),`MMMM d, yyyy`)]}),t===_&&_!==-1&&(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] uppercase tracking-tighter bg-primary/5 text-primary border-primary/20`,children:`Latest`})]}),(0,W.jsx)(is,{className:c(`group transition-all duration-300 hover:border-primary/50 cursor-pointer overflow-hidden backdrop-blur-sm`,t===_&&_!==-1?`bg-primary/5 border-primary/20 shadow-lg shadow-primary/5`:e.prerelease?`bg-card/30 border-amber-500/10`:`bg-card/50`),onClick:()=>u(e),children:(0,W.jsxs)(as,{className:`p-4 flex flex-row items-center justify-between space-y-0`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(os,{className:`text-base font-bold group-hover:text-primary transition-colors`,children:e.name||`Release ${e.tag_name}`}),(0,W.jsx)(ss,{className:`line-clamp-2 text-sm leading-relaxed`,children:e.body.split(`
|
|
46
46
|
`)[0].replace(/#+\s*/,``)||`Lihat detail pembaruan...`})]}),(0,W.jsx)(At,{className:`w-5 h-5 text-muted-foreground group-hover:text-primary group-hover:translate-x-1 transition-all`})]})})]})]},e.id))}),i&&(0,W.jsx)(`div`,{className:`flex justify-center pt-4`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(vo,{className:`w-3.5 h-3.5 animate-spin`}),`Loading page...`]})}),p>1&&!i&&(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-1 pt-8 pb-4`,children:[(0,W.jsx)(H,{variant:`ghost`,size:`sm`,disabled:d===1,onClick:()=>f(1),className:`size-9 p-0`,children:(0,W.jsx)(wa,{className:`w-4 h-4`})}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,disabled:d===1,onClick:()=>f(e=>e-1),className:`size-9 p-0`,children:(0,W.jsx)(vr,{className:`w-4 h-4`})}),(0,W.jsx)(`div`,{className:`flex items-center gap-1 px-2`,children:(()=>{let e=[];for(let t=1;t<=p;t++)t===1||t===p||t>=d-1&&t<=d+1?e.push(t):e[e.length-1]!==`ellipsis`&&e.push(`ellipsis`);return e.map((e,t)=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${t}`):(0,W.jsx)(H,{variant:e===d?`default`:`ghost`,size:`sm`,onClick:()=>f(e),className:`min-w-9 h-9 p-0 text-xs font-mono`,children:e},e))})()}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,disabled:d===p,onClick:()=>f(e=>e+1),className:`size-9 p-0`,children:(0,W.jsx)(At,{className:`w-4 h-4`})}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,disabled:d===p,onClick:()=>f(p),className:`size-9 p-0`,children:(0,W.jsx)(Ta,{className:`w-4 h-4`})})]}),p>1&&!i&&(0,W.jsxs)(`p`,{className:`text-center text-[11px] text-muted-foreground/60 pb-2`,children:[`Page `,d,` of `,p]})]})}),(0,W.jsx)($r,{open:!!l,onOpenChange:e=>!e&&u(null),children:(0,W.jsx)(qr,{className:`sm:max-w-2xl`,children:l&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Qr,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,W.jsxs)(tm,{className:`font-mono text-xs`,children:[`v`,l.tag_name.replace(`v`,``)]}),l.prerelease?(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-700 border-amber-500/30 dark:text-amber-400`,children:`Pre-release`}):(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] uppercase tracking-tighter bg-emerald-500/10 text-emerald-700 border-emerald-500/30 dark:text-emerald-400`,children:`Stable`}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[(0,W.jsx)(hr,{className:`w-3 h-3`}),lr(new Date(l.published_at),`MMMM d, yyyy`)]})]}),(0,W.jsx)(Jr,{className:`text-2xl`,children:l.name||`Release ${l.tag_name}`})]}),(0,W.jsx)(Yr,{className:`bg-muted/50`,children:(0,W.jsx)(`div`,{className:`prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-pre:border-border dark:prose-pre:bg-black/50`,children:(0,W.jsx)(lv,{remarkPlugins:[Dy],children:l.body})})}),(0,W.jsx)(Xr,{children:(0,W.jsxs)(H,{variant:`secondary`,size:`sm`,render:(0,W.jsx)(`a`,{href:l.html_url,target:`_blank`,rel:`noreferrer`}),children:[(0,W.jsx)(za,{className:`w-4 h-4 mr-2`}),`View on GitHub`]})})]})})})]})}function kue(e){let t=e?.data;if(!t)return{projects:0,notes:0,diagrams:0,entities:0,columns:0,relationships:0,flowcharts:0,drawings:0,ai_chat_sessions:0,ai_chat_messages:0,skipped_existing:0};let n=0,r=0,i=0;for(let e of t.diagrams||[]){n+=(e.entities||[]).length;for(let t of e.entities||[])r+=(t.columns||[]).length;i+=(e.relationships||[]).length}let a=0;for(let e of t.ai_chat_sessions||[])a+=(e.messages||[]).length;return{projects:(t.projects||[]).length,notes:(t.notes||[]).length,diagrams:(t.diagrams||[]).length,entities:n,columns:r,relationships:i,flowcharts:(t.flowcharts||[]).length,drawings:(t.drawings||[]).length,ai_chat_sessions:(t.ai_chat_sessions||[]).length,ai_chat_messages:a,skipped_existing:0}}function Aue(e){let t=e?.data;if(!t)return 1;let n=0;n+=(t.projects||[]).length,n+=(t.notes||[]).length;for(let e of t.diagrams||[]){n+=1;let t=e.entities||[];n+=t.length;for(let e of t)n+=(e.columns||[]).length;n+=(e.relationships||[]).length}n+=(t.flowcharts||[]).length,n+=(t.drawings||[]).length;for(let e of t.ai_chat_sessions||[])n+=1,n+=(e.messages||[]).length;return Math.max(n,1)}function jue(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function ky(){return sessionStorage.getItem(`auth_mode`)===`guest`?`guest`:typeof window<`u`&&(window.__TAURI__||window.__TAURI_INTERNALS__)?`desktop`:`web`}function Mue(){let e=(0,U.useRef)(null),t=(0,U.useRef)(null),n=(0,U.useRef)(null),r=(0,U.useRef)(null),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(`idle`),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)({current:0,total:1,phase:``}),b=ky();(0,U.useEffect)(()=>(a===`done`&&(t.current=setTimeout(()=>{window.location.reload()},2500)),()=>{t.current&&=(clearTimeout(t.current),null)}),[a]);let x=(0,U.useCallback)(async t=>{let n=t.target.files?.[0];if(!n)return;let a=n.name.split(`.`).pop()?.toLowerCase();if(a===`db`||a===`sqlite`||a===`sqlite3`){if(ky()!==`desktop`){d.error(`Database file restore is only available in the Desktop app.`),e.current&&(e.current.value=``);return}c(`db`),p({fileName:n.name,fileSize:jue(n.size)}),u(null),_(``),o(`preview`),i.current=n,e.current&&(e.current.value=``)}else if(a===`json`){let t;try{t=JSON.parse(await n.text())}catch{d.error(`Invalid JSON file. Please select a valid export file.`),e.current&&(e.current.value=``);return}if(!t.data||typeof t.data!=`object`){d.error(`Invalid export format. Missing "data" field.`),e.current&&(e.current.value=``);return}let i=kue(t);if(Object.values(i).reduce((e,t)=>e+(t||0),0)<=1){d.info(`The export file contains no data to import.`),e.current&&(e.current.value=``);return}r.current=t,c(`json`),u(i),p(null),_(``),o(`preview`),e.current&&(e.current.value=``)}else d.error(`Unsupported file type ".${a}". Please select a .json, .db, or .sqlite file.`),e.current&&(e.current.value=``)},[]),S=(0,U.useCallback)(async()=>{let e=r.current;if(!e)return;let t=Aue(e);o(`importing`),_(``),y({current:0,total:t,phase:`Preparing import…`});try{let r=new AbortController;n.current=r;let i=await wi(`/api/guest/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:r.signal});if(!i.ok){let e=`Server returned ${i.status}`;try{e=(await i.json()).error||e}catch{}throw Error(e)}let a=i.body?.getReader();if(!a)throw Error(`Browser does not support streaming responses.`);let s=new TextDecoder,c=``;for(;;){let{done:e,value:r}=await a.read();if(e)break;c+=s.decode(r,{stream:!0});let i=c.split(`
|
|
47
47
|
`);c=i.pop()||``;for(let e of i)if(e.trim())try{let r=JSON.parse(e);if(r.type===`progress`)y({current:Number(r.current)||0,total:Number(r.total)||t,phase:String(r.phase||``)});else if(r.type===`complete`){h(r.summary),o(`done`),d.success(r.message||`Import completed successfully!`),n.current=null;return}else if(r.type===`error`)throw Error(r.error||`Import failed on server.`)}catch(e){if(e instanceof SyntaxError)continue;throw e}}throw Error(`Stream ended unexpectedly. Import may be incomplete.`)}catch(e){if(e.name===`AbortError`)return;o(`error`),_(e.message||`Import failed`),d.error(`Import failed: `+(e.message||`Unknown error`))}n.current=null},[b]),C=(0,U.useCallback)(async()=>{let e=i.current;if(e){o(`importing`),_(``),y({current:0,total:5,phase:`Uploading database file…`});try{let t=new AbortController;n.current=t;let r=new FormData;r.append(`database`,e);let i=await wi(`/api/desktop/restore/database`,{method:`POST`,body:r,signal:t.signal});if(!i.ok){let e=`Server returned ${i.status}`;try{e=(await i.json()).error||e}catch{}throw Error(e)}let a=i.body?.getReader();if(!a)throw Error(`Browser does not support streaming responses.`);let s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await a.read();if(e)break;c+=s.decode(t,{stream:!0});let r=c.split(`
|
|
48
|
-
`);c=r.pop()||``;for(let e of r)if(e.trim())try{let t=JSON.parse(e);if(t.type===`progress`)y({current:Number(t.current)||0,total:Number(t.total)||5,phase:String(t.phase||``)});else if(t.type===`complete`){await ea.clearAllPendingSyncs(),o(`done`),d.success(t.message||`Database restored successfully!`),n.current=null;return}else if(t.type===`error`)throw Error(t.error||`Restore failed on server.`)}catch(e){if(e instanceof SyntaxError)continue;throw e}}throw Error(`Stream ended unexpectedly. Restore may be incomplete.`)}catch(e){if(e.name===`AbortError`)return;o(`error`),_(e.message||`Restore failed`),d.error(`Restore failed: `+(e.message||`Unknown error`))}n.current=null}},[]),w=(0,U.useCallback)(()=>{t.current&&=(clearTimeout(t.current),null),r.current=null,i.current=null,o(`idle`),c(null),h(null),u(null),p(null),_(``),y({current:0,total:1,phase:``})},[]),T=(0,U.useCallback)(()=>{r.current=null,i.current=null,u(null),p(null),o(`idle`),c(null)},[]),E=(0,U.useCallback)(()=>{t.current&&=(clearTimeout(t.current),null),window.location.reload()},[]),D=(0,U.useCallback)(()=>{n.current&&=(n.current.abort(),null),r.current=null,i.current=null,o(`idle`),c(null),y({current:0,total:1,phase:``})},[]),O=(0,U.useCallback)(()=>{s===`db`?C():S()},[s,C,S]),k=Math.min(Math.round(v.current/v.total*100),100),{accept:A,acceptLabel:j}=b===`desktop`?{accept:`.json,.db,.sqlite,.sqlite3`,acceptLabel:`.json (data) or .db / .sqlite (database restore)`}:{accept:`.json`,acceptLabel:`.json format from Guest Mode export`};if(a===`done`)return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl`,children:[(0,W.jsx)(Or,{className:`size-6 text-emerald-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:s===`db`?`Database Restored`:`Import Completed`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:s===`db`?`The database file has been restored. The app will reload to apply the changes.`:`Data has been added to your workspace.`})]})]}),m&&(0,W.jsx)(Ay,{summary:m}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:E,children:[(0,W.jsx)(Hr,{className:`size-3.5 mr-1.5`}),`Reload App Now`]}),(0,W.jsx)(H,{variant:`outline`,size:`sm`,onClick:w,children:`Import Another File`})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`App will reload automatically in a few seconds…`})]});if(a===`preview`){if(s===`db`&&f)return(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Ka,{className:`size-5 text-blue-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Restore Database File`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`This will `,(0,W.jsx)(`strong`,{className:`text-amber-500`,children:`replace`}),` your current local database with the selected file. A safety backup will be created automatically before the restore.`]}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Use this if you reinstalled the app and want to restore from a previous`,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px] mx-0.5`,children:`.db`}),` file that you saved manually.`]})]})]}),(0,W.jsxs)(`div`,{className:`bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`File`}),(0,W.jsx)(`span`,{className:`font-medium`,children:f.fileName})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Size`}),(0,W.jsx)(`span`,{className:`font-medium`,children:f.fileSize})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:O,children:[(0,W.jsx)(rr,{className:`size-3.5 mr-1.5`}),`Restore Database`]}),(0,W.jsxs)(H,{variant:`outline`,size:`sm`,onClick:T,children:[(0,W.jsx)(Gr,{className:`size-3.5 mr-1.5`}),`Cancel`]})]})]});if(s===`json`&&l){let e=Object.values(l).reduce((e,t)=>e+(t||0),0);return(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Wa,{className:`size-5 text-blue-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Import Preview`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e,` items found in the export file. Click `,(0,W.jsx)(`strong`,{children:`Submit`}),` to import the data.`]})]})]}),(0,W.jsx)(Ay,{summary:l}),(0,W.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:O,children:[(0,W.jsx)(rr,{className:`size-3.5 mr-1.5`}),`Submit`]}),(0,W.jsxs)(H,{variant:`outline`,size:`sm`,onClick:T,children:[(0,W.jsx)(Gr,{className:`size-3.5 mr-1.5`}),`Cancel`]})]})]})}}return a===`error`?(0,W.jsx)(`div`,{className:`space-y-5`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg`,children:[(0,W.jsx)(tr,{className:`size-4 text-red-500 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{className:`text-xs text-red-600`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:s===`db`?`Database restore failed`:`Import failed`}),(0,W.jsx)(`p`,{className:`mt-0.5`,children:g}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,className:`mt-2 h-auto py-1 text-xs`,onClick:w,children:`Try again`})]})]})}):(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Br,{className:`size-5 text-blue-500 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{className:`text-sm space-y-1`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Import Data`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Upload a `,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px]`,children:`.json`}),` file exported from Guest Mode. All data will be `,(0,W.jsx)(`strong`,{children:`added`}),` to your workspace — existing items with the same ID will be skipped. New projects will be created for any project‑scoped items.`]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects.`}),b===`desktop`&&(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40`,children:[(0,W.jsx)(`strong`,{className:`text-amber-500`,children:`Desktop only:`}),` You can also restore a`,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px] mx-0.5`,children:`.db`}),` database file — useful after reinstalling the app to recover data from a manually saved copy. A safety backup is created automatically.`]})]})]}),(0,W.jsxs)(`div`,{onClick:()=>{a!==`importing`&&e.current?.click()},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&a!==`importing`&&e.current?.click()},role:`button`,tabIndex:0,className:`border-2 border-dashed border-border/50 hover:border-primary/40 rounded-xl p-8 text-center cursor-pointer transition-colors`,children:[(0,W.jsx)(`input`,{ref:e,type:`file`,accept:A,className:`hidden`,onChange:x}),a===`importing`?(0,W.jsxs)(`div`,{className:`w-full max-w-sm mx-auto space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground truncate mr-2`,children:v.phase||`Importing…`}),(0,W.jsxs)(`span`,{className:`text-muted-foreground shrink-0 tabular-nums`,children:[k,`%`]})]}),(0,W.jsx)(`div`,{className:`w-full h-2 bg-muted/50 rounded-full overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300 ease-out`,style:{width:`${k}%`}})}),(0,W.jsxs)(`p`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[v.current.toLocaleString(),` / `,v.total.toLocaleString(),` items`]})]}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),D()},className:`text-xs`,children:`Cancel`})]}):(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`p-3 bg-muted/30 rounded-full`,children:(0,W.jsx)(sr,{className:`size-6 text-muted-foreground`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:`Click to select a file`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:j})]})]})]})]})}function Ay({summary:e}){return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:[(0,W.jsx)(jy,{label:`Projects`,value:e.projects}),(0,W.jsx)(jy,{label:`Notes`,value:e.notes}),(0,W.jsx)(jy,{label:`ERD Diagrams`,value:e.diagrams}),(0,W.jsx)(jy,{label:`Tables (Entities)`,value:e.entities}),(0,W.jsx)(jy,{label:`Columns`,value:e.columns}),(0,W.jsx)(jy,{label:`Relationships`,value:e.relationships}),(0,W.jsx)(jy,{label:`Flowcharts`,value:e.flowcharts}),(0,W.jsx)(jy,{label:`Drawings`,value:e.drawings}),(0,W.jsx)(jy,{label:`AI Sessions`,value:e.ai_chat_sessions})]}),e.ai_chat_messages>0&&(0,W.jsxs)(`p`,{className:`text-[11px] text-muted-foreground px-0.5`,children:[`Includes `,e.ai_chat_messages.toLocaleString(),` AI chat messages.`]}),e.skipped_existing>0&&(0,W.jsxs)(`p`,{className:`text-[11px] text-amber-500 px-0.5`,children:[e.skipped_existing.toLocaleString(),` item(s) already existed and were skipped.`]})]})}function jy({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`bg-muted/20 border border-border/40 rounded-lg p-3 text-center`,children:[(0,W.jsx)(`p`,{className:`text-lg font-bold`,children:t.toLocaleString()}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:e})]})}function Nue(){return sessionStorage.getItem(`auth_mode`)===`guest`}function Pue(e){if(!e||typeof e!=`string`)return null;try{let t=JSON.parse(e);return t?.dbml_source??t?.dbmlSource??null}catch{return null}}function Fue(e){let t=e.dbml_source??e.dbmlSource??Pue(e.data);return{...e,dbml_source:t??null,dbmlSource:t??null}}async function My(e){try{return(await ea.getAllResources(e)||[]).filter(e=>!e.is_deleted)}catch{return[]}}function Iue(e){return!e.messages||!Array.isArray(e.messages)?[]:e.messages.map(e=>({id:e.id||e.uid,role:e.role,content:e.content,selection_text:e.selection_text||null,created_at:e.created_at||null}))}async function Lue(){if(!Nue()){let e=await wi(`/api/guest/export`);if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to export data`)}return e.json()}let[e,t,n,r,i,a]=await Promise.all([My(`project`),My(`notes`),My(`erd`),My(`flowchart`),My(`drawings`),My(`ai_chat_session`)]),o=a.map(e=>({uid:e.uid||e.id,title:e.title||`Untitled`,entity_type:e.entity_type||null,entity_uid:e.entity_uid||null,project_id:e.project_id??null,created_at:e.created_at||null,updated_at:e.updated_at||null,messages:Iue(e)})),s={projects:e.length,notes:t.length,diagrams:n.length,flowcharts:r.length,drawings:i.length,ai_chat_sessions:o.length};return{version:`1.0`,exported_at:new Date().toISOString(),application:`ERD Builder Pro`,total_items:s,data:{projects:e,notes:t,diagrams:n.map(Fue),flowcharts:r,drawings:i,ai_chat_sessions:o}}}function Rue(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`erd-data-export-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}async function Ny(){Rue(await Lue())}function zue(){let[e,t]=(0,U.useState)(!1);return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Export Data`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Download projects, notes, ERDs, DBML, flowcharts, drawings, and AI chats as JSON.`})]}),(0,W.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-muted/10 p-5 max-w-xl`,children:(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:`JSON Backup`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:`Use this file with Import Data to restore or migrate your workspace data.`})]}),(0,W.jsxs)(H,{onClick:async()=>{t(!0);try{await Ny(),d.success(`Data exported successfully`)}catch(e){d.error(`Export failed: `+(e.message||`Unknown error`))}finally{t(!1)}},disabled:e,className:`shrink-0`,children:[e?(0,W.jsx)(vo,{className:`size-3.5 mr-2 animate-spin`}):(0,W.jsx)(Yn,{className:`size-3.5 mr-2`}),e?`Exporting...`:`Export JSON`]})]})})]})}function Bue(){if(typeof window>`u`||!window.__TAURI__&&!window.__TAURI_INTERNALS__&&window.ERD_INSTALL_MODE!==`cli`)return(0,W.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,W.jsx)(is,{className:`border-border/50 bg-background/50 backdrop-blur-sm`,children:(0,W.jsxs)(ls,{className:`py-12 text-center`,children:[(0,W.jsx)(Br,{className:`w-8 h-8 mx-auto text-muted-foreground/40`}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-4 text-sm`,children:`Storage configuration is only available in the desktop app or CLI mode.`})]})})});let[e,t]=(0,U.useState)({type:`r2`,accountId:``,endpoint:``,region:`auto`,accessKeyId:``,secretAccessKey:``,bucketName:``,publicUrl:``}),[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(`none`),[o,s]=(0,U.useState)(!0),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)({type:``,message:``}),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),v=(0,U.useCallback)(async()=>{s(!0);try{let e=await wi(`/api/storage/config`,{credentials:`include`});if(e.ok){let n=await e.json();a(n.source),n.config&&(r(n.config),t({type:n.config.type||`r2`,accountId:n.config.accountId||``,endpoint:n.config.endpoint||``,region:n.config.region||`auto`,accessKeyId:n.config.accessKeyId||``,secretAccessKey:n.config.secretAccessKey||``,bucketName:n.config.bucketName||``,publicUrl:n.config.publicUrl||``}))}}catch(e){console.error(`Failed to load storage config:`,e)}finally{s(!1)}},[]);(0,U.useEffect)(()=>{v()},[v]);let y=async()=>{l(!0),p({type:``,message:``});try{let t=await wi(`/api/storage/config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),credentials:`include`});if(t.ok)p({type:`success`,message:`Storage configuration saved successfully.`}),r({...e}),await v();else{let e=await t.json();p({type:`error`,message:e.error||`Failed to save configuration`})}}catch(e){p({type:`error`,message:e.message||`Network error`})}finally{l(!1)}},b=async()=>{d(!0),p({type:``,message:``});try{let t=await wi(`/api/storage/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),credentials:`include`});if(t.ok)p({type:`success`,message:`Successfully connected to storage.`});else{let e=await t.json();p({type:`error`,message:e.error||`Connection failed`})}}catch(e){p({type:`error`,message:e.message||`Network error`})}finally{d(!1)}},x=(e,n)=>{t(t=>({...t,[e]:n})),p({type:``,message:``})};return o?(0,W.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,W.jsx)(is,{className:`border-border/50 bg-background/50 backdrop-blur-sm`,children:(0,W.jsxs)(ls,{className:`py-12 text-center`,children:[(0,W.jsx)(Hr,{className:`w-6 h-6 animate-spin mx-auto text-muted-foreground`}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-4 text-sm`,children:`Loading storage configuration...`})]})})}):(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsxs)(is,{className:`border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg`,children:[(0,W.jsxs)(as,{className:`border-b border-border/30 pb-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(Pa,{className:`w-6 h-6 text-blue-500`}),(0,W.jsx)(os,{className:`text-xl md:text-2xl font-bold`,children:`Storage Configuration`})]}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Configure Cloudflare R2 or S3-compatible storage for image uploads in Notes and Drawings.`})]}),(0,W.jsxs)(ls,{className:`space-y-6 p-4 md:p-6`,children:[i===`env`&&(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20`,children:[(0,W.jsx)(Dr,{className:`w-4 h-4 text-blue-500 shrink-0`}),(0,W.jsx)(`p`,{className:`text-xs text-blue-600 dark:text-blue-400`,children:`Pre-filled from environment variables. Save to override with custom settings.`})]}),f.type&&(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 rounded-lg border ${f.type===`success`?`bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400`:`bg-red-500/10 border-red-500/20 text-red-600 dark:text-red-400`}`,children:[f.type===`success`?(0,W.jsx)(wn,{className:`w-5 h-5 shrink-0`}):(0,W.jsx)(Aa,{className:`w-5 h-5 shrink-0`}),(0,W.jsx)(`p`,{className:`text-sm`,children:f.message})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(Br,{className:`size-3`}),`Storage Provider`]}),(0,W.jsxs)(Er,{value:e.type,onValueChange:(e,t)=>e&&x(`type`,e),children:[(0,W.jsx)(Cr,{className:`h-9 text-sm`,children:(0,W.jsx)(Tr,{children:e.type===`r2`?(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Pa,{className:`w-4 h-4`}),`Cloudflare R2`]}):(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Br,{className:`w-4 h-4`}),`S3-Compatible`]})})}),(0,W.jsxs)(Sr,{children:[(0,W.jsx)(xr,{value:`r2`,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Pa,{className:`w-4 h-4`}),`Cloudflare R2`]})}),(0,W.jsx)(xr,{value:`s3-compatible`,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Br,{className:`w-4 h-4`}),`S3-Compatible`]})})]})]})]}),e.type===`r2`&&(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Account ID`]}),(0,W.jsx)(Oi,{placeholder:`Your Cloudflare R2 Account ID`,value:e.accountId||``,onChange:e=>x(`accountId`,e.target.value),className:`h-9 text-sm font-mono`}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70 mt-1 px-1`,children:`Found in your Cloudflare dashboard under R2 → Account ID.`})]}),e.type===`s3-compatible`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Endpoint URL`]}),(0,W.jsx)(Oi,{placeholder:`https://s3.us-east-1.amazonaws.com`,value:e.endpoint||``,onChange:e=>x(`endpoint`,e.target.value),className:`h-9 text-sm font-mono`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Region`]}),(0,W.jsx)(Oi,{placeholder:`us-east-1`,value:e.region||``,onChange:e=>x(`region`,e.target.value),className:`h-9 text-sm font-mono`})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(co,{className:`size-3`}),`Access Key ID`]}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{type:g?`text`:`password`,placeholder:`Your access key ID`,value:e.accessKeyId,onChange:e=>x(`accessKeyId`,e.target.value),className:`h-9 text-sm font-mono pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(!g),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:g?(0,W.jsx)(Lr,{className:`w-4 h-4`}):(0,W.jsx)(Ba,{className:`w-4 h-4`})})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(co,{className:`size-3`}),`Secret Access Key`]}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{type:m?`text`:`password`,placeholder:`Your secret access key`,value:e.secretAccessKey,onChange:e=>x(`secretAccessKey`,e.target.value),className:`h-9 text-sm font-mono pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:m?(0,W.jsx)(Lr,{className:`w-4 h-4`}):(0,W.jsx)(Ba,{className:`w-4 h-4`})})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(Za,{className:`size-3`}),`Bucket Name`]}),(0,W.jsx)(Oi,{placeholder:`your-bucket-name`,value:e.bucketName,onChange:e=>x(`bucketName`,e.target.value),className:`h-9 text-sm font-mono`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(go,{className:`size-3`}),`Public URL (optional)`]}),(0,W.jsx)(Oi,{placeholder:`https://cdn.yourdomain.com`,value:e.publicUrl||``,onChange:e=>x(`publicUrl`,e.target.value),className:`h-9 text-sm font-mono`}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70 mt-1 px-1`,children:e.type===`s3-compatible`?`Optional. If set, overrides the auto-constructed endpoint URL. Useful for custom CDN/domain. If empty, URL is built from Endpoint + Bucket.`:`Optional public URL prefix for direct image access (e.g., custom domain or CDN). If empty, R2 public URL is auto-constructed.`})]})]}),(0,W.jsxs)(us,{className:`bg-muted/5 border-t border-border/30 p-4 md:px-6 md:py-4 flex flex-col sm:flex-row gap-3 sm:justify-end`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:b,disabled:u||!e.bucketName||!e.accessKeyId||!e.secretAccessKey,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border text-sm font-medium whitespace-nowrap transition-colors h-10 px-4 bg-background hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none`,children:u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 shrink-0 animate-spin pointer-events-none`}),(0,W.jsx)(`span`,{className:`pointer-events-none`,children:`Testing...`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 shrink-0 pointer-events-none`}),(0,W.jsx)(`span`,{className:`pointer-events-none`,children:`Test Connection`})]})}),(0,W.jsxs)(H,{onClick:y,className:`gap-2 px-6`,disabled:c,children:[c?(0,W.jsx)(Hr,{className:`w-4 h-4 animate-spin`}):(0,W.jsx)(mr,{className:`w-4 h-4`}),c?`Saving...`:`Save Configuration`]})]})]})})}var Py=[{title:`General`,rows:[[`Sync pending changes`,`⌘ S`,`Ctrl S`],[`Focus file search`,`⌘ K`,`Ctrl K`],[`Open Settings (desktop)`,`⌘ ,`,`Ctrl ,`]]},{title:`Notes`,rows:[[`Bold`,`⌘ B`,`Ctrl B`],[`Italic`,`⌘ I`,`Ctrl I`],[`Underline`,`⌘ U`,`Ctrl U`],[`Strikethrough`,`⌘ ⇧ S`,`Ctrl Shift S`],[`Inline code`,`⌘ E`,`Ctrl E`],[`Heading 1–4`,`⌘ ⌥ 1–4`,`Ctrl Alt 1–4`],[`Bulleted list`,`⌘ ⇧ 8`,`Ctrl Shift 8`],[`Numbered list`,`⌘ ⇧ 7`,`Ctrl Shift 7`],[`Task list`,`⌘ ⇧ 9`,`Ctrl Shift 9`],[`Blockquote`,`⌘ ⇧ B`,`Ctrl Shift B`],[`Code block`,`⌘ ⌥ C`,`Ctrl Alt C`],[`Insert table`,`⌘ ⌥ T`,`Ctrl Alt T`],[`Toggle badge`,`⌘ ⌥ B`,`Ctrl Alt B`],[`Align left / center / right`,`⌘ ⇧ L / C / R`,`Ctrl Shift L / C / R`],[`Undo / redo`,`⌘ Z / ⌘ Y`,`Ctrl Z / Ctrl Y`],[`Export note`,`⌘ ⇧ E`,`Ctrl Shift E`],[`Import note`,`⌘ ⇧ I`,`Ctrl Shift I`]]},{title:`ERD Builder`,rows:[[`Jump to Table`,`⌘ ⇧ F`,`Ctrl Shift F`],[`Undo / redo`,`⌘ Z / ⌘ ⇧ Z`,`Ctrl Z / Ctrl Y`],[`Add or remove from selection`,`⌘ Click`,`Ctrl Click`]]},{title:`Flowchart`,rows:[[`Delete selected node or edge`,`Delete / Backspace`,`Delete / Backspace`]]}],Vue=[[`Focus table search`,`⌘ P`,`Ctrl P`],[`Toggle filters`,`⌘ F`,`Ctrl F`],[`Refresh records`,`⌘ R`,`Ctrl R`],[`Select all records`,`⌘ A`,`Ctrl A`],[`Add or remove a record from selection`,`⌘ Click`,`Ctrl Click`],[`Save record or structure`,`⌘ S`,`Ctrl S`],[`Run SQL query`,`⌘ Enter`,`Ctrl Enter`],[`Format SQL query`,`⌘ I`,`Ctrl I`],[`Cancel inline changes`,`Esc`,`Esc`]];function Hue(){let e=typeof navigator<`u`&&/mac|iphone|ipad|ipod/i.test(navigator.platform),t=typeof window<`u`&&(window.__TAURI__||window.__TAURI_INTERNALS__||window.ERD_INSTALL_MODE===`cli`)?[...Py,{title:`DB Client`,rows:Vue}]:Py;return(0,W.jsxs)(`div`,{className:`p-4 md:p-6 space-y-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Keymap`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Keyboard shortcuts available in ERD Builder Pro.`})]}),t.map(({title:t,rows:n})=>(0,W.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,W.jsx)(`h3`,{className:`border-b border-border bg-muted/40 px-4 py-2.5 text-sm font-medium`,children:t}),(0,W.jsx)(`div`,{className:`divide-y divide-border`,children:n.map(([t,n,r])=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-4 py-2.5 text-sm`,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`kbd`,{className:`rounded border bg-muted px-1.5 py-0.5 font-mono text-xs text-muted-foreground`,children:e?n:r})]},t))})]},t)),(0,W.jsxs)(`section`,{className:`rounded-lg border border-border p-4 text-sm`,children:[(0,W.jsx)(`h3`,{className:`font-medium`,children:`Drawings`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Drawings use Excalidraw’s built-in keymap. Open Help from its menu to view the shortcuts available for the current editor version.`})]})]})}var Fy=e=>JSON.stringify(e,null,2);function Iy(e,t){return/[\s"']/.test(e)?t?`"${e.replace(/"/g,`\\"`)}"`:`'${e.replace(/'/g,`'\\''`)}'`:e}function Uue(e){let t={command:e.command,...e.args.length?{args:e.args}:{}},n=e.args.map(t=>Iy(t,e.platform===`win32`)).join(` `),r=[`codex`,`mcp`,`add`,`erdbpro`,`--`,e.command,...e.args].map(t=>Iy(t,e.platform===`win32`)).join(` `);return[{id:`jetbrains`,label:`JetBrains AI`,description:`Paste into the MCP server JSON configuration.`,language:`json`,content:Fy({mcpServers:{erdbpro:t}})},{id:`vscode`,label:`VS Code`,description:`Save as .vscode/mcp.json or paste into the MCP configuration.`,language:`json`,content:Fy({servers:{erdbpro:{type:`stdio`,...t}}})},{id:`codex`,label:`Codex`,description:`Run once in a terminal to register the local MCP server.`,language:`bash`,content:r},{id:`hermes`,label:`Hermes Agent`,description:`Enter these values in Add MCP Server. Leave Environment empty.`,language:`text`,content:`Name: erdbpro\nTransport: stdio\nCommand: ${e.command}\nArgs: ${n||`(leave empty)`}\nEnvironment: (leave empty)`},{id:`generic`,label:`Generic MCP (STDIO)`,description:`Use for clients that accept a standard STDIO command definition.`,language:`json`,content:Fy({transport:`stdio`,...t})}]}function Wue(){let[e,t]=U.useState(null),[n,r]=U.useState(``),[i,a]=U.useState(``),[o,s]=U.useState(`jetbrains`);U.useEffect(()=>{let e=!1;return wi(`/api/mcp/client-config`).then(async n=>{let r=await n.json();if(!n.ok)throw Error(r.error||`Failed to load MCP configuration.`);e||t(r)}).catch(t=>{e||r(t instanceof Error?t.message:`Failed to load MCP configuration.`)}),()=>{e=!0}},[]);let c=async(e,t)=>{await navigator.clipboard.writeText(t),a(e),d.success(`MCP configuration copied`),window.setTimeout(()=>a(``),1500)};if(n)return(0,W.jsxs)(`div`,{className:`p-6`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`MCP Integration`}),(0,W.jsx)(`p`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,children:n})]});if(!e)return(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,W.jsx)(vo,{className:`size-5 animate-spin text-muted-foreground`})});if(e.mode===`web`)return(0,W.jsxs)(`div`,{className:`space-y-5 p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,W.jsx)(Ra,{className:`size-5`}),`Public MCP Integration`]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Detected mode: Web App. This page automatically shows the matching MCP connection for the current installation mode.`})]}),e.configured&&e.url?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Public MCP URL (Streamable HTTP)`}),(0,W.jsxs)(H,{variant:`ghost`,size:`xs`,onClick:()=>void c(`public-url`,e.url),children:[i===`public-url`?(0,W.jsx)(an,{}):(0,W.jsx)(La,{}),i===`public-url`?`Copied`:`Copy`]})]}),(0,W.jsx)(`code`,{className:`mt-1 block break-all text-xs`,children:e.url})]}),(0,W.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground`,children:`Add this URL as a custom connector in Claude Web or Claude Desktop. Authentication uses OAuth and grants user-scoped, read-only access.`})]}):(0,W.jsx)(`p`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-700 dark:text-amber-300`,children:`Public MCP is not configured. Set MCP_PUBLIC_URL on the Web App server and restart it to publish the connection URL.`})]});let l=Uue(e),u=l.find(e=>e.id===o)||l[0];return(0,W.jsxs)(`div`,{className:`space-y-5 p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,W.jsx)(ir,{className:`size-5`}),`Connect AI Clients`]}),(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Detected mode: `,e.mode===`cli`?`CLI`:`Desktop App`,`. Use ERD Builder Pro as a local MCP Server (STDIO) with an external AI client. The launcher runs headlessly without opening another app window.`]})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`MCP Server (STDIO) launcher`}),(0,W.jsx)(`code`,{className:`mt-1 block break-all text-xs`,children:e.command})]}),(0,W.jsx)(`div`,{role:`tablist`,"aria-label":`MCP client`,className:`flex w-full flex-wrap gap-1 rounded-lg border bg-muted p-1`,children:l.map(e=>{let t=e.id===u.id;return(0,W.jsx)(H,{type:`button`,size:`sm`,variant:t?`default`:`ghost`,role:`tab`,"aria-selected":t,onClick:()=>s(e.id),className:`flex-1 text-xs`,children:e.label},e.id)})}),(0,W.jsxs)(`div`,{role:`tabpanel`,"aria-label":u.label,className:`space-y-3 pt-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u.description}),(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:u.language}),(0,W.jsxs)(H,{variant:`ghost`,size:`xs`,onClick:()=>void c(u.id,u.content),children:[i===u.id?(0,W.jsx)(an,{}):(0,W.jsx)(La,{}),i===u.id?`Copied`:`Copy`]})]}),(0,W.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre p-4 text-xs leading-relaxed`,children:(0,W.jsx)(`code`,{children:u.content})})]})]})]})}function Ly(e){return{active:e.active===!0,planCode:e.planCode??e.plan_code,expiresAt:e.expiresAt??e.expires_at,lastCheckedAt:e.lastCheckedAt??e.last_checked_at,maxTeams:e.maxTeams??e.max_teams,maxMembers:e.maxMembers??e.max_members,usage:{teamCount:e.usage?.teamCount??e.usage?.team_count??0,memberCount:e.usage?.memberCount??e.usage?.member_count??0}}}function Ry(e,t){return{message:e.error||t,...e.code?{code:e.code}:{}}}async function zy(e){return e.json().catch(()=>({}))}function Gue(){let[e,t]=(0,U.useState)(null),[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),h=(0,U.useCallback)(async()=>{try{let e=await wi(`/api/license/status`),n=await zy(e);if(!e.ok){s(Ry(n,`Failed to load license status.`));return}t(Ly(n))}catch(e){s({message:e instanceof Error?e.message:`Failed to load license status.`})}},[]);(0,U.useEffect)(()=>{h()},[h]);let g=async()=>{s(null),f(!0);try{let e={license_key:n.trim()},o=i.trim();o&&(e.activation_grant=o);let c=await wi(`/api/license/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),l=await zy(c);if(!c.ok){s(Ry(l,`License activation failed.`));return}r(``),a(``),t(Ly(l)),d.success(`License activated`)}catch(e){s({message:e instanceof Error?e.message:`License activation failed.`})}finally{f(!1)}},_=async()=>{s(null),l(!0);try{let e=await wi(`/api/license/check`,{method:`POST`}),n=await zy(e);if(!e.ok){s(Ry(n,`License check failed.`));return}t(Ly(n)),d.success(`License checked successfully`)}catch(e){s({message:e instanceof Error?e.message:`License check failed.`})}finally{l(!1)}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`space-y-6 p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Application License`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This instance license controls commercial Team capacity. Personal use does not require activation.`})]}),e&&(0,W.jsxs)(`div`,{className:`rounded-lg border p-4 text-sm`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:e.active?`Active: ${e.planCode}`:`No commercial license is active`}),(0,W.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Active Teams: `,e.usage.teamCount,` /`,` `,e.maxTeams??(e.active?`No limit`:`N/A`),` · Active members: `,e.usage.memberCount,` /`,` `,e.maxMembers??(e.active?`No limit`:`N/A`)]}),e.active&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(H,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>void _(),disabled:c||u,children:[c?(0,W.jsx)(Hr,{className:`animate-spin`}):(0,W.jsx)(Hr,{}),`Check license`]}),e.lastCheckedAt&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Last checked: `,new Date(e.lastCheckedAt).toLocaleString()]})]})]}),(0,W.jsxs)(Rr,{className:`gap-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`instance-license-key`,children:`Instance license key`}),(0,W.jsx)(Oi,{id:`instance-license-key`,type:`password`,autoComplete:`off`,disabled:u,value:n,onChange:e=>{r(e.target.value),s(null)}})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`instance-activation-grant`,children:`Activation grant`}),(0,W.jsx)(Oi,{id:`instance-activation-grant`,type:`password`,autoComplete:`off`,disabled:u,"aria-describedby":`activation-grant-description`,value:i,onChange:e=>{a(e.target.value),s(null)}}),(0,W.jsx)(Ir,{id:`activation-grant-description`,children:`Only needed after resetting a deployment binding. Enter the one-time grant from SaaS with the same license key.`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(H,{onClick:()=>m(!0),disabled:!n.trim()||c||u,children:[(0,W.jsx)(co,{}),u?`Activating...`:`Activate license`]}),o&&(0,W.jsxs)(`div`,{id:`license-activation-error`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`text-sm text-destructive`,children:o.message}),o.code&&(0,W.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`Code: `,o.code]}),o.code===`LICENSE_ALREADY_BOUND`&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Reset the old deployment binding in SaaS, then enter its activation grant above.`})]})]})]}),(0,W.jsx)(kr,{isOpen:p,title:`Activate license?`,message:`This will activate the license for this Self-host instance and update its Team and member capacity.`,confirmText:`Activate license`,cancelText:`Cancel`,variant:`info`,onCancel:()=>m(!1),onConfirm:()=>{m(!1),g()}})]})}function Kue(){let{isSettingsOpen:e,setIsSettingsOpen:t,settingsTab:n,setSettingsTab:r}=ia(),i=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),a=i||typeof window<`u`&&window.ERD_INSTALL_MODE===`cli`,[o,s]=U.useState(`configuration`);U.useEffect(()=>{if(!i)return;let e,n=!1;return(async()=>{let{listen:i}=await bi(async()=>{let{listen:e}=await import(`./event-DtFyPu7u.js`);return{listen:e}},__vite__mapDeps([0,1]));n||(e=await i(`menu-settings`,()=>{r(`account`),t(!0)}))})(),()=>{n=!0,e?.()}},[i,t,r]);let{isGuest:c,user:l}=ta(),u=!!l?.isSso,d=!u&&(a||!!(l?.isSuperAdmin||l?.is_super_admin)),f=d&&!a,{providers:p,configs:m,isTesting:h,isSaving:g,handleSaveConfig:_,handleTestConnection:v,handleInitializeProviders:y,updateProviderLocal:b,updateConfigLocal:x}=lie(d),{models:S,newModel:C,editingModelId:w,isSaving:T,setNewModel:E,handleAddModel:D,handleDeleteModel:O,ensureModel:k,startEditingModel:A,cancelEdit:j,refresh:M}=uie(d),{prompts:N,isSaving:P,handleSavePrompt:F,handleDeletePrompt:I,togglePromptDefault:L}=die(),R=U.useMemo(()=>c?[{label:`General`,items:[{id:`appearance`,label:`Appearance`,icon:(0,W.jsx)(Oo,{className:`size-4`})}]},{label:`More`,items:[{id:`keymap`,label:`Keymap`,icon:(0,W.jsx)(uo,{className:`size-4`})},{id:`changelog`,label:`What's New`,icon:(0,W.jsx)(oo,{className:`size-4`})}]}]:[{label:`General`,items:[...u?[]:[{id:`account`,label:`Account`,icon:(0,W.jsx)(Qo,{className:`size-4`})}],{id:`appearance`,label:`Appearance`,icon:(0,W.jsx)(Oo,{className:`size-4`})},...a&&!u?[{id:`storage`,label:`Storage`,icon:(0,W.jsx)(Br,{className:`size-4`})}]:[],...u?[{id:`usage`,label:`Usage`,icon:(0,W.jsx)($a,{className:`size-4`})}]:[]]},{label:`Feature`,items:[...d?[{id:`ai-config`,label:`AI Configuration`,icon:(0,W.jsx)(ti,{className:`size-4`})}]:[],...f?[{id:`license`,label:`Application License`,icon:(0,W.jsx)(co,{className:`size-4`})}]:[],{id:`mcp-server`,label:`MCP Integration`,icon:(0,W.jsx)(Io,{className:`size-4`})},{id:`ai-rules`,label:`AI Rules`,icon:(0,W.jsx)(_o,{className:`size-4`})},{id:`ai-prompts`,label:`System Prompts`,icon:(0,W.jsx)(ba,{className:`size-4`})}]},{label:`More`,items:[{id:`keymap`,label:`Keymap`,icon:(0,W.jsx)(uo,{className:`size-4`})},...d?[{id:`export-data`,label:`Export Data`,icon:(0,W.jsx)(Yn,{className:`size-4`})},{id:`import-data`,label:`Import Data`,icon:(0,W.jsx)(sr,{className:`size-4`})},{id:`backups`,label:`Database Backup`,icon:(0,W.jsx)(Ar,{className:`size-4`})}]:[],{id:`changelog`,label:`What's New`,icon:(0,W.jsx)(oo,{className:`size-4`})}]}],[f,c,a,u,d]);U.useEffect(()=>{(!d&&[`ai-config`,`license`,`export-data`,`import-data`,`backups`].includes(n)||u&&n===`account`||n===`license`&&!f)&&r(c||u?`appearance`:`account`)},[f,c,u,d,n,r]);let ee=R.flatMap(e=>e.items),te=e=>ee.find(t=>t.id===e)?.label||``;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`overflow-hidden p-0 md:max-h-150 md:max-w-175 lg:max-w-237.5 bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`Settings`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Manage your application settings and AI configuration.`}),(0,W.jsxs)(Fp,{className:`items-start min-h-0! h-full`,children:[(0,W.jsx)(Ip,{collapsible:`none`,className:`w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full`,children:(0,W.jsxs)(zp,{className:`pt-4 px-2 pb-0`,children:[(0,W.jsx)(`div`,{className:`px-4 py-2 mb-2`,children:(0,W.jsxs)(`h2`,{className:`text-sm font-bold flex items-center gap-2`,children:[(0,W.jsx)(Ro,{className:`size-4`}),`Settings`]})}),R.map(e=>(0,W.jsxs)(Bp,{className:`py-1`,children:[(0,W.jsx)(Vp,{className:`text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5`,children:e.label}),(0,W.jsx)(Hp,{children:(0,W.jsx)(Up,{children:e.items.map(e=>(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{isActive:n===e.id,onClick:()=>r(e.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${n===e.id?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-muted-foreground hover:bg-sidebar-accent/50`}`,children:[e.icon,(0,W.jsx)(`span`,{className:`text-xs`,children:e.label})]})},e.id))})})]},e.label))]})}),(0,W.jsxs)(`main`,{className:`flex-1 flex flex-col h-150 overflow-hidden`,children:[(0,W.jsx)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(Kp,{className:`hidden md:flex`,children:(0,W.jsxs)(qp,{children:[(0,W.jsx)(Jp,{children:(0,W.jsx)(cie,{href:`#`,className:`text-[11px] text-muted-foreground`,children:`Settings`})}),(0,W.jsx)(Xp,{}),(0,W.jsx)(Jp,{children:(0,W.jsx)(Yp,{className:`text-[11px] font-semibold`,children:te(n)})})]})}),(0,W.jsx)(`div`,{className:`md:hidden`,children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`-ml-2 h-8 gap-2 text-xs font-semibold`,children:[(0,W.jsx)(Ro,{className:`size-3.5`}),te(n),(0,W.jsx)(on,{className:`size-3 opacity-50`})]})}),(0,W.jsx)(en,{align:`start`,className:`w-56`,children:R.map(e=>(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5`,children:e.label}),e.items.map(e=>(0,W.jsxs)(Kt,{onClick:()=>r(e.id),className:n===e.id?`bg-accent`:``,children:[e.icon,(0,W.jsx)(`span`,{className:`ml-2`,children:e.label})]},e.id)),(0,W.jsx)(tn,{})]},e.label))})]})})]})}),(0,W.jsxs)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:[d&&n===`ai-config`&&(0,W.jsxs)(`div`,{className:`p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{className:`flex gap-1 bg-muted border border-border rounded-lg p-1 w-full mb-4`,children:[(0,W.jsxs)(`button`,{onClick:()=>s(`configuration`),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${o===`configuration`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[(0,W.jsx)(Ro,{className:`w-3.5 h-3.5`}),`Configuration`]}),(0,W.jsxs)(`button`,{onClick:()=>s(`models`),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${o===`models`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[(0,W.jsx)(ba,{className:`w-3.5 h-3.5`}),`AI Models`]})]}),o===`configuration`&&(0,W.jsx)(fie,{providers:p,configs:m,models:S,isSaving:g,isTesting:h,onSave:_,onTest:e=>v(e,Object.values(S).flat()),onUpdateProvider:b,onUpdateConfig:x,onEnsureModel:k,onRefreshModels:M,onInitialize:y}),o===`models`&&(0,W.jsx)(nm,{providers:p,models:Object.values(S).flat(),newModel:C,editingModelId:w,isSaving:T,onSetNewModel:E,onAddModel:D,onEditModel:A,onDeleteModel:O,onCancelEdit:j})]}),n===`ai-prompts`&&(0,W.jsx)(pie,{prompts:N,isSaving:P,onSave:F,onDelete:I,onToggleDefault:L}),n===`ai-rules`&&(0,W.jsx)(gie,{}),n===`mcp-server`&&(0,W.jsx)(Wue,{}),f&&n===`license`&&(0,W.jsx)(Gue,{}),d&&n===`backups`&&(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsx)(Mie,{})}),!u&&n===`account`&&(0,W.jsx)(_ie,{}),n===`changelog`&&(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsx)(Oue,{})}),n===`keymap`&&(0,W.jsx)(Hue,{}),d&&n===`export-data`&&(0,W.jsx)(`div`,{className:`p-4 md:p-6 overflow-y-auto h-full`,children:(0,W.jsx)(zue,{})}),d&&n===`import-data`&&(0,W.jsxs)(`div`,{className:`p-4 md:p-6 overflow-y-auto h-full`,children:[(0,W.jsxs)(`div`,{className:`mb-6`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Import Data`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restore data from a JSON backup or replace the local database from a .db file.`})]}),(0,W.jsx)(Mue,{})]}),n===`appearance`&&(0,W.jsx)(bie,{}),n===`storage`&&(0,W.jsx)(Bue,{}),u&&n===`usage`&&(0,W.jsx)($p,{onClose:()=>t(!1)})]})]})]})]})})}async function que(){try{let{getVersion:e}=await bi(async()=>{let{getVersion:e}=await import(`./app-Dwb58oCT.js`);return{getVersion:e}},__vite__mapDeps([2,1,3]));return await e()}catch{return`0.0.0`}}function By({open:e,onOpenChange:t,hasUpdate:n=!1,latestVersion:r=null,isChecking:i=!1,isDownloading:a=!1,onCheckUpdate:o,onDownload:s}){let c=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[l,u]=(0,U.useState)(`...`),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),S=n||f,C=r||m,w=i||g,T=a||v;(0,U.useEffect)(()=>{c?que().then(u):u(`3.4.7-rc.38`)},[c]),(0,U.useEffect)(()=>{if(!e||!c||n||i||a)return;if(o){o();return}if(s)return;_(!0);let t=!1;return(async()=>{try{let{check:e}=await bi(async()=>{let{check:e}=await import(`./dist-js-CoMyUP6l.js`).then(e=>e.n);return{check:e}},__vite__mapDeps([4,5,1])),n=await e();if(t)return;n?(p(!0),h(n.version),x(n)):(p(!1),h(null),x(null))}catch{}finally{t||_(!1)}})(),()=>{t=!0}},[e,c]);let E=(0,U.useCallback)(()=>{if(s)s();else if(b){if(v)return;y(!0),b.downloadAndInstall(()=>{}).catch(e=>{let t=typeof e==`string`?e:e?.message?e.message:JSON.stringify(e);d.error(`Update failed`,{description:t||`An error occurred while downloading the update.`,duration:12e3,action:{label:`Copy Error`,onClick:()=>navigator.clipboard.writeText(t).catch(()=>{})}})}).finally(()=>y(!1))}},[s,b,v]),D=(0,U.useCallback)(()=>{T||(o?o():(_(!0),p(!1),h(null),(async()=>{try{let{check:e}=await bi(async()=>{let{check:e}=await import(`./dist-js-CoMyUP6l.js`).then(e=>e.n);return{check:e}},__vite__mapDeps([4,5,1])),t=await e();t?(p(!0),h(t.version),x(t)):(p(!1),h(null),x(null))}catch{}finally{_(!1)}})()))},[o,T]);return(0,U.useEffect)(()=>{e||(p(!1),h(null),_(!1),x(null))},[e]),(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`max-w-sm bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`About ERD Builder Pro`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Application information and credits.`}),(0,W.jsxs)(`div`,{className:`flex flex-col items-center py-6 gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex size-14 items-center justify-center`,children:[(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Light-1.svg`,alt:``,"aria-hidden":`true`,className:`size-full dark:hidden`}),(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Dark-1.svg`,alt:``,"aria-hidden":`true`,className:`hidden size-full dark:block`})]}),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`ERD Builder Pro`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`Version `,l]})]}),(0,W.jsx)(`p`,{className:`text-xs text-center text-muted-foreground max-w-60 leading-relaxed`,children:`Entity-Relationship Diagram builder, flowcharts, notes, and AI-powered assistance — all in one desktop app.`}),c&&(0,W.jsxs)(`div`,{className:`w-full`,children:[(0,W.jsx)(`div`,{className:`w-full border-t border-border/40 mb-3`}),w?(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground py-1`,children:[(0,W.jsx)(vo,{className:`size-3.5 animate-spin`}),`Checking for updates...`]}):S&&C?(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-500`,children:[(0,W.jsx)(Yn,{className:`size-3.5`}),(0,W.jsxs)(`span`,{children:[`Update `,(0,W.jsxs)(`strong`,{children:[`v`,C]}),` available`]})]}),(0,W.jsxs)(H,{variant:`default`,size:`sm`,className:`h-8 text-xs gap-1.5`,onClick:E,disabled:T,children:[T?(0,W.jsx)(vo,{className:`size-3.5 animate-spin`}):(0,W.jsx)(Yn,{className:`size-3.5`}),T?`Downloading...`:`Download Update`]})]}):(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-emerald-500`,children:[(0,W.jsx)(wn,{className:`size-3.5`}),(0,W.jsx)(`span`,{children:`You're up to date`})]}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground`,onClick:D,children:[(0,W.jsx)(Hr,{className:`size-3`}),`Check Again`]})]})]}),(0,W.jsx)(`div`,{className:`w-full border-t border-border/40`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-center text-muted-foreground/60 leading-relaxed`,children:[(0,W.jsx)(`p`,{children:`Built with React, Tauri, Express & Prisma.`}),(0,W.jsxs)(`p`,{className:`mt-0.5`,children:[`© `,new Date().getFullYear(),` Bekenweb.`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground`,onClick:()=>{Hi(`https://github.com/hadziqmtqn/erd-builder-pro`)},children:[(0,W.jsx)(za,{className:`size-3`}),`GitHub`]}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-rose-500 hover:text-rose-600`,onClick:()=>{Hi(`https://trakteer.id/khadziq_muttaqin/tip`)},children:[(0,W.jsx)(ao,{className:`size-3`}),`Support`]})]})]})]})})}function Jue(e){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),{setViewport:l,fitView:u}=z();return{isPublicView:t,setIsPublicView:n,publicData:r,isPublicLoading:a,forbiddenDoc:s,fetchPublicDocument:async(t,n,r,a,s)=>{o(!0),c(null);try{let o=t===`erd`?`files`:t===`flowchart`?`flowcharts`:t,d={"Content-Type":`application/json`};s&&(d[`x-share-token`]=s);let f=await wi(`/api/${o}/public/${n}`,{headers:d,credentials:`include`});if(!f.ok){let e=`Document not found or access denied`,t=`Access Denied`;try{e=(await f.json()).error||e,f.status===404?t=`Not Found`:(f.status===401||f.status===403)&&(t=`Access Denied`)}catch{}if(f.status===401||f.status===403||f.status===404)return c({title:t,message:e,status:f.status}),!1;throw Error(e)}let p=f.headers.get(`content-type`);if(!p||!p.includes(`application/json`))throw Error(`Received invalid response from server`);let m=await f.json();if(i(m),e(t),t===`erd`){let e=m.entities.map(e=>({id:e.id,type:`entity`,position:{x:e.x,y:e.y},data:e})),t=m.relationships.map(e=>{let t=m.entities.find(t=>String(t.id)===String(e.source_entity_id)),n=m.entities.find(t=>String(t.id)===String(e.target_entity_id)),r=e.source_handle,i=e.target_handle;if(t&&n){let a=Number(t.x)||0,o=Number(n.x)||0,s=(e.source_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``),c=(e.target_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);s&&(r=a<o?`col-${s}-source`:`col-${s}-source-l`),c&&(i=a<o?`col-${c}-target`:`col-${c}-target-r`)}let a=(e.source_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``),o=(e.target_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);return{id:e.id,source:e.source_entity_id,target:e.target_entity_id,sourceHandle:r||(a?`col-${a}-source`:void 0),targetHandle:i||(o?`col-${o}-target`:void 0),label:e.label,type:`smoothstep`,animated:!0}});r(e),a(t);let n=(t=0)=>{let n=Ni(m);n?l(n,{duration:t}):e.length>0&&u({padding:.2,duration:t})};setTimeout(()=>n(0),100)}else if(t===`flowchart`)try{let e=typeof m.data==`string`?JSON.parse(m.data):m.data;r(e.nodes||[]),a(e.edges||[]);let t=(t=0)=>{let n=Ni(m);n?l(n,{duration:t}):e.nodes?.length>0&&u({padding:.2,duration:t})};setTimeout(()=>t(0),100)}catch(e){console.error(`Failed to parse flowchart data:`,e)}else r([]),a([]);return!0}catch(e){return d.error(e.message||`Failed to load shared document`),setTimeout(()=>window.location.href=`/`,3e3),!1}finally{o(!1)}}}}var Vy=(0,U.createContext)(null),Hy=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Uy={checked(e){return e?{[Hy.checked]:``}:{[Hy.unchecked]:``}},...$e,...Ot},Wy=`data-composite-item-active`,Gy=U.createContext(void 0);function Yue(){return U.useContext(Gy)}var Ky=U.createContext(void 0);function Xue(){let e=U.useContext(Ky);if(e===void 0)throw Error(Ne(52));return e}var qy=U.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,...f}=e,p=Yue(),{disabled:m,readOnly:h,required:g,checkedValue:_,touched:v=!1,validation:y,name:b}=p??{},x=p?.setCheckedValue??Ae,S=p?.setTouched??Ae,C=p?.registerControlRef??Ae,w=p?.registerInputRef??Ae,{setDirty:T,validityData:E,setTouched:D,setFilled:O,state:k,disabled:A}=Tt(),j=ms(),{labelId:M,getDescriptionProps:N}=kt(),P=A||j.disabled||m||i,F=h||a,I=g||o,L=p?_===c:c===``,R=U.useMemo(()=>br(c),[c]),ee=U.useRef(null),te=U.useRef(null),ne=ke(e=>{e&&C(e,P)}),re=Le(l,te,w);Oe(()=>{te.current?.checked&&O(!0)},[O]),Oe(()=>{te.current&&(P&&L?w(null):(ee.current&&C(ee.current,P),w(te.current)))},[L,P,C,w]);let ie=Xe(),z=Dt({id:d,implicit:!1,controlRef:ee}),ae=u?void 0:z,oe=am(s,M,te,!u,ae),se={role:`radio`,"aria-checked":L,"aria-required":I||void 0,"aria-readonly":F||void 0,"aria-labelledby":oe,[Wy]:L?``:void 0,id:u?z:ie,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){e.defaultPrevented||P||F||(e.preventDefault(),te.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))},onFocus(e){e.defaultPrevented||P||F||!v||(te.current?.click(),S(!1))}},{getButtonProps:ce,buttonRef:le}=Me({disabled:P,native:u}),ue={type:`radio`,ref:re,id:ae,name:b,tabIndex:-1,style:b?bt:dt,"aria-hidden":!0,...c===void 0?je:{value:R},disabled:P,checked:L,required:I,readOnly:F,onChange(e){if(e.nativeEvent.defaultPrevented||P||F||c===void 0)return;let t=gt(Ze,e.nativeEvent);t.isCanceled||(D(!0),T(c!==E.initialValue),O(!0),x(c,t))},onFocus(){ee.current?.focus()}},de=U.useMemo(()=>({...k,required:I,disabled:P,readOnly:F,checked:L}),[k,P,F,L,I]),B=de,fe=p!==void 0,pe=[t,ee,le,ne],me=[se,N,y?.getValidationProps??je,f,ce],he=Pe(`span`,e,{enabled:!fe,state:de,ref:pe,props:me,stateAttributesMapping:Uy});return(0,W.jsxs)(Ky.Provider,{value:B,children:[fe?(0,W.jsx)(Zt,{tag:`span`,render:n,className:r,state:de,refs:pe,props:me,stateAttributesMapping:Uy}):he,(0,W.jsx)(`input`,{...ue})]})}),Jy=U.forwardRef(function(e,t){let{render:n,className:r,keepMounted:i=!1,...a}=e,o=Xue(),s=o.checked,{mounted:c,transitionStatus:l,setMounted:u}=We(s),d={...o,transitionStatus:l},f=U.useRef(null),p=i||c,m=Pe(`span`,e,{ref:[t,f],state:d,props:a,stateAttributesMapping:Uy});return Je({open:s,ref:f,onComplete(){s||u(!1)}}),p?m:null});function Zue(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Que=[];function $ue(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=Que}=e,[m,h]=U.useState(0),g=n>1,_=U.useRef(null),v=Le(_,l),y=U.useRef([]),b=U.useRef(!1),x=s??m,S=ke((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];it(_.current,t,o,a)}}),C=ke(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),it(_.current,n,o,a)}),w=U.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){_.current&&Ct(e.target)&&e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?rt:vt;if(!s.has(e.key)||ede(e,p)||!_.current)return;let c=o===`rtl`,l=c?at:ut,m={horizontal:l,vertical:mt,both:l}[a],h=c?ut:at,v={horizontal:h,vertical:yt,both:h}[a];if(Ct(e.target)&&!Zue(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=tt(y,f),w=Qe(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=Ye(o,n,i),l=s.findIndex(e=>e!=null&&!_t(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!_t(y,t,f)?n:e,-1);b=s[Ge({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:et([...f||y.current.map((e,t)=>_t(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:Ue(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[mt],both:[l,mt]}[a],E={horizontal:[h],vertical:[yt],both:[h,yt]}[a],D=g?s:{horizontal:u?ft:ht,vertical:u?xt:nt,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:wt(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!Ke(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return U.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function ede(e,t){for(let n of lt.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Yy(e){let{render:t,className:n,refs:r=Fe,props:i=Fe,state:a=je,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=$ue({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:sn(),disabledIndices:v,modifierKeys:y}),k=Pe(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=U.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,W.jsx)(De.Provider,{value:A,children:(0,W.jsx)(un,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var tde=[st],Xy=U.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,name:u,inputRef:d,id:f,...p}=e,{setTouched:m,setFocused:h,shouldValidateOnChange:g,validationMode:_,name:v,disabled:y,state:b,validation:x,setDirty:S,setFilled:C,validityData:w}=Tt(),{labelId:T}=kt(),{clearErrors:E}=Et(),D=fs(!0),O=y||i,k=v??u,A=Xe(f),[j,M]=cn({controlled:c,default:l,name:`RadioGroup`,state:`value`}),N=ke(s),P=ke((e,t)=>{N(e,t),!t.isCanceled&&M(e)}),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null);function R(e){let t;return d&&(typeof d==`function`?t=d(e):d.current=e),I.current=e,x.inputRef.current=e,t}let ee=ke((e,t=!1)=>{e&&(t?F.current===e&&(F.current=null):F.current??=e)}),te=ke(e=>{if(!e||e.disabled)return;L.current||=e;let t=I.current;if(e.checked||t==null||t.disabled)return R(e)});jt({id:A,commit:x.commit,value:j,controlRef:F,name:k,getValue:()=>j??null}),pt(j,()=>{E(k),S(j!==w.initialValue),C(j!=null),g()?x.commit(j):x.commit(j,!0);let e=L.current;j==null&&e&&!e.disabled&&R(e)});let[ne,re]=U.useState(!1),ie=p[`aria-labelledby`]??T??D?.legendId,z={...b,disabled:O??!1,required:o??!1,readOnly:a??!1},ae=U.useMemo(()=>({...b,checkedValue:j,disabled:O,validation:x,name:k,onValueChange:N,readOnly:a,registerControlRef:ee,registerInputRef:te,required:o,setCheckedValue:P,setTouched:re,touched:ne}),[j,O,x,b,k,N,a,ee,te,o,P,re,ne]),oe={role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":O||void 0,"aria-readonly":a||void 0,"aria-labelledby":ie,onFocus(){h(!0)},onBlur(e){ot(e.currentTarget,e.relatedTarget)||(m(!0),h(!1),_===`onBlur`&&x.commit(j))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(m(!0),re(!0),h(!0))}};return(0,W.jsx)(Gy.Provider,{value:ae,children:(0,W.jsx)(Yy,{render:n,className:r,state:z,props:[oe,x.getValidationProps,p],refs:[t],stateAttributesMapping:Ot,enableHomeAndEndKeys:!1,modifierKeys:tde})})});async function Zy(e,t,n){if(await e(),await t(),(await ea.getAllPendingSyncs()).some(e=>e.type===n.type&&[n.id,n.uid].some(t=>t!=null&&String(t)===String(e.id))))throw Error(`Save your pending changes before switching workspaces.`)}async function Qy(e,t=document){E(t),I(t);let{view:n,activeNote:r,activeDiagram:i,activeFlowchart:a,activeDrawing:o}=e,s=n===`notes`?r:n===`erd`?i:n===`flowchart`?a:o,c=!1;if(n===`notes`&&r&&!e.isReadOnlyFile(r)){let t={uid:String(r.uid??r.id),content:null};if(window.dispatchEvent(new CustomEvent(M,{detail:t})),t.content!==null){if(c=!0,e.cancelPendingNoteSaves(),t.content!==r.content&&!await e.saveNote({...r,content:t.content}))throw Error(`Could not save the note. Keep this panel open and try again.`);e.setIsLocalSaving(!1)}}await Zy(c?async()=>{}:e.flushPendingSaves,e.syncDrafts,{type:n,id:s?.id,uid:s?.uid})}function $y(e,t){let[n,r]=(0,U.useState)(()=>{try{let t=localStorage.getItem(e);if(t)return{...JSON.parse(t)}}catch{}return Object.fromEntries(t.map(e=>[e.id,e.defaultVisible]))});return(0,U.useEffect)(()=>{try{localStorage.setItem(e,JSON.stringify(n))}catch{}},[n,e]),{visible:n,toggle:(0,U.useCallback)(e=>{r(t=>({...t,[e]:!t[e]}))},[]),visibleCols:(0,U.useCallback)(()=>t.filter(e=>!e.hideable||(n[e.id]??e.defaultVisible)),[n])}}var nde=10,rde=`notes-table-column-visibility`,eb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],ide=U.memo(function({notes:e,projects:t,selectedWorkspace:n,page:r,totalNotes:i,isLoading:a,onSelectNote:o,onCreateNote:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteNote:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/nde)),{toggle:_,visibleCols:v}=$y(rde,eb),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Nt,{className:`w-5 h-5 text-yellow-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Notes`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` notes)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search notes...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:eb.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Note`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No notes yet. Create your first note to get started.`:`No notes on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})}),ade={postgresql:`PostgreSQL`,mysql:`MySQL`,sqlite:`SQLite`},ode={postgresql:`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20`,mysql:`bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20`,sqlite:`bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20`};function sde({account:e,catalogs:t,onEdit:n,onDelete:r,onTest:i,onAddCatalog:a,onImportCatalog:o,onDeleteCatalog:s,isTesting:c}){let[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),{id:p,name:m,type:h,host:g,port:_}=e,v=h===`sqlite`?g||`Local file`:g?`${g}:${_||``}`:`-`,y=e=>{e.stopPropagation(),u(!l)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rounded-lg border transition-colors hover:bg-accent/50`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-4 cursor-pointer`,onClick:y,children:[(0,W.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full border bg-muted/50`,children:(0,W.jsx)(Br,{className:`h-4 w-4 text-muted-foreground`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`truncate pr-2 text-sm font-medium`,title:m,children:m}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] px-1.5 py-0 h-4 ${ode[h]}`,children:ade[h]}),(0,W.jsx)(tm,{variant:`outline`,className:e.environment===`production`?`h-4 border-red-500/30 bg-red-500/10 px-1.5 py-0 text-[10px] uppercase text-red-600`:`h-4 px-1.5 py-0 text-[10px] uppercase`,children:e.environment||`development`}),e.safeMode===`read-only`&&(0,W.jsx)(tm,{variant:`outline`,className:`h-4 border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0 text-[10px] text-emerald-600`,children:`READ ONLY`}),e.sslMode&&e.sslMode!==`disable`&&(0,W.jsx)(tm,{variant:`outline`,className:`h-4 px-1.5 py-0 text-[10px]`,children:`TLS`}),t.length>0&&(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] px-1.5 py-0 h-4 bg-muted`,children:h===`sqlite`?`1 DB`:`${t.length} DB`})]})]}),(0,W.jsx)(`div`,{className:`mt-2 truncate text-xs text-muted-foreground`,title:v,children:v})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-7 w-7`,onClick:y,children:l?(0,W.jsx)(on,{className:`h-3.5 w-3.5`}):(0,W.jsx)(At,{className:`h-3.5 w-3.5`})}),(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-7 w-7`}),onClick:e=>e.stopPropagation(),children:(0,W.jsx)(Nr,{className:`h-3.5 w-3.5`})}),(0,W.jsxs)(en,{align:`end`,className:`w-36`,children:[(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),i(e)},disabled:c,className:`cursor-pointer`,children:[c?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,W.jsx)(xa,{className:`h-3.5 w-3.5 mr-2`}),`Test`]}),(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),n(e)},className:`cursor-pointer`,children:[(0,W.jsx)(_r,{className:`h-3.5 w-3.5 mr-2`}),`Edit`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),r(e)},className:`cursor-pointer text-destructive focus:text-destructive`,children:[(0,W.jsx)(ni,{className:`h-3.5 w-3.5 mr-2`}),`Delete`]})]})]})]})]}),l&&(0,W.jsxs)(`div`,{className:`border-t px-3 py-2 space-y-1.5`,children:[t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground py-1`,children:`No databases connected yet`}):(0,W.jsx)(Vn,{className:`max-h-48`,children:t.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-md px-2 py-1.5 hover:bg-accent/50 group/cat`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,W.jsx)(Ar,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`text-xs truncate`,children:e.label||e.databaseName}),e.label&&e.label!==e.databaseName&&(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,e.databaseName,`)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover/cat:opacity-100 transition-opacity`,children:[(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-6 w-6`,title:`Import as ERD`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,W.jsx)(Ar,{className:`h-3 w-3`})}),(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 text-destructive hover:text-destructive`,title:`Disconnect database`,onClick:t=>{t.stopPropagation(),f(e)},children:(0,W.jsx)(Xo,{className:`h-3 w-3`})})]})]},e.id))}),h!==`sqlite`&&(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`w-full h-7 text-xs justify-start text-muted-foreground hover:text-foreground`,onClick:t=>{t.stopPropagation(),a(e)},children:[(0,W.jsx)(zt,{className:`h-3 w-3 mr-1.5`}),`Add Database`]})]})]}),(0,W.jsx)(gi,{open:d!==null,onOpenChange:e=>!e&&f(null),children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(Xo,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Disconnect Database`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Disconnect `,(0,W.jsx)(`strong`,{children:d?.label||d?.databaseName}),`? ERD Builder files created from this database will also be deleted.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{d&&s(d),f(null)},children:`Disconnect`})]})]})})]})}var tb=`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,nb={local:`Local`,development:`Development`,staging:`Staging`,production:`Production`},rb={normal:`Normal`,protected:`Protected`,"read-only":`Read-only`},ib={disable:`Disable`,require:`Require`,"verify-ca":`Verify CA`,"verify-full":`Verify Full`};function cde(e){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-lg border bg-muted/20 p-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Environment`}),(0,W.jsxs)(Er,{value:e.environment,onValueChange:t=>e.onEnvironmentChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:nb[e.environment]})}),(0,W.jsx)(Sr,{children:Object.entries(nb).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Safe Mode`}),(0,W.jsxs)(Er,{value:e.safeMode,onValueChange:t=>e.onSafeModeChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:rb[e.safeMode]})}),(0,W.jsx)(Sr,{children:Object.entries(rb).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`TLS / SSL`}),(0,W.jsxs)(Er,{value:e.sslMode,onValueChange:t=>e.onSslModeChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:ib[e.sslMode]})}),(0,W.jsx)(Sr,{children:Object.entries(ib).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Query timeout (ms)`}),(0,W.jsx)(Oi,{type:`number`,min:1e3,max:6e5,value:e.queryTimeoutMs,onChange:t=>e.onQueryTimeoutChange(t.target.value)})]})]}),e.sslMode!==`disable`&&(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(Oi,{placeholder:`CA certificate path (optional)`,value:e.sslCa,onChange:t=>e.onSslCaChange(t.target.value)}),(0,W.jsx)(Oi,{placeholder:`Client certificate path (optional)`,value:e.sslCert,onChange:t=>e.onSslCertChange(t.target.value)}),(0,W.jsx)(Oi,{placeholder:`Client private key path (optional)`,value:e.sslKey,onChange:t=>e.onSslKeyChange(t.target.value)})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Protected and Production connections require the table name for destructive actions.`})]})}var ab=[{value:`postgresql`,label:`PostgreSQL`,defaultPort:5432},{value:`mysql`,label:`MySQL`,defaultPort:3306},{value:`sqlite`,label:`SQLite`,defaultPort:0}];function lde({open:e,onOpenChange:t,editing:n,onSave:r,onTest:i,getDefaultPort:a,projects:o=[]}){let[s,c]=(0,U.useState)(n?.type||`postgresql`),[l,u]=(0,U.useState)(n?.name||``),[d,f]=(0,U.useState)(n?.host||``),[p,m]=(0,U.useState)(String(n?.port??a(s))),[h,g]=(0,U.useState)(n?.user||``),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(n?.environment||`development`),[x,S]=(0,U.useState)(n?.safeMode||`protected`),[C,w]=(0,U.useState)(n?.sslMode||`disable`),[T,E]=(0,U.useState)(n?.sslCa||``),[D,O]=(0,U.useState)(n?.sslCert||``),[k,A]=(0,U.useState)(n?.sslKey||``),[j,M]=(0,U.useState)(String(n?.queryTimeoutMs||3e4)),[N,P]=(0,U.useState)(``),[F,I]=(0,U.useState)(`none`),[L,R]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(null),[ne,re]=(0,U.useState)(!1),ie=!!n;(0,U.useEffect)(()=>{e&&(n?(c(n.type),u(n.name),f(n.host||``),m(String(n.port??a(n.type))),g(n.user||``),v(``),b(n.environment||`development`),S(n.safeMode||`protected`),w(n.sslMode||`disable`),E(n.sslCa||``),O(n.sslCert||``),A(n.sslKey||``),M(String(n.queryTimeoutMs||3e4)),P(``),I(`none`)):(c(`postgresql`),u(``),f(`localhost`),m(`5432`),g(`postgres`),v(``),b(`development`),S(`protected`),w(`disable`),E(``),O(``),A(``),M(`30000`),P(``),I(`none`)),te(null))},[e,n,a]);let z=e=>{if(!e)return;let t=e;c(t),m(String(a(t))),t===`sqlite`?(f(``),g(``),v(``),P(l)):d||f(`localhost`),te(null)},ae=()=>({name:l,type:s,host:d,port:Number(p),user:h,password:_,database:s===`sqlite`?d:void 0,erdName:s===`sqlite`?N:void 0,projectId:s===`sqlite`?F:void 0,environment:y,safeMode:x,sslMode:C,sslCa:T||void 0,sslCert:D||void 0,sslKey:k||void 0,queryTimeoutMs:Number(j)||3e4}),oe=async()=>{try{let{open:e}=await bi(async()=>{let{open:e}=await Promise.resolve().then(()=>gm);return{open:e}},void 0),t=await e({multiple:!1,filters:[{name:`SQLite database`,extensions:[`db`,`sqlite`,`sqlite3`]}]});typeof t==`string`&&(f(t),l.trim()||u(t.split(/[\\/]/).pop()?.replace(/\.(db|sqlite3?|sqlite)$/i,``)||`SQLite database`),N.trim()||P(t.split(/[\\/]/).pop()?.replace(/\.(db|sqlite3?|sqlite)$/i,``)||`SQLite ERD`))}catch{te({success:!1,message:`File picker is unavailable. Enter the SQLite file path manually.`})}},se=async()=>{R(!0),te(null);let e=await i(ae());te(e),R(!1)},ce=async()=>{if(!l.trim())return;re(!0);let e=await r(ae());re(!1),e&&t(!1)},le=s===`sqlite`;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:ie?`Edit Server Account`:`New Server Account`})}),(0,W.jsxs)(Yr,{className:`space-y-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Database Type`}),(0,W.jsxs)(Er,{value:s,onValueChange:z,children:[(0,W.jsx)(Cr,{className:`h-10`,children:(0,W.jsx)(Tr,{children:ab.find(e=>e.value===s)?.label||s})}),(0,W.jsx)(Sr,{children:ab.map(e=>(0,W.jsx)(xr,{value:e.value,children:e.label},e.value))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Server Name`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`My Production DB`,value:l,onChange:e=>u(e.target.value)})]}),le?(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`SQLite File Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{className:`h-10`,placeholder:`/path/to/database.sqlite`,value:d,onChange:e=>f(e.target.value)}),(0,W.jsxs)(H,{type:`button`,variant:`outline`,className:`h-10 shrink-0`,onClick:oe,children:[(0,W.jsx)(nr,{className:`mr-1.5 h-3.5 w-3.5`}),`Choose`]})]})]}):(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,W.jsxs)(zr,{className:`col-span-2`,children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Host`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`localhost`,value:d,onChange:e=>f(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Port`}),(0,W.jsx)(Oi,{className:`h-10`,type:`number`,value:p,onChange:e=>m(e.target.value)})]})]}),!le&&(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`User`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:s===`postgresql`?`postgres`:`root`,value:h,onChange:e=>g(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Password`}),(0,W.jsx)(Oi,{className:`h-10`,type:`password`,placeholder:ie?`(saved)`:`password`,value:_,onChange:e=>v(e.target.value)})]})]}),!le&&(0,W.jsx)(cde,{environment:y,safeMode:x,sslMode:C,sslCa:T,sslCert:D,sslKey:k,queryTimeoutMs:j,onEnvironmentChange:b,onSafeModeChange:S,onSslModeChange:w,onSslCaChange:E,onSslCertChange:O,onSslKeyChange:A,onQueryTimeoutChange:M}),le&&!ie&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD New Name`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`SQLite ERD name`,value:N,onChange:e=>P(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:F,onChange:I,items:[{id:`none`,name:`Uncategorized`},...o],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]}),ee&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-sm ${ee.success?`border-green-500/20 bg-green-500/5 text-green-700 dark:text-green-400`:`border-red-500/20 bg-red-500/5 text-red-700 dark:text-red-400`}`,children:[ee.success?(0,W.jsx)(wn,{className:`h-4 w-4 shrink-0`}):(0,W.jsx)(Aa,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:ee.message})]})]}),(0,W.jsxs)(Xr,{className:`gap-2`,children:[(0,W.jsxs)(H,{variant:`outline`,className:`h-9`,onClick:se,disabled:L,children:[L?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-1.5 animate-spin`}):null,`Test Connection`]}),(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`ghost`,className:`h-9`}),children:`Cancel`}),(0,W.jsxs)(H,{className:`h-9 px-6`,disabled:!l.trim()||le&&(!d.trim()||!ie&&!N.trim())||ne,onClick:ce,children:[ne?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-1.5 animate-spin`}):null,ie?`Save`:`Create`]})]})]})})}var ude={postgresql:5432,mysql:3306,sqlite:0};function dde(){let{user:e,isGuest:t}=ta(),[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(!1),o=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),s=(0,U.useCallback)(async()=>{if(e&&!t&&o){a(!0);try{let e=await wi(`/api/accounts`);if(!e.ok)throw Error(`Failed to load accounts`);let t=await e.json();r(t)}catch(e){d.error(e.message||`Failed to load database accounts`)}finally{a(!1)}}},[e,t,o]);return(0,U.useEffect)(()=>{s()},[s]),{accounts:n,isLoading:i,fetchAccounts:s,createAccount:async e=>{try{let t=await wi(`/api/accounts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error||`Failed to save account`)}let n=await t.json();return r(e=>[n,...e]),d.success(`Server account saved`),n}catch(e){return d.error(e.message||`Failed to save account`),null}},updateAccount:async(e,t)=>{try{let n=await wi(`/api/accounts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to update account`)}let i=await n.json();return r(t=>t.map(t=>t.id===e?i:t)),d.success(`Account updated`),i}catch(e){return d.error(e.message||`Failed to update account`),null}},deleteAccount:async e=>{try{if(!(await wi(`/api/accounts/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to delete account`);r(t=>t.filter(t=>t.id!==e)),d.success(`Account deleted`)}catch(e){d.error(e.message||`Failed to delete account`)}},listDatabases:async e=>{try{let t=await wi(`/api/accounts/${e}/databases`,{method:`POST`});if(!t.ok){let e=await t.json();throw Error(e.error||`Failed to list databases`)}return(await t.json()).databases||[]}catch(e){return d.error(e.message||`Failed to list databases`),[]}},createDatabase:async(e,t)=>{try{let n=await wi(`/api/accounts/${e}/databases/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to create database`)}let r=await n.json();return d.success(`Database "${r.name}" created`),r}catch(e){return d.error(e.message||`Failed to create database`),null}},testAccount:async e=>{try{let t=await wi(`/api/accounts/${e}/test`,{method:`POST`}),n=await t.json();return!t.ok||!n.success?{success:!1,message:n.error||n.message||`Connection failed`}:{success:!0,message:n.message||`Connection successful`}}catch(e){return{success:!1,message:e.message||`Failed to test connection`}}},getDefaultPort:e=>ude[e]}}function fde(e){let{user:t,isGuest:n}=ta(),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(!1),s=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),c=(0,U.useCallback)(async()=>{if(s&&t&&!n){o(!0);try{let t=e?`?accountId=${e}`:``,n=await wi(`/api/catalogs${t}`);if(!n.ok)throw Error(`Failed to load catalog`);let r=await n.json();i(r)}catch(e){d.error(e.message||`Failed to load database catalogs`)}finally{o(!1)}}},[t,n,s,e]);return(0,U.useEffect)(()=>{c()},[c]),{catalogs:r,isLoading:a,fetchCatalogs:c,createCatalog:async(e,t,n)=>{try{let r=await wi(`/api/catalogs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:e,databaseName:t,label:n})});if(!r.ok){let e=await r.json();throw Error(e.error||`Failed to create catalog`)}let a=await r.json();return i(e=>[a,...e]),d.success(`Database "${t}" connected`),a}catch(e){return d.error(e.message||`Failed to connect database`),null}},deleteCatalog:async e=>{try{let t=await wi(`/api/catalogs/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to delete catalog`);let n=await t.json();return i(t=>t.filter(t=>t.id!==e)),d.success(`Database disconnected`),n}catch(e){return d.error(e.message||`Failed to disconnect database`),null}},importAsDbClient:async(e,t,n)=>{try{let r=await wi(`/api/catalogs/${e}/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,project_id:n??null})});if(!r.ok){let e=await r.json();throw Error(e.error||`Failed to import schema`)}let i=await r.json();return d.success(`Imported ${i.tableCount} tables as "${t}"`),i}catch(e){return d.error(e.message||`Failed to import schema`),null}},migrateOldConnections:async()=>{try{let e=await wi(`/api/migrate-connections`,{method:`POST`});if(!e.ok)throw Error(`Migration failed`);let t=await e.json();return t.migrated>0&&(d.success(`Migrated ${t.migrated} old connections`),c()),t.migrated||0}catch(e){return d.error(`Migration failed: `+e.message),0}}}}function pde({open:e,onOpenChange:t,projects:n,onImportComplete:r}){let{accounts:i,isLoading:a,createAccount:o,updateAccount:s,deleteAccount:c,listDatabases:l,createDatabase:u,testAccount:f,getDefaultPort:p,fetchAccounts:m}=dde(),{catalogs:h,fetchCatalogs:g,createCatalog:_,deleteCatalog:v,importAsDbClient:y}=fde(),[b,x]=(0,U.useState)(``),[S,C]=(0,U.useState)(!1),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(new Set),[A,j]=(0,U.useState)(null),[M,N]=(0,U.useState)([]),[P,F]=(0,U.useState)(!1),[I,L]=(0,U.useState)(`connect`),[R,ee]=(0,U.useState)(null),[te,ne]=(0,U.useState)(``),[re,ie]=(0,U.useState)(``),[z,ae]=(0,U.useState)(!1),[oe,se]=(0,U.useState)(!1),[ce,le]=(0,U.useState)(``),[ue,de]=(0,U.useState)(`none`),[B,fe]=(0,U.useState)(null),[pe,me]=(0,U.useState)(``),[he,ge]=(0,U.useState)(!1),_e=b.trim()?i.filter(e=>e.name.toLowerCase().includes(b.toLowerCase())||e.type.toLowerCase().includes(b.toLowerCase())||e.host?.toLowerCase().includes(b.toLowerCase())):i,ve=M.find(e=>e.name===te),V=()=>{T(null),L(`import`),C(!0)},ye=e=>{T(e),L(`connect`),C(!0)},be=async e=>{let n=w?await s(w.id,e):await o(e);if(n&&!w){if(e.type===`sqlite`){let i=e.database?.trim()||e.host.trim(),a=await _(n.id,i,n.name);if(a){g(),m();let i=e.projectId===`none`?null:e.projectId,o=await y(a.id,e.erdName?.trim()||n.name,i);o?.dbClient?.uid&&(t(!1),r?.(o.dbClient.uid))}}else setTimeout(()=>we(n,`import`),0)}return n},xe=async e=>{try{let{apiFetch:t}=await bi(async()=>{let{apiFetch:e}=await import(`./api-m1FDJyHM.js`).then(e=>e.r);return{apiFetch:e}},__vite__mapDeps([6,5,7])),n=await t(`/api/accounts/test-cred`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),r=await n.json();return!n.ok||!r.success?{success:!1,message:r.error||r.message||`Connection failed`}:{success:!0,message:r.message||`Connection successful`}}catch(e){return{success:!1,message:e.message||`Failed to test connection`}}},Se=async e=>{k(t=>new Set(t).add(e.id));let t=await f(e.id);k(t=>{let n=new Set(t);return n.delete(e.id),n}),t.success?(d.success(t.message),m()):d.error(t.message)},Ce=async()=>{E&&(await c(E.id),D(null))},we=async(e,t=`connect`)=>{L(t),F(!0),j(e),N([]),ne(``),ie(``),ae(!1),le(``),de(`none`);let n=await l(e.id);N(n),F(!1)},Te=e=>{ne(e),ce.trim()&&ce!==te||le(e)},Ee=async()=>{if(A&&re.trim()){se(!0);try{let e=await u(A.id,re.trim());if(!e)return;N(t=>[...t.filter(t=>t.name!==e.name),e].sort((e,t)=>e.name.localeCompare(t.name))),ie(``),ae(!1),Te(e.name)}finally{se(!1)}}},De=async()=>{if(!A||!te)return;ee(te);let e=h.find(e=>e.accountId===A.id&&e.databaseName===te)||await _(A.id,te);if(e&&(j(null),g(),m(),I===`import`)){let n=ue===`none`?null:ue,i=await y(e.id,ce.trim()||te,n);i?.dbClient?.uid&&(t(!1),r?.(i.dbClient.uid))}ee(null)},Oe=e=>{me(e.label||e.databaseName),de(`none`),fe(e)},ke=async()=>{if(B&&pe.trim()){ge(!0);try{let e=ue===`none`?null:ue,n=await y(B.id,pe.trim(),e);n?.dbClient?.uid&&(fe(null),me(``),t(!1),r?.(n.dbClient.uid))}finally{ge(!1)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Dp,{open:e,onOpenChange:t,children:(0,W.jsxs)(Op,{side:`right`,className:`w-full p-0 flex flex-col gap-0 sm:w-[min(42rem,calc(100vw-2rem))] sm:max-w-none`,children:[(0,W.jsxs)(kp,{className:`p-5 pb-3 sm:p-6 sm:pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pr-10`,children:[(0,W.jsx)(Ap,{className:`text-lg`,children:`Database Accounts`}),(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] h-4 px-1.5 text-amber-600 border-amber-400 dark:text-amber-400 dark:border-amber-500`,children:`Experimental`})]}),(0,W.jsx)(jp,{className:`max-w-xl leading-relaxed`,children:`Create DB clients from external databases and local SQLite files`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 py-3 sm:flex-row sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(Kr,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(Oi,{className:`h-10 pl-8 text-sm`,placeholder:`Search accounts...`,value:b,onChange:e=>x(e.target.value)})]}),(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsxs)(H,{size:`sm`,className:`h-10 w-full shrink-0 sm:w-auto`,onClick:V,children:[(0,W.jsx)(zt,{className:`h-3.5 w-3.5 mr-1`}),`New DB Client`]})})]}),(0,W.jsx)(Vn,{className:`min-h-0 flex-1 px-5 pb-5 sm:px-6 sm:pb-6`,children:a?(0,W.jsx)(`div`,{className:`space-y-2 pt-2`,children:[1,2,3].map(e=>(0,W.jsx)(Mp,{className:`h-16 w-full rounded-lg`},e))}):_e.length===0?(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center pt-12 text-center`,children:[(0,W.jsx)(Br,{className:`h-10 w-10 text-muted-foreground/40 mb-3`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b.trim()?`No accounts found`:`No database accounts yet`}),!b.trim()&&(0,W.jsxs)(H,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:V,children:[(0,W.jsx)(zt,{className:`h-3.5 w-3.5 mr-1.5`}),`New DB Client`]})]}):(0,W.jsx)(`div`,{className:`space-y-2 pt-2`,children:_e.map(e=>(0,W.jsx)(sde,{account:e,catalogs:h.filter(t=>t.accountId===e.id),onEdit:ye,onDelete:D,onTest:Se,onAddCatalog:e=>we(e,`import`),onImportCatalog:Oe,onDeleteCatalog:async e=>{let t=await v(e.id);g(),m(),t&&t.deletedClients>0&&d.info(`${t.deletedClients} DB Client(s) deleted: ${t.clientNames.join(`, `)}`,{duration:5e3})},isTesting:O.has(e.id)},e.id))})})]})}),(0,W.jsx)(lde,{open:S,onOpenChange:C,editing:w,onSave:be,onTest:xe,getDefaultPort:p,projects:n}),(0,W.jsx)(gi,{open:E!==null,onOpenChange:e=>!e&&D(null),children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-100`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ni,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Delete Account`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Delete server account `,(0,W.jsx)(`strong`,{children:E?.name}),`? All connected databases (`,h.filter(e=>e.accountId===E?.id).length,`) will be disconnected. Diagrams using these databases still exist, but can no longer sync.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})}),(0,W.jsx)(gi,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,W.jsxs)(ai,{children:[(0,W.jsx)(si,{children:(0,W.jsx)(_i,{children:I===`import`?`Create DB Client`:`Select Database`})}),(0,W.jsx)(mi,{children:P?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,W.jsx)(vo,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Production Database`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,W.jsx)(cr,{value:te,onChange:Te,items:M,placeholder:`Select production database`,searchPlaceholder:`Search database...`,emptyMessage:`No database found`,getItemValue:e=>e.name,getItemLabel:e=>e.isConnected?`${e.name} (connected)`:e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`}),A?.type===`sqlite`?null:(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-9 w-9`,onClick:()=>ae(e=>!e),title:`Create database`,children:(0,W.jsx)(zt,{className:`h-3.5 w-3.5`})})]})]}),z&&A?.type!==`sqlite`&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New Database`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,W.jsx)(Oi,{value:re,onChange:e=>ie(e.target.value),placeholder:`new_database`,className:`h-9`,onKeyDown:e=>{e.key===`Enter`&&re.trim()&&!oe&&Ee()}}),(0,W.jsx)(H,{type:`button`,className:`h-9`,onClick:Ee,disabled:!re.trim()||oe,children:oe?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 animate-spin`}):`Create`})]})]}),I===`import`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD File Name`}),(0,W.jsx)(Oi,{value:ce,onChange:e=>le(e.target.value),placeholder:`ERD file name`,className:`h-9`,onKeyDown:e=>{e.key===`Enter`&&te&&ce.trim()&&!R&&De()}})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:ue,onChange:de,items:[{id:`none`,name:`Uncategorized`},...n],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]})]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),M.length>0&&(0,W.jsx)(di,{onClick:De,disabled:!te||I===`connect`&&ve?.isConnected||I===`import`&&!ce.trim()||R!==null,children:R?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}),`Creating...`]}):I===`import`?`Create DB Client`:`Connect`})]})]})}),(0,W.jsx)(gi,{open:B!==null,onOpenChange:e=>!e&&fe(null),children:(0,W.jsxs)(ai,{children:[(0,W.jsx)(si,{children:(0,W.jsx)(_i,{children:`Import as ERD Diagram`})}),(0,W.jsxs)(mi,{children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`Create a new ERD diagram from `,(0,W.jsx)(`strong`,{children:B?.label||B?.databaseName}),` tables.`]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD File Name`}),(0,W.jsx)(Oi,{value:pe,onChange:e=>me(e.target.value),placeholder:`Diagram name`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&pe.trim()&&!he&&ke()}})]}),(0,W.jsxs)(zr,{className:`mt-3`,children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:ue,onChange:de,items:[{id:`none`,name:`Uncategorized`},...n],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{onClick:ke,disabled:!pe.trim()||he,children:he?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}),`Importing...`]}):`Import`})]})]})})]})}var mde=10,ob=`erd-table-column-visibility`,sb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[22%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[15%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`source`,label:`Source`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[12%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[11%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[12%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],hde=(e=ob)=>{try{let t=localStorage.getItem(e);if(t)return{...JSON.parse(t)}}catch{}return Object.fromEntries(sb.map(e=>[e.id,e.defaultVisible]))},gde=e=>e?e===`production_db`?`DB Connect`:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`—`,cb=U.memo(function({mode:e=`erd`,diagrams:t,projects:n,selectedWorkspace:r,page:i,totalDiagrams:a,isLoading:o,onSelectDiagram:s,onCreateDiagram:c,onPageChange:l,onWorkspaceClick:u,onOpenEditDocument:d,onDeleteDiagram:f,canDeleteFile:p=()=>!0,searchQuery:m,onSearchChange:h,searchRef:g}){let _=e===`db-client`,v=Math.max(1,Math.ceil(a/mde)),[y,b]=(0,U.useState)(!1),x=typeof window<`u`&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE===`cli`),S=_?sb.filter(e=>e.id!==`status`&&e.id!==`expires`):x?sb:sb.filter(e=>e.id!==`source`),C=_?`db-client-table-column-visibility`:ob,[w,T]=(0,U.useState)(()=>hde(C));(0,U.useEffect)(()=>{try{localStorage.setItem(C,JSON.stringify(w))}catch{}},[C,w]);let E=(0,U.useCallback)(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=(0,U.useCallback)(e=>{let t=S.find(t=>t.id===e);return!t||!t.hideable?!0:w[e]??t.defaultVisible},[w]),O=e=>e==null?null:n.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,k=e=>e.projects?.name||O(e.project_id)?.name||`—`,A=e=>e.projects?.uid||O(e.project_id)?.uid||null,j=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},M=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},N=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}},P=S.filter(e=>e.id===`name`||e.id===`workspace`||e.id===`actions`||D(e.id)),F=_?t:t.filter(e=>(e.source_type??`blank`)===`blank`);return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ia,{className:`w-5 h-5 text-emerald-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:_?`DB Client`:`ERD Builder`}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>u(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:n.find(e=>e.uid===r)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,a,` `,_?`files`:`diagrams`,`)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:g,type:`text`,placeholder:_?`Search DB Client files...`:`Search diagrams...`,value:m,onChange:e=>h(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:S.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:D(e.id),onCheckedChange:()=>E(e.id),children:e.label},e.id))})]}),!_&&(0,W.jsxs)(H,{size:`sm`,onClick:c,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Diagram`})]}),x&&_&&(0,W.jsxs)(H,{size:`sm`,variant:`outline`,onClick:()=>b(!0),children:[(0,W.jsx)(xa,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`DB Connect`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:S.filter(e=>P.some(t=>t.id===e.id)).map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:o&&F.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:P.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):F.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:P.length,className:`h-32 text-center text-muted-foreground`,children:a===0?_?`No DB Client files yet. Connect a database to get started.`:`No diagrams yet. Create your first ERD diagram to get started.`:_?`No DB Client files on this page.`:`No diagrams on this page.`})}):F.map(e=>{let t=e.uid??String(e.id),n=A(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>s(t),children:P.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.name||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),u(n)},children:k(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`source`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:_?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-blue-500/10 px-2 py-0.5 text-xs text-blue-500`,children:[(0,W.jsx)(Ar,{className:`size-3`}),e.catalog?.account?.type||e.catalog?.database_name||`Database`]}):e.source_type&&e.source_type!==`scratch`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-blue-500/10 text-blue-500 px-2 py-0.5 rounded-full`,children:[(0,W.jsx)(Ar,{className:`w-3 h-3`}),gde(e.source_type)]}):(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`Scratch`})},`source`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:j(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:j(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${N(e.expiry_date)?`text-red-500 font-medium`:``}`,children:M(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>d(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),_&&(0,W.jsxs)(Kt,{onClick:()=>s(t),children:[(0,W.jsx)(Ba,{className:`h-4 w-4 mr-2`}),`Detail`]}),p(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>f(t),className:`text-destructive focus:text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),v>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,i,` of `,v]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:i<=1,onClick:()=>l(i-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:v},(e,t)=>t+1).filter(e=>e===1||e===v||Math.abs(e-i)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===i?`default`:`outline`,size:`icon-xs`,onClick:()=>l(e),className:e===i?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:i>=v,onClick:()=>l(i+1),children:(0,W.jsx)(At,{className:`w-4 h-4`})})]})]}),x&&(0,W.jsx)(pde,{open:y,onOpenChange:b,projects:n,onImportComplete:e=>s(e)})]})}),_de=10,vde=`drawings-table-column-visibility`,lb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],yde=U.memo(function({drawings:e,projects:t,selectedWorkspace:n,page:r,totalDrawings:i,isLoading:a,onSelectDrawing:o,onCreateDrawing:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteDrawing:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/_de)),{toggle:_,visibleCols:v}=$y(vde,lb),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Mr,{className:`w-5 h-5 text-fuchsia-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Drawings`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` drawings)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search drawings...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:lb.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Drawing`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No drawings yet. Create your first drawing to get started.`:`No drawings on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-[280px]`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})}),bde=10,xde=`flowchart-table-column-visibility`,ub=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],Sde=U.memo(function({flowcharts:e,projects:t,selectedWorkspace:n,page:r,totalFlowcharts:i,isLoading:a,onSelectFlowchart:o,onCreateFlowchart:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteFlowchart:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/bde)),{toggle:_,visibleCols:v}=$y(xde,ub),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Eo,{className:`w-5 h-5 text-cyan-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Flowcharts`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` flowcharts)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search flowcharts...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:ub.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Flowchart`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No flowcharts yet. Create your first flowchart to get started.`:`No flowcharts on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})});function Cde(){return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-6 bg-muted/50 rounded-xl border border-dashed border-border/50 relative overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-primary/10 rounded-full blur-[100px] pointer-events-none`}),(0,W.jsxs)(`div`,{className:`relative z-10 flex flex-col items-center text-center max-w-sm`,children:[(0,W.jsxs)(`div`,{className:`mb-8 relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-primary/20 blur-2xl rounded-full scale-110`}),(0,W.jsx)(`div`,{className:`relative size-20 rounded-2xl bg-card border border-border flex items-center justify-center shadow-2xl`,children:(0,W.jsx)(Ar,{className:`size-10 text-primary`})})]}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-foreground mb-3 tracking-tight`,children:`Welcome to ERD Builder Pro`}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed mb-8 px-4`,children:`Select a project, diagram, or note from the sidebar to start designing your database schema, taking notes, or sketching ideas.`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-primary font-bold text-[10px] uppercase tracking-[0.2em] bg-primary/5 px-4 py-2 rounded-full border border-primary/20 shadow-[0_0_20px_rgba(var(--primary-rgb),0.05)]`,children:[(0,W.jsx)(pa,{className:`size-3`}),`Start from Sidebar`]})]})]})}var db=({isOpen:e,onOpenChange:t,mode:n=`move-to-trash`,activeDocument:r,view:i,deleteDiagram:a,deleteNote:o,deleteDrawing:s,deleteFlowchart:c,deleteProject:l,fetchTrash:u,itemType:d,onConfirm:f,onAfterDelete:p})=>{let m=async()=>{if(n===`permanent-delete`){f?.(),p?.();return}if(f){f(),p?.();return}let e=i===`erd`||i===`notes`||i===`flowchart`||i===`drawings`?r?.uid??r?.id:r?.id;e&&(i===`erd`?await a?.(e):i===`notes`?await o?.(String(e)):i===`drawings`?await s?.(e):i===`flowchart`?await c?.(e):i===`project`&&await l?.(e),u?.(),t(!1),p?.())},h=d===`erd`?`diagram`:d===`notes`?`note`:d===`drawings`?`drawing`:d===`project`?`workspace`:`item`;if(n===`permanent-delete`)return(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ri,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Are you absolutely sure?`})]}),(0,W.jsx)(mi,{children:(0,W.jsx)(fi,{children:d===`project`?(0,W.jsxs)(W.Fragment,{children:[`This action cannot be undone. Deleting this workspace will also permanently delete all`,(0,W.jsx)(`strong`,{children:` notes, diagrams, drawings, and flowcharts`}),` inside it.`]}):(0,W.jsxs)(W.Fragment,{children:[`This action cannot be undone. This will permanently delete the `,(0,W.jsx)(`strong`,{children:h}),` from our servers.`]})})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:m,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Permanently Delete`})]})]})});let g=i!==`project`;return(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ni,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:g?`Move to Trash?`:`Delete Workspace?`})]}),(0,W.jsx)(mi,{children:(0,W.jsx)(fi,{children:g?(0,W.jsxs)(W.Fragment,{children:[`Are you sure you want to move `,(0,W.jsx)(`strong`,{children:r?.title||r?.name||`this item`}),` to trash?`,(0,W.jsx)(`br`,{}),`You can restore it later from the trash bin.`]}):(0,W.jsxs)(W.Fragment,{children:[`This will move the workspace and all its contents to trash.`,(0,W.jsx)(`br`,{}),`You can restore it later from the trash bin.`]})})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:m,children:g?`Move to Trash`:`Delete`})]})]})})},fb=e=>e===`erd`?`diagram`:e===`notes`?`note`:e===`drawings`?`drawing`:e===`db-client`?`DB Client`:`flowchart`,pb=({isOpen:e,onOpenChange:t,mode:n=`edit`,view:r,activeDocument:i,newName:a,setNewName:o,projects:s,requireProject:c=!1,canMoveProject:l=!1,selectedProjectId:u,setSelectedProjectId:f,onCreate:p,onProjectCreate:m,updateDiagram:h,updateNote:g,updateDrawing:_,updateFlowchart:v,updateDbClient:y,onMoveDiagramToProject:b,onMoveNoteToProject:x,onMoveDrawingToProject:S,onMoveFlowchartToProject:C,onRenameSuccess:w})=>{let T=n===`create`,[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(``),[A,j]=(0,U.useState)(!1),M=e=>{e||(D(!1),k(``)),t(e)},N=async()=>{let e=O.trim();if(e&&m&&!A){j(!0);try{let t=await m(e);if(!t){d.error(`Failed to create project`);return}f(String(t.id)),D(!1),k(``)}catch{d.error(`Failed to create project`)}finally{j(!1)}}};(0,U.useEffect)(()=>{if(e&&!T&&i){let e=i?.project_id??i?.projectId;f(e==null?`none`:String(e))}},[e]);let P=async()=>{if(E||A||!a.trim()||c&&u===`none`)return;if(T){p?.(a.trim(),u===`none`?null:u),M(!1);return}let e=(r===`db-client`||r===`notes`||r===`flowchart`||r===`drawings`)&&i?.uid||i?.id;if(e&&a.trim()){let t=u===`none`?null:u,n=i?.project_id||i?.projectId,o=a.trim()!==(i?.title||i?.name),s=r!==`db-client`&&String(t)!==String(n);if(s&&!l){d.error(`Only the file creator can move this file.`);return}try{if(o&&(r===`erd`?await h?.(e,a,{silent:!0}):r===`notes`?await g?.(String(e),a,{silent:!0}):r===`drawings`?await _?.(e,a,{silent:!0}):r===`flowchart`?await v?.(e,a,{silent:!0}):r===`db-client`&&await y?.(String(e),a.trim())),s){let n;if(r===`erd`?n=await b?.(e,t,{silent:!0}):r===`notes`?n=await x?.(e,t,{silent:!0}):r===`drawings`?n=await S?.(e,t,{silent:!0}):r===`flowchart`&&(n=await C?.(e,t,{silent:!0})),n===!1)throw Error(`Failed to move document`)}(o||s)&&w&&await w(),d.success(r===`db-client`?`DB Client renamed successfully`:`Document updated successfully`),M(!1)}catch{d.error(r===`db-client`?`Failed to rename DB Client`:`Failed to update document`)}}};return(0,W.jsx)($r,{open:e,onOpenChange:M,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:T?`Create ${fb(r)}`:`Edit`}),(0,W.jsx)(Ur,{children:T?`Enter a name and select a workspace for your new ${fb(r)}.`:r===`db-client`?`Change the name of this DB Client.`:l?`Update the name and project for your ${fb(r)}.`:`Update the name of this ${fb(r)}.`})]}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`rename-input`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:T||r===`db-client`?`Name`:`New Name`}),(0,W.jsx)(Oi,{id:`rename-input`,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&P()},autoFocus:!0})]}),r!==`db-client`&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`document-project-select`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Project`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(Er,{value:u,onValueChange:e=>e!==null&&f(e),disabled:!T&&!l||E||A,children:[(0,W.jsx)(Cr,{id:`document-project-select`,className:`min-w-0 flex-1`,children:(0,W.jsx)(Tr,{children:u===`none`?c?`Select Project`:`No project`:s.find(e=>e.id.toString()===u)?.name||`Select Project`})}),(0,W.jsxs)(Sr,{children:[!c&&(0,W.jsx)(xr,{value:`none`,children:`No project`}),s.map(e=>(0,W.jsx)(xr,{value:e.id.toString(),children:e.name},e.id))]})]}),T&&m&&(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`icon-lg`,className:`shrink-0`,"aria-label":E?`Cancel adding project`:`Add a project`,"aria-expanded":E,"aria-controls":`new-project-field`,disabled:A,onClick:()=>{D(!E),k(``)},children:E?(0,W.jsx)(Gr,{className:`size-4`}):(0,W.jsx)(zt,{className:`size-4`})})]}),T&&E&&(0,W.jsxs)(`div`,{id:`new-project-field`,className:`mt-3 space-y-2`,children:[(0,W.jsx)(Fr,{htmlFor:`new-project-name`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New project name`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{id:`new-project-name`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),N())},placeholder:`Enter project name`,className:`min-w-0 flex-1`,autoFocus:!0,disabled:A}),(0,W.jsx)(H,{type:`button`,size:`lg`,className:`shrink-0`,disabled:!O.trim()||A,onClick:()=>void N(),children:A?`Adding…`:`Add project`})]})]})]})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{disabled:E||A||!a.trim()||c&&u===`none`,onClick:P,className:`h-9 px-6`,children:T?`Create`:`Save Changes`})]})]})})};function wde(){let[e,t]=(0,U.useState)([]),[n,r]=(0,U.useState)(0),[i,a]=(0,U.useState)(!1);return{dbClients:e,dbClientsTotal:n,isDbClientsLoading:i,fetchDbClients:(0,U.useCallback)(async({projectId:e,query:n=``,page:i=1}={})=>{a(!0);try{let a=new URLSearchParams({limit:`10`,offset:String((i-1)*10)});e!=null&&e!==`all`&&a.set(`project_id`,String(e)),n.trim()&&a.set(`q`,n.trim());let o=await wi(`/api/db-clients?${a}`);if(!o.ok)throw Error(`Failed to load DB Clients`);let s=await o.json();t(Array.isArray(s.data)?s.data:[]),r(Number(s.total)||0)}catch(e){d.error(e.message||`Failed to load DB Clients`)}finally{a(!1)}},[]),deleteDbClient:(0,U.useCallback)(async e=>(await wi(`/api/db-clients/${encodeURIComponent(e)}`,{method:`DELETE`})).ok?(t(t=>t.filter(t=>String(t.uid??t.id)!==String(e))),r(e=>Math.max(0,e-1)),d.success(`DB Client moved to trash`),!0):(d.error(`Failed to move DB Client to trash`),!1),[])}}function Tde(){let e=y(),{projects:t,selectedWorkspaceUid:n,tableSearchParams:r,setTableSearchParams:i,fileSearchQuery:a,setFileSearchQuery:o,fileSearchRef:s}=ia(),{dbClients:c,dbClientsTotal:l,isDbClientsLoading:u,fetchDbClients:d,deleteDbClient:f}=wde(),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(``),[S,C]=(0,U.useState)(`none`),w=Math.max(1,Number(r.get(`page`))||1),T=(0,U.useMemo)(()=>n?t.find(e=>String(e.uid)===String(n)||String(e.id)===String(n))?.id??null:null,[t,n]);(0,U.useEffect)(()=>{d({projectId:T,query:a,page:w})},[d,a,w,T]);let E=(e,t=n)=>{let a=new URLSearchParams(r);t?a.set(`workspace`,t):a.delete(`workspace`),a.set(`page`,String(e)),i(a,{replace:!0})};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(cb,{mode:`db-client`,diagrams:c,projects:t,selectedWorkspace:n,page:w,totalDiagrams:l,isLoading:u,onSelectDiagram:t=>e(`/db-client/${t}`),onPageChange:e=>E(e),onWorkspaceClick:e=>E(1,e),onOpenEditDocument:e=>{let t=c.find(t=>String(t.uid??t.id)===String(e));t&&(g(t),x(t.name||``),v(!0))},onDeleteDiagram:e=>m(c.find(t=>String(t.uid??t.id)===String(e))),searchQuery:a,onSearchChange:o,searchRef:s}),(0,W.jsx)(db,{isOpen:!!p,onOpenChange:e=>{e||m(null)},activeDocument:p,view:`db-client`,onConfirm:()=>{let e=p?.uid??p?.id;e&&f(String(e)).then(()=>m(null))}}),(0,W.jsx)(pb,{isOpen:_,onOpenChange:e=>{v(e),e||g(null)},view:`db-client`,activeDocument:h,newName:b,setNewName:x,projects:t,selectedProjectId:S,setSelectedProjectId:C,updateDbClient:async(e,t)=>{if(!(await wi(`/api/db-clients/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})})).ok)throw Error(`Failed to rename DB Client`);await d({projectId:T,query:a,page:w})}})]})}function mb(){let{feature:e}=g(),{notes:t,notesTotal:n,diagrams:r,diagramsTotal:i,drawings:a,drawingsTotal:o,flowcharts:s,flowchartsTotal:c,projects:l,selectedWorkspaceUid:u,tableSearchParams:d,setTableSearchParams:f,handleNoteSelect:p,handleDiagramSelect:m,handleDrawingSelect:h,handleFlowchartSelect:_,handleOpenEditDocument:v,handleOpenCreateDocument:y,setItemToDelete:b,setIsMoveToTrashAlertOpen:x,setTableDeleteDoc:S,isNotesLoading:C,isDiagramsLoading:w,isDrawingsLoading:T,isFlowchartsLoading:E,setTableLoadingState:D,fileSearchQuery:O,setFileSearchQuery:k,fileSearchRef:A}=ia(),{user:j,isGuest:M}=ta(),N=e=>ji(e,j?.id,M),P=e=>m(e),F=parseInt(d.get(`page`)||`1`,10),I=e=>{D(`loading`);let t=new URLSearchParams(d);t.set(`page`,String(e)),f(t,{replace:!0})},L=e=>{D(`loading`);let t=new URLSearchParams(d);e?t.set(`workspace`,e):t.delete(`workspace`),t.set(`page`,`1`),f(t,{replace:!0})},R=e=>t=>{let n=e?.find(e=>e.uid===t||String(e.id)===t||e.key===t);n&&(b({id:n.id||n.uid,type:n.type,uid:n.uid}),S(n),x(!0))};switch(e){case`notes`:return(0,W.jsx)(ide,{notes:t,projects:l,selectedWorkspace:u,page:F,totalNotes:n,isLoading:C,onSelectNote:p,onCreateNote:()=>y(`notes`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteNote:R(t),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`erd`:return(0,W.jsx)(cb,{diagrams:r,projects:l,selectedWorkspace:u,page:F,totalDiagrams:i,isLoading:w,onSelectDiagram:e=>P(e),onCreateDiagram:()=>y(`erd`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteDiagram:R(r),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`db-client`:return(0,W.jsx)(Tde,{});case`drawings`:return(0,W.jsx)(yde,{drawings:a,projects:l,selectedWorkspace:u,page:F,totalDrawings:o,isLoading:T,onSelectDrawing:h,onCreateDrawing:()=>y(`drawings`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteDrawing:R(a),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`flowchart`:return(0,W.jsx)(Sde,{flowcharts:s,projects:l,selectedWorkspace:u,page:F,totalFlowcharts:c,isLoading:E,onSelectFlowchart:_,onCreateFlowchart:()=>y(`flowchart`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteFlowchart:R(s),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});default:return(0,W.jsx)(Cde,{})}}var Ede={erd:`erd_builder`,notes:`notes`,drawings:`drawings`,flowchart:`flowcharts`,flowcharts:`flowcharts`,"db-client":`desktop_only`},Dde={erd_builder:`ERD Builder`,notes:`Notes`,drawings:`Drawings`,flowcharts:`Flowcharts`,desktop_only:`DB Client`};function Ode({capability:e,teamName:t,ssoPortalUrl:n}){let r=y(),i=Dde[e];return(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-10`,children:(0,W.jsxs)(`section`,{className:`w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,W.jsx)(tr,{className:`size-5`,"aria-hidden":`true`})}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`h1`,{className:`text-base font-semibold text-foreground`,children:[`Unlock `,i]}),(0,W.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[i,` is not included in `,t||`this Team`,`'s current Cloud plan. Upgrade to continue using it.`]})]})]}),(0,W.jsx)(`div`,{className:`mt-5 flex justify-end border-t border-border pt-4`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(H,{variant:`outline`,onClick:()=>r(`/`),children:`Return to dashboard`}),n&&(0,W.jsx)(H,{onClick:()=>{if(n)try{window.location.assign(new URL(`/pricing#cloud-saas`,n).toString())}catch{}},children:`View Cloud plans`})]})})]})})}function hb({capability:e,children:t}){let{user:n}=ta(),{activeTeamId:r,activeTeam:i,isLoading:a}=w();return!n?.isSso||!r?(0,W.jsx)(W.Fragment,{children:t}):a?(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Checking Team plan…`}):e!==`desktop_only`&&i?.capabilities?.[e]===!0?(0,W.jsx)(W.Fragment,{children:t}):(0,W.jsx)(Ode,{capability:e,teamName:i?.name,ssoPortalUrl:n?.ssoPortalUrl??n?.sso_portal_url})}function kde(){let{feature:e}=g(),t=e?Ede[e]:void 0;return t?(0,W.jsx)(hb,{capability:t,children:(0,W.jsx)(mb,{})}):(0,W.jsx)(mb,{})}var gb=U.createContext(void 0);function _b(){let e=U.useContext(gb);if(e===void 0)throw Error(Ne(64));return e}var Ade=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),vb={tabActivationDirection:e=>({[Ade.activationDirection]:e})},jde=U.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,...c}=e,l=sn(),u=Object.hasOwn(e,`defaultValue`),d=U.useRef([]),[f,p]=U.useState(()=>new Map),[m,h]=cn({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=U.useState(()=>new Map),[y,b]=U.useState(`none`),x=ke((e,t)=>{i?.(e,t),!t.isCanceled&&(h(e),b(t.activationDirection))}),S=ke((e,t)=>{p(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}),C=ke((e,t)=>{p(n=>{if(!n.has(e)||n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})}),w=U.useCallback(e=>f.get(e),[f]),T=U.useCallback(e=>{for(let t of _.values())if(e===t?.value)return t?.id},[_]),E=U.useCallback(e=>{if(e===void 0)return null;for(let[t,n]of _.entries())if(n!=null&&e===(n.value??n.index))return t;return null},[_]),D=U.useMemo(()=>({direction:l,getTabElementBySelectedValue:E,getTabIdByPanelValue:T,getTabPanelIdByValue:w,onValueChange:x,orientation:a,registerMountedTabPanel:S,setTabMap:v,unregisterMountedTabPanel:C,tabActivationDirection:y,value:m}),[l,E,T,w,x,a,S,v,C,y,m]),O=U.useMemo(()=>{for(let e of _.values())if(e!=null&&e.value===m)return e},[_,m]),k=U.useMemo(()=>{for(let e of _.values())if(e!=null&&!e.disabled)return e.value},[_]);Oe(()=>{if(g||_.size===0)return;let e=O?.disabled;if(u&&e&&m===r||!e&&(O!=null||m===null))return;let t=k??null;m!==t&&(h(t),b(`none`))},[r,k,u,g,O,b,h,_,m]);let A=Pe(`div`,e,{state:{orientation:a,tabActivationDirection:y},ref:t,props:c,stateAttributesMapping:vb});return(0,W.jsx)(gb.Provider,{value:D,children:(0,W.jsx)(un,{elementsRef:d,children:A})})}),yb=U.createContext(void 0);function Mde(){let e=U.useContext(yb);if(e===void 0)throw Error(Ne(65));return e}var Nde=U.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=_b(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=Mde(),v=Xe(o),y=U.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a]),{compositeProps:b,compositeRef:x,index:S}=ki({metadata:y}),C=a===l,w=U.useRef(!1),T=U.useRef(null);U.useEffect(()=>{let e=T.current;if(e)return h(e)},[h]),Oe(()=>{if(w.current){w.current=!1;return}if(!(C&&S>-1&&p!==S))return;let e=_;if(e!=null){let t=Ve(qe(e));if(t&&ot(e,t))return}r||g(S)},[C,S,p,g,r,_]);let{getButtonProps:E,buttonRef:D}=Me({disabled:r,native:s,focusableWhenDisabled:!0}),O=u(a),k=U.useRef(!1),A=U.useRef(!1);function j(e){C||r||m(a,gt(Ze,e.nativeEvent,void 0,{activationDirection:`none`}))}function M(e){C||(S>-1&&!r&&g(S),!r&&f&&(!k.current||k.current&&A.current)&&m(a,gt(Ze,e.nativeEvent,void 0,{activationDirection:`none`})))}function N(e){if(C||r)return;k.current=!0;function t(){k.current=!1,A.current=!1}e.button&&e.button!==0||(A.current=!0,qe(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return Pe(`button`,e,{state:{disabled:r,active:C,orientation:d},ref:[t,D,x,T],props:[b,{role:`tab`,"aria-controls":O,"aria-selected":C,id:v,onClick:j,onFocus:M,onPointerDown:N,[Wy]:C?``:void 0,onKeyDownCapture(){w.current=!0}},c,E]})}),Pde=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=He.startingStyle]=`startingStyle`,e[e.endingStyle=He.endingStyle]=`endingStyle`,e}({}),Fde={...vb,...$e},Ide=U.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=_b(),p=Xe(),m=U.useMemo(()=>({id:p,value:r}),[p,r]),{ref:h,index:g}=ln({metadata:m}),_=r===s,{mounted:v,transitionStatus:y,setMounted:b}=We(_),x=!v,S=c(r),C={hidden:x,orientation:l,tabActivationDirection:u,transitionStatus:y},w=U.useRef(null),T=Pe(`div`,e,{state:C,ref:[t,h,w],props:[{"aria-labelledby":S,hidden:x,id:p,role:`tabpanel`,tabIndex:_?0:-1,inert:St(!_),[Pde.index]:g},o],stateAttributesMapping:Fde});return Je({open:_,ref:w,onComplete(){_||b(!1)}}),Oe(()=>{if((!x||a)&&p!=null)return d(r,p),()=>{f(r,p)}},[x,a,r,p,d,f]),a||v?T:null}),Lde=U.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=_b(),[p,m]=U.useState(0),[h,g]=U.useState(null),_=U.useRef(new Set),v=U.useRef(new Set),y=U.useRef(null),b=ke(()=>{_.current.forEach(e=>{e()})});U.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=ke(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=ke(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=Rde(u,l,h,s),w=ke((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=U.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,W.jsx)(yb.Provider,{value:D,children:(0,W.jsx)(Yy,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:vb,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:Fe})})});function bb(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function Rde(e,t,n,r){let[i,a]=U.useState(null);return Oe(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=bb(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),U.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=bb(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var xb=r(u(),1);function Sb({className:e,orientation:t=`horizontal`,...n}){return(0,W.jsx)(jde,{"data-slot":`tabs`,"data-orientation":t,className:c(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var zde=Re(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Cb({className:e,variant:t=`default`,...n}){return(0,W.jsx)(Lde,{"data-slot":`tabs-list`,"data-variant":t,className:c(zde({variant:t}),e),...n})}function wb({className:e,...t}){return(0,W.jsx)(Nde,{"data-slot":`tabs-trigger`,className:c(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Bde({className:e,...t}){return(0,W.jsx)(Ide,{"data-slot":`tabs-content`,className:c(`flex-1 text-sm outline-none`,e),...t})}var Tb=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`textarea`,{className:c(`flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Tb.displayName=`Textarea`;function Vde({userName:e,value:t,onChange:n,onSubmit:r,disabled:i=!1,placeholder:a=`Reply…`,submitLabel:o=`Send reply`}){let[s,c]=(0,U.useState)(!1),l=(0,U.useRef)(null),u=s||t.length>0;(0,U.useEffect)(()=>{s&&l.current?.focus()},[s]),(0,U.useEffect)(()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[t,u]);let d=()=>{n(``),c(!1)},f=()=>{t.trim()&&!i&&(r(),c(!1))};return u?(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),f()},className:`shrink-0 border-t border-border p-3`,children:(0,W.jsxs)(`div`,{className:`flex items-end gap-1.5 rounded-lg border border-primary/60 bg-background px-2.5 py-1.5 ring-2 ring-primary/20`,children:[(0,W.jsx)(`textarea`,{"data-comment-draft":!0,ref:l,rows:1,maxLength:4e3,value:t,disabled:i,"aria-label":o,placeholder:a,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f())},className:`min-h-6 max-h-32 flex-1 resize-none bg-transparent py-0.5 text-sm outline-none placeholder:text-muted-foreground`}),(0,W.jsx)(H,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Cancel reply`,onClick:d,disabled:i,children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-3.5`})}),(0,W.jsx)(H,{type:`submit`,size:`icon-xs`,className:`rounded-full`,"aria-label":o,disabled:!t.trim()||i,children:(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-3.5`})})]})}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex w-full shrink-0 items-center gap-2.5 border-t border-border px-4 py-2.5 text-left text-sm text-muted-foreground transition-colors hover:bg-muted/50`,children:[(0,W.jsx)(Dn,{name:e,className:`size-7`}),a]})}function Eb(e,t=144){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function Db({value:e,onChange:t,className:n,...r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{i.current&&Eb(i.current)},[e]),(0,W.jsx)(Tb,{"data-comment-draft":!0,...r,ref:i,rows:1,value:e,onChange:e=>{t(e.target.value),Eb(e.currentTarget)},maxLength:4e3,className:n})}function Hde({id:e,value:t,onChange:n,onSubmit:r,placeholder:i,disabled:a,submitLabel:o}){return(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border p-3`,children:(0,W.jsxs)(`form`,{onSubmit:r,className:`relative`,children:[(0,W.jsx)(`label`,{htmlFor:e,className:`sr-only`,children:o}),(0,W.jsx)(Db,{id:e,value:t,onChange:n,placeholder:i,className:`min-h-11! max-h-36 resize-none overflow-y-auto rounded-2xl bg-muted/40 px-3 py-2 pr-12 shadow-none`,required:!0}),(0,W.jsx)(H,{type:`submit`,size:`icon`,className:`absolute right-1 bottom-1 size-9 rounded-full`,"aria-label":o,disabled:!t.trim()||a,children:(0,W.jsx)(Fo,{"aria-hidden":`true`})})]})})}function Ob(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r&&n.set(e,r);let r=n.toString();return r?`${e}?${r}`:e}async function kb(e,t){let n=await wi(e,t),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`The request could not be completed.`);return r}function Ude({message:e,canEdit:t,editing:n,editDraft:r,editOriginalBody:i,disabled:a,onEdit:o,onDelete:s,onEditDraftChange:c,onCancelEdit:l,onSaveEdit:u}){let d=e.body!==i;return(0,W.jsxs)(`div`,{className:`group/message relative flex gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-muted/40 focus-within:bg-muted/40`,children:[(0,W.jsx)(Dn,{name:e.authorName,className:`mt-0.5 size-7`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.authorName}),(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,title:Kde(e.createdAt),children:vn(e.createdAt)})]}),n&&t?(0,W.jsxs)(`form`,{onSubmit:u,className:`mt-1 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-end gap-1.5 rounded-lg border border-primary/60 bg-background px-2.5 py-1.5 ring-2 ring-primary/20`,children:[(0,W.jsx)(Db,{autoFocus:!0,onFocus:e=>{let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)},"aria-label":`Edit your message`,value:r,onChange:c,className:`min-h-6! max-h-32 flex-1 resize-none overflow-y-auto border-0 bg-transparent p-0 py-0.5 text-sm shadow-none focus-visible:ring-0`,disabled:a}),(0,W.jsx)(H,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Cancel edit`,onClick:l,disabled:a,children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-3.5`})}),(0,W.jsx)(H,{type:`submit`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Save message`,disabled:a||!r.trim()||d,children:(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-3.5`})})]}),d&&(0,W.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:`This message changed. Cancel and edit the latest version.`})]}):(0,W.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-sm`,children:e.body})]}),t&&!n&&(0,W.jsxs)(`div`,{className:`absolute -top-3 right-1 z-10 hidden rounded-md border bg-popover shadow-sm group-hover/message:flex group-focus-within/message:flex [@media(hover:none)]:flex`,children:[(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Edit message`,onClick:o,children:(0,W.jsx)(_r,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,children:`Edit`})]}),(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete message`,onClick:s,children:(0,W.jsx)(ni,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,children:`Delete`})]})]})]})}function Ab(e,t){let n=e.featureType??e.feature_type??t?.featureType,r=e.anchorType??e.anchor_type??t?.anchorType;if(![`diagram`,`note`,`drawing`,`flowchart`].includes(String(n))||r!=null&&![`general`,`table`,`relationship`,`block`,`shape`,`point`].includes(String(r)))return null;let i=e.fileId??e.file_id??t?.fileId;return i==null?null:{featureType:n,fileId:String(i),fileName:e.fileName==null&&e.file_name==null?t?.fileName??null:String(e.fileName??e.file_name),anchorType:r??`general`,anchorId:e.anchorId==null&&e.anchor_id==null&&t?.anchorId==null?null:String(e.anchorId??e.anchor_id??t?.anchorId),anchorLabel:String(e.anchorLabel??e.anchor_label??t?.anchorLabel??`General`)}}function jb(e){let t=Array.isArray(e.contexts)?e.contexts.map(e=>Ab(e)).filter(Boolean):[],n=Ab(e,t[0])||t[0]||null,r=e.anchorType??e.anchor_type,i=[`general`,`table`,`relationship`,`block`,`shape`,`point`].includes(String(r))?r:`general`,a=e.status,o=e.previewMessages??e.preview_messages,s=Array.isArray(o)?o.map(e=>Mb(e)):typeof o==`string`?(()=>{try{let e=JSON.parse(o);return Array.isArray(e)?e.map(e=>Mb(e)):[]}catch{return[]}})():[],c=e.latestMessage==null&&e.latest_message==null?null:{id:String(e.latestMessageId??e.latest_message_id??`latest`),authorId:String(e.latestAuthorId??e.latest_author_id??``),authorName:`Team member`,body:String(e.latestMessage??e.latest_message??``),createdAt:String(e.lastMessageAt??e.last_message_at??``)};return{id:String(e.id??``),featureType:n?.featureType??null,fileId:n?.fileId??(e.fileId==null&&e.file_id==null?null:String(e.fileId??e.file_id)),anchorType:n?.anchorType??i,anchorId:n?.anchorId??(e.anchorId==null&&e.anchor_id==null?null:String(e.anchorId??e.anchor_id)),anchorLabel:n?.anchorLabel??String(e.anchorLabel??e.anchor_label??`General`),contexts:t.length>0?t:n?[n]:[],status:a===`resolved`?`resolved`:`open`,canDelete:!!(e.canDelete??e.can_delete),unread:!!e.unread,latestMessageId:e.latestMessageId==null&&e.latest_message_id==null?null:String(e.latestMessageId??e.latest_message_id),latestMessage:e.latestMessage==null&&e.latest_message==null?null:String(e.latestMessage??e.latest_message),latestAuthorId:e.latestAuthorId==null&&e.latest_author_id==null?null:String(e.latestAuthorId??e.latest_author_id),lastMessageAt:e.lastMessageAt==null&&e.last_message_at==null?null:String(e.lastMessageAt??e.last_message_at),previewMessages:s.length>0?s:c?[c]:[]}}function Mb(e){return{id:String(e.id??``),threadId:e.threadId==null&&e.thread_id==null?void 0:String(e.threadId??e.thread_id),authorId:String(e.authorId??e.author_id??``),authorName:String(e.authorName??e.author_name??`Team member`),body:String(e.body??``),createdAt:String(e.createdAt??e.created_at??``)}}function Nb(e){let t=e.nextCursor;return{hasMore:e.hasMore===!0,nextCursor:t?.createdAt&&t.id?{createdAt:String(t.createdAt),id:String(t.id)}:null}}function Pb(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return[...n.values()].sort((e,t)=>Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.id.localeCompare(t.id))}function Fb(e,t,n){let r=Pb(e.messages,t).slice(-Math.max(50,e.messages.length)),i=r[0],a=e.hasMore||n.hasMore;return{messages:r,hasMore:a,nextCursor:a&&i?{createdAt:i.createdAt,id:i.id}:null}}function Wde(e,t,n,r){return e===`thread`?t===`comments`&&n?{kind:`anchor`,anchor:n,threadId:r}:r?{kind:`thread`,threadId:r}:null:null}function Gde(e){return[e.featureType||`diagram`,e.fileId||``,e.anchorType,e.anchorId||``].join(`:`)}function Ib(e){let t=new Map;for(let n of e){let e=Gde(n),r=t.get(e);r?(r.threads.push(n),r.previewMessages.push(...n.previewMessages)):t.set(e,{key:e,representative:n,threads:[n],previewMessages:[...n.previewMessages]})}return[...t.values()].map(e=>({...e,previewMessages:e.previewMessages.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()).slice(-3)}))}function Kde(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function qde(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:Gn(t,{addSuffix:!0})}function Lb(e){return e===`diagram`?`ERD`:e===`note`?`Notes`:e===`drawing`?`Drawing`:e===`flowchart`?`Flowchart`:`File`}var Jde={diagram:{Icon:Ar,className:`bg-feature-erd/10 text-feature-erd`},note:{Icon:Nt,className:`bg-feature-notes/10 text-feature-notes`},drawing:{Icon:Mr,className:`bg-feature-drawing/10 text-feature-drawing`},flowchart:{Icon:Eo,className:`bg-feature-flowchart/10 text-feature-flowchart`}},Yde={diagram:new Set([`table`,`relationship`]),note:new Set([`block`]),drawing:new Set([`point`]),flowchart:new Set([`shape`])};function Rb(e,t){return typeof t==`string`&&Yde[e].has(t)}function zb({projectId:e,teamId:t,userId:n,userName:r,fileContext:i,anchorContext:a,onContextSelected:o,anchorPreview:s,readOnly:l=!1}){let u=R(),f=(0,U.useId)(),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(`discussions`),_=h===`comments`,[v,y]=(0,U.useState)(`file`),[b,x]=(0,U.useState)(`list`),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)([]),[E,D]=(0,U.useState)(0),[O,k]=(0,U.useState)({messages:[],hasMore:!1,nextCursor:null}),[A,j]=(0,U.useState)(!1),[M,N]=(0,U.useState)(``),[P,F]=(0,U.useState)(!0),[I,L]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(``),[ne,re]=(0,U.useState)(``),[ie,z]=(0,U.useState)(null),[ae,oe]=(0,U.useState)(``),[se,ce]=(0,U.useState)(``),[le,ue]=(0,U.useState)(null),[de,B]=(0,U.useState)(!1),[fe,pe]=(0,U.useState)(``),[me,he]=(0,U.useState)(null),[ge,_e]=(0,U.useState)(null),[ve,V]=(0,U.useState)(null),ye=O.messages,be=(0,U.useRef)(0),xe=(0,U.useRef)(0),Se=(0,U.useRef)(0),Ce=(0,U.useRef)(new Map),we=(0,U.useRef)(!1),Te=(0,U.useRef)({screen:b,selectedThreadId:S});Te.current={screen:b,selectedThreadId:S};let Ee=(0,U.useCallback)(()=>{Te.current={screen:`list`,selectedThreadId:null},xe.current++,Se.current++,x(`list`),C(null),k({messages:[],hasMore:!1,nextCursor:null}),j(!1),N(``),re(``),z(null),oe(``),ce(``),ue(null),V(null)},[]),De=(0,U.useCallback)(e=>{let t=e;t!==h&&(Ee(),he(null),pe(``),g(t))},[h,Ee]),Oe=`/api/projects/${encodeURIComponent(e)}/${h===`comments`?`comments`:`discussions`}`,ke=(0,U.useMemo)(()=>Ob(Oe,{scope:h===`discussions`?v:void 0,feature_type:i.featureType,file_id:i.fileId,anchor_type:h===`comments`&&!_&&a?a.type:void 0,anchor_id:h===`comments`&&!_&&a?a.id:void 0}),[h,a,v,Oe,i.featureType,i.fileId,_]),Ae=(0,U.useCallback)(e=>Ob(`${Oe}/${encodeURIComponent(e)}`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),[h,Oe,i.featureType,i.fileId]),je=(0,U.useCallback)(async(e=!1)=>{let t=++be.current;te(``),we.current||F(!0);try{let r=await kb(ke);if(t!==be.current)return[];let i=Array.isArray(r.threads)?r.threads.map(e=>jb(e)):[];if(e&&we.current)for(let e of i){let t=Ce.current.get(e.id);e.latestMessageId&&e.latestAuthorId!==n&&(t&&e.latestMessageId!==t||!t&&e.unread)&&d.info(`New activity in ${e.contexts[0]?.fileName||`Project discussion`}`)}Ce.current=new Map(i.filter(e=>e.latestMessageId).map(e=>[e.id,e.latestMessageId])),we.current=!0,T(i);let a=Te.current;return a.screen===`thread`&&a.selectedThreadId&&!i.some(e=>e.id===a.selectedThreadId)&&Ee(),D(Number(r.unreadCount??r.unread_count)||0),i}catch{return t===be.current&&te(`Couldn't load ${h}. Try again.`),[]}finally{t===be.current&&F(!1)}},[h,Ee,ke,n]),Me=(0,U.useCallback)(e=>{o?.({featureType:i.featureType,fileId:i.fileId,anchorType:e.type,anchorId:e.id,anchorLabel:e.type===`table`?`Table`:e.type===`relationship`?`Relationship`:e.type[0].toUpperCase()+e.type.slice(1)})},[i.featureType,i.fileId,o]),Ne=(0,U.useCallback)(async(e,t,n=!1)=>{let r=++xe.current;n||re(``);try{let a=await kb(Ae(e));if(r!==xe.current)return!1;let s=Array.isArray(a.messages)?a.messages.map(e=>Mb(e)):[],c=Nb(a);k(e=>n?Fb(e,s,c):{...c,messages:s}),n||N(``),t&&kb(Ob(`${Ae(e)}/read`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`POST`}).then(()=>je()).catch(()=>{});let l=Array.isArray(a.contexts)?a.contexts.map(e=>Ab(e)).filter(Boolean):[];return l[0]&&o?.(l[0]),!0}catch{return!n&&r===xe.current&&re(`Couldn't load this ${h===`comments`?`comment`:`discussion`}. Try again.`),!1}},[h,i.fileId,i.featureType,je,o,Ae]),Pe=(0,U.useCallback)(async(e,t,n=!1,r)=>{let a=++xe.current;n||re(``);try{let s=await kb(Ob(`${Oe}/anchor`,{feature_type:i.featureType,file_id:i.fileId,anchor_type:e.type,anchor_id:e.id}));if(a!==xe.current)return!1;let c=Array.isArray(s.threads)?s.threads.map(e=>jb(e)):[];if(!c.length)return Ee(),!0;let l=Array.isArray(s.messages)?s.messages.map(e=>Mb(e)):[];T(e=>{let t=new Map(c.map(e=>[e.id,e]));return e.map(e=>{let n=t.get(e.id);return n?{...e,...n}:e})});let u=Nb(s);k(e=>n?Fb(e,l,u):{...u,messages:l}),n||N(``);let d=c.some(e=>e.id===r)?r:c[0].id;C(d);let f=Array.isArray(s.contexts)?s.contexts.map(e=>Ab(e)).filter(Boolean):[];return f[0]?o?.(f[0]):Me(e),t&&Promise.all(c.map(e=>kb(Ob(`${Oe}/${encodeURIComponent(e.id)}/read`,{feature_type:i.featureType,file_id:i.fileId}),{method:`POST`}).catch(()=>null))).then(()=>je()),!0}catch{return!n&&a===xe.current&&re(`Couldn't load the full comment history. Try again.`),!1}},[Ee,Oe,i.fileId,i.featureType,Me,je,o]),Fe=(0,U.useCallback)(e=>{if(!p)return;let t=Wde(b,h,ve,S);t&&(t.kind===`anchor`?Pe(t.anchor,e,!0,t.threadId||void 0):Ne(t.threadId,e,!0))},[ve,h,Pe,Ne,p,b,S]),Ie=(0,U.useCallback)(async()=>{let e=O.nextCursor,t=S;if(!O.hasMore||!e||!t||A)return;let n=++Se.current,r=xe.current;j(!0),N(``);try{let a={before_created_at:e.createdAt,before_id:e.id},o=await kb(_&&ve?Ob(`${Oe}/anchor`,{feature_type:i.featureType,file_id:i.fileId,anchor_type:ve.type,anchor_id:ve.id,...a}):Ob(Ae(t),a));if(n!==Se.current||r!==xe.current)return;let s=Array.isArray(o.messages)?o.messages.map(e=>Mb(e)):[],c=Nb(o);k(e=>({...c,messages:Pb(e.messages,s)}))}catch{n===Se.current&&N(`Could not load earlier messages.`)}finally{n===Se.current&&j(!1)}},[ve,Oe,i.featureType,i.fileId,_,A,O,S,Ae]);(0,U.useEffect)(()=>{we.current=!1,x(`list`),C(null),k({messages:[],hasMore:!1,nextCursor:null}),T([]),je()},[je]),(0,U.useEffect)(()=>{let n=e=>{let n=e.detail;n?.teamId!==t||n.eventType&&n.eventType!==`cloud.workspace.sync`||(je(!0),Fe(document.visibilityState===`visible`))},r=e=>{e.detail?.teamId===t&&(je(),Fe(document.visibilityState===`visible`))},i=n=>{let r=n.detail;r?.teamId===t&&String(r.projectId)===String(e)&&je(!0)};return window.addEventListener(`cloud-workspace-sync`,n),window.addEventListener(`cloud-live-sync-reconnected`,r),window.addEventListener(`collaboration-updated`,i),()=>{window.removeEventListener(`cloud-workspace-sync`,n),window.removeEventListener(`cloud-live-sync-reconnected`,r),window.removeEventListener(`collaboration-updated`,i)}},[je,e,Fe,t]),(0,U.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>{je(!0),document.hidden||Fe(!0)},15e3);return()=>window.clearInterval(e)},[je,p,Fe]),(0,U.useEffect)(()=>{let e=e=>{let t=e.detail;!t?.id||t.featureType!==i.featureType||t.fileId&&String(t.fileId)!==i.fileId||!Rb(i.featureType,t.type)||(he({type:t.type,id:t.id}),pe(``),re(``),g(`comments`),m(!0))};return window.addEventListener(`project-comment-open-request`,e),()=>window.removeEventListener(`project-comment-open-request`,e)},[i.fileId,i.featureType]),(0,U.useEffect)(()=>{if(h!==`comments`||!me)return;let e=!1,t=me;return V(t),_e(t),(async()=>{let n=await je();if(e)return;let r=Ib(n).find(e=>e.representative.anchorType===t.type&&e.representative.anchorId===t.id);r?(x(`thread`),C(r.representative.id),await Pe(t,!0,!1,r.representative.id)):x(l?`list`:`compose`),e||he(null)})(),()=>{e=!0}},[h,Pe,je,me]);let Le=(b===`thread`||b===`compose`)&&fe.trim()!==``||ie!==null&&ae!==se,Re=(e,t)=>{if(!e&&(le||de))return;let n=t?.event?.target;!e&&u&&t?.reason===`outside-press`&&n instanceof Element&&!u.host.current?.contains(n)||!e&&t?.reason===`outside-press`&&n instanceof Element&&n.closest(`[data-slot="dropdown-menu-content"]`)||(!e&&Le?B(!0):(m(e),e?(je(),b===`thread`&&_&&ve?Pe(ve,!0,!1,S||void 0):b===`thread`&&S&&Ne(S,!0)):(Ke(),ue(null))))},ze=async e=>{pe(``),Ke(),ue(null);let t=e.contexts[0]||Ab(e),n=t?.anchorType??e.anchorType,r=t?.anchorId??e.anchorId,a=t?.featureType??e.featureType??i.featureType,s=r&&Rb(a,n)?{type:n,id:r}:null;_&&s?(V(s),x(`thread`),C(e.id),k({messages:[],hasMore:!1,nextCursor:null}),Me(s),await Pe(s,!0,!1,e.id)):(x(`thread`),C(e.id),k({messages:[],hasMore:!1,nextCursor:null}),await Ne(e.id,!0)&&t&&o?.(t))},Be=async e=>{let t=e.representative.featureType??i.featureType;e.representative.anchorType&&e.representative.anchorId&&Rb(t,e.representative.anchorType)&&{type:e.representative.anchorType,id:e.representative.anchorId}&&await ze(e.representative)},Ve=()=>{let e=h===`comments`?(_?ve:a)??null:null;h===`comments`&&!e?d.info(`Select an item on this file before adding a comment.`):(_e(e),pe(``),re(``),Ke(),x(`compose`))},He=()=>window.dispatchEvent(new CustomEvent(`collaboration-updated`,{detail:{teamId:t,projectId:e}})),Ue=async e=>{e.preventDefault();let t=fe.trim();if(t&&!I){L(!0),re(``);try{let e=await kb(Oe,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:t,context:{type:h===`comments`?ge?.type:`general`,...h===`comments`?{id:ge?.id}:{},featureType:i.featureType,fileId:i.fileId}})});pe(``),_e(null),C(e.id),x(`thread`),He(),await je(),_&&ge?await Pe(ge,!0,!1,e.id):await Ne(e.id,!0)}catch{re(`Couldn't start the ${h===`comments`?`comment`:`discussion`}. Try again.`)}finally{L(!1)}}},We=async()=>{let e=fe.trim();if(e&&S&&!I){L(!0),re(``);try{await kb(Ob(`${Oe}/${encodeURIComponent(S)}/messages`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:e})}),pe(``),He(),_&&ve?await Pe(ve,!0,!0,S):await Ne(S,!0,!0),await je()}catch{re(`Couldn't send the reply. Reopen the ${h===`comments`?`comment`:`discussion`} if it was resolved.`)}finally{L(!1)}}},Ge=e=>{h===`discussions`&&e.authorId===n&&(z(e.id),oe(e.body),ce(e.body))},Ke=()=>{z(null),oe(``),ce(``)},qe=async(e,t)=>{t.preventDefault();let r=ae.trim(),i=S;if(h===`discussions`&&e.authorId===n&&i&&r&&e.body===se&&!I){L(!0);try{await kb(`${Oe}/${encodeURIComponent(i)}/messages/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:r,expectedBody:se})}),k(t=>({...t,messages:t.messages.map(t=>t.id===e.id?{...t,body:r}:t)})),Ke(),He()}catch(e){await Ne(i,!0,!0),d.error(e instanceof Error?e.message:`Couldn't update this message. Try again.`)}finally{L(!1)}}},Je=async e=>{let t=w.find(t=>t.id===e);if(h===`discussions`&&t?.canDelete&&!I){L(!0);try{await kb(`${Oe}/${encodeURIComponent(t.id)}`,{method:`DELETE`}),ue(null),S===e&&Ee(),He()}catch(e){d.error(e instanceof Error?e.message:`Couldn't delete this discussion. Try again.`)}finally{L(!1)}}},Ye=async(e,t)=>{if(!(h!==`discussions`||S!==e||t.authorId!==n||I)){L(!0);try{await kb(`${Oe}/${encodeURIComponent(e)}/messages/${encodeURIComponent(t.id)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({expectedBody:t.body})}),k(e=>({...e,messages:e.messages.filter(e=>e.id!==t.id)})),ie===t.id&&Ke(),ue(null),await je(),He()}catch(t){await Ne(e,!0,!0),d.error(t instanceof Error?t.message:`Couldn't delete this message. Try again.`)}finally{L(!1)}}},Xe=async()=>{let e=w.find(e=>e.id===S);if(!e||I)return;L(!0);let t=e.status;try{await kb(Ob(`${Oe}/${encodeURIComponent(e.id)}`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:t===`open`?`resolved`:`open`,expectedStatus:t})}),He(),await je()}catch(e){re(e instanceof Error?e.message:`Couldn't update this ${h===`comments`?`comment`:`discussion`}. Try again.`),await je()}finally{L(!1)}},Ze=w.find(e=>e.id===S),Qe=(0,U.useMemo)(()=>Ib(w),[w]),$e=h===`discussions`?`Discussions`:b===`compose`?`New comment`:b===`thread`?Ze?.anchorLabel||`Comment`:`Comments`,et=b===`list`?v===`file`?i.label:null:b===`compose`?i.label:Ze?.contexts[0]?.fileName||(Ze?.fileId===i.fileId?i.label:null),tt=h===`comments`?_?`Latest activity on ${i.label}`:`Comments on ${i.label}`:et?`Related to ${et}`:b===`list`?`All project discussions`:`Project discussion`,nt=`${f}-description`;return(0,W.jsxs)(Ut,{open:p,onOpenChange:Re,children:[(0,W.jsx)(Vt,{render:(0,W.jsxs)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`relative shrink-0 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`${_?`Open comments`:`Open discussions`}${E?`, ${E} unread`:``}`,title:_?`Comments`:`Discussions`,children:[_?(0,W.jsx)(ar,{"aria-hidden":`true`}):(0,W.jsx)(Co,{"aria-hidden":`true`}),E>0&&(0,W.jsx)(tm,{variant:`default`,className:`absolute -right-1 -top-1 h-4 min-w-4 px-1 text-[10px] leading-none`,children:E})]})}),(0,W.jsxs)(Rt,{anchor:u?()=>{let e=u.host.current;return e?{contextElement:e,getBoundingClientRect:()=>{let t=e.getBoundingClientRect();return new DOMRect(t.right-8,t.top+8,0,0)}}:null}:void 0,side:u?`bottom`:`left`,align:u?`end`:`start`,sideOffset:8,"data-discussions-panel":``,className:c(`flex h-[min(42rem,calc(100svh-5rem))] w-[min(24rem,calc(100vw-1rem))] max-w-[calc(100vw-1rem)] flex-col gap-0 overflow-hidden p-0`,u&&`max-h-(--available-height)`),"aria-describedby":nt,children:[(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border px-3 py-2`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b!==`list`&&(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Back to list`,onClick:()=>x(`list`),children:(0,W.jsx)(pa,{"aria-hidden":`true`,className:`size-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:$e}),(0,W.jsx)(`p`,{id:nt,className:`truncate text-xs text-muted-foreground`,children:tt})]}),h===`discussions`&&b===`thread`&&Ze&&!l&&(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Discussion actions`,children:(0,W.jsx)(Nr,{"aria-hidden":`true`,className:`size-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,positionerClassName:`z-[210]`,children:(0,W.jsxs)(Yt,{children:[(0,W.jsxs)(Kt,{onClick:()=>void Xe(),disabled:I,children:[Ze.status===`open`?(0,W.jsx)(an,{"aria-hidden":`true`}):(0,W.jsx)(Xn,{"aria-hidden":`true`}),Ze.status===`open`?`Resolve`:`Reopen`]}),Ze.canDelete&&(0,W.jsxs)(Kt,{variant:`destructive`,onClick:()=>ue({type:`thread`,threadId:Ze.id}),children:[(0,W.jsx)(ni,{"aria-hidden":`true`}),`Delete Thread`]})]})})]}),(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${h}`,onClick:()=>Re(!1),children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-4`})})]})}),(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-2`,children:(0,W.jsx)(Sb,{value:h,onValueChange:De,className:`w-full`,children:(0,W.jsxs)(Cb,{className:`mx-auto`,children:[(0,W.jsx)(wb,{value:`discussions`,children:`Discussions`}),(0,W.jsx)(wb,{value:`comments`,children:`Comments`})]})})}),b===`list`&&(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[h===`discussions`?(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-2`,children:(0,W.jsx)(Sb,{value:v,onValueChange:e=>y(e),className:`w-full`,children:(0,W.jsxs)(Cb,{className:`mx-auto`,children:[(0,W.jsx)(wb,{value:`file`,children:`This File`}),(0,W.jsx)(wb,{value:`project`,children:`All Project`})]})})}):_?(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`Latest messages. Open a card for the full history.`}):(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2 text-xs text-muted-foreground`,children:a?`Selected ${a.type}`:`Select a table or relationship to add a comment.`}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-24`,children:[P&&(0,W.jsxs)(`p`,{role:`status`,className:`px-4 py-5 text-center text-sm text-muted-foreground`,children:[`Loading `,h,`…`]}),!P&&ee&&(0,W.jsxs)(`div`,{className:`m-4 rounded-lg border border-destructive/40 p-4 text-sm`,children:[(0,W.jsx)(`p`,{children:ee}),(0,W.jsx)(H,{variant:`outline`,className:`mt-3 min-h-11`,onClick:()=>void je(),children:`Retry`})]}),!P&&!ee&&(_?Qe.length:w.length)===0&&(0,W.jsxs)(`div`,{className:`mx-4 mt-4 rounded-lg border border-dashed border-border px-4 py-8 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:h===`comments`?`No comments on this file yet.`:`No discussions in this view yet.`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l?`You can read threads here, but only members with comment access can start one.`:h===`comments`?`Use the node context menu to start one.`:`Start a thread to capture a question or design decision.`})]}),!ee&&_&&Qe.map(e=>{let t=e.representative,n=e.previewMessages[e.previewMessages.length-1],r=t.anchorId?s?.(t.anchorId):null,i=n?.authorName||`Team member`;return(0,W.jsxs)(`button`,{type:`button`,className:c(`w-full border-b border-border/70 px-3 py-2 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t.unread&&`bg-primary/5`),onClick:()=>void Be(e),children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,W.jsx)(Dn,{name:i}),t.unread&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`New activity`,className:`absolute -right-0.5 -top-0.5 size-2 rounded-full bg-primary ring-2 ring-popover`})]}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs font-semibold`,children:i}),t.status===`resolved`&&(0,W.jsx)(wn,{role:`img`,"aria-label":`Resolved`,className:`size-3.5 shrink-0 text-emerald-500`}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground`,children:vn(t.lastMessageAt??``)})]}),(0,W.jsxs)(`span`,{className:`mt-1 block space-y-0.5 pl-8`,children:[r?(0,W.jsx)(`span`,{className:`line-clamp-2 border-l-2 border-yellow-500/70 pl-2 text-xs leading-snug text-muted-foreground`,children:r.length>50?`${r.slice(0,50).trimEnd()}…`:r}):(0,W.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:t.anchorLabel||`Comment`}),n&&(0,W.jsx)(`span`,{className:`block truncate text-xs`,children:n.body})]})]},e.key)}),!ee&&!_&&w.map(e=>{let t=e.featureType?Jde[e.featureType]:null,n=t?.Icon??Co,r=e.contexts[0]?.fileName||(e.fileId===i.fileId?i.label:`Project discussion`);return(0,W.jsxs)(`button`,{type:`button`,className:c(`flex min-h-18 w-full items-center gap-3 border-b border-border/70 px-4 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.unread&&`bg-primary/5`),onClick:()=>void ze(e),children:[(0,W.jsxs)(`span`,{"aria-hidden":`true`,className:c(`relative flex size-10 shrink-0 items-center justify-center rounded-full`,t?.className??`bg-muted text-muted-foreground`),children:[(0,W.jsx)(n,{}),e.unread&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-0.5 top-0.5 size-2 rounded-full bg-primary ring-2 ring-popover`})]}),(0,W.jsxs)(`span`,{className:`sr-only`,children:[Lb(e.featureType),` file`]}),(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:c(`min-w-0 flex-1 truncate text-sm`,e.unread?`font-semibold text-foreground`:`font-medium`),children:r}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:qde(e.lastMessageAt)})]}),(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:c(`min-w-0 flex-1 truncate text-sm`,e.unread?`text-foreground`:`text-muted-foreground`),children:e.latestMessage||``}),e.status===`resolved`&&(0,W.jsxs)(tm,{variant:`outline`,className:`shrink-0 gap-1 font-normal text-muted-foreground`,children:[(0,W.jsx)(wn,{"aria-hidden":`true`}),`Resolved`]})]}),e.unread&&(0,W.jsx)(`span`,{className:`sr-only`,children:`New activity`})]})]},e.id)})]}),!l&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,size:`icon-lg`,className:`absolute bottom-4 right-4 z-10 min-h-11 min-w-11 rounded-full shadow-lg`,"aria-label":h===`comments`?`Add a comment`:`Start a discussion`,onClick:Ve,children:(0,W.jsx)(zt,{"aria-hidden":`true`})})}),(0,W.jsx)(Wt,{side:`left`,children:h===`comments`?`Add a comment`:`Start a discussion`})]})})]}),b===`compose`&&(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4`,children:[h===`comments`&&(0,W.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Context`}),(0,W.jsx)(`p`,{className:`mt-1 font-medium`,children:`${ge?.type||`node`} · ${i.label}`})]}),ne&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:ne})]}),(0,W.jsx)(Hde,{id:`${f}-composer`,value:fe,onChange:pe,onSubmit:Ue,placeholder:h===`comments`?`Write a comment...`:`Write a question or design decision...`,disabled:I,submitLabel:I?`Sending…`:h===`comments`?`Add comment`:`Start discussion`})]}),b===`thread`&&Ze&&(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[h===`comments`&&(0,W.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border px-3 py-1.5`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(()=>{let e=Ze.anchorId&&(_||Ze.fileId===i.fileId)?s?.(Ze.anchorId):null;return e?(0,W.jsx)(`p`,{className:`line-clamp-2 border-l-2 border-yellow-500/70 pl-2 text-xs leading-snug text-muted-foreground`,children:e}):(0,W.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[Ze.anchorType===`general`?`General`:Ze.anchorType,Ze.featureType&&` · ${Lb(Ze.featureType)}`]})})()}),!l&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0`,"aria-label":Ze.status===`open`?`Resolve`:`Reopen`,onClick:()=>void Xe(),disabled:I,children:Ze.status===`open`?(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-4`}):(0,W.jsx)(Xn,{"aria-hidden":`true`,className:`size-4`})})}),(0,W.jsx)(Wt,{side:`left`,children:Ze.status===`open`?`Resolve`:`Reopen`})]})})]}),ne&&(0,W.jsxs)(`div`,{className:`m-4 rounded-lg border border-destructive/40 p-4 text-sm`,role:`alert`,children:[(0,W.jsx)(`p`,{children:ne}),(0,W.jsx)(H,{variant:`outline`,className:`mt-3 min-h-11`,onClick:()=>void(_&&ve?Pe(ve,!0):Ne(Ze.id,!0)),children:`Retry`})]}),!ne&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsx)(Pn,{defaultScrollPosition:`end`,children:(0,W.jsxs)(On,{className:`flex-1`,children:[(0,W.jsx)(qn,{"aria-label":`${h===`comments`?`Comment`:`Discussion`} messages`,children:(0,W.jsxs)(Sn,{className:`gap-1 p-3`,children:[O.hasMore&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,W.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void Ie(),disabled:A,children:A?`Loading…`:`Load earlier messages`}),M&&(0,W.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:M})]}),ye.map(e=>(0,W.jsx)(dn,{messageId:e.id,scrollAnchor:!0,children:(0,W.jsx)(Ude,{message:e,canEdit:h===`discussions`&&e.authorId===n&&!l,editing:ie===e.id,editDraft:ae,editOriginalBody:se,disabled:I,onEdit:()=>Ge(e),onDelete:()=>ue({type:`message`,threadId:Ze.id,message:e}),onEditDraftChange:oe,onCancelEdit:Ke,onSaveEdit:t=>{qe(e,t)}})},e.id))]})}),(0,W.jsx)(kn,{})]})},Ze.id)}),Ze.status===`open`&&!ne&&!l&&(0,W.jsx)(Vde,{userName:r||`You`,value:fe,onChange:pe,onSubmit:()=>void We(),disabled:I,submitLabel:I?`Sending…`:`Send reply`}),Ze.status===`resolved`&&!l&&(0,W.jsx)(`p`,{className:`border-t border-border px-4 py-3 text-sm text-muted-foreground`,children:`Reopen this thread to reply.`}),l&&(0,W.jsx)(`p`,{className:`border-t border-border px-4 py-3 text-sm text-muted-foreground`,children:`You can read this thread but not reply to it.`})]})]}),(0,W.jsx)(kr,{isOpen:de,title:`Discard unsent changes?`,message:`You have text that hasn't been sent or saved. If you close this panel now, it will be lost.`,confirmText:`Discard`,cancelText:`Cancel`,variant:`warning`,onCancel:()=>{B(!1),window.setTimeout(()=>document.querySelector(`[data-discussions-panel] textarea`)?.focus(),150)},onConfirm:()=>{B(!1),pe(``),Ke(),m(!1)}}),(0,W.jsx)(kr,{isOpen:le!==null,title:le?.type===`message`?`Delete message?`:`Delete discussion?`,message:le?.type===`message`?`This message will be permanently deleted.`:`This permanently deletes the discussion and all its messages. This action cannot be undone.`,confirmText:le?.type===`message`?`Delete message`:`Delete Thread`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>ue(null),onConfirm:()=>{le?.type===`message`?Ye(le.threadId,le.message):le&&Je(le.threadId)}})]})}function Xde({file:e,active:t,target:n,teamId:r}){let i=ia(),a=y(),o=i.activeDocument,s=o?.project_id??o?.projectId,c=i.projects.find(e=>String(e.id)===String(s)),l=c?.team_id??c?.teamId;if(!n||!o||i.isGuest||!l||String(l)!==String(r))return null;let u=e.type===`erd`?`diagram`:e.type===`notes`?`note`:e.type===`drawings`?`drawing`:`flowchart`,d=t=>{t.featureType===u&&String(t.fileId)===e.uid?u===`diagram`&&t.anchorId&&window.dispatchEvent(new CustomEvent(`erd-discussion-anchor-selected`,{detail:{fileId:e.uid,type:t.anchorType,id:t.anchorId}})):a(`/${{diagram:`diagrams`,note:`notes`,drawing:`drawings`,flowchart:`flowcharts`}[t.featureType]}/${encodeURIComponent(t.fileId)}`)},f=i.selectedEdgeId?{type:`relationship`,id:i.selectedEdgeId}:i.selectedNodeId?{type:`table`,id:i.selectedNodeId}:null;return(0,xb.createPortal)((0,W.jsx)(`span`,{hidden:!t,children:(0,W.jsx)(zb,{projectId:String(s),teamId:String(r),fileContext:{featureType:u,fileId:e.uid,label:o.title||o.name||e.title},userId:i.user?.id?String(i.user.id):void 0,userName:i.user?.name||i.user?.email,readOnly:i.getFileAccessRole(o)===`viewer`,anchorContext:f,onContextSelected:d,anchorPreview:u===`note`?e=>new DOMParser().parseFromString(o.content||``,`text/html`).querySelector(`[data-comment-anchor-id="${CSS.escape(e)}"]`)?.textContent?.trim()||null:void 0})}),n)}var Zde=(0,U.lazy)(()=>bi(()=>import(`./NoteEditorRoute-BwHXTyYF.js`).then(e=>({default:e.NoteEditorRoute})),__vite__mapDeps([8,5,9,10,11,12,7,13,14,15,16,17,6,18,19,20,21,4,1,22]))),Qde=(0,U.lazy)(()=>bi(()=>import(`./DiagramEditorRoute-CLADDbwI.js`).then(e=>({default:e.DiagramEditorRoute})),__vite__mapDeps([23,5,9,10,14,12,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),$de=(0,U.lazy)(()=>bi(()=>import(`./FlowchartEditorRoute-Ddyctcrx.js`).then(e=>({default:e.FlowchartEditorRoute})),__vite__mapDeps([54,5,9,12,10,14,15,16,17,7,6,11,28,27,26,29,30,31,32,33,34,35,36,37,38,39,40,55,46,50,42,13,18,19,20,21,4,1,22,51,52,53]))),efe=(0,U.lazy)(()=>bi(()=>import(`./DrawingEditorRoute-Cx5d1LPX.js`).then(e=>({default:e.DrawingEditorRoute})),__vite__mapDeps([56,5,9,10,30,12,11,57,47,7,6,13,14,15,16,17,18,19,20,21,4,1,22])));function tfe({file:e,scope:t,root:n,discussionTarget:r,onUpdate:i,teamState:a}){let o=ia(),s=(0,U.useMemo)(()=>({...o,theme:n.theme,resolvedTheme:n.resolvedTheme,setTheme:n.setTheme,setIsSettingsOpen:n.setIsSettingsOpen,setSettingsTab:n.setSettingsTab}),[o,n.theme,n.resolvedTheme,n.setTheme,n.setIsSettingsOpen,n.setSettingsTab]),c=An(),l=Bi(),u=(0,U.useRef)(s),d=(0,U.useRef)(null);u.current=s;let f=(0,U.useMemo)(()=>()=>Qy(u.current,t.host.current??document),[t]);return(0,U.useEffect)(()=>{i(F(e),{file:e,scope:t,workspace:s,ai:c,canvas:l,flush:f})},[e,t,s,c,l,f,i]),(0,U.useEffect)(()=>{e.previewSchema&&d.current!==e&&!s.isERDItemLoading&&s.activeDiagram&&!s.isReadOnlyFile(s.activeDiagram)&&c.applyContent(e.previewSchema,`append`,`erd-generate-sql`)&&(d.current=e)},[e.previewSchema,s.isERDItemLoading,!!s.activeDiagram,c.applyContent]),(0,W.jsxs)(aa.Provider,{value:s,children:[(0,W.jsx)(Xde,{file:e,active:t.active.current,target:r,teamId:a?.activeTeamId}),(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{role:`status`,className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading editor…`}),children:(0,W.jsx)(m,{context:a})})]})}var nfe=(0,U.memo)(function({file:e,active:t,scope:n,root:r,mainAI:i,teamState:a,discussionTarget:o,onUpdate:s,onNavigate:c}){n.active.current=t;let l=(0,U.useContext)(v),u=(0,U.useRef)(c);u.current=c;let d=(0,U.useMemo)(()=>({...l,navigator:{...l.navigator,push:e=>u.current(typeof e==`string`?e:`${e.pathname??``}${e.search??``}`),replace:t=>{let n=typeof t==`string`?t:`${t.pathname??``}${t.search??``}`;n.split(`?`)[0]!==k(e).split(`?`)[0]&&u.current(n)}}}),[l,e.type,e.uid]);return(0,W.jsx)(j.Provider,{value:n,children:(0,W.jsx)(v.Provider,{value:d,children:(0,W.jsx)(S,{location:k(e),children:(0,W.jsxs)(x,{element:(e=>(0,W.jsx)(de,{children:(0,W.jsx)(Yi,{isPublicView:!1,publicData:null,isPublicLoading:!1,forbiddenDoc:null,fetchPublicDocument:void 0,setIsPublicView:r.setIsPublicView,handleLogout:async()=>{await r.handleLogout()},children:(0,W.jsx)(Wn,{panelMode:i.rightPanelMode,onPanelModeChange:i.setRightPanelMode,children:e})})}))((0,W.jsx)(tfe,{file:e,scope:n,root:r,discussionTarget:o,onUpdate:s,teamState:a})),children:[(0,W.jsx)(x,{path:`notes/:id`,element:(0,W.jsx)(hb,{capability:`notes`,children:(0,W.jsx)(Zde,{})})}),(0,W.jsx)(x,{path:`diagrams/:id`,element:(0,W.jsx)(hb,{capability:`erd_builder`,children:(0,W.jsx)(Qde,{})})}),(0,W.jsx)(x,{path:`flowcharts/:id`,element:(0,W.jsx)(hb,{capability:`flowcharts`,children:(0,W.jsx)($de,{})})}),(0,W.jsx)(x,{path:`drawings/:id`,element:(0,W.jsx)(hb,{capability:`drawings`,children:(0,W.jsx)(efe,{})})})]})})})})});function Bb({className:e,...t}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`button-group`,className:c(`inline-flex items-center rounded-lg shadow-xs [&>button:not(:first-child)]:rounded-l-none [&>button:not(:first-child)]:border-l-0 [&>button:not(:last-child)]:rounded-r-none`,e),...t})}function rfe({file:e,title:t,feature:n,icon:r,active:i,onSelect:a}){let o=Mt(),s=e&&o?.files.some(t=>F(t)===F(e)),c=o?.files.length?!!s:i;return(0,W.jsxs)(Bb,{"aria-label":t,children:[(0,W.jsxs)(H,{variant:c?`default`:`outline`,size:`sm`,"aria-current":c?`page`:void 0,"data-state":c?`active`:`inactive`,onClick:a,className:`max-w-44 border-input`,title:`${n}: ${t}`,children:[(0,W.jsx)(r,{"data-icon":`inline-start`}),(0,W.jsx)(`span`,{className:`truncate`,children:t})]}),o?.desktop&&o.canSplit&&e&&(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:c?`default`:`outline`,size:`icon-sm`,className:`rounded-r-lg! border border-input data-open:rounded-r-lg!`,"aria-label":`File options: ${t}`,children:(0,W.jsx)(on,{})})}),(0,W.jsx)(en,{align:`start`,className:`w-60`,children:(0,W.jsx)(Yt,{children:(0,W.jsx)(Kt,{className:`whitespace-nowrap`,disabled:o.files.length<2&&c,onClick:()=>s&&o.files.length===2?o.close(e):o.open(e),children:s&&o.files.length===2?`Close pane`:`Open side by side`})})})]})]})}var Vb=[{id:`notes`,label:`Notes`,icon:Nt,route:`/notes`},{id:`erd`,label:`ERD Builder`,icon:Ar,route:`/diagrams`},{id:`db-client`,label:`DB Client`,icon:jr,route:`/db-client`},{id:`flowchart`,label:`Flowchart`,icon:Ht,route:`/flowcharts`},{id:`drawings`,label:`Drawings`,icon:Mr,route:`/drawings`}],Hb=e=>e.title||e.name||`Untitled`,Ub=e=>e.uid||e.id,Wb=e=>new Date(e.created_at||e.createdAt||0).getTime(),ife=3e4,Gb=new Map,Kb=new Map,qb=(e,t)=>{let n=e?.uid??e?.id;return n==null?null:{type:t,uid:String(n),title:Hb(e),createdAt:e.created_at??e.createdAt}};function Jb(e,t){let n=t=>!t.is_deleted&&!t.isDeleted&&String(t.project_id??t.projectId)===String(e),r=(e,t)=>e.filter(n).map(e=>qb(e,t)).filter(e=>e!==null);return[...r(t.notes,`notes`),...r(t.diagrams.filter(e=>(e.source_type??e.sourceType)!==`production_db`),`erd`),...r(t.flowcharts,`flowchart`),...r(t.drawings,`drawings`)]}function afe(...e){return[...new Map(e.flatMap(e=>e.map(e=>[`${e.type}-${e.uid}`,e]))).values()].sort((e,t)=>Wb(e)-Wb(t))}async function ofe(e,t){let n=String(e),r=`${t}:${n}`,i=Gb.get(r);if(i&&i.expiresAt>Date.now())return i;let a=Kb.get(r);if(a)return a;let o=wi(`/api/projects/${encodeURIComponent(n)}/files`).then(async e=>{if(!e.ok)throw Error(`Failed to load project files`);let t=await e.json(),n={files:Array.isArray(t.data)?t.data:[]};return Gb.set(r,{...n,expiresAt:Date.now()+ife}),n}).finally(()=>Kb.delete(r));return Kb.set(r,o),o}function Yb({currentView:e,currentFile:t,host:n=!1}){let r=(0,U.useContext)(Vy),i=Mt(),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(`notes`),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)({projectKey:``,files:[]}),g=(0,U.useRef)(null),v=y(),[b]=_(),{user:x,isGuest:S,activeProjectId:C,notes:w,diagrams:T,drawings:E,flowcharts:D,activeDiagram:O,activeNote:k,activeDrawing:A,activeFlowchart:j,activeDiagramId:M,activeNoteUid:N,activeDrawingId:P,activeFlowchartId:F,handleDiagramSelect:I,handleSidebarDiagramCreate:L,handleSidebarNoteCreate:R,handleSidebarDrawingCreate:ee,handleSidebarFlowchartCreate:te}=ia();(0,U.useEffect)(()=>{a&&setTimeout(()=>g.current?.focus(),0)},[a,s]);let ne=(0,U.useMemo)(()=>{let n=t??(e===`notes`?k:e===`erd`?O:e===`flowchart`?j:A);return n?.project_id??n?.projectId??(C&&C!==`all`?C:b.get(`pid`))},[C,k,O,j,A,t,e,b]),re=ne==null?``:String(ne),ie=m.projectKey===re?m.files:[],z=(0,U.useMemo)(()=>ne?Jb(ne,{notes:w,diagrams:T,drawings:E,flowcharts:D}):[],[ne,w,T,E,D]);(0,U.useEffect)(()=>{if(!ne){h({projectKey:``,files:[]});return}if(!S&&x?.id==null)return;let e=!1,t=String(ne);return(async()=>{try{let n;if(S){let[e,t,r,i]=await Promise.all([ea.getAllResources(`notes`),ea.getAllResources(`erd`),ea.getAllResources(`flowchart`),ea.getAllResources(`drawings`)]);n=Jb(ne,{notes:e,diagrams:t,flowcharts:r,drawings:i})}else n=(await ofe(ne,x.id)).files;e||h({projectKey:t,files:n})}catch{e||h({projectKey:t,files:[]})}})(),()=>{e=!0}},[ne,S,x?.id]);let ae=(0,U.useMemo)(()=>{if(!ne)return[];let n=t??(e===`notes`?k:e===`erd`?O:e===`flowchart`?j:A),r=n?qb(n,e):null;return afe(ie,z,r?[r]:[]).map(e=>({file:e,type:e.type}))},[ne,ie,z,e,t,k,O,j,A]),oe=t?Ub(t):e===`notes`?N:e===`erd`?O?.uid||M:e===`flowchart`?j?.uid||F:A?.uid||P,se=(e,t)=>{if(i&&e!==`db-client`){i.select({type:e,uid:String(Ub(t)),title:Hb(t),projectId:String(ne)});return}if(e===`erd`){I(String(Ub(t)));return}let n=Vb.find(t=>t.id===e);if(!n)return;let r=new URLSearchParams({pid:String(ne)});v(`${n.route}/${Ub(t)}?${r}`)},ce=async()=>{let e=u.trim();if(e&&!f&&ne){p(!0);try{let t=String(ne);s===`notes`?await R(e,t):s===`erd`?await L(e,t):s===`flowchart`?await te(e,t):await ee(e,t),o(!1),d(``)}finally{p(!1)}}},le=(0,U.useRef)(null),[ue,de]=(0,U.useState)({before:!1,after:!1}),B=(0,U.useCallback)(()=>{let e=le.current;if(!e)return;let t=e.scrollLeft>1,n=e.scrollLeft+e.clientWidth<e.scrollWidth-1;de(e=>e.before===t&&e.after===n?e:{before:t,after:n})},[]);(0,U.useEffect)(()=>{let e=le.current;if(!e)return;let t=()=>{let t=e.querySelector(`[aria-current="page"]`);if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.left<r.left?e.scrollLeft-=r.left-n.left+8:n.right>r.right&&(e.scrollLeft+=Math.min(n.right-r.right+8,n.left-r.left))}B()};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[oe,ae.length,B,r]);let fe=e=>{let t=le.current;t&&t.scrollBy({left:e*Math.max(t.clientWidth*.6,160),behavior:`smooth`})};return!ne||i&&!n||!r?null:(0,xb.createPortal)((0,W.jsxs)(`nav`,{"aria-label":`Project files`,className:`flex w-full min-w-0 items-center gap-1 py-1`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[ue.before&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>fe(-1),className:`absolute inset-y-0 left-0 z-10 flex items-center bg-gradient-to-r from-background from-60% to-transparent pl-0.5 pr-3 text-muted-foreground hover:text-foreground`,"aria-label":`Scroll files left`,children:(0,W.jsx)(vr,{className:`size-4`})}),ue.after&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>fe(1),className:`absolute inset-y-0 right-0 z-10 flex items-center bg-gradient-to-l from-background from-60% to-transparent pl-3 pr-0.5 text-muted-foreground hover:text-foreground`,"aria-label":`Scroll files right`,children:(0,W.jsx)(At,{className:`size-4`})}),(0,W.jsx)(`div`,{ref:le,onScroll:B,onWheel:e=>{Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(e.currentTarget.scrollLeft+=e.deltaY)},className:`overflow-x-auto scrollbar-hide`,children:(0,W.jsx)(`div`,{className:`flex w-max items-center justify-start gap-1 py-1`,children:ae.map(({file:t,type:n})=>{let r=Vb.find(e=>e.id===n),i=r.icon,a=Ub(t),o=n===`db-client`?null:{type:n,uid:String(a),title:Hb(t),projectId:String(ne)};return(0,W.jsx)(rfe,{file:o,title:Hb(t),feature:r.label,icon:i,active:e===n&&String(oe)===String(a),onSelect:()=>se(n,t)},`${n}-${a}`)})})})]}),(0,W.jsxs)(Ut,{open:a,onOpenChange:e=>{o(e),e||d(``)},children:[(0,W.jsx)(Pt,{children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(`span`,{className:`inline-flex shrink-0`}),children:(0,W.jsx)(Vt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,"aria-label":`Create file`,children:(0,W.jsx)(zt,{})})})}),(0,W.jsx)(Wt,{side:`bottom`,children:`Create file`})]})}),(0,W.jsxs)(Rt,{align:`end`,className:`w-72 max-w-[calc(100vw-1rem)] overflow-hidden p-0`,children:[(0,W.jsx)(`div`,{className:`max-h-56 overflow-y-auto p-1`,children:Vb.filter(e=>e.id!==`db-client`).map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{onClick:()=>l(e.id),className:c(`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent`,s===e.id&&`bg-accent text-accent-foreground`),children:[(0,W.jsx)(t,{className:`size-4`}),(0,W.jsx)(`span`,{className:`flex-1`,children:e.label}),s===e.id&&(0,W.jsx)(an,{className:`size-4`})]},e.id)})}),(0,W.jsxs)(`div`,{className:`sticky bottom-0 flex gap-2 border-t bg-popover p-2`,children:[(0,W.jsx)(Oi,{ref:g,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ce(),e.key===`Escape`&&(o(!1),d(``))},placeholder:`New file name`,className:`h-8 text-xs`,disabled:f}),(0,W.jsx)(`button`,{onClick:ce,disabled:!u.trim()||f,className:`h-8 shrink-0 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:`Create`})]})]})]})]}),r)}function sfe({children:e,root:t,mainAI:n,teamState:r,discussionTarget:i,onFocusedSession:a,onPairChange:o,paneAIRef:s}){let c=h(),l=y(),[u,f]=(0,U.useState)(()=>window.matchMedia(`(min-width: 1024px)`).matches),[p,m]=(0,U.useState)([]),g=u&&p.length===2;(0,U.useLayoutEffect)(()=>(o(g),()=>o(!1)),[g,o]);let[_,v]=(0,U.useState)(``),b=(0,U.useRef)(_);b.current=_;let[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(!1),D=(0,U.useRef)(!1),O=(0,U.useRef)(c.pathname+c.search),A=(0,U.useRef)(null),j=(0,U.useRef)(new Map),M=(0,U.useRef)(new Map),N=(0,U.useRef)(null),[I,R]=(0,U.useState)(50),ee=(0,U.useRef)(!1),te=r,ne=(0,U.useMemo)(()=>({activeTeamId:te.activeTeamId,activeTeam:te.activeTeam,isLoading:te.isLoading}),[te.activeTeamId,te.activeTeam,te.isLoading]),re=c.pathname.match(/^\/(notes|diagrams|flowcharts|drawings)\/([^/]+)$/),ie={notes:`notes`,diagrams:`erd`,flowcharts:`flowchart`,drawings:`drawings`},z=re?ie[re[1]]:null,ae=z===`notes`?t.activeNote:z===`erd`?t.activeDiagram:z===`flowchart`?t.activeFlowchart:t.activeDrawing,oe=ae?.project_id??ae?.projectId,se=z&&ae&&oe!=null?{type:z,uid:String(ae.uid??ae.id),title:ae.title||ae.name||`Untitled`,projectId:String(oe)}:null,ce=se??p[0]??null,le=`${t.user?.id}:${t.teamScopeVersion}`;(0,U.useLayoutEffect)(()=>{if(s)return s.current=e=>p.some(t=>F(t)===e)?j.current.get(e)?.ai:void 0,()=>{s.current=null}},[s,p]);let ue=(0,U.useCallback)((e,t)=>{j.current.set(e,t),e===b.current&&a(t)},[a]);(0,U.useEffect)(()=>{a(j.current.get(_)??null)},[_,a]),(0,U.useEffect)(()=>()=>a(null),[a]),(0,U.useEffect)(()=>{m([]),S(null),v(``),j.current.clear(),M.current.clear(),a(null)},[le,a]),(0,U.useEffect)(()=>{t.isPublicView&&(m([]),S(null),v(``),a(null))},[t.isPublicView,a]),(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>f(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let de=(0,U.useCallback)(async e=>{let t=j.current.get(F(e));if(!t)throw Error(`Wait for the editor to finish loading.`);await t.flush()},[]);(0,U.useEffect)(()=>{let e=e=>{p.length&&e.detail.push(Promise.all(p.map(de)).then(()=>{}))};return window.addEventListener(P,e),()=>window.removeEventListener(P,e)},[p,de]);let B=async e=>{if(!D.current){D.current=!0,E(!0);try{await e()}catch(e){d.error(e instanceof Error?e.message:`Could not switch files.`)}finally{D.current=!1,E(!1)}}},fe=e=>{b.current=F(e),v(F(e)),a(j.current.get(F(e))??null)},pe=e=>{let n=p[0]??ce;(u||e.previewSchema)&&n&&L(p,n,e)!==`reject`&&(p.some(t=>F(t)===F(e))?(e.previewSchema&&m(t=>t.map(t=>F(t)===F(e)?e:t)),fe(e)):(p.length||F(n)!==F(e))&&(p.length===2?(S(e),w(``)):B(async()=>{p.length||await Qy(t),m([...p.length?p:[n],e]),fe(e)})))},me=e=>{p.some(t=>F(t)===F(e))?fe(e):p.length===2&&u?pe(e):B(async()=>{p.length?await Promise.all(p.map(de)):await Qy(t),m([]),v(``),a(null),l(k(e))})},he=e=>void B(async()=>{await de(e);let t=p.filter(t=>F(t)!==F(e));j.current.delete(F(e)),M.current.delete(F(e)),m(t),t[0]&&(fe(t[0]),c.pathname!==k(t[0]).split(`?`)[0]&&l(k(t[0]),{replace:!0}))}),ge=e=>{let n=e.match(/^\/(notes|diagrams|flowcharts|drawings)\/([^/?]+)/);if(n&&ce){let e=ie[n[1]],r=decodeURIComponent(n[2]),i=(e===`notes`?t.notes:e===`erd`?t.diagrams:e===`flowchart`?t.flowcharts:t.drawings).find(e=>String(e.uid)===r||String(e.id)===r)??[...j.current.values()].find(t=>t.file.type===e&&(String(t.workspace.activeDocument?.id)===r||t.file.uid===r))?.workspace.activeDocument;me({type:e,uid:String(i?.uid??i?.id??r),title:i?.title||i?.name||`Untitled`,projectId:String(i?.project_id??i?.projectId??ce.projectId)})}else B(async()=>{await Promise.all(p.map(de)),m([]),v(``),a(null),l(e)})},_e=(0,U.useRef)(pe),ve=(0,U.useRef)(ge);ve.current=ge;let V=(0,U.useCallback)(e=>ve.current(e),[]);_e.current=pe,(0,U.useEffect)(()=>{let e=c.pathname+c.search;if(!p.length){O.current=e;return}if(T||O.current===e||re&&(!se||se.uid!==decodeURIComponent(re[2])&&String(ae?.id)!==decodeURIComponent(re[2])))return;let t=O.current;O.current=e;let n=se&&p.find(e=>F(e)===F(se));re&&n?fe(n):re&&se&&p.length===2&&se.projectId===p[0].projectId?(A.current=t,S(se),w(``)):B(async()=>{try{await Promise.all(p.map(de)),m([]),v(``),a(null)}catch(e){throw O.current=t,l(t,{replace:!0}),e}})},[c.pathname,c.search,se?.uid,se?.projectId,p,T,de,l,a]);let be=()=>{T||(S(null),A.current&&=(O.current=A.current,l(A.current,{replace:!0}),null))};if((0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.file;ye(t)&&_e.current(t)};return window.addEventListener(Ee,e),()=>window.removeEventListener(Ee,e)},[]),(0,U.useEffect)(()=>{let e=e=>{if(!ee.current||!N.current)return;let t=N.current.getBoundingClientRect();R(Math.max(30,Math.min(70,(e.clientX-t.left)/t.width*100)))},t=()=>{ee.current=!1};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]),!ce||!re&&!p.length||t.isPublicView)return(0,W.jsx)(W.Fragment,{children:e});let xe=p.find(e=>F(e)===_)??ce,Se=j.current.get(F(xe))?.workspace.activeDocument??(se&&F(xe)===F(se)?ae:void 0),Ce=T?{inert:``}:{};return(0,W.jsxs)(It.Provider,{value:{files:p,focused:_,desktop:u,canSplit:!!(p[0]??ce),open:pe,select:me,close:he},children:[(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,W.jsx)(Yb,{host:!0,currentView:xe.type,currentFile:Se}),p.length?(0,W.jsx)(`div`,{ref:N,className:`flex min-h-0 flex-1 overflow-hidden`,"aria-label":`Open files`,children:p.map((e,r)=>{let a=F(e),o=M.current.get(a);return o||(o={active:{current:_===a},host:{current:null}},M.current.set(a,o)),(0,W.jsxs)(`div`,{className:g||_===a?`contents`:`hidden`,children:[g&&r===1&&(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize editors`,"aria-orientation":`vertical`,"aria-valuemin":30,"aria-valuemax":70,"aria-valuenow":Math.round(I),tabIndex:0,className:`w-2 shrink-0 cursor-col-resize touch-none border-x bg-muted/30 focus-visible:bg-accent`,onPointerDown:e=>{ee.current=!0,e.currentTarget.setPointerCapture(e.pointerId)},onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),R(t=>Math.max(30,Math.min(70,t+(e.key===`ArrowLeft`?-2:2)))))}}),(0,W.jsxs)(`section`,{"data-file-session":a,"data-active":_===a,"aria-label":e.title,...Ce,onPointerDownCapture:()=>fe(e),onFocusCapture:()=>{_!==a&&fe(e)},className:`relative flex min-h-0 min-w-0 flex-col overflow-hidden`,style:g?{width:r===0?`${I}%`:void 0,flex:r===1?1:void 0}:{flex:1},children:[g&&(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between gap-2 border-b px-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.title}),(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close pane: ${e.title}`,disabled:T,onClick:()=>he(e),children:(0,W.jsx)(Gr,{})})]}),(0,W.jsx)(`div`,{ref:o.host,className:`relative isolate flex min-h-0 flex-1 flex-col overflow-hidden [transform:translateZ(0)]`,children:(0,W.jsx)(nfe,{file:e,active:_===a,scope:o,root:t,mainAI:n,teamState:ne,discussionTarget:i,onUpdate:ue,onNavigate:V})})]})]},a)})}):(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,...Ce,children:e})]}),(0,W.jsx)(gi,{open:!!x,onOpenChange:e=>{e||be()},children:(0,W.jsxs)(ai,{children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(_i,{children:`Replace an open file`}),(0,W.jsxs)(fi,{children:[`Choose the file to close before opening `,x?.title,`.`]})]}),(0,W.jsx)(mi,{className:`p-4`,children:(0,W.jsx)(Xy,{"aria-label":`File to replace`,value:C,onValueChange:e=>w(String(e)),className:`flex flex-col gap-2`,children:p.map(e=>(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-lg border p-3`,children:[(0,W.jsx)(qy,{value:F(e),className:`flex size-4 shrink-0 items-center justify-center rounded-full border border-input data-checked:border-primary focus-visible:ring-2 focus-visible:ring-ring`,children:(0,W.jsx)(Jy,{className:`size-2 rounded-full bg-primary`})}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate`,children:e.title}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:{notes:`Notes`,erd:`ERD Builder`,flowchart:`Flowchart`,drawings:`Drawings`}[e.type]})]})]},F(e)))})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(H,{variant:`outline`,disabled:T,onClick:be,children:`Cancel`}),(0,W.jsx)(H,{disabled:!C||T,onClick:()=>void B(async()=>{let e=p.find(e=>F(e)===C);x&&e&&(await de(e),j.current.delete(C),M.current.delete(C),m(p.map(e=>F(e)===C?x:e)),fe(x),S(null),A.current=null,se&&F(se)===F(e)&&l(k(x),{replace:!0}))}),children:`Replace file`})]})]})})]})}var Xb=U.createContext(void 0);function Zb(){let e=U.useContext(Xb);if(e===void 0)throw Error(Ne(13));return e}var Qb={imageLoadingStatus:()=>null},cfe=U.forwardRef(function(e,t){let{className:n,render:r,...i}=e,[a,o]=U.useState(`idle`),s={imageLoadingStatus:a},c=U.useMemo(()=>({imageLoadingStatus:a,setImageLoadingStatus:o}),[a,o]),l=Pe(`span`,e,{state:s,ref:t,props:i,stateAttributesMapping:Qb});return(0,W.jsx)(Xb.Provider,{value:c,children:l})});function lfe(e,{referrerPolicy:t,crossOrigin:n}){let[r,i]=U.useState(`idle`);return Oe(()=>{if(!e)return i(`error`),Ae;let r=!0,a=new window.Image,o=e=>()=>{r&&i(e)};return i(`loading`),a.onload=o(`loaded`),a.onerror=o(`error`),t&&(a.referrerPolicy=t),a.crossOrigin=n??null,a.src=e,()=>{r=!1}},[e,n,t]),r}var ufe={...Qb,...$e},dfe=U.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,referrerPolicy:a,crossOrigin:o,...s}=e,c=Zb(),l=lfe(e.src,{referrerPolicy:a,crossOrigin:o}),u=l===`loaded`,{mounted:d,transitionStatus:f,setMounted:p}=We(u),m=U.useRef(null),h=ke(e=>{i?.(e),c.setImageLoadingStatus(e)});Oe(()=>{l!==`idle`&&h(l)},[l,h]);let g={imageLoadingStatus:l,transitionStatus:f};Je({open:u,ref:m,onComplete(){u||p(!1)}});let _=Pe(`img`,e,{state:g,ref:[t,m],props:s,stateAttributesMapping:ufe,enabled:d});return d?_:null}),ffe=U.forwardRef(function(e,t){let{className:n,render:r,delay:i,...a}=e,{imageLoadingStatus:o}=Zb(),[s,c]=U.useState(i===void 0),l=ct();return U.useEffect(()=>(i!==void 0&&l.start(i,()=>c(!0)),l.clear),[l,i]),Pe(`span`,e,{state:{imageLoadingStatus:o},ref:t,props:a,stateAttributesMapping:Qb,enabled:o!==`loaded`&&s})}),$b=U.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,W.jsx)(cfe,{ref:r,"data-slot":`avatar`,"data-size":t,className:c(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n}));$b.displayName=`Avatar`;var ex=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(dfe,{ref:n,"data-slot":`avatar-image`,className:c(`aspect-square size-full rounded-full object-cover`,e),...t}));ex.displayName=`AvatarImage`;var tx=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(ffe,{ref:n,"data-slot":`avatar-fallback`,className:c(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t}));tx.displayName=`AvatarFallback`;function pfe({open:e,onOpenChange:t}){let[n,r]=(0,U.useState)(!1);return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-105 bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`Guest Data Backup`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Export your Guest Mode data as a JSON file for safe keeping or future import.`}),(0,W.jsxs)(`div`,{className:`p-2 space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`p-2.5 bg-amber-500/10 rounded-xl`,children:(0,W.jsx)(Qo,{className:`size-5 text-amber-500`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold text-base`,children:`Guest Mode`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`You are browsing as a guest`})]})]}),(0,W.jsxs)(`div`,{className:`bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Ar,{className:`size-4 text-muted-foreground shrink-0 mt-0.5`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:(0,W.jsxs)(`p`,{children:[`Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a `,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px]`,children:`.json`}),` `,`file so you can import it after signing in.`]})})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Wa,{className:`size-4 text-muted-foreground shrink-0 mt-0.5`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:(0,W.jsxs)(`p`,{children:[`The export file can be imported into any ERD Builder Pro account via`,(0,W.jsx)(`strong`,{children:` Settings → Guest Data Import`}),`.`]})})]})]}),(0,W.jsx)(H,{onClick:async()=>{r(!0);try{await Ny(),d.success(`Data exported successfully!`)}catch(e){d.error(`Export failed: `+(e.message||`Unknown error`))}finally{r(!1)}},disabled:n,className:`w-full`,children:n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`size-4 mr-2 animate-spin`}),`Exporting…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Yn,{className:`size-4 mr-2`}),`Export My Data`]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`span`,{className:`w-full border-t border-border/30`})}),(0,W.jsx)(`div`,{className:`relative flex justify-center text-xs`,children:(0,W.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`Need an account?`})})]}),(0,W.jsx)(`div`,{className:`text-center space-y-2`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Sign up or log in from the main page to import your backup.`})})]})]})})}function mfe({user:e,onLogout:t,onViewChange:n,isOnline:r,onOpenFeedback:i,compact:a=!1}){let{isMobile:o}=Pp(),{isGuest:s,setIsSettingsOpen:l,setSettingsTab:u,hasUpdate:d,latestVersion:f,isCheckingUpdate:p,isDownloadingUpdate:m,isWebOutdated:h,showOutdatedBadge:g,checkForUpdates:_,downloadUpdate:v}=ia(),y=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!e)return null;let b=e.email||``,x=e.name||e.user_metadata?.full_name||e.user_metadata?.name||b.split(`@`)[0]||`User`,S=e.user_metadata?.avatar_url||``,C=x.substring(0,2).toUpperCase(),w=e=>{u(e),l(!0)},[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(Gp,{size:`lg`,"aria-label":a?`Account menu for ${x}`:void 0,title:a?x:void 0,className:c(`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,a&&`!size-8 !justify-center !p-0`),children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsxs)($b,{className:`h-8 w-8 rounded-lg`,children:[(0,W.jsx)(ex,{src:S,alt:x}),(0,W.jsx)(tx,{className:`rounded-lg`,children:C})]}),g&&(0,W.jsx)(`span`,{className:`absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar`,title:d?`Update available: v${f}`:h?`New version available: v${f}. You're on v3.4.7-rc.38. Pull latest Docker image or update your install.`:``})]}),!a&&(0,W.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,W.jsx)(`span`,{className:`truncate font-semibold`,children:x}),(0,W.jsx)(`span`,{className:`truncate text-xs`,children:b})]}),!a&&(0,W.jsx)(Ea,{className:`ml-auto size-4`})]})}),(0,W.jsxs)(en,{className:`w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg`,side:o?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,W.jsx)(Yt,{children:(0,W.jsx)($t,{className:`p-0 font-normal`,children:(0,W.jsx)(Yt,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-left text-sm`,children:[(0,W.jsxs)($b,{className:`h-8 w-8 rounded-lg`,children:[(0,W.jsx)(ex,{src:S,alt:x}),(0,W.jsx)(tx,{className:`rounded-lg`,children:C})]}),(0,W.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,W.jsx)(`span`,{className:`truncate font-semibold`,children:x}),(0,W.jsx)(`span`,{className:`truncate text-xs`,children:b})]})]})})})}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Yt,{children:[(0,W.jsxs)(Kt,{onClick:()=>w(s||e.isSso?`appearance`:`account`),className:`cursor-pointer`,disabled:!s&&!r,children:[(0,W.jsx)(Ro,{className:`mr-2 size-4`}),`Settings`]}),s&&(0,W.jsxs)(Kt,{onClick:()=>E(!0),className:`cursor-pointer`,children:[(0,W.jsx)(Yn,{className:`mr-2 size-4`}),`Backup Data`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>O(!0),className:`cursor-pointer`,children:[d?(0,W.jsx)(Da,{className:`mr-2 size-4 text-emerald-400`}):h?(0,W.jsx)(_a,{className:`mr-2 size-4 text-amber-500`}):(0,W.jsx)(Dr,{className:`mr-2 size-4`}),`About`,g&&(0,W.jsx)(`span`,{className:`ml-auto flex size-2 rounded-full ${d?`bg-emerald-400`:`bg-amber-500`}`})]}),(0,W.jsxs)(Kt,{render:(0,W.jsx)(`a`,{href:`https://github.com/hadziqmtqn/erd-builder-pro`,target:`_blank`,rel:`noopener noreferrer`}),className:`cursor-pointer`,children:[(0,W.jsx)(to,{className:`mr-2 size-4`}),`Github`]}),(0,W.jsxs)(Kt,{onClick:i,className:`cursor-pointer`,children:[(0,W.jsx)(So,{className:`mr-2 size-4`}),`Feedback`]})]}),(0,W.jsx)(tn,{}),(0,W.jsx)(Yt,{children:(0,W.jsxs)(Kt,{onClick:()=>r&&n(`trash`),disabled:!r,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!r&&`opacity-50 cursor-not-allowed`}`,children:[(0,W.jsx)(ni,{className:`mr-2 size-4`}),`Trash`]})}),(0,W.jsx)(tn,{}),!y&&(0,W.jsxs)(Kt,{onClick:()=>r&&t(),disabled:!r,className:`cursor-pointer ${!r&&`opacity-50 cursor-not-allowed`}`,title:r?``:`Logging out while offline may cause data loss of unsynced changes`,children:[(0,W.jsx)(xo,{className:`mr-2 size-4`}),`Log out`]})]})]})})}),(0,W.jsx)(pfe,{open:T,onOpenChange:E}),(0,W.jsx)(By,{open:D,onOpenChange:O,hasUpdate:d,latestVersion:f,isChecking:p,isDownloading:m,onCheckUpdate:_,onDownload:v})]})}function nx({label:e,icon:t,active:n=!1,locked:r=!1,disabled:i=!1,onClick:a}){let o=r?`${e}. Paid Cloud plan required.`:e;return(0,W.jsx)(Wp,{children:(0,W.jsx)(Gp,{isActive:n,disabled:i,"aria-label":o,className:c(`relative mx-auto !size-8 !justify-center !p-0`,r&&`cursor-not-allowed`),tooltip:{children:r?`${e} · PRO`:e,hidden:!1},onClick:a,children:(0,W.jsx)(t,{"aria-hidden":`true`,className:r?`text-muted-foreground`:void 0})})})}function hfe({activeFeatureView:e,canManageInstance:t,cloudFeatureLocked:n,isOnline:r,isSelfHosted:i,onFeatureClick:a,onLogout:o,onOpenFeedback:s,onViewChange:c,ssoPortalUrl:l,user:u,showDbClient:d}){let f=h(),p=y(),{isMobile:m}=Pp(),g=()=>{if(l)try{window.location.assign(new URL(`/dashboard`,l).toString())}catch{}},_=async()=>{r&&(await c(`erd`,!0),p(`/table/db-client`))};return(0,W.jsxs)(Ip,{collapsible:`none`,className:`w-[calc(var(--sidebar-width-icon,3rem)+1px)]! shrink-0 border-r`,children:[(0,W.jsx)(Lp,{className:`items-center border-b border-sidebar-border p-2`,children:(0,W.jsxs)(`div`,{className:`flex size-8 items-center justify-center`,role:`img`,"aria-label":`ERD Builder Pro`,children:[(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Light-1.svg`,alt:``,className:`size-full dark:hidden`}),(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Dark-1.svg`,alt:``,className:`hidden size-full dark:block`})]})}),(0,W.jsx)(zp,{className:`items-center overflow-y-auto px-1 py-3`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[(0,W.jsxs)(Up,{className:`gap-1`,children:[(0,W.jsx)(nx,{label:`Dashboard`,icon:fo,active:f.pathname===`/`,onClick:()=>p(`/`)}),u?.isSso&&l&&(0,W.jsx)(nx,{label:`Manage account & billing`,icon:za,onClick:g}),i&&t&&(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{openOnHover:!0,delay:0,closeDelay:120,render:(0,W.jsx)(Gp,{isActive:f.pathname===`/team-workspaces`||f.pathname===`/users`,"aria-label":`Instance Administration (Self-Host)`,title:`Instance Administration (Self-Host)`,className:`relative mx-auto !size-8 !justify-center !p-0`,children:(0,W.jsx)(Ho,{"aria-hidden":`true`})})}),(0,W.jsxs)(en,{side:m?`bottom`:`right`,align:`start`,sideOffset:8,children:[(0,W.jsxs)(Kt,{onClick:()=>p(`/team-workspaces`),children:[(0,W.jsx)(Qa,{"aria-hidden":`true`}),`Team`]}),(0,W.jsxs)(Kt,{onClick:()=>p(`/users`),children:[(0,W.jsx)($o,{"aria-hidden":`true`}),`Users`]})]})]})})]}),(0,W.jsx)(`div`,{className:`mx-auto h-px w-8 bg-sidebar-border`,"aria-hidden":`true`}),(0,W.jsxs)(Up,{className:`gap-1`,children:[(0,W.jsx)(nx,{label:`Notes`,icon:Nt,active:e===`notes`,locked:n(`notes`),onClick:()=>a(`Notes`,`notes`,()=>c(`notes`,!0))}),(0,W.jsx)(nx,{label:`ERD Builder`,icon:Ar,active:e===`erd`,locked:n(`erd_builder`),onClick:()=>a(`ERD Builder`,`erd_builder`,()=>c(`erd`,!0))}),d&&(0,W.jsx)(nx,{label:`DB Client`,icon:jr,active:e===`db-client`,disabled:!r,onClick:()=>{_()}}),(0,W.jsx)(nx,{label:`Flowchart`,icon:Eo,active:e===`flowchart`,locked:n(`flowcharts`),onClick:()=>a(`Flowchart`,`flowcharts`,()=>c(`flowchart`,!0))}),(0,W.jsx)(nx,{label:`Drawings`,icon:Mr,active:e===`drawings`,locked:n(`drawings`),onClick:()=>a(`Drawings`,`drawings`,()=>c(`drawings`,!0))})]}),u?.isSso&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mx-auto h-px w-8 bg-sidebar-border`,"aria-hidden":`true`}),(0,W.jsx)(Up,{className:`gap-1`,children:(0,W.jsx)(nx,{label:`Library`,icon:mo,active:f.pathname===`/library`,disabled:!r,onClick:()=>p(`/library`)})})]})]})}),(0,W.jsx)(Rp,{className:`items-center border-t border-sidebar-border p-2`,children:(0,W.jsx)(mfe,{user:u,onLogout:o,onViewChange:c,isOnline:r,onOpenFeedback:s,compact:!0})})]})}function gfe(e){try{let t=new URL(e);return t.searchParams.set(`utm_source`,`erdbuilderpro.com`),t.searchParams.set(`utm_medium`,`referral`),t.searchParams.set(`utm_campaign`,`sponsor`),t.toString()}catch{return e}}var _fe=[{logoOnLightSurfaceSrc:`https://s3.erdbuilderpro.com/sponsors/Sumopod-Light.png`,logoOnDarkSurfaceSrc:`https://s3.erdbuilderpro.com/sponsors/Sumopod-Dark.png`,logoAlt:`SumoPod`,title:`Deploy your App in 15 Seconds!`,description:`Seamless container deployment for businesses of all sizes.`,buttonText:`Get Started →`,buttonAction:`https://sumopod.com`}];function vfe(){let e=_fe[0];return(0,W.jsx)(`div`,{className:`px-2 pb-2`,children:(0,W.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-dashed border-zinc-700 bg-zinc-950 p-3 text-zinc-50 dark:border-zinc-300 dark:bg-zinc-100 dark:text-zinc-950`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[e.icon?(0,W.jsx)(e.icon,{className:`w-5 h-5 text-rose-500 shrink-0`}):e.logoOnDarkSurfaceSrc||e.logoOnLightSurfaceSrc?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`img`,{src:e.logoOnDarkSurfaceSrc??e.logoOnLightSurfaceSrc,alt:e.logoAlt??``,className:`h-8 w-auto max-w-full shrink-0 object-contain dark:hidden`}),e.logoOnLightSurfaceSrc&&(0,W.jsx)(`img`,{src:e.logoOnLightSurfaceSrc,alt:e.logoAlt??``,className:`hidden h-8 w-auto max-w-full shrink-0 object-contain dark:block`})]}):null,(0,W.jsx)(`p`,{className:`max-w-full truncate text-center text-xs font-semibold text-zinc-50 dark:text-zinc-950`,children:e.title}),(0,W.jsx)(`p`,{className:`wrap-break-word text-center text-[11px] leading-relaxed text-zinc-300 dark:text-zinc-600`,children:e.description}),(0,W.jsx)(H,{type:`button`,className:`mt-1 w-full bg-[#1a5fd4] text-white hover:bg-[#174ea6]`,onClick:()=>Hi(gfe(e.buttonAction)),children:e.buttonText})]})})})}function yfe({teams:e,activeTeamId:t,enabled:n,canManageTeams:r,onOpen:i,onSelect:a,onAdd:o,onManage:s}){let{isMobile:c}=Pp(),l=(e.find(e=>e.id===t)||null)?.name||(t?`Loading workspace…`:`Personal`),u=(0,W.jsxs)(Gp,{size:`lg`,"aria-label":`Switch workspace. Current workspace: ${l}`,title:`Workspace: ${l}`,className:`h-9 cursor-pointer px-2 transition-colors hover:bg-accent/50 active:bg-accent/70`,onClick:n?void 0:()=>a(null),children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:l}),n&&(0,W.jsx)(Ea,{className:`ml-auto size-4 shrink-0`})]});return n?(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{onOpenChange:e=>{e&&i()},children:[(0,W.jsx)(Jt,{render:u}),(0,W.jsxs)(en,{className:`min-w-64 border border-border/70 p-1.5 shadow-xl`,side:c?`bottom`:`right`,align:`start`,sideOffset:6,children:[(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80`,children:`Team`}),(0,W.jsxs)(Kt,{onClick:()=>a(null),className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand ${t?``:`bg-brand/10 text-foreground [&>svg]:text-brand`}`,children:[(0,W.jsx)(Zo,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{children:`Personal`}),!t&&(0,W.jsx)(an,{className:`ml-auto size-4 text-brand`})]})]}),e.length>0&&(0,W.jsx)(tn,{className:`my-1.5`}),e.length>0&&(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80`,children:`Teams`}),e.map(e=>(0,W.jsxs)(Kt,{onClick:()=>a(e.id),className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand ${t===e.id?`bg-brand/10 text-foreground [&>svg]:text-brand`:``}`,children:[(0,W.jsx)($o,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[t===e.id&&(0,W.jsx)(an,{className:`size-4 text-brand`}),e.canManage&&(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Open Team Management for ${e.name}`,className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent bg-muted/50 text-muted-foreground transition-all hover:border-brand/40 hover:bg-brand hover:text-white hover:shadow-sm focus-visible:border-brand focus-visible:bg-brand focus-visible:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/40`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e)},children:(0,W.jsx)(Lo,{className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,className:`text-xs`,children:`Manage team`})]})]})]},e.id))]}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{className:`my-1.5`}),(0,W.jsx)(Yt,{children:(0,W.jsxs)(Kt,{onClick:o,className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand`,children:[(0,W.jsx)(zt,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{children:`Add Team`})]})})]})]})]})})}):(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:u})})}function bfe(){if(typeof navigator>`u`)return`Ctrl+K`;let e=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad/i.test(e)?`⌘K`:`Ctrl+K`}function xfe({isLoading:e,isOnline:t,onQueryChange:n,onResultSelect:r,query:i,results:a,showDbClient:o}){let[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(`all`),d=(0,U.useRef)(null),f=bfe(),p=[{value:`all`,label:`All`},{value:`workspace`,label:`Projects`},{value:`erd`,label:`ERD Builder`},...o?[{value:`db-client`,label:`DB Client`}]:[],{value:`notes`,label:`Notes`},{value:`flowchart`,label:`Flowcharts`},{value:`drawings`,label:`Drawings`}],m=l===`all`?a:a.filter(e=>e.type===l);return(0,U.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),c(!0),d.current?.focus(),d.current?.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,U.useEffect)(()=>{s&&window.setTimeout(()=>{d.current?.focus(),d.current?.select()},0)},[s]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{type:`button`,onClick:()=>c(!0),disabled:!t,"aria-label":`Search files (${f})`,title:`Search files (${f})`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,children:(0,W.jsx)(Kr,{className:`size-4`,"aria-hidden":`true`})}),(0,W.jsx)($r,{open:s,onOpenChange:e=>{c(e),e||(u(`all`),n(``))},children:(0,W.jsxs)(qr,{size:`2xl`,showCloseButton:!1,className:`translate-y-0! max-h-[76vh] sm:max-w-2xl`,style:{top:`12vh`},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/60 px-4 py-3`,children:[(0,W.jsx)(Kr,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,W.jsx)(Oi,{ref:d,value:i,onChange:e=>n(e.target.value),placeholder:`Search files and projects`,"aria-label":`Spotlight file search`,className:`min-w-0 flex-1`}),(0,W.jsx)(`kbd`,{className:`rounded-lg border border-border/60 bg-muted/50 px-2.5 py-1.5 text-xs font-medium text-muted-foreground`,children:`ESC`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto border-b border-border/60 px-4 py-2.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Filter:`}),(0,W.jsx)(`div`,{className:`flex min-w-max items-center gap-1`,children:p.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(e.value),className:`min-h-10 rounded-md px-2.5 py-1 font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${l===e.value?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`}`,children:e.label},e.value))})]}),(e||i.trim().length>=2)&&(0,W.jsx)(`div`,{className:`max-h-[min(26rem,60vh)] overflow-y-auto p-2`,children:e?(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,W.jsx)(vo,{className:`size-4 animate-spin`,"aria-hidden":`true`}),` Searching...`]}):m.length===0?(0,W.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No results found.`}):m.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),c(!1)},className:`group flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,W.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-muted`,children:e.type===`workspace`?(0,W.jsx)(Ya,{className:`size-4 text-muted-foreground`}):e.type===`erd`?(0,W.jsx)(Ar,{className:`size-4 text-muted-foreground`}):e.type===`db-client`?(0,W.jsx)(jr,{className:`size-4 text-muted-foreground`}):e.type===`notes`?(0,W.jsx)(Nt,{className:`size-4 text-muted-foreground`}):e.type===`flowchart`?(0,W.jsx)(Eo,{className:`size-4 text-muted-foreground`}):(0,W.jsx)(Mr,{className:`size-4 text-muted-foreground`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name||`(Untitled)`}),(0,W.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e.type===`workspace`?`Project`:e.type===`erd`?`ERD Builder`:e.type===`db-client`?`DB Client`:e.type===`flowchart`?`Flowchart`:e.type===`notes`?`Note`:`Drawing`,e.workspace?.name&&` · ${e.workspace.name}`]})]}),(0,W.jsx)(ha,{className:`size-4 shrink-0 text-muted-foreground/40 group-hover:text-primary`,"aria-hidden":`true`})]},`${e.type}-${e.uid??e.id}`))})]})})]})}var rx={owner:`Creator`,manager:`Manager`,editor:`Editor`,commenter:`Commenter`,viewer:`Viewer`},Sfe=[`editor`,`commenter`,`viewer`],Cfe={editor:`Can change the files.`,commenter:`Can read and comment (default).`,viewer:`Can read only.`};function wfe(e){return{userId:String(e.user_id??e.userId),name:e.name??null,email:e.email??null,teamRole:String(e.team_role??e.teamRole??`staff`),role:e.role,canChange:(e.can_change??e.canChange)===!0}}function Tfe({project:e,onOpenChange:t}){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),c=e?.id,l=(0,U.useCallback)(async()=>{if(c!==void 0){a(``);try{let e=await wi(`/api/projects/${encodeURIComponent(String(c))}/access`),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Could not load access.`);r((t.members??[]).map(wfe))}catch(e){r(null),a(e instanceof Error?e.message:`Could not load access.`)}}},[c]);(0,U.useEffect)(()=>{r(null),c!==void 0&&l()},[c,l]);let u=async(e,t)=>{if(t!==e.role&&c!==void 0){s(e.userId);try{let n=`/api/projects/${encodeURIComponent(String(c))}/access/${encodeURIComponent(e.userId)}`,i=t===`commenter`?await wi(n,{method:`DELETE`}):await wi(n,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:t})}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||`Could not change access.`);r(n=>n?.map(n=>n.userId===e.userId?{...n,role:t}:n)??n),d.success(`${e.name||e.email||`Member`} is now ${rx[t]}.`)}catch(e){d.error(e instanceof Error?e.message:`Could not change access.`),await l()}finally{s(null)}}};return(0,W.jsx)($r,{open:e!==null,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-lg`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Project access`}),(0,W.jsxs)(Ur,{children:[`Choose what each Team member can do in `,e?.name,`. The creator and Team Managers always have full access.`]})]}),(0,W.jsxs)(Yr,{children:[i&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i}),!i&&n===null&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,children:[(0,W.jsx)(vo,{className:`size-4 animate-spin`,"aria-hidden":`true`}),` Loading members…`]}),n&&n.length===0&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team has no other active members.`}),n&&n.length>0&&(0,W.jsx)(`ul`,{className:`divide-y rounded-lg border`,"aria-label":`Project members`,children:n.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name||e.email||`Member`}),e.name&&e.email&&(0,W.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),e.canChange?(0,W.jsxs)(Er,{value:e.role,onValueChange:t=>{t&&u(e,t)},disabled:o===e.userId,children:[(0,W.jsx)(Cr,{className:`w-36`,"aria-label":`Access for ${e.name||e.email||`member`}`,children:(0,W.jsx)(Tr,{children:rx[e.role]})}),(0,W.jsx)(Sr,{className:`min-w-72`,children:(0,W.jsx)(wr,{children:Sfe.map(e=>(0,W.jsx)(xr,{value:e,children:(0,W.jsxs)(`span`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{children:rx[e]}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Cfe[e]})]})},e))})})]}):(0,W.jsx)(`span`,{className:`w-36 px-3 text-sm text-muted-foreground`,children:rx[e.role]})]},e.userId))})]})]})})}function Efe({activeTeamId:e,globalSearchQuery:t,globalSearchResults:n,isGlobalSearchLoading:r,isOnline:i,isProjectsLoading:a,onGlobalSearchChange:o,onGlobalSearchResultSelect:s,onTeamAdd:c,onTeamManage:l,onTeamSelect:u,onTeamsRefresh:d,onProjectCreate:f,onProjectDelete:p,onProjectUpdate:m,onWorkspaceFilter:h,projects:g,selectedWorkspaceUid:_,showDbClient:v,showSponsor:y,teams:b,teamsAvailable:x,user:S}){let[C,w]=(0,U.useState)(null),[T,E]=(0,U.useState)(``),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(null),[j,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(``),F=g.filter(e=>!e.is_deleted),I=(e,t)=>{h(e??(t==null?null:String(t)))};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ip,{collapsible:`none`,className:`min-w-0 flex-1`,children:[(0,W.jsxs)(Lp,{className:`gap-3.5 border-b border-sidebar-border px-2 py-4`,children:[(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(yfe,{teams:b,activeTeamId:e,enabled:x||b.length>0,canManageTeams:!!(S?.isSuperAdmin||S?.is_super_admin),onOpen:d,onSelect:u,onAdd:c,onManage:l})}),(0,W.jsx)(xfe,{query:t,results:n,isLoading:r,isOnline:i,showDbClient:v,onQueryChange:o,onResultSelect:s})]}),(0,W.jsxs)(H,{type:`button`,variant:`secondary`,className:`h-9 w-full justify-start gap-2`,onClick:()=>{P(``),M(!0)},children:[(0,W.jsx)(zt,{className:`size-4`}),`New Project`]})]}),(0,W.jsx)(zp,{children:(0,W.jsxs)(Bp,{className:`px-2`,children:[(0,W.jsx)(Vp,{children:`Projects`}),(0,W.jsx)(Hp,{children:(0,W.jsxs)(Up,{children:[(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{tooltip:`All Projects`,isActive:_===null||_===``,onClick:()=>I(null),children:[(0,W.jsx)(Ya,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:`All Projects`})]})}),a?(0,W.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground animate-pulse`,children:`Loading projects...`}):F.length===0?(0,W.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground`,children:`No projects yet`}):F.map(t=>(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{tooltip:t.name,isActive:_===t.uid||String(_??``)===String(t.id??``),onClick:()=>I(t.uid,t.id),children:[(0,W.jsx)(Ya,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:t.name}),(0,W.jsx)(`span`,{className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Project options for ${t.name}`,className:`flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,W.jsx)(Nr,{className:`size-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`min-w-44`,children:[e&&(t.access_role===`owner`||t.access_role===`manager`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Kt,{onClick:()=>A({id:t.id,name:t.name}),children:[(0,W.jsx)(es,{className:`size-3.5`,"aria-hidden":`true`}),`Manage access`]}),(0,W.jsx)(tn,{})]}),ji(t,S?.id,S?.id===`guest`)?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Kt,{onClick:()=>{E(t.name),w(t)},children:[(0,W.jsx)(_r,{className:`size-3.5`,"aria-hidden":`true`}),`Rename`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>O(t),children:[(0,W.jsx)(ni,{className:`size-3.5 text-destructive`,"aria-hidden":`true`}),`Delete`]})]}):(0,W.jsx)(Kt,{disabled:!0,children:`Only the creator can rename or delete`})]})]})})]})},t.uid??t.id))]})})]})}),y&&(0,W.jsx)(Rp,{className:`shrink-0 border-t border-sidebar-border p-2`,children:(0,W.jsx)(vfe,{})})]}),(0,W.jsx)(Tfe,{project:k,onOpenChange:e=>{e||A(null)}}),(0,W.jsx)($r,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Rename Project`})}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`rename-project-input`,children:`Name`}),(0,W.jsx)(Oi,{id:`rename-project-input`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T.trim()&&C&&(m(C.id,T.trim()),w(null))},autoFocus:!0})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{className:`h-9 px-6`,disabled:!T.trim(),onClick:()=>{C&&T.trim()&&(m(C.id,T.trim()),w(null))},children:`Save Changes`})]})]})}),(0,W.jsx)($r,{open:j,onOpenChange:M,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Create Project`})}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`create-project-input`,children:`Project name`}),(0,W.jsx)(Oi,{id:`create-project-input`,value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N.trim()&&(f(N.trim()),M(!1),P(``))},autoFocus:!0})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{className:`h-9 px-6`,disabled:!N.trim(),onClick:()=>{N.trim()&&(f(N.trim()),M(!1),P(``))},children:`Create`})]})]})}),(0,W.jsx)(db,{isOpen:D!==null,onOpenChange:e=>{e||O(null)},mode:`move-to-trash`,view:`project`,activeDocument:D?{id:D.id,name:D.name}:void 0,deleteProject:p,onAfterDelete:()=>O(null)})]})}function Dfe({open:e,onOpenChange:t,onCreate:n,onCreated:r}){let[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{e||(a(``),s(``),l(!1))},[e]),(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsx)(qr,{size:`md`,children:(0,W.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),s(``),l(!0);try{let e=await n({name:i});t(!1),r?.(e)}catch(e){s(e?.message||`Team could not be created.`)}finally{l(!1)}},children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Add Team`}),(0,W.jsx)(Ur,{children:`Create a Team using this installation's active license.`})]}),(0,W.jsxs)(Yr,{className:`space-y-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`team-name`,children:`Team name`}),(0,W.jsx)(Oi,{id:`team-name`,value:i,onChange:e=>a(e.target.value),placeholder:`Acme Engineering`,maxLength:100,required:!0,autoFocus:!0})]}),o&&(0,W.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:o})]}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>t(!1),disabled:c,children:`Cancel`}),(0,W.jsx)(H,{type:`submit`,disabled:c||!i.trim(),children:c?`Creating…`:`Add Team`})]})]})})})}var Ofe=U.memo(({projects:e,activeFeatureView:t,globalSearchResults:n,isGlobalSearchLoading:r,onGlobalSearchResultSelect:i,onViewChange:a,onProjectCreate:o,onProjectUpdate:s,onProjectDelete:l,onLogout:u,onWorkspaceFilter:d,selectedWorkspaceUid:f,globalSearchQuery:p,onGlobalSearchChange:m,isProjectsLoading:h,user:g,isOnline:_,onOpenFeedback:v,teams:y,teamsAvailable:b,licenseRequired:x,activeTeamId:S,onTeamsRefresh:C,onTeamSelect:w,onTeamManage:T,onTeamCreate:E,onTeamCreated:D,ssoPortalUrl:O,...k})=>{let[A,j]=(0,U.useState)(!1),[M,N]=(0,U.useState)(null),P=Ei(),F=!P&&!g?.isSso&&(g?.isSuperAdmin!==void 0||g?.is_super_admin!==void 0),I=g?.isSso===!0||P||F&&x,L=y.find(e=>e.id===S)||null,R=g?.isSso&&S&&b?L?.capabilities||{}:null,ee=e=>R!==null&&R[e]!==!0,te=()=>{if(O)try{window.location.assign(new URL(`/pricing#cloud-saas`,O).toString())}catch{}},ne=(e,t,n)=>{ee(t)?N(e):n()};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ip,{collapsible:`icon`,...k,className:c(`overflow-hidden *:data-[sidebar=sidebar]:flex-row`,k.className),children:(0,W.jsxs)(`div`,{"data-sidebar":`sidebar`,className:`flex h-full min-h-0 w-full`,children:[(0,W.jsx)(hfe,{activeFeatureView:t,canManageInstance:!!(g?.isSuperAdmin||g?.is_super_admin),cloudFeatureLocked:ee,isOnline:_,isSelfHosted:F,onFeatureClick:ne,onLogout:u,onOpenFeedback:v,onViewChange:a,ssoPortalUrl:O,user:g,showDbClient:P}),(0,W.jsx)(Efe,{activeTeamId:S,globalSearchQuery:p,globalSearchResults:n,isGlobalSearchLoading:r,isOnline:_,isProjectsLoading:h,onGlobalSearchChange:m,onGlobalSearchResultSelect:i,onTeamAdd:()=>j(!0),onTeamManage:T,onTeamSelect:w,onTeamsRefresh:C,onProjectCreate:o,onProjectDelete:l,onProjectUpdate:s,onWorkspaceFilter:d,projects:e,selectedWorkspaceUid:f,showDbClient:P,showSponsor:I,teams:y,teamsAvailable:b,user:g})]})}),(0,W.jsx)(Dfe,{open:A,onOpenChange:j,onCreate:E,onCreated:D}),(0,W.jsx)($r,{open:M!==null,onOpenChange:e=>{e||N(null)},children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,W.jsx)(ti,{className:`size-4`,"aria-hidden":`true`})}),(0,W.jsxs)(Jr,{children:[`Unlock `,M]})]}),(0,W.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[M,` is available with a paid Cloud plan. Upgrade to keep using this feature in your Team workspace.`]})]}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-primary/20 bg-primary/5 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Cloud workspace feature`}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Plans, limits, and checkout are managed in ERDBPro SaaS.`})]}),(0,W.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-[0.14em] text-primary`,children:`PRO`})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Not now`}),(0,W.jsxs)(H,{className:`h-9`,onClick:te,disabled:!O,children:[`View Cloud plans`,(0,W.jsx)(ha,{className:`size-4`})]})]})]})})]})});function kfe({isOpen:e,onOpenChange:t,documentType:n,documentUid:r,documentId:i,documentTitle:a,isPublicView:o=!1,initialSettings:s,onSettingsSaved:c}){let[l,u]=U.useState(s?.share_token||``),[f,p]=U.useState(!1),[m,h]=U.useState(s?.is_public||!1),[g,_]=U.useState(``),[v,y]=U.useState(!1);U.useEffect(()=>{if(s?.expiry_date){let e=new Date(s.expiry_date),t=new Date,n=e.getTime()-t.getTime(),r=Math.ceil(n/864e5);r>0&&_(r.toString())}u(s?.share_token||``),h(s?.is_public||!1)},[s]);let b={erd:`diagram`,notes:`note`,drawings:`drawing`,flowchart:`flowchart`}[n]||n,x=`${window.location.origin}/view/${b}/${r}`;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:o?`Share Document`:`Share "${a}"`}),(0,W.jsx)(Ur,{children:o?`Share this link with others to view this document.`:m?`Anyone with this link can view this document. No account required.`:`This document is currently private. Only you can access it.`})]}),(0,W.jsxs)(Yr,{className:`space-y-4`,children:[!o&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50`,children:[(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,W.jsx)(no,{className:`w-4 h-4 text-primary`}):(0,W.jsx)(yo,{className:`w-4 h-4 text-muted-foreground`}),(0,W.jsx)(oa,{htmlFor:`public-status`,className:`text-sm font-bold`,children:`Public Access`})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Enable sharing via public link`})]}),(0,W.jsx)(pm,{id:`public-status`,checked:m,onCheckedChange:e=>h(e)})]}),(0,W.jsxs)(`div`,{className:`space-y-4 transition-all duration-300 ${m||o?`opacity-100`:`opacity-40 pointer-events-none grayscale-[0.5]`}`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(oa,{htmlFor:`share-link`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Public Link`}),(0,W.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,W.jsx)(Oi,{id:`share-link`,readOnly:!0,value:x,className:`flex-1 bg-muted/20 font-mono text-xs`}),(0,W.jsx)(H,{onClick:()=>{navigator.clipboard.writeText(x),p(!0),d.success(`Link copied to clipboard!`),setTimeout(()=>p(!1),2e3)},size:`icon`,variant:`outline`,className:`shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors`,disabled:!m&&!o,children:f?(0,W.jsx)(an,{className:`w-4 h-4 text-green-500`}):(0,W.jsx)(La,{className:`w-4 h-4`})})]})]}),!o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(oa,{htmlFor:`access-token`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Access Token (Optional)`}),(0,W.jsxs)(H,{variant:`link`,size:`sm`,onClick:()=>{let e=Math.random().toString(36).substring(2,10).toUpperCase();u(e),d.info(`Secure token generated`)},className:`h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline`,disabled:!m,children:[(0,W.jsx)(Hr,{className:`w-3 h-3 mr-1`}),`Generate`]})]}),(0,W.jsx)(Oi,{id:`access-token`,placeholder:`Enter or generate a token...`,value:l,onChange:e=>u(e.target.value),disabled:!m,className:`font-mono text-xs`})]}),(0,W.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,W.jsx)(oa,{htmlFor:`valid-until`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Duration (Days)`}),(0,W.jsx)(Oi,{id:`valid-until`,type:`number`,placeholder:`Forever`,value:g,onChange:e=>_(e.target.value),disabled:!m,className:`text-xs`})]})]})]})]}),(0,W.jsx)(Xr,{className:`flex flex-col sm:flex-row gap-2 sm:justify-end`,children:o?(0,W.jsx)(H,{type:`button`,onClick:()=>t(!1),className:`cursor-pointer w-full sm:w-auto font-bold`,children:`Close`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{variant:`ghost`,onClick:()=>t(!1),className:`cursor-pointer order-2 sm:order-1 font-semibold`,disabled:v,children:`Cancel`}),(0,W.jsx)(H,{type:`button`,onClick:async()=>{y(!0);try{let e=n===`erd`?`diagrams`:n===`flowchart`?`flowcharts`:n,r=null;if(g&&!isNaN(parseInt(g))){let e=new Date;e.setDate(e.getDate()+parseInt(g)),r=e.toISOString()}if(!(await wi(`/api/${e}/${i}/share`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({is_public:m,share_token:l,expiry_date:r})})).ok)throw Error(`Failed to save settings`);d.success(`Sharing settings updated!`),c&&c(),t(!1)}catch(e){d.error(e.message||`Something went wrong`)}finally{y(!1)}},className:`cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]`,disabled:v,children:v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 mr-2 animate-spin`}),`Saving...`]}):`Save Changes`})]})})]})})}function Afe({open:e,onOpenChange:t}){return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{size:`2xl`,className:`max-h-[82vh]`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Table Calculation Guide`})}),(0,W.jsxs)(Yr,{className:`space-y-5 overflow-y-auto pr-1 text-sm leading-6`,children:[(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`How it works`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Type a formula command in a table cell, then leave the cell. The editor replaces the command with the calculated result. Hover the result cell to see the Excel-style source range used for that value.`})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Vertical formulas`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Vertical formulas calculate numeric values in the same column. They are intended for header or footer rows.`}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted/30 p-3`,children:[(0,W.jsx)(`code`,{children:`=SUM`}),(0,W.jsx)(`code`,{children:`=SUMV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sum values vertically, for example: SUMV(B2:B5).`}),(0,W.jsx)(`code`,{children:`=AVG`}),(0,W.jsx)(`code`,{children:`=AVGV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Average values vertically, for example: AVGV(C2:C5).`}),(0,W.jsx)(`code`,{children:`=MUL`}),(0,W.jsx)(`code`,{children:`=PRODUCT`}),(0,W.jsx)(`code`,{children:`=MULV`}),(0,W.jsx)(`code`,{children:`=PRODUCTV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Multiply values vertically, for example: PRODUCTV(D2:D5).`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Horizontal formulas`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Horizontal formulas calculate numeric values to the left of the formula cell in the same row.`}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted/30 p-3`,children:[(0,W.jsx)(`code`,{children:`=SUMH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sum values horizontally, for example: SUMH(B2:C2).`}),(0,W.jsx)(`code`,{children:`=AVGH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Average values horizontally, for example: AVGH(B2:D2).`}),(0,W.jsx)(`code`,{children:`=MULH`}),(0,W.jsx)(`code`,{children:`=PRODUCTH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Multiply values horizontally, for example: PRODUCTH(B2:C2).`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Examples`}),(0,W.jsx)(`div`,{className:`rounded-md border overflow-hidden`,children:(0,W.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,W.jsx)(`thead`,{className:`bg-muted/50`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Item`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Qty`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Price`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Total`})]})}),(0,W.jsxs)(`tbody`,{children:[(0,W.jsxs)(`tr`,{className:`border-t`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`Hosting`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`12`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`90.000`}),(0,W.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,W.jsx)(`code`,{children:`=MULH`}),` becomes 1.080.000`]})]}),(0,W.jsxs)(`tr`,{className:`border-t`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`Setup`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`100.000`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`50.000`}),(0,W.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,W.jsx)(`code`,{children:`=SUMH`}),` becomes 150.000`]})]})]})]})}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Text cells are skipped. Indonesian number formatting such as 1.080.000 and decimal commas is accepted. Currency symbols are ignored when possible.`})]})]})]})})}var jfe=({onShare:e,onCopyPath:t,onRename:n,onDelete:r,onDuplicate:i,onExportAll:a,onExportMarkdown:o,onCopyMarkdown:s,onImportMarkdown:c,onExportImage:l,isOnline:u,isPublicView:f=!1,isPublic:p=!1,activeFileUid:m,documentType:h,noteContent:g,historyEnabled:_=!1,onOpenHistory:v,onRefresh:y,isRefreshing:b=!1})=>{let[x,S]=(0,U.useState)(!1),C=e=>e.replace(/<[^>]+>/g,``).replace(/&[^;]+;/g,` `).trim(),w=(e=>{let t=e?C(e):``;return t?{words:t.split(/\s+/).filter(Boolean).length,sentences:t.split(/[.!?]+(?:\s|$)/).filter(e=>e.trim().length>0).length,paragraphs:e&&(e.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||t.split(/\n\s*\n/).filter(Boolean).length,characters:t.replace(/\s/g,``).length}:{words:0,sentences:0,paragraphs:0,characters:0}})(g),T=()=>{if(!m){d.error(`Document link not available`);return}let e={erd:`diagram`,notes:`note`,drawings:`drawing`,flowchart:`flowchart`}[h]||h,t=`${window.location.origin}/view/${e}/${m}`;navigator.clipboard.writeText(t),d.success(`Public share link copied to clipboard`)};return(0,W.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(H,{"aria-label":`Actions`,variant:`ghost`,size:`sm`,className:`h-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200`,children:[(0,W.jsx)(`span`,{className:`hidden sm:inline mr-1.5 text-xs font-medium`,children:`Actions`}),(0,W.jsx)(Nr,{className:`h-4 w-4`})]})}),(0,W.jsxs)(en,{align:`end`,className:`w-56`,children:[f?(0,W.jsxs)(Kt,{onClick:T,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Public Link`})]}):(0,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsxs)(Kt,{onClick:t,children:[(0,W.jsx)(La,{className:`text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Path`})]}),e&&(0,W.jsxs)(Kt,{disabled:!u,onClick:e,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(zo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Share`})]}),p&&(0,W.jsxs)(Kt,{disabled:!u,onClick:T,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Public Link`})]}),(0,W.jsx)(tn,{}),n&&(0,W.jsxs)(Kt,{disabled:!u,onClick:n,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Mo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Edit`})]}),y&&(0,W.jsxs)(Kt,{disabled:!u||b,onClick:()=>y(),className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Hr,{className:`h-4 w-4 text-muted-foreground ${b?`animate-spin`:``}`}),(0,W.jsx)(`span`,{children:`Refresh`})]}),v&&(0,W.jsxs)(Kt,{disabled:!_,onClick:()=>v(),className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(oo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Version History`})]}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{disabled:!u,onClick:r,className:`gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer`,children:[(0,W.jsx)(ni,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:`Move to Trash`})]})]})]}),(h===`notes`||h===`drawings`)&&!f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{disabled:!u,onClick:i,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(La,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Duplicate`})]})]}),h===`erd`&&!f&&a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(qt,{children:[(0,W.jsxs)(rn,{className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Export All`})]}),(0,W.jsxs)(Xt,{className:`w-48`,children:[(0,W.jsx)(Kt,{onClick:a,className:`gap-2 cursor-pointer`,children:(0,W.jsx)(`span`,{children:`Export Schemas`})}),(0,W.jsx)(Kt,{onClick:l,className:`gap-2 cursor-pointer`,children:(0,W.jsx)(`span`,{children:`Download SVG`})})]})]})]}),h===`notes`&&!f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>S(!0),children:[(0,W.jsx)(Sa,{className:`text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Calculation Guide`})]}),(0,W.jsx)(Kt,{disabled:!u,onClick:s,className:`gap-2 cursor-pointer flex items-center`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(La,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Markdown`})]})}),c&&(0,W.jsxs)(Kt,{disabled:!u,onClick:c,className:`gap-2 cursor-pointer flex items-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(sr,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Import`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 text-muted-foreground/60`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⌘`}),(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⇧`}),(0,W.jsx)(`span`,{className:`text-[15px] font-mono font-bold mt-0.5`,children:`I`})]})]}),(0,W.jsxs)(Kt,{disabled:!u,onClick:o,className:`gap-2 cursor-pointer flex items-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Export`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 text-muted-foreground/60`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⌘`}),(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⇧`}),(0,W.jsx)(`span`,{className:`text-[15px] font-mono font-bold mt-0.5`,children:`E`})]})]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(qt,{children:[(0,W.jsxs)(rn,{className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Ca,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Text Stats`})]}),(0,W.jsx)(Xt,{className:`w-52 p-1`,children:(0,W.jsxs)(`div`,{className:`px-3 py-1.5 space-y-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Words`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.words.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sentences`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.sentences.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Paragraphs`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.paragraphs.toLocaleString()})]}),(0,W.jsx)(tn,{className:`my-1.5`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Characters`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.characters.toLocaleString()})]})]})})]})]})]})]}),h===`notes`&&(0,W.jsx)(Afe,{open:x,onOpenChange:S})]})},Mfe=U.memo(({featureLabel:e,documentPath:t,sidebarDisabled:n=!1,activeProjectName:r,activeFileName:i,view:a,hasActiveItem:o,syncError:s,isSyncing:c,isRefreshing:l,isLocalSaving:u=!1,hasPendingSyncs:f,activeFileUid:p,activeFileId:m,initialShareSettings:g,onSettingsSaved:_,isPublicView:v=!1,isOnline:y,updatedAt:b,onDelete:x,onRename:S,onSave:C,onExportAll:w,onExportSQL:T,onExportImage:E,onExportMarkdown:D,onCopyMarkdown:O,onImportMarkdown:k,onDuplicate:A,isGuest:j=!1,breadcrumbLabel:M,noteContent:N,historyAvailable:P=!0,canManage:F=!0,onRefresh:I,discussionPanel:L,tabsRef:R})=>{let ee=h(),[te,ne]=U.useState(!1),{setRightPanelMode:re}=An(),ie=!(!P||a!==`erd`&&a!==`flowchart`&&(a!==`notes`&&a!==`drawings`||!a)||!p||j||v||!y||u||c||f),z=U.useCallback(()=>re(`history`),[re]),ae=U.useCallback(e=>{navigator.clipboard.writeText(`${e} > ${r||`No Workspace`} > ${i}`).then(()=>d.success(`File path copied`)).catch(()=>d.error(`Failed to copy file path`))},[i,r]),oe=t??ee.pathname,se=!v&&/^\/(notes|diagrams|drawings|flowcharts|db-client)\/[^/]+$/.test(oe);return(0,W.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 w-full overflow-hidden border-b bg-background/50 backdrop-blur-sm`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 px-2 sm:px-4`,children:[!v&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(nie,{className:`-ml-1 shrink-0`,disabled:n}),(0,W.jsx)(Ep,{orientation:`vertical`,className:`h-4 shrink-0 bg-border/50`})]}),(0,W.jsx)(`div`,{ref:R,className:se?`flex min-w-0 flex-1 items-center`:`hidden`}),!se&&(0,W.jsx)(Kp,{className:`min-w-0 flex items-center`,children:(0,W.jsx)(qp,{className:`min-w-0 flex-nowrap items-center`,children:!v&&(()=>{let n=t??ee.pathname;if(n===`/`)return(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:`Dashboard`})});if(n.startsWith(`/table/`)){let e={notes:`Notes`,erd:`ERD Builder`,"db-client":`DB Client`,drawings:`Drawings`,flowchart:`Flowcharts`},t=n.match(/^\/table\/([^/]+)$/)?.[1],r=t?e[t]||t:`Unknown`;return(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:r})})}return n.startsWith(`/trash`)?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:`Trash`})}):n.startsWith(`/library`)?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:`Library`})}):n.startsWith(`/teams/`)?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Jp,{className:`shrink-0 text-muted-foreground`,children:`Teams`}),(0,W.jsx)(Xp,{}),(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:M||`Team management`})})]}):M?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:M})}):(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-muted-foreground`,children:e})})})()})})]}),!y&&!v&&(0,W.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 px-3 py-1 rounded-full bg-destructive/10 border border-destructive/20 text-destructive animate-in fade-in slide-in-from-top-1 duration-500`,children:[(0,W.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-destructive animate-pulse`}),(0,W.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:`Offline Mode: Navigation Disabled`})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 pr-2 sm:pr-4`,children:!!ee.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[!v&&s&&(0,W.jsxs)(`span`,{role:`status`,title:`Changes saved locally, but cloud sync failed. We'll retry automatically.`,className:`flex shrink-0 items-center gap-1 text-destructive`,children:[(0,W.jsx)(Na,{className:`size-4`}),(0,W.jsx)(`span`,{className:`hidden lg:inline text-xs`,children:`Sync Failed`})]}),!v&&g?.is_public&&(0,W.jsxs)(tm,{variant:`outline`,title:`This document is shared publicly via a secret link.`,className:`shrink-0 gap-1`,children:[(0,W.jsx)(no,{className:`size-3`}),(0,W.jsx)(`span`,{className:`hidden lg:inline`,children:`Public`})]}),L,(0,W.jsx)(jfe,{onCopyPath:v?void 0:()=>ae(new URLSearchParams(ee.search).get(`feature`)===`db-client`?`DB Client`:{notes:`Notes`,erd:`ERD Builder`,flowchart:`Flowcharts`,drawings:`Drawings`}[a]||e),onShare:F?()=>y&&ne(!0):void 0,onDelete:x,onRename:S,onDuplicate:A,onExportAll:w,onExportSQL:T,onExportImage:E,onExportMarkdown:D,onCopyMarkdown:O,onImportMarkdown:k,isOnline:y,isPublicView:v,isPublic:g?.is_public,activeFileUid:p,documentType:a,noteContent:N,historyEnabled:ie,onOpenHistory:j||v?void 0:z,onRefresh:j||v?void 0:I,isRefreshing:l}),p&&m&&y&&(0,W.jsx)(kfe,{isOpen:te,onOpenChange:ne,documentType:a,documentUid:p,documentId:m,documentTitle:i||`Untitled`,isPublicView:v,initialSettings:g,onSettingsSaved:_})]})})]})}),ix=`(max-width: 1023px)`;function Nfe(){let[e,t]=(0,U.useState)(()=>typeof window>`u`||!window.matchMedia(ix).matches);return(0,U.useEffect)(()=>{let e=window.matchMedia(ix),n=e=>t(!e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),{open:e,onOpenChange:t}}var Pfe=`https://api.erdbuilderpro.com/api/feedback`;function Ffe(){return Pfe}function Ife({open:e,onOpenChange:t}){let[n,r]=U.useState(!1),[i,a]=U.useState(``),[o,s]=U.useState(`suggestion`),[c,l]=U.useState(``);return(0,W.jsx)($r,{open:e,onOpenChange:e=>{t(e),e||a(``)},children:(0,W.jsx)(qr,{className:`sm:max-w-106.25 border-border bg-popover/95 backdrop-blur-xl shadow-2xl`,children:(0,W.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),i.trim()){r(!0);try{if((await fetch(Ffe(),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`omit`,body:JSON.stringify({content:i,category:o,email:c,url:window.location.href,browser:navigator.userAgent})})).ok)d.success(`Feedback terkirim! Terima kasih masukannya.`),t(!1),a(``);else throw Error()}catch{d.error(`Gagal mengirim feedback. Coba lagi nanti.`)}finally{r(!1)}}},className:`flex flex-col max-h-[inherit]`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{className:`text-xl font-bold`,children:`Kirim Masukan`}),(0,W.jsx)(Ur,{className:`text-sm text-muted-foreground`,children:`Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!`})]}),(0,W.jsxs)(Yr,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`category`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Tipe Masukan`}),(0,W.jsxs)(Er,{value:o,onValueChange:e=>e&&s(e),children:[(0,W.jsx)(Cr,{id:`category`,className:`bg-white/5 border-white/10 focus:ring-primary/50`,children:(0,W.jsx)(Tr,{placeholder:`Pilih tipe`,children:o===`suggestion`?`Saran Fitur`:o===`bug`?`Lapor Bug`:o===`other`?`Kritik / Lainnya`:o})}),(0,W.jsxs)(Sr,{className:`bg-popover border-border text-popover-foreground`,children:[(0,W.jsx)(xr,{value:`suggestion`,className:`focus:bg-muted`,children:`Saran Fitur`}),(0,W.jsx)(xr,{value:`bug`,className:`focus:bg-muted text-destructive`,children:`Lapor Bug`}),(0,W.jsx)(xr,{value:`other`,className:`focus:bg-muted`,children:`Kritik / Lainnya`})]})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`content`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Pesan`}),(0,W.jsx)(`textarea`,{id:`content`,autoComplete:`off`,className:`flex min-h-35 w-full rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm ring-offset-background placeholder:text-muted-foreground/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-all resize-none`,placeholder:`Tuliskan masukan Anda di sini...`,value:i,onChange:e=>a(e.target.value),maxLength:3e3,required:!0})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`email`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Email (Opsional)`}),(0,W.jsx)(Oi,{id:`email`,type:`email`,autoComplete:`off`,placeholder:`email@contoh.com`,className:`bg-muted/50 border-border focus:ring-primary/50 h-10 px-4`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,W.jsxs)(Xr,{className:`gap-3`,children:[(0,W.jsx)(H,{variant:`ghost`,type:`button`,onClick:()=>t(!1),className:`hover:bg-muted`,children:`Batal`}),(0,W.jsx)(H,{type:`submit`,disabled:n,className:`bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20`,children:n?`Mengirim...`:`Kirim Masukan`})]})]})})})}var Lfe=({isOpen:e,onOpenChange:t,selectedEntity:n,deleteEntity:r,setSelectedNodeId:i})=>(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ri,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Delete Table`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Are you sure you want to delete the table `,(0,W.jsx)(`strong`,{children:n?.name}),`? This action cannot be undone.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:()=>{n&&(r(n.id),i(null),t(!1))},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})}),Rfe=({isOpen:e,onOpenChange:t,view:n,duplicateName:r,setDuplicateName:i,executeDuplicate:a,isRefreshing:o})=>(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Duplicate Document`}),(0,W.jsxs)(Ur,{children:[`Create a copy of this `,n===`erd`?`diagram`:n===`notes`?`note`:n===`drawings`?`drawing`:`flowchart`,`.`]})]}),(0,W.jsx)(Yr,{children:(0,W.jsx)(`div`,{className:`space-y-4`,children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`duplicate-input`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New Name`}),(0,W.jsx)(Oi,{id:`duplicate-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r.trim()&&a()},autoFocus:!0})]})})}),(0,W.jsxs)(Xr,{className:`gap-2 sm:gap-0`,children:[(0,W.jsx)(H,{variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(H,{onClick:a,disabled:!r.trim()||o,children:o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`mr-2 h-4 w-4 animate-spin`}),`Duplicating...`]}):`Duplicate`})]})]})}),zfe=r(he(),1);function ax(){return ax=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ax.apply(null,arguments)}function Bfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ox=[],sx=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?sx:ox).push(n+=e[t])})();function Vfe(e){if(e<768)return!1;for(let t=0,n=ox.length;;){let r=t+n>>1;if(e<ox[r])n=r;else if(e>=sx[r])t=r+1;else return!0;if(t==n)return!1}}function cx(e){return e>=127462&&e<=127487}var lx=8205;function Hfe(e,t,n=!0,r=!0){return(n?ux:Ufe)(e,t,r)}function ux(e,t,n){if(t==e.length)return t;t&&fx(e.charCodeAt(t))&&px(e.charCodeAt(t-1))&&t--;let r=dx(e,t);for(t+=mx(r);t<e.length;){let i=dx(e,t);if(r==lx||i==lx||n&&Vfe(i))t+=mx(i),r=i;else if(cx(i)){let n=0,r=t-2;for(;r>=0&&cx(dx(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Ufe(e,t,n){for(;t>0;){let r=ux(e,t-2,n);if(r<t)return r;t--}return 0}function dx(e,t){let n=e.charCodeAt(t);if(!px(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return fx(r)?(n-55296<<10)+(r-56320)+65536:n}function fx(e){return e>=56320&&e<57344}function px(e){return e>=55296&&e<56320}function mx(e){return e<65536?1:2}var hx=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Cx(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),_x.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Cx(this,e,t);let n=[];return this.decompose(e,t,n,0),_x.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new bx(this),i=new bx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new bx(this,e)}iterRange(e,t=this.length){return new xx(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Sx(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new gx(t):_x.from(gx.split(t,[]))}},gx=class e extends hx{constructor(e,t=Wfe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Gfe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(yx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=vx(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Cx(this,t,n);let i=vx(this.text,vx(r.text,yx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):_x.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
48
|
+
`);c=r.pop()||``;for(let e of r)if(e.trim())try{let t=JSON.parse(e);if(t.type===`progress`)y({current:Number(t.current)||0,total:Number(t.total)||5,phase:String(t.phase||``)});else if(t.type===`complete`){await ea.clearAllPendingSyncs(),o(`done`),d.success(t.message||`Database restored successfully!`),n.current=null;return}else if(t.type===`error`)throw Error(t.error||`Restore failed on server.`)}catch(e){if(e instanceof SyntaxError)continue;throw e}}throw Error(`Stream ended unexpectedly. Restore may be incomplete.`)}catch(e){if(e.name===`AbortError`)return;o(`error`),_(e.message||`Restore failed`),d.error(`Restore failed: `+(e.message||`Unknown error`))}n.current=null}},[]),w=(0,U.useCallback)(()=>{t.current&&=(clearTimeout(t.current),null),r.current=null,i.current=null,o(`idle`),c(null),h(null),u(null),p(null),_(``),y({current:0,total:1,phase:``})},[]),T=(0,U.useCallback)(()=>{r.current=null,i.current=null,u(null),p(null),o(`idle`),c(null)},[]),E=(0,U.useCallback)(()=>{t.current&&=(clearTimeout(t.current),null),window.location.reload()},[]),D=(0,U.useCallback)(()=>{n.current&&=(n.current.abort(),null),r.current=null,i.current=null,o(`idle`),c(null),y({current:0,total:1,phase:``})},[]),O=(0,U.useCallback)(()=>{s===`db`?C():S()},[s,C,S]),k=Math.min(Math.round(v.current/v.total*100),100),{accept:A,acceptLabel:j}=b===`desktop`?{accept:`.json,.db,.sqlite,.sqlite3`,acceptLabel:`.json (data) or .db / .sqlite (database restore)`}:{accept:`.json`,acceptLabel:`.json format from Guest Mode export`};if(a===`done`)return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl`,children:[(0,W.jsx)(Or,{className:`size-6 text-emerald-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:s===`db`?`Database Restored`:`Import Completed`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:s===`db`?`The database file has been restored. The app will reload to apply the changes.`:`Data has been added to your workspace.`})]})]}),m&&(0,W.jsx)(Ay,{summary:m}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:E,children:[(0,W.jsx)(Hr,{className:`size-3.5 mr-1.5`}),`Reload App Now`]}),(0,W.jsx)(H,{variant:`outline`,size:`sm`,onClick:w,children:`Import Another File`})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`App will reload automatically in a few seconds…`})]});if(a===`preview`){if(s===`db`&&f)return(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Ka,{className:`size-5 text-blue-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Restore Database File`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`This will `,(0,W.jsx)(`strong`,{className:`text-amber-500`,children:`replace`}),` your current local database with the selected file. A safety backup will be created automatically before the restore.`]}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Use this if you reinstalled the app and want to restore from a previous`,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px] mx-0.5`,children:`.db`}),` file that you saved manually.`]})]})]}),(0,W.jsxs)(`div`,{className:`bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`File`}),(0,W.jsx)(`span`,{className:`font-medium`,children:f.fileName})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Size`}),(0,W.jsx)(`span`,{className:`font-medium`,children:f.fileSize})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:O,children:[(0,W.jsx)(rr,{className:`size-3.5 mr-1.5`}),`Restore Database`]}),(0,W.jsxs)(H,{variant:`outline`,size:`sm`,onClick:T,children:[(0,W.jsx)(Gr,{className:`size-3.5 mr-1.5`}),`Cancel`]})]})]});if(s===`json`&&l){let e=Object.values(l).reduce((e,t)=>e+(t||0),0);return(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Wa,{className:`size-5 text-blue-500 shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Import Preview`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e,` items found in the export file. Click `,(0,W.jsx)(`strong`,{children:`Submit`}),` to import the data.`]})]})]}),(0,W.jsx)(Ay,{summary:l}),(0,W.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,W.jsxs)(H,{variant:`default`,size:`sm`,onClick:O,children:[(0,W.jsx)(rr,{className:`size-3.5 mr-1.5`}),`Submit`]}),(0,W.jsxs)(H,{variant:`outline`,size:`sm`,onClick:T,children:[(0,W.jsx)(Gr,{className:`size-3.5 mr-1.5`}),`Cancel`]})]})]})}}return a===`error`?(0,W.jsx)(`div`,{className:`space-y-5`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg`,children:[(0,W.jsx)(tr,{className:`size-4 text-red-500 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{className:`text-xs text-red-600`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:s===`db`?`Database restore failed`:`Import failed`}),(0,W.jsx)(`p`,{className:`mt-0.5`,children:g}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,className:`mt-2 h-auto py-1 text-xs`,onClick:w,children:`Try again`})]})]})}):(0,W.jsxs)(`div`,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl`,children:[(0,W.jsx)(Br,{className:`size-5 text-blue-500 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{className:`text-sm space-y-1`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Import Data`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Upload a `,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px]`,children:`.json`}),` file exported from Guest Mode. All data will be `,(0,W.jsx)(`strong`,{children:`added`}),` to your workspace — existing items with the same ID will be skipped. New projects will be created for any project‑scoped items.`]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects.`}),b===`desktop`&&(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40`,children:[(0,W.jsx)(`strong`,{className:`text-amber-500`,children:`Desktop only:`}),` You can also restore a`,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px] mx-0.5`,children:`.db`}),` database file — useful after reinstalling the app to recover data from a manually saved copy. A safety backup is created automatically.`]})]})]}),(0,W.jsxs)(`div`,{onClick:()=>{a!==`importing`&&e.current?.click()},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&a!==`importing`&&e.current?.click()},role:`button`,tabIndex:0,className:`border-2 border-dashed border-border/50 hover:border-primary/40 rounded-xl p-8 text-center cursor-pointer transition-colors`,children:[(0,W.jsx)(`input`,{ref:e,type:`file`,accept:A,className:`hidden`,onChange:x}),a===`importing`?(0,W.jsxs)(`div`,{className:`w-full max-w-sm mx-auto space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground truncate mr-2`,children:v.phase||`Importing…`}),(0,W.jsxs)(`span`,{className:`text-muted-foreground shrink-0 tabular-nums`,children:[k,`%`]})]}),(0,W.jsx)(`div`,{className:`w-full h-2 bg-muted/50 rounded-full overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300 ease-out`,style:{width:`${k}%`}})}),(0,W.jsxs)(`p`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[v.current.toLocaleString(),` / `,v.total.toLocaleString(),` items`]})]}),(0,W.jsx)(H,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),D()},className:`text-xs`,children:`Cancel`})]}):(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`p-3 bg-muted/30 rounded-full`,children:(0,W.jsx)(sr,{className:`size-6 text-muted-foreground`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:`Click to select a file`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:j})]})]})]})]})}function Ay({summary:e}){return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:[(0,W.jsx)(jy,{label:`Projects`,value:e.projects}),(0,W.jsx)(jy,{label:`Notes`,value:e.notes}),(0,W.jsx)(jy,{label:`ERD Diagrams`,value:e.diagrams}),(0,W.jsx)(jy,{label:`Tables (Entities)`,value:e.entities}),(0,W.jsx)(jy,{label:`Columns`,value:e.columns}),(0,W.jsx)(jy,{label:`Relationships`,value:e.relationships}),(0,W.jsx)(jy,{label:`Flowcharts`,value:e.flowcharts}),(0,W.jsx)(jy,{label:`Drawings`,value:e.drawings}),(0,W.jsx)(jy,{label:`AI Sessions`,value:e.ai_chat_sessions})]}),e.ai_chat_messages>0&&(0,W.jsxs)(`p`,{className:`text-[11px] text-muted-foreground px-0.5`,children:[`Includes `,e.ai_chat_messages.toLocaleString(),` AI chat messages.`]}),e.skipped_existing>0&&(0,W.jsxs)(`p`,{className:`text-[11px] text-amber-500 px-0.5`,children:[e.skipped_existing.toLocaleString(),` item(s) already existed and were skipped.`]})]})}function jy({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`bg-muted/20 border border-border/40 rounded-lg p-3 text-center`,children:[(0,W.jsx)(`p`,{className:`text-lg font-bold`,children:t.toLocaleString()}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:e})]})}function Nue(){return sessionStorage.getItem(`auth_mode`)===`guest`}function Pue(e){if(!e||typeof e!=`string`)return null;try{let t=JSON.parse(e);return t?.dbml_source??t?.dbmlSource??null}catch{return null}}function Fue(e){let t=e.dbml_source??e.dbmlSource??Pue(e.data);return{...e,dbml_source:t??null,dbmlSource:t??null}}async function My(e){try{return(await ea.getAllResources(e)||[]).filter(e=>!e.is_deleted)}catch{return[]}}function Iue(e){return!e.messages||!Array.isArray(e.messages)?[]:e.messages.map(e=>({id:e.id||e.uid,role:e.role,content:e.content,selection_text:e.selection_text||null,created_at:e.created_at||null}))}async function Lue(){if(!Nue()){let e=await wi(`/api/guest/export`);if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to export data`)}return e.json()}let[e,t,n,r,i,a]=await Promise.all([My(`project`),My(`notes`),My(`erd`),My(`flowchart`),My(`drawings`),My(`ai_chat_session`)]),o=a.map(e=>({uid:e.uid||e.id,title:e.title||`Untitled`,entity_type:e.entity_type||null,entity_uid:e.entity_uid||null,project_id:e.project_id??null,created_at:e.created_at||null,updated_at:e.updated_at||null,messages:Iue(e)})),s={projects:e.length,notes:t.length,diagrams:n.length,flowcharts:r.length,drawings:i.length,ai_chat_sessions:o.length};return{version:`1.0`,exported_at:new Date().toISOString(),application:`ERD Builder Pro`,total_items:s,data:{projects:e,notes:t,diagrams:n.map(Fue),flowcharts:r,drawings:i,ai_chat_sessions:o}}}function Rue(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`erd-data-export-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}async function Ny(){Rue(await Lue())}function zue(){let[e,t]=(0,U.useState)(!1);return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Export Data`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Download projects, notes, ERDs, DBML, flowcharts, drawings, and AI chats as JSON.`})]}),(0,W.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-muted/10 p-5 max-w-xl`,children:(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:`JSON Backup`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:`Use this file with Import Data to restore or migrate your workspace data.`})]}),(0,W.jsxs)(H,{onClick:async()=>{t(!0);try{await Ny(),d.success(`Data exported successfully`)}catch(e){d.error(`Export failed: `+(e.message||`Unknown error`))}finally{t(!1)}},disabled:e,className:`shrink-0`,children:[e?(0,W.jsx)(vo,{className:`size-3.5 mr-2 animate-spin`}):(0,W.jsx)(Yn,{className:`size-3.5 mr-2`}),e?`Exporting...`:`Export JSON`]})]})})]})}function Bue(){if(typeof window>`u`||!window.__TAURI__&&!window.__TAURI_INTERNALS__&&window.ERD_INSTALL_MODE!==`cli`)return(0,W.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,W.jsx)(is,{className:`border-border/50 bg-background/50 backdrop-blur-sm`,children:(0,W.jsxs)(ls,{className:`py-12 text-center`,children:[(0,W.jsx)(Br,{className:`w-8 h-8 mx-auto text-muted-foreground/40`}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-4 text-sm`,children:`Storage configuration is only available in the desktop app or CLI mode.`})]})})});let[e,t]=(0,U.useState)({type:`r2`,accountId:``,endpoint:``,region:`auto`,accessKeyId:``,secretAccessKey:``,bucketName:``,publicUrl:``}),[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(`none`),[o,s]=(0,U.useState)(!0),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)({type:``,message:``}),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),v=(0,U.useCallback)(async()=>{s(!0);try{let e=await wi(`/api/storage/config`,{credentials:`include`});if(e.ok){let n=await e.json();a(n.source),n.config&&(r(n.config),t({type:n.config.type||`r2`,accountId:n.config.accountId||``,endpoint:n.config.endpoint||``,region:n.config.region||`auto`,accessKeyId:n.config.accessKeyId||``,secretAccessKey:n.config.secretAccessKey||``,bucketName:n.config.bucketName||``,publicUrl:n.config.publicUrl||``}))}}catch(e){console.error(`Failed to load storage config:`,e)}finally{s(!1)}},[]);(0,U.useEffect)(()=>{v()},[v]);let y=async()=>{l(!0),p({type:``,message:``});try{let t=await wi(`/api/storage/config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),credentials:`include`});if(t.ok)p({type:`success`,message:`Storage configuration saved successfully.`}),r({...e}),await v();else{let e=await t.json();p({type:`error`,message:e.error||`Failed to save configuration`})}}catch(e){p({type:`error`,message:e.message||`Network error`})}finally{l(!1)}},b=async()=>{d(!0),p({type:``,message:``});try{let t=await wi(`/api/storage/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),credentials:`include`});if(t.ok)p({type:`success`,message:`Successfully connected to storage.`});else{let e=await t.json();p({type:`error`,message:e.error||`Connection failed`})}}catch(e){p({type:`error`,message:e.message||`Network error`})}finally{d(!1)}},x=(e,n)=>{t(t=>({...t,[e]:n})),p({type:``,message:``})};return o?(0,W.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,W.jsx)(is,{className:`border-border/50 bg-background/50 backdrop-blur-sm`,children:(0,W.jsxs)(ls,{className:`py-12 text-center`,children:[(0,W.jsx)(Hr,{className:`w-6 h-6 animate-spin mx-auto text-muted-foreground`}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-4 text-sm`,children:`Loading storage configuration...`})]})})}):(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsxs)(is,{className:`border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg`,children:[(0,W.jsxs)(as,{className:`border-b border-border/30 pb-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(Pa,{className:`w-6 h-6 text-blue-500`}),(0,W.jsx)(os,{className:`text-xl md:text-2xl font-bold`,children:`Storage Configuration`})]}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Configure Cloudflare R2 or S3-compatible storage for image uploads in Notes and Drawings.`})]}),(0,W.jsxs)(ls,{className:`space-y-6 p-4 md:p-6`,children:[i===`env`&&(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20`,children:[(0,W.jsx)(Dr,{className:`w-4 h-4 text-blue-500 shrink-0`}),(0,W.jsx)(`p`,{className:`text-xs text-blue-600 dark:text-blue-400`,children:`Pre-filled from environment variables. Save to override with custom settings.`})]}),f.type&&(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-4 rounded-lg border ${f.type===`success`?`bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400`:`bg-red-500/10 border-red-500/20 text-red-600 dark:text-red-400`}`,children:[f.type===`success`?(0,W.jsx)(wn,{className:`w-5 h-5 shrink-0`}):(0,W.jsx)(Aa,{className:`w-5 h-5 shrink-0`}),(0,W.jsx)(`p`,{className:`text-sm`,children:f.message})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(Br,{className:`size-3`}),`Storage Provider`]}),(0,W.jsxs)(Er,{value:e.type,onValueChange:(e,t)=>e&&x(`type`,e),children:[(0,W.jsx)(Cr,{className:`h-9 text-sm`,children:(0,W.jsx)(Tr,{children:e.type===`r2`?(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Pa,{className:`w-4 h-4`}),`Cloudflare R2`]}):(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Br,{className:`w-4 h-4`}),`S3-Compatible`]})})}),(0,W.jsxs)(Sr,{children:[(0,W.jsx)(xr,{value:`r2`,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Pa,{className:`w-4 h-4`}),`Cloudflare R2`]})}),(0,W.jsx)(xr,{value:`s3-compatible`,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Br,{className:`w-4 h-4`}),`S3-Compatible`]})})]})]})]}),e.type===`r2`&&(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Account ID`]}),(0,W.jsx)(Oi,{placeholder:`Your Cloudflare R2 Account ID`,value:e.accountId||``,onChange:e=>x(`accountId`,e.target.value),className:`h-9 text-sm font-mono`}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70 mt-1 px-1`,children:`Found in your Cloudflare dashboard under R2 → Account ID.`})]}),e.type===`s3-compatible`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Endpoint URL`]}),(0,W.jsx)(Oi,{placeholder:`https://s3.us-east-1.amazonaws.com`,value:e.endpoint||``,onChange:e=>x(`endpoint`,e.target.value),className:`h-9 text-sm font-mono`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(no,{className:`size-3`}),`Region`]}),(0,W.jsx)(Oi,{placeholder:`us-east-1`,value:e.region||``,onChange:e=>x(`region`,e.target.value),className:`h-9 text-sm font-mono`})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(co,{className:`size-3`}),`Access Key ID`]}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{type:g?`text`:`password`,placeholder:`Your access key ID`,value:e.accessKeyId,onChange:e=>x(`accessKeyId`,e.target.value),className:`h-9 text-sm font-mono pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(!g),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:g?(0,W.jsx)(Lr,{className:`w-4 h-4`}):(0,W.jsx)(Ba,{className:`w-4 h-4`})})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(co,{className:`size-3`}),`Secret Access Key`]}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{type:m?`text`:`password`,placeholder:`Your secret access key`,value:e.secretAccessKey,onChange:e=>x(`secretAccessKey`,e.target.value),className:`h-9 text-sm font-mono pr-10`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:m?(0,W.jsx)(Lr,{className:`w-4 h-4`}):(0,W.jsx)(Ba,{className:`w-4 h-4`})})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(Za,{className:`size-3`}),`Bucket Name`]}),(0,W.jsx)(Oi,{placeholder:`your-bucket-name`,value:e.bucketName,onChange:e=>x(`bucketName`,e.target.value),className:`h-9 text-sm font-mono`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsxs)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1`,children:[(0,W.jsx)(go,{className:`size-3`}),`Public URL (optional)`]}),(0,W.jsx)(Oi,{placeholder:`https://cdn.yourdomain.com`,value:e.publicUrl||``,onChange:e=>x(`publicUrl`,e.target.value),className:`h-9 text-sm font-mono`}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70 mt-1 px-1`,children:e.type===`s3-compatible`?`Optional. If set, overrides the auto-constructed endpoint URL. Useful for custom CDN/domain. If empty, URL is built from Endpoint + Bucket.`:`Optional public URL prefix for direct image access (e.g., custom domain or CDN). If empty, R2 public URL is auto-constructed.`})]})]}),(0,W.jsxs)(us,{className:`bg-muted/5 border-t border-border/30 p-4 md:px-6 md:py-4 flex flex-col sm:flex-row gap-3 sm:justify-end`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:b,disabled:u||!e.bucketName||!e.accessKeyId||!e.secretAccessKey,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border text-sm font-medium whitespace-nowrap transition-colors h-10 px-4 bg-background hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none`,children:u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 shrink-0 animate-spin pointer-events-none`}),(0,W.jsx)(`span`,{className:`pointer-events-none`,children:`Testing...`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 shrink-0 pointer-events-none`}),(0,W.jsx)(`span`,{className:`pointer-events-none`,children:`Test Connection`})]})}),(0,W.jsxs)(H,{onClick:y,className:`gap-2 px-6`,disabled:c,children:[c?(0,W.jsx)(Hr,{className:`w-4 h-4 animate-spin`}):(0,W.jsx)(mr,{className:`w-4 h-4`}),c?`Saving...`:`Save Configuration`]})]})]})})}var Py=[{title:`General`,rows:[[`Sync pending changes`,`⌘ S`,`Ctrl S`],[`Focus file search`,`⌘ K`,`Ctrl K`],[`Open Settings (desktop)`,`⌘ ,`,`Ctrl ,`]]},{title:`Notes`,rows:[[`Bold`,`⌘ B`,`Ctrl B`],[`Italic`,`⌘ I`,`Ctrl I`],[`Underline`,`⌘ U`,`Ctrl U`],[`Strikethrough`,`⌘ ⇧ S`,`Ctrl Shift S`],[`Inline code`,`⌘ E`,`Ctrl E`],[`Heading 1–4`,`⌘ ⌥ 1–4`,`Ctrl Alt 1–4`],[`Bulleted list`,`⌘ ⇧ 8`,`Ctrl Shift 8`],[`Numbered list`,`⌘ ⇧ 7`,`Ctrl Shift 7`],[`Task list`,`⌘ ⇧ 9`,`Ctrl Shift 9`],[`Blockquote`,`⌘ ⇧ B`,`Ctrl Shift B`],[`Code block`,`⌘ ⌥ C`,`Ctrl Alt C`],[`Insert table`,`⌘ ⌥ T`,`Ctrl Alt T`],[`Toggle badge`,`⌘ ⌥ B`,`Ctrl Alt B`],[`Align left / center / right`,`⌘ ⇧ L / C / R`,`Ctrl Shift L / C / R`],[`Undo / redo`,`⌘ Z / ⌘ Y`,`Ctrl Z / Ctrl Y`],[`Export note`,`⌘ ⇧ E`,`Ctrl Shift E`],[`Import note`,`⌘ ⇧ I`,`Ctrl Shift I`]]},{title:`ERD Builder`,rows:[[`Jump to Table`,`⌘ ⇧ F`,`Ctrl Shift F`],[`Undo / redo`,`⌘ Z / ⌘ ⇧ Z`,`Ctrl Z / Ctrl Y`],[`Add or remove from selection`,`⌘ Click`,`Ctrl Click`]]},{title:`Flowchart`,rows:[[`Delete selected node or edge`,`Delete / Backspace`,`Delete / Backspace`]]}],Vue=[[`Focus table search`,`⌘ P`,`Ctrl P`],[`Toggle filters`,`⌘ F`,`Ctrl F`],[`Refresh records`,`⌘ R`,`Ctrl R`],[`Select all records`,`⌘ A`,`Ctrl A`],[`Add or remove a record from selection`,`⌘ Click`,`Ctrl Click`],[`Save record or structure`,`⌘ S`,`Ctrl S`],[`Run SQL query`,`⌘ Enter`,`Ctrl Enter`],[`Format SQL query`,`⌘ I`,`Ctrl I`],[`Cancel inline changes`,`Esc`,`Esc`]];function Hue(){let e=typeof navigator<`u`&&/mac|iphone|ipad|ipod/i.test(navigator.platform),t=typeof window<`u`&&(window.__TAURI__||window.__TAURI_INTERNALS__||window.ERD_INSTALL_MODE===`cli`)?[...Py,{title:`DB Client`,rows:Vue}]:Py;return(0,W.jsxs)(`div`,{className:`p-4 md:p-6 space-y-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Keymap`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Keyboard shortcuts available in ERD Builder Pro.`})]}),t.map(({title:t,rows:n})=>(0,W.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,W.jsx)(`h3`,{className:`border-b border-border bg-muted/40 px-4 py-2.5 text-sm font-medium`,children:t}),(0,W.jsx)(`div`,{className:`divide-y divide-border`,children:n.map(([t,n,r])=>(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-4 py-2.5 text-sm`,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`kbd`,{className:`rounded border bg-muted px-1.5 py-0.5 font-mono text-xs text-muted-foreground`,children:e?n:r})]},t))})]},t)),(0,W.jsxs)(`section`,{className:`rounded-lg border border-border p-4 text-sm`,children:[(0,W.jsx)(`h3`,{className:`font-medium`,children:`Drawings`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Drawings use Excalidraw’s built-in keymap. Open Help from its menu to view the shortcuts available for the current editor version.`})]})]})}var Fy=e=>JSON.stringify(e,null,2);function Iy(e,t){return/[\s"']/.test(e)?t?`"${e.replace(/"/g,`\\"`)}"`:`'${e.replace(/'/g,`'\\''`)}'`:e}function Uue(e){let t={command:e.command,...e.args.length?{args:e.args}:{}},n=e.args.map(t=>Iy(t,e.platform===`win32`)).join(` `),r=[`codex`,`mcp`,`add`,`erdbpro`,`--`,e.command,...e.args].map(t=>Iy(t,e.platform===`win32`)).join(` `);return[{id:`jetbrains`,label:`JetBrains AI`,description:`Paste into the MCP server JSON configuration.`,language:`json`,content:Fy({mcpServers:{erdbpro:t}})},{id:`vscode`,label:`VS Code`,description:`Save as .vscode/mcp.json or paste into the MCP configuration.`,language:`json`,content:Fy({servers:{erdbpro:{type:`stdio`,...t}}})},{id:`codex`,label:`Codex`,description:`Run once in a terminal to register the local MCP server.`,language:`bash`,content:r},{id:`hermes`,label:`Hermes Agent`,description:`Enter these values in Add MCP Server. Leave Environment empty.`,language:`text`,content:`Name: erdbpro\nTransport: stdio\nCommand: ${e.command}\nArgs: ${n||`(leave empty)`}\nEnvironment: (leave empty)`},{id:`generic`,label:`Generic MCP (STDIO)`,description:`Use for clients that accept a standard STDIO command definition.`,language:`json`,content:Fy({transport:`stdio`,...t})}]}function Wue(){let[e,t]=U.useState(null),[n,r]=U.useState(``),[i,a]=U.useState(``),[o,s]=U.useState(`jetbrains`);U.useEffect(()=>{let e=!1;return wi(`/api/mcp/client-config`).then(async n=>{let r=await n.json();if(!n.ok)throw Error(r.error||`Failed to load MCP configuration.`);e||t(r)}).catch(t=>{e||r(t instanceof Error?t.message:`Failed to load MCP configuration.`)}),()=>{e=!0}},[]);let c=async(e,t)=>{await navigator.clipboard.writeText(t),a(e),d.success(`MCP configuration copied`),window.setTimeout(()=>a(``),1500)};if(n)return(0,W.jsxs)(`div`,{className:`p-6`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`MCP Integration`}),(0,W.jsx)(`p`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive`,children:n})]});if(!e)return(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,W.jsx)(vo,{className:`size-5 animate-spin text-muted-foreground`})});if(e.mode===`web`)return(0,W.jsxs)(`div`,{className:`space-y-5 p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,W.jsx)(Ra,{className:`size-5`}),`Public MCP Integration`]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Detected mode: Web App. This page automatically shows the matching MCP connection for the current installation mode.`})]}),e.configured&&e.url?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Public MCP URL (Streamable HTTP)`}),(0,W.jsxs)(H,{variant:`ghost`,size:`xs`,onClick:()=>void c(`public-url`,e.url),children:[i===`public-url`?(0,W.jsx)(an,{}):(0,W.jsx)(La,{}),i===`public-url`?`Copied`:`Copy`]})]}),(0,W.jsx)(`code`,{className:`mt-1 block break-all text-xs`,children:e.url})]}),(0,W.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground`,children:`Add this URL as a custom connector in Claude Web or Claude Desktop. Authentication uses OAuth and grants user-scoped, read-only access.`})]}):(0,W.jsx)(`p`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-700 dark:text-amber-300`,children:`Public MCP is not configured. Set MCP_PUBLIC_URL on the Web App server and restart it to publish the connection URL.`})]});let l=Uue(e),u=l.find(e=>e.id===o)||l[0];return(0,W.jsxs)(`div`,{className:`space-y-5 p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,W.jsx)(ir,{className:`size-5`}),`Connect AI Clients`]}),(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Detected mode: `,e.mode===`cli`?`CLI`:`Desktop App`,`. Use ERD Builder Pro as a local MCP Server (STDIO) with an external AI client. The launcher runs headlessly without opening another app window.`]})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:`MCP Server (STDIO) launcher`}),(0,W.jsx)(`code`,{className:`mt-1 block break-all text-xs`,children:e.command})]}),(0,W.jsx)(`div`,{role:`tablist`,"aria-label":`MCP client`,className:`flex w-full flex-wrap gap-1 rounded-lg border bg-muted p-1`,children:l.map(e=>{let t=e.id===u.id;return(0,W.jsx)(H,{type:`button`,size:`sm`,variant:t?`default`:`ghost`,role:`tab`,"aria-selected":t,onClick:()=>s(e.id),className:`flex-1 text-xs`,children:e.label},e.id)})}),(0,W.jsxs)(`div`,{role:`tabpanel`,"aria-label":u.label,className:`space-y-3 pt-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u.description}),(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted/40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:u.language}),(0,W.jsxs)(H,{variant:`ghost`,size:`xs`,onClick:()=>void c(u.id,u.content),children:[i===u.id?(0,W.jsx)(an,{}):(0,W.jsx)(La,{}),i===u.id?`Copied`:`Copy`]})]}),(0,W.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre p-4 text-xs leading-relaxed`,children:(0,W.jsx)(`code`,{children:u.content})})]})]})]})}function Ly(e){return{active:e.active===!0,planCode:e.planCode??e.plan_code,expiresAt:e.expiresAt??e.expires_at,lastCheckedAt:e.lastCheckedAt??e.last_checked_at,maxTeams:e.maxTeams??e.max_teams,maxMembers:e.maxMembers??e.max_members,usage:{teamCount:e.usage?.teamCount??e.usage?.team_count??0,memberCount:e.usage?.memberCount??e.usage?.member_count??0}}}function Ry(e,t){return{message:e.error||t,...e.code?{code:e.code}:{}}}async function zy(e){return e.json().catch(()=>({}))}function Gue(){let[e,t]=(0,U.useState)(null),[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),h=(0,U.useCallback)(async()=>{try{let e=await wi(`/api/license/status`),n=await zy(e);if(!e.ok){s(Ry(n,`Failed to load license status.`));return}t(Ly(n))}catch(e){s({message:e instanceof Error?e.message:`Failed to load license status.`})}},[]);(0,U.useEffect)(()=>{h()},[h]);let g=async()=>{s(null),f(!0);try{let e={license_key:n.trim()},o=i.trim();o&&(e.activation_grant=o);let c=await wi(`/api/license/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),l=await zy(c);if(!c.ok){s(Ry(l,`License activation failed.`));return}r(``),a(``),t(Ly(l)),d.success(`License activated`)}catch(e){s({message:e instanceof Error?e.message:`License activation failed.`})}finally{f(!1)}},_=async()=>{s(null),l(!0);try{let e=await wi(`/api/license/check`,{method:`POST`}),n=await zy(e);if(!e.ok){s(Ry(n,`License check failed.`));return}t(Ly(n)),d.success(`License checked successfully`)}catch(e){s({message:e instanceof Error?e.message:`License check failed.`})}finally{l(!1)}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`space-y-6 p-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Application License`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This instance license controls commercial Team capacity. Personal use does not require activation.`})]}),e&&(0,W.jsxs)(`div`,{className:`rounded-lg border p-4 text-sm`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:e.active?`Active: ${e.planCode}`:`No commercial license is active`}),(0,W.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Active Teams: `,e.usage.teamCount,` /`,` `,e.maxTeams??(e.active?`No limit`:`N/A`),` · Active members: `,e.usage.memberCount,` /`,` `,e.maxMembers??(e.active?`No limit`:`N/A`)]}),e.active&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(H,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>void _(),disabled:c||u,children:[c?(0,W.jsx)(Hr,{className:`animate-spin`}):(0,W.jsx)(Hr,{}),`Check license`]}),e.lastCheckedAt&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Last checked: `,new Date(e.lastCheckedAt).toLocaleString()]})]})]}),(0,W.jsxs)(Rr,{className:`gap-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`instance-license-key`,children:`Instance license key`}),(0,W.jsx)(Oi,{id:`instance-license-key`,type:`password`,autoComplete:`off`,disabled:u,value:n,onChange:e=>{r(e.target.value),s(null)}})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`instance-activation-grant`,children:`Activation grant`}),(0,W.jsx)(Oi,{id:`instance-activation-grant`,type:`password`,autoComplete:`off`,disabled:u,"aria-describedby":`activation-grant-description`,value:i,onChange:e=>{a(e.target.value),s(null)}}),(0,W.jsx)(Ir,{id:`activation-grant-description`,children:`Only needed after resetting a deployment binding. Enter the one-time grant from SaaS with the same license key.`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(H,{onClick:()=>m(!0),disabled:!n.trim()||c||u,children:[(0,W.jsx)(co,{}),u?`Activating...`:`Activate license`]}),o&&(0,W.jsxs)(`div`,{id:`license-activation-error`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`text-sm text-destructive`,children:o.message}),o.code&&(0,W.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`Code: `,o.code]}),o.code===`LICENSE_ALREADY_BOUND`&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Reset the old deployment binding in SaaS, then enter its activation grant above.`})]})]})]}),(0,W.jsx)(kr,{isOpen:p,title:`Activate license?`,message:`This will activate the license for this Self-host instance and update its Team and member capacity.`,confirmText:`Activate license`,cancelText:`Cancel`,variant:`info`,onCancel:()=>m(!1),onConfirm:()=>{m(!1),g()}})]})}function Kue(){let{isSettingsOpen:e,setIsSettingsOpen:t,settingsTab:n,setSettingsTab:r}=ia(),i=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),a=i||typeof window<`u`&&window.ERD_INSTALL_MODE===`cli`,[o,s]=U.useState(`configuration`);U.useEffect(()=>{if(!i)return;let e,n=!1;return(async()=>{let{listen:i}=await bi(async()=>{let{listen:e}=await import(`./event-DtFyPu7u.js`);return{listen:e}},__vite__mapDeps([0,1]));n||(e=await i(`menu-settings`,()=>{r(`account`),t(!0)}))})(),()=>{n=!0,e?.()}},[i,t,r]);let{isGuest:c,user:l}=ta(),u=!!l?.isSso,d=!u&&(a||!!(l?.isSuperAdmin||l?.is_super_admin)),f=d&&!a,{providers:p,configs:m,isTesting:h,isSaving:g,handleSaveConfig:_,handleTestConnection:v,handleInitializeProviders:y,updateProviderLocal:b,updateConfigLocal:x}=lie(d),{models:S,newModel:C,editingModelId:w,isSaving:T,setNewModel:E,handleAddModel:D,handleDeleteModel:O,ensureModel:k,startEditingModel:A,cancelEdit:j,refresh:M}=uie(d),{prompts:N,isSaving:P,handleSavePrompt:F,handleDeletePrompt:I,togglePromptDefault:L}=die(),R=U.useMemo(()=>c?[{label:`General`,items:[{id:`appearance`,label:`Appearance`,icon:(0,W.jsx)(Oo,{className:`size-4`})}]},{label:`More`,items:[{id:`keymap`,label:`Keymap`,icon:(0,W.jsx)(uo,{className:`size-4`})},{id:`changelog`,label:`What's New`,icon:(0,W.jsx)(oo,{className:`size-4`})}]}]:[{label:`General`,items:[...u?[]:[{id:`account`,label:`Account`,icon:(0,W.jsx)(Qo,{className:`size-4`})}],{id:`appearance`,label:`Appearance`,icon:(0,W.jsx)(Oo,{className:`size-4`})},...a&&!u?[{id:`storage`,label:`Storage`,icon:(0,W.jsx)(Br,{className:`size-4`})}]:[],...u?[{id:`usage`,label:`Usage`,icon:(0,W.jsx)($a,{className:`size-4`})}]:[]]},{label:`Feature`,items:[...d?[{id:`ai-config`,label:`AI Configuration`,icon:(0,W.jsx)(ti,{className:`size-4`})}]:[],...f?[{id:`license`,label:`Application License`,icon:(0,W.jsx)(co,{className:`size-4`})}]:[],{id:`mcp-server`,label:`MCP Integration`,icon:(0,W.jsx)(Io,{className:`size-4`})},{id:`ai-rules`,label:`AI Rules`,icon:(0,W.jsx)(_o,{className:`size-4`})},{id:`ai-prompts`,label:`System Prompts`,icon:(0,W.jsx)(ba,{className:`size-4`})}]},{label:`More`,items:[{id:`keymap`,label:`Keymap`,icon:(0,W.jsx)(uo,{className:`size-4`})},...d?[{id:`export-data`,label:`Export Data`,icon:(0,W.jsx)(Yn,{className:`size-4`})},{id:`import-data`,label:`Import Data`,icon:(0,W.jsx)(sr,{className:`size-4`})},{id:`backups`,label:`Database Backup`,icon:(0,W.jsx)(Ar,{className:`size-4`})}]:[],{id:`changelog`,label:`What's New`,icon:(0,W.jsx)(oo,{className:`size-4`})}]}],[f,c,a,u,d]);U.useEffect(()=>{(!d&&[`ai-config`,`license`,`export-data`,`import-data`,`backups`].includes(n)||u&&n===`account`||n===`license`&&!f)&&r(c||u?`appearance`:`account`)},[f,c,u,d,n,r]);let ee=R.flatMap(e=>e.items),te=e=>ee.find(t=>t.id===e)?.label||``;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`overflow-hidden p-0 md:max-h-150 md:max-w-175 lg:max-w-237.5 bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`Settings`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Manage your application settings and AI configuration.`}),(0,W.jsxs)(Fp,{className:`items-start min-h-0! h-full`,children:[(0,W.jsx)(Ip,{collapsible:`none`,className:`w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full`,children:(0,W.jsxs)(zp,{className:`pt-4 px-2 pb-0`,children:[(0,W.jsx)(`div`,{className:`px-4 py-2 mb-2`,children:(0,W.jsxs)(`h2`,{className:`text-sm font-bold flex items-center gap-2`,children:[(0,W.jsx)(Ro,{className:`size-4`}),`Settings`]})}),R.map(e=>(0,W.jsxs)(Bp,{className:`py-1`,children:[(0,W.jsx)(Vp,{className:`text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5`,children:e.label}),(0,W.jsx)(Hp,{children:(0,W.jsx)(Up,{children:e.items.map(e=>(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{isActive:n===e.id,onClick:()=>r(e.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${n===e.id?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-muted-foreground hover:bg-sidebar-accent/50`}`,children:[e.icon,(0,W.jsx)(`span`,{className:`text-xs`,children:e.label})]})},e.id))})})]},e.label))]})}),(0,W.jsxs)(`main`,{className:`flex-1 flex flex-col h-150 overflow-hidden`,children:[(0,W.jsx)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(Kp,{className:`hidden md:flex`,children:(0,W.jsxs)(qp,{children:[(0,W.jsx)(Jp,{children:(0,W.jsx)(cie,{href:`#`,className:`text-[11px] text-muted-foreground`,children:`Settings`})}),(0,W.jsx)(Xp,{}),(0,W.jsx)(Jp,{children:(0,W.jsx)(Yp,{className:`text-[11px] font-semibold`,children:te(n)})})]})}),(0,W.jsx)(`div`,{className:`md:hidden`,children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`-ml-2 h-8 gap-2 text-xs font-semibold`,children:[(0,W.jsx)(Ro,{className:`size-3.5`}),te(n),(0,W.jsx)(on,{className:`size-3 opacity-50`})]})}),(0,W.jsx)(en,{align:`start`,className:`w-56`,children:R.map(e=>(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5`,children:e.label}),e.items.map(e=>(0,W.jsxs)(Kt,{onClick:()=>r(e.id),className:n===e.id?`bg-accent`:``,children:[e.icon,(0,W.jsx)(`span`,{className:`ml-2`,children:e.label})]},e.id)),(0,W.jsx)(tn,{})]},e.label))})]})})]})}),(0,W.jsxs)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:[d&&n===`ai-config`&&(0,W.jsxs)(`div`,{className:`p-4 md:p-6`,children:[(0,W.jsxs)(`div`,{className:`flex gap-1 bg-muted border border-border rounded-lg p-1 w-full mb-4`,children:[(0,W.jsxs)(`button`,{onClick:()=>s(`configuration`),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${o===`configuration`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[(0,W.jsx)(Ro,{className:`w-3.5 h-3.5`}),`Configuration`]}),(0,W.jsxs)(`button`,{onClick:()=>s(`models`),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${o===`models`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[(0,W.jsx)(ba,{className:`w-3.5 h-3.5`}),`AI Models`]})]}),o===`configuration`&&(0,W.jsx)(fie,{providers:p,configs:m,models:S,isSaving:g,isTesting:h,onSave:_,onTest:e=>v(e,Object.values(S).flat()),onUpdateProvider:b,onUpdateConfig:x,onEnsureModel:k,onRefreshModels:M,onInitialize:y}),o===`models`&&(0,W.jsx)(nm,{providers:p,models:Object.values(S).flat(),newModel:C,editingModelId:w,isSaving:T,onSetNewModel:E,onAddModel:D,onEditModel:A,onDeleteModel:O,onCancelEdit:j})]}),n===`ai-prompts`&&(0,W.jsx)(pie,{prompts:N,isSaving:P,onSave:F,onDelete:I,onToggleDefault:L}),n===`ai-rules`&&(0,W.jsx)(gie,{}),n===`mcp-server`&&(0,W.jsx)(Wue,{}),f&&n===`license`&&(0,W.jsx)(Gue,{}),d&&n===`backups`&&(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsx)(Mie,{})}),!u&&n===`account`&&(0,W.jsx)(_ie,{}),n===`changelog`&&(0,W.jsx)(`div`,{className:`p-6 space-y-6`,children:(0,W.jsx)(Oue,{})}),n===`keymap`&&(0,W.jsx)(Hue,{}),d&&n===`export-data`&&(0,W.jsx)(`div`,{className:`p-4 md:p-6 overflow-y-auto h-full`,children:(0,W.jsx)(zue,{})}),d&&n===`import-data`&&(0,W.jsxs)(`div`,{className:`p-4 md:p-6 overflow-y-auto h-full`,children:[(0,W.jsxs)(`div`,{className:`mb-6`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Import Data`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restore data from a JSON backup or replace the local database from a .db file.`})]}),(0,W.jsx)(Mue,{})]}),n===`appearance`&&(0,W.jsx)(bie,{}),n===`storage`&&(0,W.jsx)(Bue,{}),u&&n===`usage`&&(0,W.jsx)($p,{onClose:()=>t(!1)})]})]})]})]})})}async function que(){try{let{getVersion:e}=await bi(async()=>{let{getVersion:e}=await import(`./app-Dwb58oCT.js`);return{getVersion:e}},__vite__mapDeps([2,1,3]));return await e()}catch{return`0.0.0`}}function By({open:e,onOpenChange:t,hasUpdate:n=!1,latestVersion:r=null,isChecking:i=!1,isDownloading:a=!1,onCheckUpdate:o,onDownload:s}){let c=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[l,u]=(0,U.useState)(`...`),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),S=n||f,C=r||m,w=i||g,T=a||v;(0,U.useEffect)(()=>{c?que().then(u):u(`3.4.7-rc.39`)},[c]),(0,U.useEffect)(()=>{if(!e||!c||n||i||a)return;if(o){o();return}if(s)return;_(!0);let t=!1;return(async()=>{try{let{check:e}=await bi(async()=>{let{check:e}=await import(`./dist-js-CoMyUP6l.js`).then(e=>e.n);return{check:e}},__vite__mapDeps([4,5,1])),n=await e();if(t)return;n?(p(!0),h(n.version),x(n)):(p(!1),h(null),x(null))}catch{}finally{t||_(!1)}})(),()=>{t=!0}},[e,c]);let E=(0,U.useCallback)(()=>{if(s)s();else if(b){if(v)return;y(!0),b.downloadAndInstall(()=>{}).catch(e=>{let t=typeof e==`string`?e:e?.message?e.message:JSON.stringify(e);d.error(`Update failed`,{description:t||`An error occurred while downloading the update.`,duration:12e3,action:{label:`Copy Error`,onClick:()=>navigator.clipboard.writeText(t).catch(()=>{})}})}).finally(()=>y(!1))}},[s,b,v]),D=(0,U.useCallback)(()=>{T||(o?o():(_(!0),p(!1),h(null),(async()=>{try{let{check:e}=await bi(async()=>{let{check:e}=await import(`./dist-js-CoMyUP6l.js`).then(e=>e.n);return{check:e}},__vite__mapDeps([4,5,1])),t=await e();t?(p(!0),h(t.version),x(t)):(p(!1),h(null),x(null))}catch{}finally{_(!1)}})()))},[o,T]);return(0,U.useEffect)(()=>{e||(p(!1),h(null),_(!1),x(null))},[e]),(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`max-w-sm bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`About ERD Builder Pro`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Application information and credits.`}),(0,W.jsxs)(`div`,{className:`flex flex-col items-center py-6 gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex size-14 items-center justify-center`,children:[(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Light-1.svg`,alt:``,"aria-hidden":`true`,className:`size-full dark:hidden`}),(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Dark-1.svg`,alt:``,"aria-hidden":`true`,className:`hidden size-full dark:block`})]}),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`ERD Builder Pro`}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`Version `,l]})]}),(0,W.jsx)(`p`,{className:`text-xs text-center text-muted-foreground max-w-60 leading-relaxed`,children:`Entity-Relationship Diagram builder, flowcharts, notes, and AI-powered assistance — all in one desktop app.`}),c&&(0,W.jsxs)(`div`,{className:`w-full`,children:[(0,W.jsx)(`div`,{className:`w-full border-t border-border/40 mb-3`}),w?(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground py-1`,children:[(0,W.jsx)(vo,{className:`size-3.5 animate-spin`}),`Checking for updates...`]}):S&&C?(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-500`,children:[(0,W.jsx)(Yn,{className:`size-3.5`}),(0,W.jsxs)(`span`,{children:[`Update `,(0,W.jsxs)(`strong`,{children:[`v`,C]}),` available`]})]}),(0,W.jsxs)(H,{variant:`default`,size:`sm`,className:`h-8 text-xs gap-1.5`,onClick:E,disabled:T,children:[T?(0,W.jsx)(vo,{className:`size-3.5 animate-spin`}):(0,W.jsx)(Yn,{className:`size-3.5`}),T?`Downloading...`:`Download Update`]})]}):(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-emerald-500`,children:[(0,W.jsx)(wn,{className:`size-3.5`}),(0,W.jsx)(`span`,{children:`You're up to date`})]}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground`,onClick:D,children:[(0,W.jsx)(Hr,{className:`size-3`}),`Check Again`]})]})]}),(0,W.jsx)(`div`,{className:`w-full border-t border-border/40`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-center text-muted-foreground/60 leading-relaxed`,children:[(0,W.jsx)(`p`,{children:`Built with React, Tauri, Express & Prisma.`}),(0,W.jsxs)(`p`,{className:`mt-0.5`,children:[`© `,new Date().getFullYear(),` Bekenweb.`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground`,onClick:()=>{Hi(`https://github.com/hadziqmtqn/erd-builder-pro`)},children:[(0,W.jsx)(za,{className:`size-3`}),`GitHub`]}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`h-7 text-[11px] gap-1 text-rose-500 hover:text-rose-600`,onClick:()=>{Hi(`https://trakteer.id/khadziq_muttaqin/tip`)},children:[(0,W.jsx)(ao,{className:`size-3`}),`Support`]})]})]})]})})}function Jue(e){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),{setViewport:l,fitView:u}=z();return{isPublicView:t,setIsPublicView:n,publicData:r,isPublicLoading:a,forbiddenDoc:s,fetchPublicDocument:async(t,n,r,a,s)=>{o(!0),c(null);try{let o=t===`erd`?`files`:t===`flowchart`?`flowcharts`:t,d={"Content-Type":`application/json`};s&&(d[`x-share-token`]=s);let f=await wi(`/api/${o}/public/${n}`,{headers:d,credentials:`include`});if(!f.ok){let e=`Document not found or access denied`,t=`Access Denied`;try{e=(await f.json()).error||e,f.status===404?t=`Not Found`:(f.status===401||f.status===403)&&(t=`Access Denied`)}catch{}if(f.status===401||f.status===403||f.status===404)return c({title:t,message:e,status:f.status}),!1;throw Error(e)}let p=f.headers.get(`content-type`);if(!p||!p.includes(`application/json`))throw Error(`Received invalid response from server`);let m=await f.json();if(i(m),e(t),t===`erd`){let e=m.entities.map(e=>({id:e.id,type:`entity`,position:{x:e.x,y:e.y},data:e})),t=m.relationships.map(e=>{let t=m.entities.find(t=>String(t.id)===String(e.source_entity_id)),n=m.entities.find(t=>String(t.id)===String(e.target_entity_id)),r=e.source_handle,i=e.target_handle;if(t&&n){let a=Number(t.x)||0,o=Number(n.x)||0,s=(e.source_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``),c=(e.target_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);s&&(r=a<o?`col-${s}-source`:`col-${s}-source-l`),c&&(i=a<o?`col-${c}-target`:`col-${c}-target-r`)}let a=(e.source_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``),o=(e.target_column_id||``).replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);return{id:e.id,source:e.source_entity_id,target:e.target_entity_id,sourceHandle:r||(a?`col-${a}-source`:void 0),targetHandle:i||(o?`col-${o}-target`:void 0),label:e.label,type:`smoothstep`,animated:!0}});r(e),a(t);let n=(t=0)=>{let n=Ni(m);n?l(n,{duration:t}):e.length>0&&u({padding:.2,duration:t})};setTimeout(()=>n(0),100)}else if(t===`flowchart`)try{let e=typeof m.data==`string`?JSON.parse(m.data):m.data;r(e.nodes||[]),a(e.edges||[]);let t=(t=0)=>{let n=Ni(m);n?l(n,{duration:t}):e.nodes?.length>0&&u({padding:.2,duration:t})};setTimeout(()=>t(0),100)}catch(e){console.error(`Failed to parse flowchart data:`,e)}else r([]),a([]);return!0}catch(e){return d.error(e.message||`Failed to load shared document`),setTimeout(()=>window.location.href=`/`,3e3),!1}finally{o(!1)}}}}var Vy=(0,U.createContext)(null),Hy=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Uy={checked(e){return e?{[Hy.checked]:``}:{[Hy.unchecked]:``}},...$e,...Ot},Wy=`data-composite-item-active`,Gy=U.createContext(void 0);function Yue(){return U.useContext(Gy)}var Ky=U.createContext(void 0);function Xue(){let e=U.useContext(Ky);if(e===void 0)throw Error(Ne(52));return e}var qy=U.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,...f}=e,p=Yue(),{disabled:m,readOnly:h,required:g,checkedValue:_,touched:v=!1,validation:y,name:b}=p??{},x=p?.setCheckedValue??Ae,S=p?.setTouched??Ae,C=p?.registerControlRef??Ae,w=p?.registerInputRef??Ae,{setDirty:T,validityData:E,setTouched:D,setFilled:O,state:k,disabled:A}=Tt(),j=ms(),{labelId:M,getDescriptionProps:N}=kt(),P=A||j.disabled||m||i,F=h||a,I=g||o,L=p?_===c:c===``,R=U.useMemo(()=>br(c),[c]),ee=U.useRef(null),te=U.useRef(null),ne=ke(e=>{e&&C(e,P)}),re=Le(l,te,w);Oe(()=>{te.current?.checked&&O(!0)},[O]),Oe(()=>{te.current&&(P&&L?w(null):(ee.current&&C(ee.current,P),w(te.current)))},[L,P,C,w]);let ie=Xe(),z=Dt({id:d,implicit:!1,controlRef:ee}),ae=u?void 0:z,oe=am(s,M,te,!u,ae),se={role:`radio`,"aria-checked":L,"aria-required":I||void 0,"aria-readonly":F||void 0,"aria-labelledby":oe,[Wy]:L?``:void 0,id:u?z:ie,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){e.defaultPrevented||P||F||(e.preventDefault(),te.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))},onFocus(e){e.defaultPrevented||P||F||!v||(te.current?.click(),S(!1))}},{getButtonProps:ce,buttonRef:le}=Me({disabled:P,native:u}),ue={type:`radio`,ref:re,id:ae,name:b,tabIndex:-1,style:b?bt:dt,"aria-hidden":!0,...c===void 0?je:{value:R},disabled:P,checked:L,required:I,readOnly:F,onChange(e){if(e.nativeEvent.defaultPrevented||P||F||c===void 0)return;let t=gt(Ze,e.nativeEvent);t.isCanceled||(D(!0),T(c!==E.initialValue),O(!0),x(c,t))},onFocus(){ee.current?.focus()}},de=U.useMemo(()=>({...k,required:I,disabled:P,readOnly:F,checked:L}),[k,P,F,L,I]),B=de,fe=p!==void 0,pe=[t,ee,le,ne],me=[se,N,y?.getValidationProps??je,f,ce],he=Pe(`span`,e,{enabled:!fe,state:de,ref:pe,props:me,stateAttributesMapping:Uy});return(0,W.jsxs)(Ky.Provider,{value:B,children:[fe?(0,W.jsx)(Zt,{tag:`span`,render:n,className:r,state:de,refs:pe,props:me,stateAttributesMapping:Uy}):he,(0,W.jsx)(`input`,{...ue})]})}),Jy=U.forwardRef(function(e,t){let{render:n,className:r,keepMounted:i=!1,...a}=e,o=Xue(),s=o.checked,{mounted:c,transitionStatus:l,setMounted:u}=We(s),d={...o,transitionStatus:l},f=U.useRef(null),p=i||c,m=Pe(`span`,e,{ref:[t,f],state:d,props:a,stateAttributesMapping:Uy});return Je({open:s,ref:f,onComplete(){s||u(!1)}}),p?m:null});function Zue(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Que=[];function $ue(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=Que}=e,[m,h]=U.useState(0),g=n>1,_=U.useRef(null),v=Le(_,l),y=U.useRef([]),b=U.useRef(!1),x=s??m,S=ke((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];it(_.current,t,o,a)}}),C=ke(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),it(_.current,n,o,a)}),w=U.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){_.current&&Ct(e.target)&&e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?rt:vt;if(!s.has(e.key)||ede(e,p)||!_.current)return;let c=o===`rtl`,l=c?at:ut,m={horizontal:l,vertical:mt,both:l}[a],h=c?ut:at,v={horizontal:h,vertical:yt,both:h}[a];if(Ct(e.target)&&!Zue(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=tt(y,f),w=Qe(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=Ye(o,n,i),l=s.findIndex(e=>e!=null&&!_t(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!_t(y,t,f)?n:e,-1);b=s[Ge({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:et([...f||y.current.map((e,t)=>_t(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:Ue(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[mt],both:[l,mt]}[a],E={horizontal:[h],vertical:[yt],both:[h,yt]}[a],D=g?s:{horizontal:u?ft:ht,vertical:u?xt:nt,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:wt(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!Ke(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return U.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function ede(e,t){for(let n of lt.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Yy(e){let{render:t,className:n,refs:r=Fe,props:i=Fe,state:a=je,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=$ue({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:sn(),disabledIndices:v,modifierKeys:y}),k=Pe(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=U.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,W.jsx)(De.Provider,{value:A,children:(0,W.jsx)(un,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var tde=[st],Xy=U.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,name:u,inputRef:d,id:f,...p}=e,{setTouched:m,setFocused:h,shouldValidateOnChange:g,validationMode:_,name:v,disabled:y,state:b,validation:x,setDirty:S,setFilled:C,validityData:w}=Tt(),{labelId:T}=kt(),{clearErrors:E}=Et(),D=fs(!0),O=y||i,k=v??u,A=Xe(f),[j,M]=cn({controlled:c,default:l,name:`RadioGroup`,state:`value`}),N=ke(s),P=ke((e,t)=>{N(e,t),!t.isCanceled&&M(e)}),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null);function R(e){let t;return d&&(typeof d==`function`?t=d(e):d.current=e),I.current=e,x.inputRef.current=e,t}let ee=ke((e,t=!1)=>{e&&(t?F.current===e&&(F.current=null):F.current??=e)}),te=ke(e=>{if(!e||e.disabled)return;L.current||=e;let t=I.current;if(e.checked||t==null||t.disabled)return R(e)});jt({id:A,commit:x.commit,value:j,controlRef:F,name:k,getValue:()=>j??null}),pt(j,()=>{E(k),S(j!==w.initialValue),C(j!=null),g()?x.commit(j):x.commit(j,!0);let e=L.current;j==null&&e&&!e.disabled&&R(e)});let[ne,re]=U.useState(!1),ie=p[`aria-labelledby`]??T??D?.legendId,z={...b,disabled:O??!1,required:o??!1,readOnly:a??!1},ae=U.useMemo(()=>({...b,checkedValue:j,disabled:O,validation:x,name:k,onValueChange:N,readOnly:a,registerControlRef:ee,registerInputRef:te,required:o,setCheckedValue:P,setTouched:re,touched:ne}),[j,O,x,b,k,N,a,ee,te,o,P,re,ne]),oe={role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":O||void 0,"aria-readonly":a||void 0,"aria-labelledby":ie,onFocus(){h(!0)},onBlur(e){ot(e.currentTarget,e.relatedTarget)||(m(!0),h(!1),_===`onBlur`&&x.commit(j))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(m(!0),re(!0),h(!0))}};return(0,W.jsx)(Gy.Provider,{value:ae,children:(0,W.jsx)(Yy,{render:n,className:r,state:z,props:[oe,x.getValidationProps,p],refs:[t],stateAttributesMapping:Ot,enableHomeAndEndKeys:!1,modifierKeys:tde})})});async function Zy(e,t,n){if(await e(),await t(),(await ea.getAllPendingSyncs()).some(e=>e.type===n.type&&[n.id,n.uid].some(t=>t!=null&&String(t)===String(e.id))))throw Error(`Save your pending changes before switching workspaces.`)}async function Qy(e,t=document){E(t),I(t);let{view:n,activeNote:r,activeDiagram:i,activeFlowchart:a,activeDrawing:o}=e,s=n===`notes`?r:n===`erd`?i:n===`flowchart`?a:o,c=!1;if(n===`notes`&&r&&!e.isReadOnlyFile(r)){let t={uid:String(r.uid??r.id),content:null};if(window.dispatchEvent(new CustomEvent(M,{detail:t})),t.content!==null){if(c=!0,e.cancelPendingNoteSaves(),t.content!==r.content&&!await e.saveNote({...r,content:t.content}))throw Error(`Could not save the note. Keep this panel open and try again.`);e.setIsLocalSaving(!1)}}await Zy(c?async()=>{}:e.flushPendingSaves,e.syncDrafts,{type:n,id:s?.id,uid:s?.uid})}function $y(e,t){let[n,r]=(0,U.useState)(()=>{try{let t=localStorage.getItem(e);if(t)return{...JSON.parse(t)}}catch{}return Object.fromEntries(t.map(e=>[e.id,e.defaultVisible]))});return(0,U.useEffect)(()=>{try{localStorage.setItem(e,JSON.stringify(n))}catch{}},[n,e]),{visible:n,toggle:(0,U.useCallback)(e=>{r(t=>({...t,[e]:!t[e]}))},[]),visibleCols:(0,U.useCallback)(()=>t.filter(e=>!e.hideable||(n[e.id]??e.defaultVisible)),[n])}}var nde=10,rde=`notes-table-column-visibility`,eb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],ide=U.memo(function({notes:e,projects:t,selectedWorkspace:n,page:r,totalNotes:i,isLoading:a,onSelectNote:o,onCreateNote:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteNote:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/nde)),{toggle:_,visibleCols:v}=$y(rde,eb),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Nt,{className:`w-5 h-5 text-yellow-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Notes`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` notes)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search notes...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:eb.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Note`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No notes yet. Create your first note to get started.`:`No notes on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})}),ade={postgresql:`PostgreSQL`,mysql:`MySQL`,sqlite:`SQLite`},ode={postgresql:`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20`,mysql:`bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20`,sqlite:`bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20`};function sde({account:e,catalogs:t,onEdit:n,onDelete:r,onTest:i,onAddCatalog:a,onImportCatalog:o,onDeleteCatalog:s,isTesting:c}){let[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),{id:p,name:m,type:h,host:g,port:_}=e,v=h===`sqlite`?g||`Local file`:g?`${g}:${_||``}`:`-`,y=e=>{e.stopPropagation(),u(!l)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rounded-lg border transition-colors hover:bg-accent/50`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3 p-4 cursor-pointer`,onClick:y,children:[(0,W.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full border bg-muted/50`,children:(0,W.jsx)(Br,{className:`h-4 w-4 text-muted-foreground`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`truncate pr-2 text-sm font-medium`,title:m,children:m}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] px-1.5 py-0 h-4 ${ode[h]}`,children:ade[h]}),(0,W.jsx)(tm,{variant:`outline`,className:e.environment===`production`?`h-4 border-red-500/30 bg-red-500/10 px-1.5 py-0 text-[10px] uppercase text-red-600`:`h-4 px-1.5 py-0 text-[10px] uppercase`,children:e.environment||`development`}),e.safeMode===`read-only`&&(0,W.jsx)(tm,{variant:`outline`,className:`h-4 border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0 text-[10px] text-emerald-600`,children:`READ ONLY`}),e.sslMode&&e.sslMode!==`disable`&&(0,W.jsx)(tm,{variant:`outline`,className:`h-4 px-1.5 py-0 text-[10px]`,children:`TLS`}),t.length>0&&(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] px-1.5 py-0 h-4 bg-muted`,children:h===`sqlite`?`1 DB`:`${t.length} DB`})]})]}),(0,W.jsx)(`div`,{className:`mt-2 truncate text-xs text-muted-foreground`,title:v,children:v})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-7 w-7`,onClick:y,children:l?(0,W.jsx)(on,{className:`h-3.5 w-3.5`}):(0,W.jsx)(At,{className:`h-3.5 w-3.5`})}),(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-7 w-7`}),onClick:e=>e.stopPropagation(),children:(0,W.jsx)(Nr,{className:`h-3.5 w-3.5`})}),(0,W.jsxs)(en,{align:`end`,className:`w-36`,children:[(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),i(e)},disabled:c,className:`cursor-pointer`,children:[c?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,W.jsx)(xa,{className:`h-3.5 w-3.5 mr-2`}),`Test`]}),(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),n(e)},className:`cursor-pointer`,children:[(0,W.jsx)(_r,{className:`h-3.5 w-3.5 mr-2`}),`Edit`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:t=>{t.stopPropagation(),r(e)},className:`cursor-pointer text-destructive focus:text-destructive`,children:[(0,W.jsx)(ni,{className:`h-3.5 w-3.5 mr-2`}),`Delete`]})]})]})]})]}),l&&(0,W.jsxs)(`div`,{className:`border-t px-3 py-2 space-y-1.5`,children:[t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground py-1`,children:`No databases connected yet`}):(0,W.jsx)(Vn,{className:`max-h-48`,children:t.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-md px-2 py-1.5 hover:bg-accent/50 group/cat`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,W.jsx)(Ar,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`text-xs truncate`,children:e.label||e.databaseName}),e.label&&e.label!==e.databaseName&&(0,W.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,e.databaseName,`)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover/cat:opacity-100 transition-opacity`,children:[(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-6 w-6`,title:`Import as ERD`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,W.jsx)(Ar,{className:`h-3 w-3`})}),(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,className:`h-6 w-6 text-destructive hover:text-destructive`,title:`Disconnect database`,onClick:t=>{t.stopPropagation(),f(e)},children:(0,W.jsx)(Xo,{className:`h-3 w-3`})})]})]},e.id))}),h!==`sqlite`&&(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,className:`w-full h-7 text-xs justify-start text-muted-foreground hover:text-foreground`,onClick:t=>{t.stopPropagation(),a(e)},children:[(0,W.jsx)(zt,{className:`h-3 w-3 mr-1.5`}),`Add Database`]})]})]}),(0,W.jsx)(gi,{open:d!==null,onOpenChange:e=>!e&&f(null),children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(Xo,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Disconnect Database`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Disconnect `,(0,W.jsx)(`strong`,{children:d?.label||d?.databaseName}),`? ERD Builder files created from this database will also be deleted.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:()=>{d&&s(d),f(null)},children:`Disconnect`})]})]})})]})}var tb=`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,nb={local:`Local`,development:`Development`,staging:`Staging`,production:`Production`},rb={normal:`Normal`,protected:`Protected`,"read-only":`Read-only`},ib={disable:`Disable`,require:`Require`,"verify-ca":`Verify CA`,"verify-full":`Verify Full`};function cde(e){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-lg border bg-muted/20 p-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Environment`}),(0,W.jsxs)(Er,{value:e.environment,onValueChange:t=>e.onEnvironmentChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:nb[e.environment]})}),(0,W.jsx)(Sr,{children:Object.entries(nb).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Safe Mode`}),(0,W.jsxs)(Er,{value:e.safeMode,onValueChange:t=>e.onSafeModeChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:rb[e.safeMode]})}),(0,W.jsx)(Sr,{children:Object.entries(rb).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`TLS / SSL`}),(0,W.jsxs)(Er,{value:e.sslMode,onValueChange:t=>e.onSslModeChange(t),children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{children:ib[e.sslMode]})}),(0,W.jsx)(Sr,{children:Object.entries(ib).map(([e,t])=>(0,W.jsx)(xr,{value:e,children:t},e))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:tb,children:`Query timeout (ms)`}),(0,W.jsx)(Oi,{type:`number`,min:1e3,max:6e5,value:e.queryTimeoutMs,onChange:t=>e.onQueryTimeoutChange(t.target.value)})]})]}),e.sslMode!==`disable`&&(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(Oi,{placeholder:`CA certificate path (optional)`,value:e.sslCa,onChange:t=>e.onSslCaChange(t.target.value)}),(0,W.jsx)(Oi,{placeholder:`Client certificate path (optional)`,value:e.sslCert,onChange:t=>e.onSslCertChange(t.target.value)}),(0,W.jsx)(Oi,{placeholder:`Client private key path (optional)`,value:e.sslKey,onChange:t=>e.onSslKeyChange(t.target.value)})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Protected and Production connections require the table name for destructive actions.`})]})}var ab=[{value:`postgresql`,label:`PostgreSQL`,defaultPort:5432},{value:`mysql`,label:`MySQL`,defaultPort:3306},{value:`sqlite`,label:`SQLite`,defaultPort:0}];function lde({open:e,onOpenChange:t,editing:n,onSave:r,onTest:i,getDefaultPort:a,projects:o=[]}){let[s,c]=(0,U.useState)(n?.type||`postgresql`),[l,u]=(0,U.useState)(n?.name||``),[d,f]=(0,U.useState)(n?.host||``),[p,m]=(0,U.useState)(String(n?.port??a(s))),[h,g]=(0,U.useState)(n?.user||``),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(n?.environment||`development`),[x,S]=(0,U.useState)(n?.safeMode||`protected`),[C,w]=(0,U.useState)(n?.sslMode||`disable`),[T,E]=(0,U.useState)(n?.sslCa||``),[D,O]=(0,U.useState)(n?.sslCert||``),[k,A]=(0,U.useState)(n?.sslKey||``),[j,M]=(0,U.useState)(String(n?.queryTimeoutMs||3e4)),[N,P]=(0,U.useState)(``),[F,I]=(0,U.useState)(`none`),[L,R]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(null),[ne,re]=(0,U.useState)(!1),ie=!!n;(0,U.useEffect)(()=>{e&&(n?(c(n.type),u(n.name),f(n.host||``),m(String(n.port??a(n.type))),g(n.user||``),v(``),b(n.environment||`development`),S(n.safeMode||`protected`),w(n.sslMode||`disable`),E(n.sslCa||``),O(n.sslCert||``),A(n.sslKey||``),M(String(n.queryTimeoutMs||3e4)),P(``),I(`none`)):(c(`postgresql`),u(``),f(`localhost`),m(`5432`),g(`postgres`),v(``),b(`development`),S(`protected`),w(`disable`),E(``),O(``),A(``),M(`30000`),P(``),I(`none`)),te(null))},[e,n,a]);let z=e=>{if(!e)return;let t=e;c(t),m(String(a(t))),t===`sqlite`?(f(``),g(``),v(``),P(l)):d||f(`localhost`),te(null)},ae=()=>({name:l,type:s,host:d,port:Number(p),user:h,password:_,database:s===`sqlite`?d:void 0,erdName:s===`sqlite`?N:void 0,projectId:s===`sqlite`?F:void 0,environment:y,safeMode:x,sslMode:C,sslCa:T||void 0,sslCert:D||void 0,sslKey:k||void 0,queryTimeoutMs:Number(j)||3e4}),oe=async()=>{try{let{open:e}=await bi(async()=>{let{open:e}=await Promise.resolve().then(()=>gm);return{open:e}},void 0),t=await e({multiple:!1,filters:[{name:`SQLite database`,extensions:[`db`,`sqlite`,`sqlite3`]}]});typeof t==`string`&&(f(t),l.trim()||u(t.split(/[\\/]/).pop()?.replace(/\.(db|sqlite3?|sqlite)$/i,``)||`SQLite database`),N.trim()||P(t.split(/[\\/]/).pop()?.replace(/\.(db|sqlite3?|sqlite)$/i,``)||`SQLite ERD`))}catch{te({success:!1,message:`File picker is unavailable. Enter the SQLite file path manually.`})}},se=async()=>{R(!0),te(null);let e=await i(ae());te(e),R(!1)},ce=async()=>{if(!l.trim())return;re(!0);let e=await r(ae());re(!1),e&&t(!1)},le=s===`sqlite`;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:ie?`Edit Server Account`:`New Server Account`})}),(0,W.jsxs)(Yr,{className:`space-y-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Database Type`}),(0,W.jsxs)(Er,{value:s,onValueChange:z,children:[(0,W.jsx)(Cr,{className:`h-10`,children:(0,W.jsx)(Tr,{children:ab.find(e=>e.value===s)?.label||s})}),(0,W.jsx)(Sr,{children:ab.map(e=>(0,W.jsx)(xr,{value:e.value,children:e.label},e.value))})]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Server Name`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`My Production DB`,value:l,onChange:e=>u(e.target.value)})]}),le?(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`SQLite File Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{className:`h-10`,placeholder:`/path/to/database.sqlite`,value:d,onChange:e=>f(e.target.value)}),(0,W.jsxs)(H,{type:`button`,variant:`outline`,className:`h-10 shrink-0`,onClick:oe,children:[(0,W.jsx)(nr,{className:`mr-1.5 h-3.5 w-3.5`}),`Choose`]})]})]}):(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,W.jsxs)(zr,{className:`col-span-2`,children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Host`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`localhost`,value:d,onChange:e=>f(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Port`}),(0,W.jsx)(Oi,{className:`h-10`,type:`number`,value:p,onChange:e=>m(e.target.value)})]})]}),!le&&(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`User`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:s===`postgresql`?`postgres`:`root`,value:h,onChange:e=>g(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Password`}),(0,W.jsx)(Oi,{className:`h-10`,type:`password`,placeholder:ie?`(saved)`:`password`,value:_,onChange:e=>v(e.target.value)})]})]}),!le&&(0,W.jsx)(cde,{environment:y,safeMode:x,sslMode:C,sslCa:T,sslCert:D,sslKey:k,queryTimeoutMs:j,onEnvironmentChange:b,onSafeModeChange:S,onSslModeChange:w,onSslCaChange:E,onSslCertChange:O,onSslKeyChange:A,onQueryTimeoutChange:M}),le&&!ie&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD New Name`}),(0,W.jsx)(Oi,{className:`h-10`,placeholder:`SQLite ERD name`,value:N,onChange:e=>P(e.target.value)})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:F,onChange:I,items:[{id:`none`,name:`Uncategorized`},...o],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]}),ee&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-sm ${ee.success?`border-green-500/20 bg-green-500/5 text-green-700 dark:text-green-400`:`border-red-500/20 bg-red-500/5 text-red-700 dark:text-red-400`}`,children:[ee.success?(0,W.jsx)(wn,{className:`h-4 w-4 shrink-0`}):(0,W.jsx)(Aa,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:ee.message})]})]}),(0,W.jsxs)(Xr,{className:`gap-2`,children:[(0,W.jsxs)(H,{variant:`outline`,className:`h-9`,onClick:se,disabled:L,children:[L?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-1.5 animate-spin`}):null,`Test Connection`]}),(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`ghost`,className:`h-9`}),children:`Cancel`}),(0,W.jsxs)(H,{className:`h-9 px-6`,disabled:!l.trim()||le&&(!d.trim()||!ie&&!N.trim())||ne,onClick:ce,children:[ne?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-1.5 animate-spin`}):null,ie?`Save`:`Create`]})]})]})})}var ude={postgresql:5432,mysql:3306,sqlite:0};function dde(){let{user:e,isGuest:t}=ta(),[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(!1),o=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),s=(0,U.useCallback)(async()=>{if(e&&!t&&o){a(!0);try{let e=await wi(`/api/accounts`);if(!e.ok)throw Error(`Failed to load accounts`);let t=await e.json();r(t)}catch(e){d.error(e.message||`Failed to load database accounts`)}finally{a(!1)}}},[e,t,o]);return(0,U.useEffect)(()=>{s()},[s]),{accounts:n,isLoading:i,fetchAccounts:s,createAccount:async e=>{try{let t=await wi(`/api/accounts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();throw Error(e.error||`Failed to save account`)}let n=await t.json();return r(e=>[n,...e]),d.success(`Server account saved`),n}catch(e){return d.error(e.message||`Failed to save account`),null}},updateAccount:async(e,t)=>{try{let n=await wi(`/api/accounts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to update account`)}let i=await n.json();return r(t=>t.map(t=>t.id===e?i:t)),d.success(`Account updated`),i}catch(e){return d.error(e.message||`Failed to update account`),null}},deleteAccount:async e=>{try{if(!(await wi(`/api/accounts/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to delete account`);r(t=>t.filter(t=>t.id!==e)),d.success(`Account deleted`)}catch(e){d.error(e.message||`Failed to delete account`)}},listDatabases:async e=>{try{let t=await wi(`/api/accounts/${e}/databases`,{method:`POST`});if(!t.ok){let e=await t.json();throw Error(e.error||`Failed to list databases`)}return(await t.json()).databases||[]}catch(e){return d.error(e.message||`Failed to list databases`),[]}},createDatabase:async(e,t)=>{try{let n=await wi(`/api/accounts/${e}/databases/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to create database`)}let r=await n.json();return d.success(`Database "${r.name}" created`),r}catch(e){return d.error(e.message||`Failed to create database`),null}},testAccount:async e=>{try{let t=await wi(`/api/accounts/${e}/test`,{method:`POST`}),n=await t.json();return!t.ok||!n.success?{success:!1,message:n.error||n.message||`Connection failed`}:{success:!0,message:n.message||`Connection successful`}}catch(e){return{success:!1,message:e.message||`Failed to test connection`}}},getDefaultPort:e=>ude[e]}}function fde(e){let{user:t,isGuest:n}=ta(),[r,i]=(0,U.useState)([]),[a,o]=(0,U.useState)(!1),s=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),c=(0,U.useCallback)(async()=>{if(s&&t&&!n){o(!0);try{let t=e?`?accountId=${e}`:``,n=await wi(`/api/catalogs${t}`);if(!n.ok)throw Error(`Failed to load catalog`);let r=await n.json();i(r)}catch(e){d.error(e.message||`Failed to load database catalogs`)}finally{o(!1)}}},[t,n,s,e]);return(0,U.useEffect)(()=>{c()},[c]),{catalogs:r,isLoading:a,fetchCatalogs:c,createCatalog:async(e,t,n)=>{try{let r=await wi(`/api/catalogs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({accountId:e,databaseName:t,label:n})});if(!r.ok){let e=await r.json();throw Error(e.error||`Failed to create catalog`)}let a=await r.json();return i(e=>[a,...e]),d.success(`Database "${t}" connected`),a}catch(e){return d.error(e.message||`Failed to connect database`),null}},deleteCatalog:async e=>{try{let t=await wi(`/api/catalogs/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to delete catalog`);let n=await t.json();return i(t=>t.filter(t=>t.id!==e)),d.success(`Database disconnected`),n}catch(e){return d.error(e.message||`Failed to disconnect database`),null}},importAsDbClient:async(e,t,n)=>{try{let r=await wi(`/api/catalogs/${e}/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,project_id:n??null})});if(!r.ok){let e=await r.json();throw Error(e.error||`Failed to import schema`)}let i=await r.json();return d.success(`Imported ${i.tableCount} tables as "${t}"`),i}catch(e){return d.error(e.message||`Failed to import schema`),null}},migrateOldConnections:async()=>{try{let e=await wi(`/api/migrate-connections`,{method:`POST`});if(!e.ok)throw Error(`Migration failed`);let t=await e.json();return t.migrated>0&&(d.success(`Migrated ${t.migrated} old connections`),c()),t.migrated||0}catch(e){return d.error(`Migration failed: `+e.message),0}}}}function pde({open:e,onOpenChange:t,projects:n,onImportComplete:r}){let{accounts:i,isLoading:a,createAccount:o,updateAccount:s,deleteAccount:c,listDatabases:l,createDatabase:u,testAccount:f,getDefaultPort:p,fetchAccounts:m}=dde(),{catalogs:h,fetchCatalogs:g,createCatalog:_,deleteCatalog:v,importAsDbClient:y}=fde(),[b,x]=(0,U.useState)(``),[S,C]=(0,U.useState)(!1),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(new Set),[A,j]=(0,U.useState)(null),[M,N]=(0,U.useState)([]),[P,F]=(0,U.useState)(!1),[I,L]=(0,U.useState)(`connect`),[R,ee]=(0,U.useState)(null),[te,ne]=(0,U.useState)(``),[re,ie]=(0,U.useState)(``),[z,ae]=(0,U.useState)(!1),[oe,se]=(0,U.useState)(!1),[ce,le]=(0,U.useState)(``),[ue,de]=(0,U.useState)(`none`),[B,fe]=(0,U.useState)(null),[pe,me]=(0,U.useState)(``),[he,ge]=(0,U.useState)(!1),_e=b.trim()?i.filter(e=>e.name.toLowerCase().includes(b.toLowerCase())||e.type.toLowerCase().includes(b.toLowerCase())||e.host?.toLowerCase().includes(b.toLowerCase())):i,ve=M.find(e=>e.name===te),V=()=>{T(null),L(`import`),C(!0)},ye=e=>{T(e),L(`connect`),C(!0)},be=async e=>{let n=w?await s(w.id,e):await o(e);if(n&&!w){if(e.type===`sqlite`){let i=e.database?.trim()||e.host.trim(),a=await _(n.id,i,n.name);if(a){g(),m();let i=e.projectId===`none`?null:e.projectId,o=await y(a.id,e.erdName?.trim()||n.name,i);o?.dbClient?.uid&&(t(!1),r?.(o.dbClient.uid))}}else setTimeout(()=>we(n,`import`),0)}return n},xe=async e=>{try{let{apiFetch:t}=await bi(async()=>{let{apiFetch:e}=await import(`./api-m1FDJyHM.js`).then(e=>e.r);return{apiFetch:e}},__vite__mapDeps([6,5,7])),n=await t(`/api/accounts/test-cred`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),r=await n.json();return!n.ok||!r.success?{success:!1,message:r.error||r.message||`Connection failed`}:{success:!0,message:r.message||`Connection successful`}}catch(e){return{success:!1,message:e.message||`Failed to test connection`}}},Se=async e=>{k(t=>new Set(t).add(e.id));let t=await f(e.id);k(t=>{let n=new Set(t);return n.delete(e.id),n}),t.success?(d.success(t.message),m()):d.error(t.message)},Ce=async()=>{E&&(await c(E.id),D(null))},we=async(e,t=`connect`)=>{L(t),F(!0),j(e),N([]),ne(``),ie(``),ae(!1),le(``),de(`none`);let n=await l(e.id);N(n),F(!1)},Te=e=>{ne(e),ce.trim()&&ce!==te||le(e)},Ee=async()=>{if(A&&re.trim()){se(!0);try{let e=await u(A.id,re.trim());if(!e)return;N(t=>[...t.filter(t=>t.name!==e.name),e].sort((e,t)=>e.name.localeCompare(t.name))),ie(``),ae(!1),Te(e.name)}finally{se(!1)}}},De=async()=>{if(!A||!te)return;ee(te);let e=h.find(e=>e.accountId===A.id&&e.databaseName===te)||await _(A.id,te);if(e&&(j(null),g(),m(),I===`import`)){let n=ue===`none`?null:ue,i=await y(e.id,ce.trim()||te,n);i?.dbClient?.uid&&(t(!1),r?.(i.dbClient.uid))}ee(null)},Oe=e=>{me(e.label||e.databaseName),de(`none`),fe(e)},ke=async()=>{if(B&&pe.trim()){ge(!0);try{let e=ue===`none`?null:ue,n=await y(B.id,pe.trim(),e);n?.dbClient?.uid&&(fe(null),me(``),t(!1),r?.(n.dbClient.uid))}finally{ge(!1)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Dp,{open:e,onOpenChange:t,children:(0,W.jsxs)(Op,{side:`right`,className:`w-full p-0 flex flex-col gap-0 sm:w-[min(42rem,calc(100vw-2rem))] sm:max-w-none`,children:[(0,W.jsxs)(kp,{className:`p-5 pb-3 sm:p-6 sm:pb-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pr-10`,children:[(0,W.jsx)(Ap,{className:`text-lg`,children:`Database Accounts`}),(0,W.jsx)(tm,{variant:`outline`,className:`text-[10px] h-4 px-1.5 text-amber-600 border-amber-400 dark:text-amber-400 dark:border-amber-500`,children:`Experimental`})]}),(0,W.jsx)(jp,{className:`max-w-xl leading-relaxed`,children:`Create DB clients from external databases and local SQLite files`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 py-3 sm:flex-row sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(Kr,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(Oi,{className:`h-10 pl-8 text-sm`,placeholder:`Search accounts...`,value:b,onChange:e=>x(e.target.value)})]}),(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsxs)(H,{size:`sm`,className:`h-10 w-full shrink-0 sm:w-auto`,onClick:V,children:[(0,W.jsx)(zt,{className:`h-3.5 w-3.5 mr-1`}),`New DB Client`]})})]}),(0,W.jsx)(Vn,{className:`min-h-0 flex-1 px-5 pb-5 sm:px-6 sm:pb-6`,children:a?(0,W.jsx)(`div`,{className:`space-y-2 pt-2`,children:[1,2,3].map(e=>(0,W.jsx)(Mp,{className:`h-16 w-full rounded-lg`},e))}):_e.length===0?(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center pt-12 text-center`,children:[(0,W.jsx)(Br,{className:`h-10 w-10 text-muted-foreground/40 mb-3`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b.trim()?`No accounts found`:`No database accounts yet`}),!b.trim()&&(0,W.jsxs)(H,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:V,children:[(0,W.jsx)(zt,{className:`h-3.5 w-3.5 mr-1.5`}),`New DB Client`]})]}):(0,W.jsx)(`div`,{className:`space-y-2 pt-2`,children:_e.map(e=>(0,W.jsx)(sde,{account:e,catalogs:h.filter(t=>t.accountId===e.id),onEdit:ye,onDelete:D,onTest:Se,onAddCatalog:e=>we(e,`import`),onImportCatalog:Oe,onDeleteCatalog:async e=>{let t=await v(e.id);g(),m(),t&&t.deletedClients>0&&d.info(`${t.deletedClients} DB Client(s) deleted: ${t.clientNames.join(`, `)}`,{duration:5e3})},isTesting:O.has(e.id)},e.id))})})]})}),(0,W.jsx)(lde,{open:S,onOpenChange:C,editing:w,onSave:be,onTest:xe,getDefaultPort:p,projects:n}),(0,W.jsx)(gi,{open:E!==null,onOpenChange:e=>!e&&D(null),children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-100`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ni,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Delete Account`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Delete server account `,(0,W.jsx)(`strong`,{children:E?.name}),`? All connected databases (`,h.filter(e=>e.accountId===E?.id).length,`) will be disconnected. Diagrams using these databases still exist, but can no longer sync.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})}),(0,W.jsx)(gi,{open:A!==null,onOpenChange:e=>!e&&j(null),children:(0,W.jsxs)(ai,{children:[(0,W.jsx)(si,{children:(0,W.jsx)(_i,{children:I===`import`?`Create DB Client`:`Select Database`})}),(0,W.jsx)(mi,{children:P?(0,W.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,W.jsx)(vo,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Production Database`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,W.jsx)(cr,{value:te,onChange:Te,items:M,placeholder:`Select production database`,searchPlaceholder:`Search database...`,emptyMessage:`No database found`,getItemValue:e=>e.name,getItemLabel:e=>e.isConnected?`${e.name} (connected)`:e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`}),A?.type===`sqlite`?null:(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`icon-sm`,className:`h-9 w-9`,onClick:()=>ae(e=>!e),title:`Create database`,children:(0,W.jsx)(zt,{className:`h-3.5 w-3.5`})})]})]}),z&&A?.type!==`sqlite`&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New Database`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,W.jsx)(Oi,{value:re,onChange:e=>ie(e.target.value),placeholder:`new_database`,className:`h-9`,onKeyDown:e=>{e.key===`Enter`&&re.trim()&&!oe&&Ee()}}),(0,W.jsx)(H,{type:`button`,className:`h-9`,onClick:Ee,disabled:!re.trim()||oe,children:oe?(0,W.jsx)(vo,{className:`h-3.5 w-3.5 animate-spin`}):`Create`})]})]}),I===`import`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD File Name`}),(0,W.jsx)(Oi,{value:ce,onChange:e=>le(e.target.value),placeholder:`ERD file name`,className:`h-9`,onKeyDown:e=>{e.key===`Enter`&&te&&ce.trim()&&!R&&De()}})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:ue,onChange:de,items:[{id:`none`,name:`Uncategorized`},...n],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]})]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),M.length>0&&(0,W.jsx)(di,{onClick:De,disabled:!te||I===`connect`&&ve?.isConnected||I===`import`&&!ce.trim()||R!==null,children:R?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}),`Creating...`]}):I===`import`?`Create DB Client`:`Connect`})]})]})}),(0,W.jsx)(gi,{open:B!==null,onOpenChange:e=>!e&&fe(null),children:(0,W.jsxs)(ai,{children:[(0,W.jsx)(si,{children:(0,W.jsx)(_i,{children:`Import as ERD Diagram`})}),(0,W.jsxs)(mi,{children:[(0,W.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`Create a new ERD diagram from `,(0,W.jsx)(`strong`,{children:B?.label||B?.databaseName}),` tables.`]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`ERD File Name`}),(0,W.jsx)(Oi,{value:pe,onChange:e=>me(e.target.value),placeholder:`Diagram name`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&pe.trim()&&!he&&ke()}})]}),(0,W.jsxs)(zr,{className:`mt-3`,children:[(0,W.jsx)(Fr,{className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Workspace`}),(0,W.jsx)(cr,{value:ue,onChange:de,items:[{id:`none`,name:`Uncategorized`},...n],placeholder:`Workspace (optional)`,searchPlaceholder:`Search workspace...`,emptyMessage:`No workspace found`,getItemValue:e=>String(e.id),getItemLabel:e=>e.name,filterItem:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase()),className:`h-9 text-sm`})]})]}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{children:`Cancel`}),(0,W.jsx)(di,{onClick:ke,disabled:!pe.trim()||he,children:he?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`h-3.5 w-3.5 mr-2 animate-spin`}),`Importing...`]}):`Import`})]})]})})]})}var mde=10,ob=`erd-table-column-visibility`,sb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[22%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[15%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`source`,label:`Source`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[12%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[11%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[12%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],hde=(e=ob)=>{try{let t=localStorage.getItem(e);if(t)return{...JSON.parse(t)}}catch{}return Object.fromEntries(sb.map(e=>[e.id,e.defaultVisible]))},gde=e=>e?e===`production_db`?`DB Connect`:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`—`,cb=U.memo(function({mode:e=`erd`,diagrams:t,projects:n,selectedWorkspace:r,page:i,totalDiagrams:a,isLoading:o,onSelectDiagram:s,onCreateDiagram:c,onPageChange:l,onWorkspaceClick:u,onOpenEditDocument:d,onDeleteDiagram:f,canDeleteFile:p=()=>!0,searchQuery:m,onSearchChange:h,searchRef:g}){let _=e===`db-client`,v=Math.max(1,Math.ceil(a/mde)),[y,b]=(0,U.useState)(!1),x=typeof window<`u`&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE===`cli`),S=_?sb.filter(e=>e.id!==`status`&&e.id!==`expires`):x?sb:sb.filter(e=>e.id!==`source`),C=_?`db-client-table-column-visibility`:ob,[w,T]=(0,U.useState)(()=>hde(C));(0,U.useEffect)(()=>{try{localStorage.setItem(C,JSON.stringify(w))}catch{}},[C,w]);let E=(0,U.useCallback)(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=(0,U.useCallback)(e=>{let t=S.find(t=>t.id===e);return!t||!t.hideable?!0:w[e]??t.defaultVisible},[w]),O=e=>e==null?null:n.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,k=e=>e.projects?.name||O(e.project_id)?.name||`—`,A=e=>e.projects?.uid||O(e.project_id)?.uid||null,j=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},M=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},N=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}},P=S.filter(e=>e.id===`name`||e.id===`workspace`||e.id===`actions`||D(e.id)),F=_?t:t.filter(e=>(e.source_type??`blank`)===`blank`);return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ia,{className:`w-5 h-5 text-emerald-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:_?`DB Client`:`ERD Builder`}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>u(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:n.find(e=>e.uid===r)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,a,` `,_?`files`:`diagrams`,`)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:g,type:`text`,placeholder:_?`Search DB Client files...`:`Search diagrams...`,value:m,onChange:e=>h(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:S.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:D(e.id),onCheckedChange:()=>E(e.id),children:e.label},e.id))})]}),!_&&(0,W.jsxs)(H,{size:`sm`,onClick:c,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Diagram`})]}),x&&_&&(0,W.jsxs)(H,{size:`sm`,variant:`outline`,onClick:()=>b(!0),children:[(0,W.jsx)(xa,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`DB Connect`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:S.filter(e=>P.some(t=>t.id===e.id)).map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:o&&F.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:P.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):F.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:P.length,className:`h-32 text-center text-muted-foreground`,children:a===0?_?`No DB Client files yet. Connect a database to get started.`:`No diagrams yet. Create your first ERD diagram to get started.`:_?`No DB Client files on this page.`:`No diagrams on this page.`})}):F.map(e=>{let t=e.uid??String(e.id),n=A(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>s(t),children:P.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.name||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),u(n)},children:k(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`source`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:_?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-blue-500/10 px-2 py-0.5 text-xs text-blue-500`,children:[(0,W.jsx)(Ar,{className:`size-3`}),e.catalog?.account?.type||e.catalog?.database_name||`Database`]}):e.source_type&&e.source_type!==`scratch`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-blue-500/10 text-blue-500 px-2 py-0.5 rounded-full`,children:[(0,W.jsx)(Ar,{className:`w-3 h-3`}),gde(e.source_type)]}):(0,W.jsx)(`span`,{className:`text-muted-foreground/50`,children:`Scratch`})},`source`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:j(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:j(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${N(e.expiry_date)?`text-red-500 font-medium`:``}`,children:M(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>d(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),_&&(0,W.jsxs)(Kt,{onClick:()=>s(t),children:[(0,W.jsx)(Ba,{className:`h-4 w-4 mr-2`}),`Detail`]}),p(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>f(t),className:`text-destructive focus:text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),v>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,i,` of `,v]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:i<=1,onClick:()=>l(i-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:v},(e,t)=>t+1).filter(e=>e===1||e===v||Math.abs(e-i)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===i?`default`:`outline`,size:`icon-xs`,onClick:()=>l(e),className:e===i?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:i>=v,onClick:()=>l(i+1),children:(0,W.jsx)(At,{className:`w-4 h-4`})})]})]}),x&&(0,W.jsx)(pde,{open:y,onOpenChange:b,projects:n,onImportComplete:e=>s(e)})]})}),_de=10,vde=`drawings-table-column-visibility`,lb=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],yde=U.memo(function({drawings:e,projects:t,selectedWorkspace:n,page:r,totalDrawings:i,isLoading:a,onSelectDrawing:o,onCreateDrawing:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteDrawing:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/_de)),{toggle:_,visibleCols:v}=$y(vde,lb),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Mr,{className:`w-5 h-5 text-fuchsia-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Drawings`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` drawings)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search drawings...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:lb.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Drawing`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No drawings yet. Create your first drawing to get started.`:`No drawings on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-[280px]`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})}),bde=10,xde=`flowchart-table-column-visibility`,ub=[{id:`name`,label:`Name`,defaultVisible:!0,hideable:!1,width:`w-[30%]`},{id:`workspace`,label:`Workspace`,defaultVisible:!0,hideable:!1,width:`w-[20%]`},{id:`creator`,label:`Creator`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`updated`,label:`Updated`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`status`,label:`Status`,defaultVisible:!0,hideable:!0,width:`w-[8%]`},{id:`created`,label:`Created`,defaultVisible:!0,hideable:!0,width:`w-[12%]`},{id:`expires`,label:`Expires`,defaultVisible:!1,hideable:!0,width:`w-[14%]`},{id:`actions`,label:`Actions`,defaultVisible:!0,hideable:!1,width:`w-[8%]`}],Sde=U.memo(function({flowcharts:e,projects:t,selectedWorkspace:n,page:r,totalFlowcharts:i,isLoading:a,onSelectFlowchart:o,onCreateFlowchart:s,onPageChange:c,onWorkspaceClick:l,onOpenEditDocument:u,onDeleteFlowchart:d,canDeleteFile:f,searchQuery:p,onSearchChange:m,searchRef:h}){let g=Math.max(1,Math.ceil(i/bde)),{toggle:_,visibleCols:v}=$y(xde,ub),y=v(),b=e=>e==null?null:t.find(t=>String(t.id)===String(e)||String(t.uid)===String(e))||null,x=e=>e.projects?.name||b(e.project_id)?.name||`—`,S=e=>e.projects?.uid||b(e.project_id)?.uid||null,C=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}catch{return e.slice(0,10)}},w=e=>{if(!e)return`—`;try{return new Intl.DateTimeFormat(`id-ID`,{dateStyle:`long`}).format(new Date(e))}catch{return e.slice(0,10)}},T=e=>{if(!e)return!1;try{return new Date(e)<new Date}catch{return!1}};return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col gap-4 overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Eo,{className:`w-5 h-5 text-cyan-400`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Flowcharts`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,W.jsx)(`button`,{onClick:()=>l(null),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:t.find(e=>e.uid===n)?.name||`Workspace`})]}),(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-2`,children:[`(`,i,` flowcharts)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex items-center max-w-64 w-full`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground`}),(0,W.jsx)(Oi,{ref:h,type:`text`,placeholder:`Search flowcharts...`,value:p,onChange:e=>m(e.target.value),className:`h-8 pl-8 text-xs`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`outline`,size:`icon-sm`,"aria-label":`Columns`,title:`Columns`,children:(0,W.jsx)(Ia,{className:`w-4 h-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,children:ub.filter(e=>e.hideable).map(e=>(0,W.jsx)(Qt,{checked:y.some(t=>t.id===e.id),onCheckedChange:()=>_(e.id),children:e.label},e.id))})]}),(0,W.jsxs)(H,{size:`sm`,onClick:s,children:[(0,W.jsx)(zt,{className:`w-4 h-4 sm:mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:`Create Flowchart`})]})]})]})]}),(0,W.jsx)(`div`,{className:`overflow-auto rounded-xl border`,children:(0,W.jsxs)(ym,{children:[(0,W.jsx)(bm,{children:(0,W.jsx)(Sm,{children:y.map(e=>(0,W.jsx)(Cm,{className:e.width,children:e.label},e.id))})}),(0,W.jsx)(xm,{children:a&&e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),`Loading...`]})})}):e.length===0?(0,W.jsx)(Sm,{children:(0,W.jsx)(wm,{colSpan:y.length,className:`h-32 text-center text-muted-foreground`,children:i===0?`No flowcharts yet. Create your first flowchart to get started.`:`No flowcharts on this page.`})}):e.map(e=>{let t=e.uid??String(e.id),n=S(e);return(0,W.jsx)(Sm,{className:`cursor-pointer group`,onClick:()=>o(t),children:y.map(r=>r.id===`name`?(0,W.jsx)(wm,{className:`font-medium`,children:(0,W.jsx)(`span`,{className:`truncate block max-w-70`,children:e.title||`Untitled`})},`name`):r.id===`workspace`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs bg-muted px-2 py-0.5 rounded-full cursor-pointer hover:bg-accent transition-colors`,onClick:e=>{e.stopPropagation(),l(n)},children:x(e)})},`workspace`):r.id===`creator`?(0,W.jsx)(wm,{className:`text-xs text-muted-foreground`,children:e.user?.name||e.user?.email||`—`},`creator`):r.id===`updated`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.updated_at)},`updated`):r.id===`status`?(0,W.jsx)(wm,{children:(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full ${e.is_public?`bg-green-500/10 text-green-500`:`bg-muted text-muted-foreground`}`,children:e.is_public?`Public`:`Private`})},`status`):r.id===`created`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs`,children:C(e.created_at)},`created`):r.id===`expires`?(0,W.jsx)(wm,{className:`text-muted-foreground text-xs ${T(e.expiry_date)?`text-red-500 font-medium`:``}`,children:w(e.expiry_date)},`expires`):r.id===`actions`?(0,W.jsx)(wm,{className:`text-right`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,W.jsx)(Nr,{className:`h-4 w-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`w-44`,children:[(0,W.jsxs)(Kt,{onClick:()=>u(t),children:[(0,W.jsx)(_r,{className:`h-4 w-4 mr-2`}),`Edit`]}),f(e)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>d(t),className:`text-destructive`,children:[(0,W.jsx)(ni,{className:`h-4 w-4 mr-2`}),`Delete`]})]})]})]})},`actions`):null)},t)})})]})}),g>1&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-x border-b bg-background px-4 py-2 shrink-0 rounded-b-xl`,children:[(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,r,` of `,g]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r<=1,onClick:()=>c(r-1),children:(0,W.jsx)(vr,{className:`h-4 w-4`})}),Array.from({length:g},(e,t)=>t+1).filter(e=>e===1||e===g||Math.abs(e-r)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map(e=>e===`ellipsis`?(0,W.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${e}`):(0,W.jsx)(H,{variant:e===r?`default`:`outline`,size:`icon-xs`,onClick:()=>c(e),className:e===r?``:`text-muted-foreground`,children:e},e)),(0,W.jsx)(H,{variant:`outline`,size:`icon-xs`,disabled:r>=g,onClick:()=>c(r+1),children:(0,W.jsx)(At,{className:`h-4 w-4`})})]})]})]})});function Cde(){return(0,W.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-6 bg-muted/50 rounded-xl border border-dashed border-border/50 relative overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-primary/10 rounded-full blur-[100px] pointer-events-none`}),(0,W.jsxs)(`div`,{className:`relative z-10 flex flex-col items-center text-center max-w-sm`,children:[(0,W.jsxs)(`div`,{className:`mb-8 relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-primary/20 blur-2xl rounded-full scale-110`}),(0,W.jsx)(`div`,{className:`relative size-20 rounded-2xl bg-card border border-border flex items-center justify-center shadow-2xl`,children:(0,W.jsx)(Ar,{className:`size-10 text-primary`})})]}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-foreground mb-3 tracking-tight`,children:`Welcome to ERD Builder Pro`}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed mb-8 px-4`,children:`Select a project, diagram, or note from the sidebar to start designing your database schema, taking notes, or sketching ideas.`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-primary font-bold text-[10px] uppercase tracking-[0.2em] bg-primary/5 px-4 py-2 rounded-full border border-primary/20 shadow-[0_0_20px_rgba(var(--primary-rgb),0.05)]`,children:[(0,W.jsx)(pa,{className:`size-3`}),`Start from Sidebar`]})]})]})}var db=({isOpen:e,onOpenChange:t,mode:n=`move-to-trash`,activeDocument:r,view:i,deleteDiagram:a,deleteNote:o,deleteDrawing:s,deleteFlowchart:c,deleteProject:l,fetchTrash:u,itemType:d,onConfirm:f,onAfterDelete:p})=>{let m=async()=>{if(n===`permanent-delete`){f?.(),p?.();return}if(f){f(),p?.();return}let e=i===`erd`||i===`notes`||i===`flowchart`||i===`drawings`?r?.uid??r?.id:r?.id;e&&(i===`erd`?await a?.(e):i===`notes`?await o?.(String(e)):i===`drawings`?await s?.(e):i===`flowchart`?await c?.(e):i===`project`&&await l?.(e),u?.(),t(!1),p?.())},h=d===`erd`?`diagram`:d===`notes`?`note`:d===`drawings`?`drawing`:d===`project`?`workspace`:`item`;if(n===`permanent-delete`)return(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ri,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Are you absolutely sure?`})]}),(0,W.jsx)(mi,{children:(0,W.jsx)(fi,{children:d===`project`?(0,W.jsxs)(W.Fragment,{children:[`This action cannot be undone. Deleting this workspace will also permanently delete all`,(0,W.jsx)(`strong`,{children:` notes, diagrams, drawings, and flowcharts`}),` inside it.`]}):(0,W.jsxs)(W.Fragment,{children:[`This action cannot be undone. This will permanently delete the `,(0,W.jsx)(`strong`,{children:h}),` from our servers.`]})})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:m,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Permanently Delete`})]})]})});let g=i!==`project`;return(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ni,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:g?`Move to Trash?`:`Delete Workspace?`})]}),(0,W.jsx)(mi,{children:(0,W.jsx)(fi,{children:g?(0,W.jsxs)(W.Fragment,{children:[`Are you sure you want to move `,(0,W.jsx)(`strong`,{children:r?.title||r?.name||`this item`}),` to trash?`,(0,W.jsx)(`br`,{}),`You can restore it later from the trash bin.`]}):(0,W.jsxs)(W.Fragment,{children:[`This will move the workspace and all its contents to trash.`,(0,W.jsx)(`br`,{}),`You can restore it later from the trash bin.`]})})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:m,children:g?`Move to Trash`:`Delete`})]})]})})},fb=e=>e===`erd`?`diagram`:e===`notes`?`note`:e===`drawings`?`drawing`:e===`db-client`?`DB Client`:`flowchart`,pb=({isOpen:e,onOpenChange:t,mode:n=`edit`,view:r,activeDocument:i,newName:a,setNewName:o,projects:s,requireProject:c=!1,canMoveProject:l=!1,selectedProjectId:u,setSelectedProjectId:f,onCreate:p,onProjectCreate:m,updateDiagram:h,updateNote:g,updateDrawing:_,updateFlowchart:v,updateDbClient:y,onMoveDiagramToProject:b,onMoveNoteToProject:x,onMoveDrawingToProject:S,onMoveFlowchartToProject:C,onRenameSuccess:w})=>{let T=n===`create`,[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(``),[A,j]=(0,U.useState)(!1),M=e=>{e||(D(!1),k(``)),t(e)},N=async()=>{let e=O.trim();if(e&&m&&!A){j(!0);try{let t=await m(e);if(!t){d.error(`Failed to create project`);return}f(String(t.id)),D(!1),k(``)}catch{d.error(`Failed to create project`)}finally{j(!1)}}};(0,U.useEffect)(()=>{if(e&&!T&&i){let e=i?.project_id??i?.projectId;f(e==null?`none`:String(e))}},[e]);let P=async()=>{if(E||A||!a.trim()||c&&u===`none`)return;if(T){p?.(a.trim(),u===`none`?null:u),M(!1);return}let e=(r===`db-client`||r===`notes`||r===`flowchart`||r===`drawings`)&&i?.uid||i?.id;if(e&&a.trim()){let t=u===`none`?null:u,n=i?.project_id||i?.projectId,o=a.trim()!==(i?.title||i?.name),s=r!==`db-client`&&String(t)!==String(n);if(s&&!l){d.error(`Only the file creator can move this file.`);return}try{if(o&&(r===`erd`?await h?.(e,a,{silent:!0}):r===`notes`?await g?.(String(e),a,{silent:!0}):r===`drawings`?await _?.(e,a,{silent:!0}):r===`flowchart`?await v?.(e,a,{silent:!0}):r===`db-client`&&await y?.(String(e),a.trim())),s){let n;if(r===`erd`?n=await b?.(e,t,{silent:!0}):r===`notes`?n=await x?.(e,t,{silent:!0}):r===`drawings`?n=await S?.(e,t,{silent:!0}):r===`flowchart`&&(n=await C?.(e,t,{silent:!0})),n===!1)throw Error(`Failed to move document`)}(o||s)&&w&&await w(),d.success(r===`db-client`?`DB Client renamed successfully`:`Document updated successfully`),M(!1)}catch{d.error(r===`db-client`?`Failed to rename DB Client`:`Failed to update document`)}}};return(0,W.jsx)($r,{open:e,onOpenChange:M,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:T?`Create ${fb(r)}`:`Edit`}),(0,W.jsx)(Ur,{children:T?`Enter a name and select a workspace for your new ${fb(r)}.`:r===`db-client`?`Change the name of this DB Client.`:l?`Update the name and project for your ${fb(r)}.`:`Update the name of this ${fb(r)}.`})]}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`rename-input`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:T||r===`db-client`?`Name`:`New Name`}),(0,W.jsx)(Oi,{id:`rename-input`,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&P()},autoFocus:!0})]}),r!==`db-client`&&(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`document-project-select`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`Project`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(Er,{value:u,onValueChange:e=>e!==null&&f(e),disabled:!T&&!l||E||A,children:[(0,W.jsx)(Cr,{id:`document-project-select`,className:`min-w-0 flex-1`,children:(0,W.jsx)(Tr,{children:u===`none`?c?`Select Project`:`No project`:s.find(e=>e.id.toString()===u)?.name||`Select Project`})}),(0,W.jsxs)(Sr,{children:[!c&&(0,W.jsx)(xr,{value:`none`,children:`No project`}),s.map(e=>(0,W.jsx)(xr,{value:e.id.toString(),children:e.name},e.id))]})]}),T&&m&&(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`icon-lg`,className:`shrink-0`,"aria-label":E?`Cancel adding project`:`Add a project`,"aria-expanded":E,"aria-controls":`new-project-field`,disabled:A,onClick:()=>{D(!E),k(``)},children:E?(0,W.jsx)(Gr,{className:`size-4`}):(0,W.jsx)(zt,{className:`size-4`})})]}),T&&E&&(0,W.jsxs)(`div`,{id:`new-project-field`,className:`mt-3 space-y-2`,children:[(0,W.jsx)(Fr,{htmlFor:`new-project-name`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New project name`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{id:`new-project-name`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),N())},placeholder:`Enter project name`,className:`min-w-0 flex-1`,autoFocus:!0,disabled:A}),(0,W.jsx)(H,{type:`button`,size:`lg`,className:`shrink-0`,disabled:!O.trim()||A,onClick:()=>void N(),children:A?`Adding…`:`Add project`})]})]})]})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{disabled:E||A||!a.trim()||c&&u===`none`,onClick:P,className:`h-9 px-6`,children:T?`Create`:`Save Changes`})]})]})})};function wde(){let[e,t]=(0,U.useState)([]),[n,r]=(0,U.useState)(0),[i,a]=(0,U.useState)(!1);return{dbClients:e,dbClientsTotal:n,isDbClientsLoading:i,fetchDbClients:(0,U.useCallback)(async({projectId:e,query:n=``,page:i=1}={})=>{a(!0);try{let a=new URLSearchParams({limit:`10`,offset:String((i-1)*10)});e!=null&&e!==`all`&&a.set(`project_id`,String(e)),n.trim()&&a.set(`q`,n.trim());let o=await wi(`/api/db-clients?${a}`);if(!o.ok)throw Error(`Failed to load DB Clients`);let s=await o.json();t(Array.isArray(s.data)?s.data:[]),r(Number(s.total)||0)}catch(e){d.error(e.message||`Failed to load DB Clients`)}finally{a(!1)}},[]),deleteDbClient:(0,U.useCallback)(async e=>(await wi(`/api/db-clients/${encodeURIComponent(e)}`,{method:`DELETE`})).ok?(t(t=>t.filter(t=>String(t.uid??t.id)!==String(e))),r(e=>Math.max(0,e-1)),d.success(`DB Client moved to trash`),!0):(d.error(`Failed to move DB Client to trash`),!1),[])}}function Tde(){let e=y(),{projects:t,selectedWorkspaceUid:n,tableSearchParams:r,setTableSearchParams:i,fileSearchQuery:a,setFileSearchQuery:o,fileSearchRef:s}=ia(),{dbClients:c,dbClientsTotal:l,isDbClientsLoading:u,fetchDbClients:d,deleteDbClient:f}=wde(),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(``),[S,C]=(0,U.useState)(`none`),w=Math.max(1,Number(r.get(`page`))||1),T=(0,U.useMemo)(()=>n?t.find(e=>String(e.uid)===String(n)||String(e.id)===String(n))?.id??null:null,[t,n]);(0,U.useEffect)(()=>{d({projectId:T,query:a,page:w})},[d,a,w,T]);let E=(e,t=n)=>{let a=new URLSearchParams(r);t?a.set(`workspace`,t):a.delete(`workspace`),a.set(`page`,String(e)),i(a,{replace:!0})};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(cb,{mode:`db-client`,diagrams:c,projects:t,selectedWorkspace:n,page:w,totalDiagrams:l,isLoading:u,onSelectDiagram:t=>e(`/db-client/${t}`),onPageChange:e=>E(e),onWorkspaceClick:e=>E(1,e),onOpenEditDocument:e=>{let t=c.find(t=>String(t.uid??t.id)===String(e));t&&(g(t),x(t.name||``),v(!0))},onDeleteDiagram:e=>m(c.find(t=>String(t.uid??t.id)===String(e))),searchQuery:a,onSearchChange:o,searchRef:s}),(0,W.jsx)(db,{isOpen:!!p,onOpenChange:e=>{e||m(null)},activeDocument:p,view:`db-client`,onConfirm:()=>{let e=p?.uid??p?.id;e&&f(String(e)).then(()=>m(null))}}),(0,W.jsx)(pb,{isOpen:_,onOpenChange:e=>{v(e),e||g(null)},view:`db-client`,activeDocument:h,newName:b,setNewName:x,projects:t,selectedProjectId:S,setSelectedProjectId:C,updateDbClient:async(e,t)=>{if(!(await wi(`/api/db-clients/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})})).ok)throw Error(`Failed to rename DB Client`);await d({projectId:T,query:a,page:w})}})]})}function mb(){let{feature:e}=g(),{notes:t,notesTotal:n,diagrams:r,diagramsTotal:i,drawings:a,drawingsTotal:o,flowcharts:s,flowchartsTotal:c,projects:l,selectedWorkspaceUid:u,tableSearchParams:d,setTableSearchParams:f,handleNoteSelect:p,handleDiagramSelect:m,handleDrawingSelect:h,handleFlowchartSelect:_,handleOpenEditDocument:v,handleOpenCreateDocument:y,setItemToDelete:b,setIsMoveToTrashAlertOpen:x,setTableDeleteDoc:S,isNotesLoading:C,isDiagramsLoading:w,isDrawingsLoading:T,isFlowchartsLoading:E,setTableLoadingState:D,fileSearchQuery:O,setFileSearchQuery:k,fileSearchRef:A}=ia(),{user:j,isGuest:M}=ta(),N=e=>ji(e,j?.id,M),P=e=>m(e),F=parseInt(d.get(`page`)||`1`,10),I=e=>{D(`loading`);let t=new URLSearchParams(d);t.set(`page`,String(e)),f(t,{replace:!0})},L=e=>{D(`loading`);let t=new URLSearchParams(d);e?t.set(`workspace`,e):t.delete(`workspace`),t.set(`page`,`1`),f(t,{replace:!0})},R=e=>t=>{let n=e?.find(e=>e.uid===t||String(e.id)===t||e.key===t);n&&(b({id:n.id||n.uid,type:n.type,uid:n.uid}),S(n),x(!0))};switch(e){case`notes`:return(0,W.jsx)(ide,{notes:t,projects:l,selectedWorkspace:u,page:F,totalNotes:n,isLoading:C,onSelectNote:p,onCreateNote:()=>y(`notes`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteNote:R(t),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`erd`:return(0,W.jsx)(cb,{diagrams:r,projects:l,selectedWorkspace:u,page:F,totalDiagrams:i,isLoading:w,onSelectDiagram:e=>P(e),onCreateDiagram:()=>y(`erd`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteDiagram:R(r),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`db-client`:return(0,W.jsx)(Tde,{});case`drawings`:return(0,W.jsx)(yde,{drawings:a,projects:l,selectedWorkspace:u,page:F,totalDrawings:o,isLoading:T,onSelectDrawing:h,onCreateDrawing:()=>y(`drawings`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteDrawing:R(a),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});case`flowchart`:return(0,W.jsx)(Sde,{flowcharts:s,projects:l,selectedWorkspace:u,page:F,totalFlowcharts:c,isLoading:E,onSelectFlowchart:_,onCreateFlowchart:()=>y(`flowchart`),onPageChange:I,onWorkspaceClick:L,onOpenEditDocument:e=>v(e),onDeleteFlowchart:R(s),canDeleteFile:N,searchQuery:O,onSearchChange:k,searchRef:A});default:return(0,W.jsx)(Cde,{})}}var Ede={erd:`erd_builder`,notes:`notes`,drawings:`drawings`,flowchart:`flowcharts`,flowcharts:`flowcharts`,"db-client":`desktop_only`},Dde={erd_builder:`ERD Builder`,notes:`Notes`,drawings:`Drawings`,flowcharts:`Flowcharts`,desktop_only:`DB Client`};function Ode({capability:e,teamName:t,ssoPortalUrl:n}){let r=y(),i=Dde[e];return(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-10`,children:(0,W.jsxs)(`section`,{className:`w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,W.jsx)(tr,{className:`size-5`,"aria-hidden":`true`})}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`h1`,{className:`text-base font-semibold text-foreground`,children:[`Unlock `,i]}),(0,W.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[i,` is not included in `,t||`this Team`,`'s current Cloud plan. Upgrade to continue using it.`]})]})]}),(0,W.jsx)(`div`,{className:`mt-5 flex justify-end border-t border-border pt-4`,children:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(H,{variant:`outline`,onClick:()=>r(`/`),children:`Return to dashboard`}),n&&(0,W.jsx)(H,{onClick:()=>{if(n)try{window.location.assign(new URL(`/pricing#cloud-saas`,n).toString())}catch{}},children:`View Cloud plans`})]})})]})})}function hb({capability:e,children:t}){let{user:n}=ta(),{activeTeamId:r,activeTeam:i,isLoading:a}=w();return!n?.isSso||!r?(0,W.jsx)(W.Fragment,{children:t}):a?(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Checking Team plan…`}):e!==`desktop_only`&&i?.capabilities?.[e]===!0?(0,W.jsx)(W.Fragment,{children:t}):(0,W.jsx)(Ode,{capability:e,teamName:i?.name,ssoPortalUrl:n?.ssoPortalUrl??n?.sso_portal_url})}function kde(){let{feature:e}=g(),t=e?Ede[e]:void 0;return t?(0,W.jsx)(hb,{capability:t,children:(0,W.jsx)(mb,{})}):(0,W.jsx)(mb,{})}var gb=U.createContext(void 0);function _b(){let e=U.useContext(gb);if(e===void 0)throw Error(Ne(64));return e}var Ade=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),vb={tabActivationDirection:e=>({[Ade.activationDirection]:e})},jde=U.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,...c}=e,l=sn(),u=Object.hasOwn(e,`defaultValue`),d=U.useRef([]),[f,p]=U.useState(()=>new Map),[m,h]=cn({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=U.useState(()=>new Map),[y,b]=U.useState(`none`),x=ke((e,t)=>{i?.(e,t),!t.isCanceled&&(h(e),b(t.activationDirection))}),S=ke((e,t)=>{p(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}),C=ke((e,t)=>{p(n=>{if(!n.has(e)||n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})}),w=U.useCallback(e=>f.get(e),[f]),T=U.useCallback(e=>{for(let t of _.values())if(e===t?.value)return t?.id},[_]),E=U.useCallback(e=>{if(e===void 0)return null;for(let[t,n]of _.entries())if(n!=null&&e===(n.value??n.index))return t;return null},[_]),D=U.useMemo(()=>({direction:l,getTabElementBySelectedValue:E,getTabIdByPanelValue:T,getTabPanelIdByValue:w,onValueChange:x,orientation:a,registerMountedTabPanel:S,setTabMap:v,unregisterMountedTabPanel:C,tabActivationDirection:y,value:m}),[l,E,T,w,x,a,S,v,C,y,m]),O=U.useMemo(()=>{for(let e of _.values())if(e!=null&&e.value===m)return e},[_,m]),k=U.useMemo(()=>{for(let e of _.values())if(e!=null&&!e.disabled)return e.value},[_]);Oe(()=>{if(g||_.size===0)return;let e=O?.disabled;if(u&&e&&m===r||!e&&(O!=null||m===null))return;let t=k??null;m!==t&&(h(t),b(`none`))},[r,k,u,g,O,b,h,_,m]);let A=Pe(`div`,e,{state:{orientation:a,tabActivationDirection:y},ref:t,props:c,stateAttributesMapping:vb});return(0,W.jsx)(gb.Provider,{value:D,children:(0,W.jsx)(un,{elementsRef:d,children:A})})}),yb=U.createContext(void 0);function Mde(){let e=U.useContext(yb);if(e===void 0)throw Error(Ne(65));return e}var Nde=U.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=_b(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=Mde(),v=Xe(o),y=U.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a]),{compositeProps:b,compositeRef:x,index:S}=ki({metadata:y}),C=a===l,w=U.useRef(!1),T=U.useRef(null);U.useEffect(()=>{let e=T.current;if(e)return h(e)},[h]),Oe(()=>{if(w.current){w.current=!1;return}if(!(C&&S>-1&&p!==S))return;let e=_;if(e!=null){let t=Ve(qe(e));if(t&&ot(e,t))return}r||g(S)},[C,S,p,g,r,_]);let{getButtonProps:E,buttonRef:D}=Me({disabled:r,native:s,focusableWhenDisabled:!0}),O=u(a),k=U.useRef(!1),A=U.useRef(!1);function j(e){C||r||m(a,gt(Ze,e.nativeEvent,void 0,{activationDirection:`none`}))}function M(e){C||(S>-1&&!r&&g(S),!r&&f&&(!k.current||k.current&&A.current)&&m(a,gt(Ze,e.nativeEvent,void 0,{activationDirection:`none`})))}function N(e){if(C||r)return;k.current=!0;function t(){k.current=!1,A.current=!1}e.button&&e.button!==0||(A.current=!0,qe(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return Pe(`button`,e,{state:{disabled:r,active:C,orientation:d},ref:[t,D,x,T],props:[b,{role:`tab`,"aria-controls":O,"aria-selected":C,id:v,onClick:j,onFocus:M,onPointerDown:N,[Wy]:C?``:void 0,onKeyDownCapture(){w.current=!0}},c,E]})}),Pde=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=He.startingStyle]=`startingStyle`,e[e.endingStyle=He.endingStyle]=`endingStyle`,e}({}),Fde={...vb,...$e},Ide=U.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=_b(),p=Xe(),m=U.useMemo(()=>({id:p,value:r}),[p,r]),{ref:h,index:g}=ln({metadata:m}),_=r===s,{mounted:v,transitionStatus:y,setMounted:b}=We(_),x=!v,S=c(r),C={hidden:x,orientation:l,tabActivationDirection:u,transitionStatus:y},w=U.useRef(null),T=Pe(`div`,e,{state:C,ref:[t,h,w],props:[{"aria-labelledby":S,hidden:x,id:p,role:`tabpanel`,tabIndex:_?0:-1,inert:St(!_),[Pde.index]:g},o],stateAttributesMapping:Fde});return Je({open:_,ref:w,onComplete(){_||b(!1)}}),Oe(()=>{if((!x||a)&&p!=null)return d(r,p),()=>{f(r,p)}},[x,a,r,p,d,f]),a||v?T:null}),Lde=U.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=_b(),[p,m]=U.useState(0),[h,g]=U.useState(null),_=U.useRef(new Set),v=U.useRef(new Set),y=U.useRef(null),b=ke(()=>{_.current.forEach(e=>{e()})});U.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=ke(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=ke(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=Rde(u,l,h,s),w=ke((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=U.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,W.jsx)(yb.Provider,{value:D,children:(0,W.jsx)(Yy,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:vb,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:Fe})})});function bb(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function Rde(e,t,n,r){let[i,a]=U.useState(null);return Oe(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=bb(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),U.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=bb(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var xb=r(u(),1);function Sb({className:e,orientation:t=`horizontal`,...n}){return(0,W.jsx)(jde,{"data-slot":`tabs`,"data-orientation":t,className:c(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var zde=Re(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Cb({className:e,variant:t=`default`,...n}){return(0,W.jsx)(Lde,{"data-slot":`tabs-list`,"data-variant":t,className:c(zde({variant:t}),e),...n})}function wb({className:e,...t}){return(0,W.jsx)(Nde,{"data-slot":`tabs-trigger`,className:c(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Bde({className:e,...t}){return(0,W.jsx)(Ide,{"data-slot":`tabs-content`,className:c(`flex-1 text-sm outline-none`,e),...t})}var Tb=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`textarea`,{className:c(`flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Tb.displayName=`Textarea`;function Vde({userName:e,value:t,onChange:n,onSubmit:r,disabled:i=!1,placeholder:a=`Reply…`,submitLabel:o=`Send reply`}){let[s,c]=(0,U.useState)(!1),l=(0,U.useRef)(null),u=s||t.length>0;(0,U.useEffect)(()=>{s&&l.current?.focus()},[s]),(0,U.useEffect)(()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[t,u]);let d=()=>{n(``),c(!1)},f=()=>{t.trim()&&!i&&(r(),c(!1))};return u?(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),f()},className:`shrink-0 border-t border-border p-3`,children:(0,W.jsxs)(`div`,{className:`flex items-end gap-1.5 rounded-lg border border-primary/60 bg-background px-2.5 py-1.5 ring-2 ring-primary/20`,children:[(0,W.jsx)(`textarea`,{"data-comment-draft":!0,ref:l,rows:1,maxLength:4e3,value:t,disabled:i,"aria-label":o,placeholder:a,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f())},className:`min-h-6 max-h-32 flex-1 resize-none bg-transparent py-0.5 text-sm outline-none placeholder:text-muted-foreground`}),(0,W.jsx)(H,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Cancel reply`,onClick:d,disabled:i,children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-3.5`})}),(0,W.jsx)(H,{type:`submit`,size:`icon-xs`,className:`rounded-full`,"aria-label":o,disabled:!t.trim()||i,children:(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-3.5`})})]})}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex w-full shrink-0 items-center gap-2.5 border-t border-border px-4 py-2.5 text-left text-sm text-muted-foreground transition-colors hover:bg-muted/50`,children:[(0,W.jsx)(Dn,{name:e,className:`size-7`}),a]})}function Eb(e,t=144){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function Db({value:e,onChange:t,className:n,...r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{i.current&&Eb(i.current)},[e]),(0,W.jsx)(Tb,{"data-comment-draft":!0,...r,ref:i,rows:1,value:e,onChange:e=>{t(e.target.value),Eb(e.currentTarget)},maxLength:4e3,className:n})}function Hde({id:e,value:t,onChange:n,onSubmit:r,placeholder:i,disabled:a,submitLabel:o}){return(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border p-3`,children:(0,W.jsxs)(`form`,{onSubmit:r,className:`relative`,children:[(0,W.jsx)(`label`,{htmlFor:e,className:`sr-only`,children:o}),(0,W.jsx)(Db,{id:e,value:t,onChange:n,placeholder:i,className:`min-h-11! max-h-36 resize-none overflow-y-auto rounded-2xl bg-muted/40 px-3 py-2 pr-12 shadow-none`,required:!0}),(0,W.jsx)(H,{type:`submit`,size:`icon`,className:`absolute right-1 bottom-1 size-9 rounded-full`,"aria-label":o,disabled:!t.trim()||a,children:(0,W.jsx)(Fo,{"aria-hidden":`true`})})]})})}function Ob(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r&&n.set(e,r);let r=n.toString();return r?`${e}?${r}`:e}async function kb(e,t){let n=await wi(e,t),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`The request could not be completed.`);return r}function Ude({message:e,canEdit:t,editing:n,editDraft:r,editOriginalBody:i,disabled:a,onEdit:o,onDelete:s,onEditDraftChange:c,onCancelEdit:l,onSaveEdit:u}){let d=e.body!==i;return(0,W.jsxs)(`div`,{className:`group/message relative flex gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-muted/40 focus-within:bg-muted/40`,children:[(0,W.jsx)(Dn,{name:e.authorName,className:`mt-0.5 size-7`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.authorName}),(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,title:Kde(e.createdAt),children:vn(e.createdAt)})]}),n&&t?(0,W.jsxs)(`form`,{onSubmit:u,className:`mt-1 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-end gap-1.5 rounded-lg border border-primary/60 bg-background px-2.5 py-1.5 ring-2 ring-primary/20`,children:[(0,W.jsx)(Db,{autoFocus:!0,onFocus:e=>{let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)},"aria-label":`Edit your message`,value:r,onChange:c,className:`min-h-6! max-h-32 flex-1 resize-none overflow-y-auto border-0 bg-transparent p-0 py-0.5 text-sm shadow-none focus-visible:ring-0`,disabled:a}),(0,W.jsx)(H,{type:`button`,variant:`secondary`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Cancel edit`,onClick:l,disabled:a,children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-3.5`})}),(0,W.jsx)(H,{type:`submit`,size:`icon-xs`,className:`rounded-full`,"aria-label":`Save message`,disabled:a||!r.trim()||d,children:(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-3.5`})})]}),d&&(0,W.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:`This message changed. Cancel and edit the latest version.`})]}):(0,W.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-sm`,children:e.body})]}),t&&!n&&(0,W.jsxs)(`div`,{className:`absolute -top-3 right-1 z-10 hidden rounded-md border bg-popover shadow-sm group-hover/message:flex group-focus-within/message:flex [@media(hover:none)]:flex`,children:[(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Edit message`,onClick:o,children:(0,W.jsx)(_r,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,children:`Edit`})]}),(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete message`,onClick:s,children:(0,W.jsx)(ni,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,children:`Delete`})]})]})]})}function Ab(e,t){let n=e.featureType??e.feature_type??t?.featureType,r=e.anchorType??e.anchor_type??t?.anchorType;if(![`diagram`,`note`,`drawing`,`flowchart`].includes(String(n))||r!=null&&![`general`,`table`,`relationship`,`block`,`shape`,`point`].includes(String(r)))return null;let i=e.fileId??e.file_id??t?.fileId;return i==null?null:{featureType:n,fileId:String(i),fileName:e.fileName==null&&e.file_name==null?t?.fileName??null:String(e.fileName??e.file_name),anchorType:r??`general`,anchorId:e.anchorId==null&&e.anchor_id==null&&t?.anchorId==null?null:String(e.anchorId??e.anchor_id??t?.anchorId),anchorLabel:String(e.anchorLabel??e.anchor_label??t?.anchorLabel??`General`)}}function jb(e){let t=Array.isArray(e.contexts)?e.contexts.map(e=>Ab(e)).filter(Boolean):[],n=Ab(e,t[0])||t[0]||null,r=e.anchorType??e.anchor_type,i=[`general`,`table`,`relationship`,`block`,`shape`,`point`].includes(String(r))?r:`general`,a=e.status,o=e.previewMessages??e.preview_messages,s=Array.isArray(o)?o.map(e=>Mb(e)):typeof o==`string`?(()=>{try{let e=JSON.parse(o);return Array.isArray(e)?e.map(e=>Mb(e)):[]}catch{return[]}})():[],c=e.latestMessage==null&&e.latest_message==null?null:{id:String(e.latestMessageId??e.latest_message_id??`latest`),authorId:String(e.latestAuthorId??e.latest_author_id??``),authorName:`Team member`,body:String(e.latestMessage??e.latest_message??``),createdAt:String(e.lastMessageAt??e.last_message_at??``)};return{id:String(e.id??``),featureType:n?.featureType??null,fileId:n?.fileId??(e.fileId==null&&e.file_id==null?null:String(e.fileId??e.file_id)),anchorType:n?.anchorType??i,anchorId:n?.anchorId??(e.anchorId==null&&e.anchor_id==null?null:String(e.anchorId??e.anchor_id)),anchorLabel:n?.anchorLabel??String(e.anchorLabel??e.anchor_label??`General`),contexts:t.length>0?t:n?[n]:[],status:a===`resolved`?`resolved`:`open`,canDelete:!!(e.canDelete??e.can_delete),unread:!!e.unread,latestMessageId:e.latestMessageId==null&&e.latest_message_id==null?null:String(e.latestMessageId??e.latest_message_id),latestMessage:e.latestMessage==null&&e.latest_message==null?null:String(e.latestMessage??e.latest_message),latestAuthorId:e.latestAuthorId==null&&e.latest_author_id==null?null:String(e.latestAuthorId??e.latest_author_id),lastMessageAt:e.lastMessageAt==null&&e.last_message_at==null?null:String(e.lastMessageAt??e.last_message_at),previewMessages:s.length>0?s:c?[c]:[]}}function Mb(e){return{id:String(e.id??``),threadId:e.threadId==null&&e.thread_id==null?void 0:String(e.threadId??e.thread_id),authorId:String(e.authorId??e.author_id??``),authorName:String(e.authorName??e.author_name??`Team member`),body:String(e.body??``),createdAt:String(e.createdAt??e.created_at??``)}}function Nb(e){let t=e.nextCursor;return{hasMore:e.hasMore===!0,nextCursor:t?.createdAt&&t.id?{createdAt:String(t.createdAt),id:String(t.id)}:null}}function Pb(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return[...n.values()].sort((e,t)=>Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.id.localeCompare(t.id))}function Fb(e,t,n){let r=Pb(e.messages,t).slice(-Math.max(50,e.messages.length)),i=r[0],a=e.hasMore||n.hasMore;return{messages:r,hasMore:a,nextCursor:a&&i?{createdAt:i.createdAt,id:i.id}:null}}function Wde(e,t,n,r){return e===`thread`?t===`comments`&&n?{kind:`anchor`,anchor:n,threadId:r}:r?{kind:`thread`,threadId:r}:null:null}function Gde(e){return[e.featureType||`diagram`,e.fileId||``,e.anchorType,e.anchorId||``].join(`:`)}function Ib(e){let t=new Map;for(let n of e){let e=Gde(n),r=t.get(e);r?(r.threads.push(n),r.previewMessages.push(...n.previewMessages)):t.set(e,{key:e,representative:n,threads:[n],previewMessages:[...n.previewMessages]})}return[...t.values()].map(e=>({...e,previewMessages:e.previewMessages.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()).slice(-3)}))}function Kde(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function qde(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:Gn(t,{addSuffix:!0})}function Lb(e){return e===`diagram`?`ERD`:e===`note`?`Notes`:e===`drawing`?`Drawing`:e===`flowchart`?`Flowchart`:`File`}var Jde={diagram:{Icon:Ar,className:`bg-feature-erd/10 text-feature-erd`},note:{Icon:Nt,className:`bg-feature-notes/10 text-feature-notes`},drawing:{Icon:Mr,className:`bg-feature-drawing/10 text-feature-drawing`},flowchart:{Icon:Eo,className:`bg-feature-flowchart/10 text-feature-flowchart`}},Yde={diagram:new Set([`table`,`relationship`]),note:new Set([`block`]),drawing:new Set([`point`]),flowchart:new Set([`shape`])};function Rb(e,t){return typeof t==`string`&&Yde[e].has(t)}function zb({projectId:e,teamId:t,userId:n,userName:r,fileContext:i,anchorContext:a,onContextSelected:o,anchorPreview:s,readOnly:l=!1}){let u=R(),f=(0,U.useId)(),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(`discussions`),_=h===`comments`,[v,y]=(0,U.useState)(`file`),[b,x]=(0,U.useState)(`list`),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)([]),[E,D]=(0,U.useState)(0),[O,k]=(0,U.useState)({messages:[],hasMore:!1,nextCursor:null}),[A,j]=(0,U.useState)(!1),[M,N]=(0,U.useState)(``),[P,F]=(0,U.useState)(!0),[I,L]=(0,U.useState)(!1),[ee,te]=(0,U.useState)(``),[ne,re]=(0,U.useState)(``),[ie,z]=(0,U.useState)(null),[ae,oe]=(0,U.useState)(``),[se,ce]=(0,U.useState)(``),[le,ue]=(0,U.useState)(null),[de,B]=(0,U.useState)(!1),[fe,pe]=(0,U.useState)(``),[me,he]=(0,U.useState)(null),[ge,_e]=(0,U.useState)(null),[ve,V]=(0,U.useState)(null),ye=O.messages,be=(0,U.useRef)(0),xe=(0,U.useRef)(0),Se=(0,U.useRef)(0),Ce=(0,U.useRef)(new Map),we=(0,U.useRef)(!1),Te=(0,U.useRef)({screen:b,selectedThreadId:S});Te.current={screen:b,selectedThreadId:S};let Ee=(0,U.useCallback)(()=>{Te.current={screen:`list`,selectedThreadId:null},xe.current++,Se.current++,x(`list`),C(null),k({messages:[],hasMore:!1,nextCursor:null}),j(!1),N(``),re(``),z(null),oe(``),ce(``),ue(null),V(null)},[]),De=(0,U.useCallback)(e=>{let t=e;t!==h&&(Ee(),he(null),pe(``),g(t))},[h,Ee]),Oe=`/api/projects/${encodeURIComponent(e)}/${h===`comments`?`comments`:`discussions`}`,ke=(0,U.useMemo)(()=>Ob(Oe,{scope:h===`discussions`?v:void 0,feature_type:i.featureType,file_id:i.fileId,anchor_type:h===`comments`&&!_&&a?a.type:void 0,anchor_id:h===`comments`&&!_&&a?a.id:void 0}),[h,a,v,Oe,i.featureType,i.fileId,_]),Ae=(0,U.useCallback)(e=>Ob(`${Oe}/${encodeURIComponent(e)}`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),[h,Oe,i.featureType,i.fileId]),je=(0,U.useCallback)(async(e=!1)=>{let t=++be.current;te(``),we.current||F(!0);try{let r=await kb(ke);if(t!==be.current)return[];let i=Array.isArray(r.threads)?r.threads.map(e=>jb(e)):[];if(e&&we.current)for(let e of i){let t=Ce.current.get(e.id);e.latestMessageId&&e.latestAuthorId!==n&&(t&&e.latestMessageId!==t||!t&&e.unread)&&d.info(`New activity in ${e.contexts[0]?.fileName||`Project discussion`}`)}Ce.current=new Map(i.filter(e=>e.latestMessageId).map(e=>[e.id,e.latestMessageId])),we.current=!0,T(i);let a=Te.current;return a.screen===`thread`&&a.selectedThreadId&&!i.some(e=>e.id===a.selectedThreadId)&&Ee(),D(Number(r.unreadCount??r.unread_count)||0),i}catch{return t===be.current&&te(`Couldn't load ${h}. Try again.`),[]}finally{t===be.current&&F(!1)}},[h,Ee,ke,n]),Me=(0,U.useCallback)(e=>{o?.({featureType:i.featureType,fileId:i.fileId,anchorType:e.type,anchorId:e.id,anchorLabel:e.type===`table`?`Table`:e.type===`relationship`?`Relationship`:e.type[0].toUpperCase()+e.type.slice(1)})},[i.featureType,i.fileId,o]),Ne=(0,U.useCallback)(async(e,t,n=!1)=>{let r=++xe.current;n||re(``);try{let a=await kb(Ae(e));if(r!==xe.current)return!1;let s=Array.isArray(a.messages)?a.messages.map(e=>Mb(e)):[],c=Nb(a);k(e=>n?Fb(e,s,c):{...c,messages:s}),n||N(``),t&&kb(Ob(`${Ae(e)}/read`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`POST`}).then(()=>je()).catch(()=>{});let l=Array.isArray(a.contexts)?a.contexts.map(e=>Ab(e)).filter(Boolean):[];return l[0]&&o?.(l[0]),!0}catch{return!n&&r===xe.current&&re(`Couldn't load this ${h===`comments`?`comment`:`discussion`}. Try again.`),!1}},[h,i.fileId,i.featureType,je,o,Ae]),Pe=(0,U.useCallback)(async(e,t,n=!1,r)=>{let a=++xe.current;n||re(``);try{let s=await kb(Ob(`${Oe}/anchor`,{feature_type:i.featureType,file_id:i.fileId,anchor_type:e.type,anchor_id:e.id}));if(a!==xe.current)return!1;let c=Array.isArray(s.threads)?s.threads.map(e=>jb(e)):[];if(!c.length)return Ee(),!0;let l=Array.isArray(s.messages)?s.messages.map(e=>Mb(e)):[];T(e=>{let t=new Map(c.map(e=>[e.id,e]));return e.map(e=>{let n=t.get(e.id);return n?{...e,...n}:e})});let u=Nb(s);k(e=>n?Fb(e,l,u):{...u,messages:l}),n||N(``);let d=c.some(e=>e.id===r)?r:c[0].id;C(d);let f=Array.isArray(s.contexts)?s.contexts.map(e=>Ab(e)).filter(Boolean):[];return f[0]?o?.(f[0]):Me(e),t&&Promise.all(c.map(e=>kb(Ob(`${Oe}/${encodeURIComponent(e.id)}/read`,{feature_type:i.featureType,file_id:i.fileId}),{method:`POST`}).catch(()=>null))).then(()=>je()),!0}catch{return!n&&a===xe.current&&re(`Couldn't load the full comment history. Try again.`),!1}},[Ee,Oe,i.fileId,i.featureType,Me,je,o]),Fe=(0,U.useCallback)(e=>{if(!p)return;let t=Wde(b,h,ve,S);t&&(t.kind===`anchor`?Pe(t.anchor,e,!0,t.threadId||void 0):Ne(t.threadId,e,!0))},[ve,h,Pe,Ne,p,b,S]),Ie=(0,U.useCallback)(async()=>{let e=O.nextCursor,t=S;if(!O.hasMore||!e||!t||A)return;let n=++Se.current,r=xe.current;j(!0),N(``);try{let a={before_created_at:e.createdAt,before_id:e.id},o=await kb(_&&ve?Ob(`${Oe}/anchor`,{feature_type:i.featureType,file_id:i.fileId,anchor_type:ve.type,anchor_id:ve.id,...a}):Ob(Ae(t),a));if(n!==Se.current||r!==xe.current)return;let s=Array.isArray(o.messages)?o.messages.map(e=>Mb(e)):[],c=Nb(o);k(e=>({...c,messages:Pb(e.messages,s)}))}catch{n===Se.current&&N(`Could not load earlier messages.`)}finally{n===Se.current&&j(!1)}},[ve,Oe,i.featureType,i.fileId,_,A,O,S,Ae]);(0,U.useEffect)(()=>{we.current=!1,x(`list`),C(null),k({messages:[],hasMore:!1,nextCursor:null}),T([]),je()},[je]),(0,U.useEffect)(()=>{let n=e=>{let n=e.detail;n?.teamId!==t||n.eventType&&n.eventType!==`cloud.workspace.sync`||(je(!0),Fe(document.visibilityState===`visible`))},r=e=>{e.detail?.teamId===t&&(je(),Fe(document.visibilityState===`visible`))},i=n=>{let r=n.detail;r?.teamId===t&&String(r.projectId)===String(e)&&je(!0)};return window.addEventListener(`cloud-workspace-sync`,n),window.addEventListener(`cloud-live-sync-reconnected`,r),window.addEventListener(`collaboration-updated`,i),()=>{window.removeEventListener(`cloud-workspace-sync`,n),window.removeEventListener(`cloud-live-sync-reconnected`,r),window.removeEventListener(`collaboration-updated`,i)}},[je,e,Fe,t]),(0,U.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>{je(!0),document.hidden||Fe(!0)},15e3);return()=>window.clearInterval(e)},[je,p,Fe]),(0,U.useEffect)(()=>{let e=e=>{let t=e.detail;!t?.id||t.featureType!==i.featureType||t.fileId&&String(t.fileId)!==i.fileId||!Rb(i.featureType,t.type)||(he({type:t.type,id:t.id}),pe(``),re(``),g(`comments`),m(!0))};return window.addEventListener(`project-comment-open-request`,e),()=>window.removeEventListener(`project-comment-open-request`,e)},[i.fileId,i.featureType]),(0,U.useEffect)(()=>{if(h!==`comments`||!me)return;let e=!1,t=me;return V(t),_e(t),(async()=>{let n=await je();if(e)return;let r=Ib(n).find(e=>e.representative.anchorType===t.type&&e.representative.anchorId===t.id);r?(x(`thread`),C(r.representative.id),await Pe(t,!0,!1,r.representative.id)):x(l?`list`:`compose`),e||he(null)})(),()=>{e=!0}},[h,Pe,je,me]);let Le=(b===`thread`||b===`compose`)&&fe.trim()!==``||ie!==null&&ae!==se,Re=(e,t)=>{if(!e&&(le||de))return;let n=t?.event?.target;!e&&u&&t?.reason===`outside-press`&&n instanceof Element&&!u.host.current?.contains(n)||!e&&t?.reason===`outside-press`&&n instanceof Element&&n.closest(`[data-slot="dropdown-menu-content"]`)||(!e&&Le?B(!0):(m(e),e?(je(),b===`thread`&&_&&ve?Pe(ve,!0,!1,S||void 0):b===`thread`&&S&&Ne(S,!0)):(Ke(),ue(null))))},ze=async e=>{pe(``),Ke(),ue(null);let t=e.contexts[0]||Ab(e),n=t?.anchorType??e.anchorType,r=t?.anchorId??e.anchorId,a=t?.featureType??e.featureType??i.featureType,s=r&&Rb(a,n)?{type:n,id:r}:null;_&&s?(V(s),x(`thread`),C(e.id),k({messages:[],hasMore:!1,nextCursor:null}),Me(s),await Pe(s,!0,!1,e.id)):(x(`thread`),C(e.id),k({messages:[],hasMore:!1,nextCursor:null}),await Ne(e.id,!0)&&t&&o?.(t))},Be=async e=>{let t=e.representative.featureType??i.featureType;e.representative.anchorType&&e.representative.anchorId&&Rb(t,e.representative.anchorType)&&{type:e.representative.anchorType,id:e.representative.anchorId}&&await ze(e.representative)},Ve=()=>{let e=h===`comments`?(_?ve:a)??null:null;h===`comments`&&!e?d.info(`Select an item on this file before adding a comment.`):(_e(e),pe(``),re(``),Ke(),x(`compose`))},He=()=>window.dispatchEvent(new CustomEvent(`collaboration-updated`,{detail:{teamId:t,projectId:e}})),Ue=async e=>{e.preventDefault();let t=fe.trim();if(t&&!I){L(!0),re(``);try{let e=await kb(Oe,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:t,context:{type:h===`comments`?ge?.type:`general`,...h===`comments`?{id:ge?.id}:{},featureType:i.featureType,fileId:i.fileId}})});pe(``),_e(null),C(e.id),x(`thread`),He(),await je(),_&&ge?await Pe(ge,!0,!1,e.id):await Ne(e.id,!0)}catch{re(`Couldn't start the ${h===`comments`?`comment`:`discussion`}. Try again.`)}finally{L(!1)}}},We=async()=>{let e=fe.trim();if(e&&S&&!I){L(!0),re(``);try{await kb(Ob(`${Oe}/${encodeURIComponent(S)}/messages`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:e})}),pe(``),He(),_&&ve?await Pe(ve,!0,!0,S):await Ne(S,!0,!0),await je()}catch{re(`Couldn't send the reply. Reopen the ${h===`comments`?`comment`:`discussion`} if it was resolved.`)}finally{L(!1)}}},Ge=e=>{h===`discussions`&&e.authorId===n&&(z(e.id),oe(e.body),ce(e.body))},Ke=()=>{z(null),oe(``),ce(``)},qe=async(e,t)=>{t.preventDefault();let r=ae.trim(),i=S;if(h===`discussions`&&e.authorId===n&&i&&r&&e.body===se&&!I){L(!0);try{await kb(`${Oe}/${encodeURIComponent(i)}/messages/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:r,expectedBody:se})}),k(t=>({...t,messages:t.messages.map(t=>t.id===e.id?{...t,body:r}:t)})),Ke(),He()}catch(e){await Ne(i,!0,!0),d.error(e instanceof Error?e.message:`Couldn't update this message. Try again.`)}finally{L(!1)}}},Je=async e=>{let t=w.find(t=>t.id===e);if(h===`discussions`&&t?.canDelete&&!I){L(!0);try{await kb(`${Oe}/${encodeURIComponent(t.id)}`,{method:`DELETE`}),ue(null),S===e&&Ee(),He()}catch(e){d.error(e instanceof Error?e.message:`Couldn't delete this discussion. Try again.`)}finally{L(!1)}}},Ye=async(e,t)=>{if(!(h!==`discussions`||S!==e||t.authorId!==n||I)){L(!0);try{await kb(`${Oe}/${encodeURIComponent(e)}/messages/${encodeURIComponent(t.id)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({expectedBody:t.body})}),k(e=>({...e,messages:e.messages.filter(e=>e.id!==t.id)})),ie===t.id&&Ke(),ue(null),await je(),He()}catch(t){await Ne(e,!0,!0),d.error(t instanceof Error?t.message:`Couldn't delete this message. Try again.`)}finally{L(!1)}}},Xe=async()=>{let e=w.find(e=>e.id===S);if(!e||I)return;L(!0);let t=e.status;try{await kb(Ob(`${Oe}/${encodeURIComponent(e.id)}`,h===`comments`?{feature_type:i.featureType,file_id:i.fileId}:{}),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:t===`open`?`resolved`:`open`,expectedStatus:t})}),He(),await je()}catch(e){re(e instanceof Error?e.message:`Couldn't update this ${h===`comments`?`comment`:`discussion`}. Try again.`),await je()}finally{L(!1)}},Ze=w.find(e=>e.id===S),Qe=(0,U.useMemo)(()=>Ib(w),[w]),$e=h===`discussions`?`Discussions`:b===`compose`?`New comment`:b===`thread`?Ze?.anchorLabel||`Comment`:`Comments`,et=b===`list`?v===`file`?i.label:null:b===`compose`?i.label:Ze?.contexts[0]?.fileName||(Ze?.fileId===i.fileId?i.label:null),tt=h===`comments`?_?`Latest activity on ${i.label}`:`Comments on ${i.label}`:et?`Related to ${et}`:b===`list`?`All project discussions`:`Project discussion`,nt=`${f}-description`;return(0,W.jsxs)(Ut,{open:p,onOpenChange:Re,children:[(0,W.jsx)(Vt,{render:(0,W.jsxs)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`relative shrink-0 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`${_?`Open comments`:`Open discussions`}${E?`, ${E} unread`:``}`,title:_?`Comments`:`Discussions`,children:[_?(0,W.jsx)(ar,{"aria-hidden":`true`}):(0,W.jsx)(Co,{"aria-hidden":`true`}),E>0&&(0,W.jsx)(tm,{variant:`default`,className:`absolute -right-1 -top-1 h-4 min-w-4 px-1 text-[10px] leading-none`,children:E})]})}),(0,W.jsxs)(Rt,{anchor:u?()=>{let e=u.host.current;return e?{contextElement:e,getBoundingClientRect:()=>{let t=e.getBoundingClientRect();return new DOMRect(t.right-8,t.top+8,0,0)}}:null}:void 0,side:u?`bottom`:`left`,align:u?`end`:`start`,sideOffset:8,"data-discussions-panel":``,className:c(`flex h-[min(42rem,calc(100svh-5rem))] w-[min(24rem,calc(100vw-1rem))] max-w-[calc(100vw-1rem)] flex-col gap-0 overflow-hidden p-0`,u&&`max-h-(--available-height)`),"aria-describedby":nt,children:[(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border px-3 py-2`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b!==`list`&&(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Back to list`,onClick:()=>x(`list`),children:(0,W.jsx)(pa,{"aria-hidden":`true`,className:`size-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:$e}),(0,W.jsx)(`p`,{id:nt,className:`truncate text-xs text-muted-foreground`,children:tt})]}),h===`discussions`&&b===`thread`&&Ze&&!l&&(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Discussion actions`,children:(0,W.jsx)(Nr,{"aria-hidden":`true`,className:`size-4`})})}),(0,W.jsx)(en,{align:`end`,className:`w-44`,positionerClassName:`z-[210]`,children:(0,W.jsxs)(Yt,{children:[(0,W.jsxs)(Kt,{onClick:()=>void Xe(),disabled:I,children:[Ze.status===`open`?(0,W.jsx)(an,{"aria-hidden":`true`}):(0,W.jsx)(Xn,{"aria-hidden":`true`}),Ze.status===`open`?`Resolve`:`Reopen`]}),Ze.canDelete&&(0,W.jsxs)(Kt,{variant:`destructive`,onClick:()=>ue({type:`thread`,threadId:Ze.id}),children:[(0,W.jsx)(ni,{"aria-hidden":`true`}),`Delete Thread`]})]})})]}),(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${h}`,onClick:()=>Re(!1),children:(0,W.jsx)(Gr,{"aria-hidden":`true`,className:`size-4`})})]})}),(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-2`,children:(0,W.jsx)(Sb,{value:h,onValueChange:De,className:`w-full`,children:(0,W.jsxs)(Cb,{className:`mx-auto`,children:[(0,W.jsx)(wb,{value:`discussions`,children:`Discussions`}),(0,W.jsx)(wb,{value:`comments`,children:`Comments`})]})})}),b===`list`&&(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden`,children:[h===`discussions`?(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-2`,children:(0,W.jsx)(Sb,{value:v,onValueChange:e=>y(e),className:`w-full`,children:(0,W.jsxs)(Cb,{className:`mx-auto`,children:[(0,W.jsx)(wb,{value:`file`,children:`This File`}),(0,W.jsx)(wb,{value:`project`,children:`All Project`})]})})}):_?(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`Latest messages. Open a card for the full history.`}):(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2 text-xs text-muted-foreground`,children:a?`Selected ${a.type}`:`Select a table or relationship to add a comment.`}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-24`,children:[P&&(0,W.jsxs)(`p`,{role:`status`,className:`px-4 py-5 text-center text-sm text-muted-foreground`,children:[`Loading `,h,`…`]}),!P&&ee&&(0,W.jsxs)(`div`,{className:`m-4 rounded-lg border border-destructive/40 p-4 text-sm`,children:[(0,W.jsx)(`p`,{children:ee}),(0,W.jsx)(H,{variant:`outline`,className:`mt-3 min-h-11`,onClick:()=>void je(),children:`Retry`})]}),!P&&!ee&&(_?Qe.length:w.length)===0&&(0,W.jsxs)(`div`,{className:`mx-4 mt-4 rounded-lg border border-dashed border-border px-4 py-8 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:h===`comments`?`No comments on this file yet.`:`No discussions in this view yet.`}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l?`You can read threads here, but only members with comment access can start one.`:h===`comments`?`Use the node context menu to start one.`:`Start a thread to capture a question or design decision.`})]}),!ee&&_&&Qe.map(e=>{let t=e.representative,n=e.previewMessages[e.previewMessages.length-1],r=t.anchorId?s?.(t.anchorId):null,i=n?.authorName||`Team member`;return(0,W.jsxs)(`button`,{type:`button`,className:c(`w-full border-b border-border/70 px-3 py-2 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t.unread&&`bg-primary/5`),onClick:()=>void Be(e),children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,W.jsx)(Dn,{name:i}),t.unread&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`New activity`,className:`absolute -right-0.5 -top-0.5 size-2 rounded-full bg-primary ring-2 ring-popover`})]}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs font-semibold`,children:i}),t.status===`resolved`&&(0,W.jsx)(wn,{role:`img`,"aria-label":`Resolved`,className:`size-3.5 shrink-0 text-emerald-500`}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground`,children:vn(t.lastMessageAt??``)})]}),(0,W.jsxs)(`span`,{className:`mt-1 block space-y-0.5 pl-8`,children:[r?(0,W.jsx)(`span`,{className:`line-clamp-2 border-l-2 border-yellow-500/70 pl-2 text-xs leading-snug text-muted-foreground`,children:r.length>50?`${r.slice(0,50).trimEnd()}…`:r}):(0,W.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:t.anchorLabel||`Comment`}),n&&(0,W.jsx)(`span`,{className:`block truncate text-xs`,children:n.body})]})]},e.key)}),!ee&&!_&&w.map(e=>{let t=e.featureType?Jde[e.featureType]:null,n=t?.Icon??Co,r=e.contexts[0]?.fileName||(e.fileId===i.fileId?i.label:`Project discussion`);return(0,W.jsxs)(`button`,{type:`button`,className:c(`flex min-h-18 w-full items-center gap-3 border-b border-border/70 px-4 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,e.unread&&`bg-primary/5`),onClick:()=>void ze(e),children:[(0,W.jsxs)(`span`,{"aria-hidden":`true`,className:c(`relative flex size-10 shrink-0 items-center justify-center rounded-full`,t?.className??`bg-muted text-muted-foreground`),children:[(0,W.jsx)(n,{}),e.unread&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-0.5 top-0.5 size-2 rounded-full bg-primary ring-2 ring-popover`})]}),(0,W.jsxs)(`span`,{className:`sr-only`,children:[Lb(e.featureType),` file`]}),(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:c(`min-w-0 flex-1 truncate text-sm`,e.unread?`font-semibold text-foreground`:`font-medium`),children:r}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:qde(e.lastMessageAt)})]}),(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:c(`min-w-0 flex-1 truncate text-sm`,e.unread?`text-foreground`:`text-muted-foreground`),children:e.latestMessage||``}),e.status===`resolved`&&(0,W.jsxs)(tm,{variant:`outline`,className:`shrink-0 gap-1 font-normal text-muted-foreground`,children:[(0,W.jsx)(wn,{"aria-hidden":`true`}),`Resolved`]})]}),e.unread&&(0,W.jsx)(`span`,{className:`sr-only`,children:`New activity`})]})]},e.id)})]}),!l&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,size:`icon-lg`,className:`absolute bottom-4 right-4 z-10 min-h-11 min-w-11 rounded-full shadow-lg`,"aria-label":h===`comments`?`Add a comment`:`Start a discussion`,onClick:Ve,children:(0,W.jsx)(zt,{"aria-hidden":`true`})})}),(0,W.jsx)(Wt,{side:`left`,children:h===`comments`?`Add a comment`:`Start a discussion`})]})})]}),b===`compose`&&(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4`,children:[h===`comments`&&(0,W.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Context`}),(0,W.jsx)(`p`,{className:`mt-1 font-medium`,children:`${ge?.type||`node`} · ${i.label}`})]}),ne&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:ne})]}),(0,W.jsx)(Hde,{id:`${f}-composer`,value:fe,onChange:pe,onSubmit:Ue,placeholder:h===`comments`?`Write a comment...`:`Write a question or design decision...`,disabled:I,submitLabel:I?`Sending…`:h===`comments`?`Add comment`:`Start discussion`})]}),b===`thread`&&Ze&&(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[h===`comments`&&(0,W.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border px-3 py-1.5`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(()=>{let e=Ze.anchorId&&(_||Ze.fileId===i.fileId)?s?.(Ze.anchorId):null;return e?(0,W.jsx)(`p`,{className:`line-clamp-2 border-l-2 border-yellow-500/70 pl-2 text-xs leading-snug text-muted-foreground`,children:e}):(0,W.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[Ze.anchorType===`general`?`General`:Ze.anchorType,Ze.featureType&&` · ${Lb(Ze.featureType)}`]})})()}),!l&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0`,"aria-label":Ze.status===`open`?`Resolve`:`Reopen`,onClick:()=>void Xe(),disabled:I,children:Ze.status===`open`?(0,W.jsx)(an,{"aria-hidden":`true`,className:`size-4`}):(0,W.jsx)(Xn,{"aria-hidden":`true`,className:`size-4`})})}),(0,W.jsx)(Wt,{side:`left`,children:Ze.status===`open`?`Resolve`:`Reopen`})]})})]}),ne&&(0,W.jsxs)(`div`,{className:`m-4 rounded-lg border border-destructive/40 p-4 text-sm`,role:`alert`,children:[(0,W.jsx)(`p`,{children:ne}),(0,W.jsx)(H,{variant:`outline`,className:`mt-3 min-h-11`,onClick:()=>void(_&&ve?Pe(ve,!0):Ne(Ze.id,!0)),children:`Retry`})]}),!ne&&(0,W.jsx)(Pt,{delay:250,children:(0,W.jsx)(Pn,{defaultScrollPosition:`end`,children:(0,W.jsxs)(On,{className:`flex-1`,children:[(0,W.jsx)(qn,{"aria-label":`${h===`comments`?`Comment`:`Discussion`} messages`,children:(0,W.jsxs)(Sn,{className:`gap-1 p-3`,children:[O.hasMore&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,W.jsx)(H,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void Ie(),disabled:A,children:A?`Loading…`:`Load earlier messages`}),M&&(0,W.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:M})]}),ye.map(e=>(0,W.jsx)(dn,{messageId:e.id,scrollAnchor:!0,children:(0,W.jsx)(Ude,{message:e,canEdit:h===`discussions`&&e.authorId===n&&!l,editing:ie===e.id,editDraft:ae,editOriginalBody:se,disabled:I,onEdit:()=>Ge(e),onDelete:()=>ue({type:`message`,threadId:Ze.id,message:e}),onEditDraftChange:oe,onCancelEdit:Ke,onSaveEdit:t=>{qe(e,t)}})},e.id))]})}),(0,W.jsx)(kn,{})]})},Ze.id)}),Ze.status===`open`&&!ne&&!l&&(0,W.jsx)(Vde,{userName:r||`You`,value:fe,onChange:pe,onSubmit:()=>void We(),disabled:I,submitLabel:I?`Sending…`:`Send reply`}),Ze.status===`resolved`&&!l&&(0,W.jsx)(`p`,{className:`border-t border-border px-4 py-3 text-sm text-muted-foreground`,children:`Reopen this thread to reply.`}),l&&(0,W.jsx)(`p`,{className:`border-t border-border px-4 py-3 text-sm text-muted-foreground`,children:`You can read this thread but not reply to it.`})]})]}),(0,W.jsx)(kr,{isOpen:de,title:`Discard unsent changes?`,message:`You have text that hasn't been sent or saved. If you close this panel now, it will be lost.`,confirmText:`Discard`,cancelText:`Cancel`,variant:`warning`,onCancel:()=>{B(!1),window.setTimeout(()=>document.querySelector(`[data-discussions-panel] textarea`)?.focus(),150)},onConfirm:()=>{B(!1),pe(``),Ke(),m(!1)}}),(0,W.jsx)(kr,{isOpen:le!==null,title:le?.type===`message`?`Delete message?`:`Delete discussion?`,message:le?.type===`message`?`This message will be permanently deleted.`:`This permanently deletes the discussion and all its messages. This action cannot be undone.`,confirmText:le?.type===`message`?`Delete message`:`Delete Thread`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>ue(null),onConfirm:()=>{le?.type===`message`?Ye(le.threadId,le.message):le&&Je(le.threadId)}})]})}function Xde({file:e,active:t,target:n,teamId:r}){let i=ia(),a=y(),o=i.activeDocument,s=o?.project_id??o?.projectId,c=i.projects.find(e=>String(e.id)===String(s)),l=c?.team_id??c?.teamId;if(!n||!o||i.isGuest||!l||String(l)!==String(r))return null;let u=e.type===`erd`?`diagram`:e.type===`notes`?`note`:e.type===`drawings`?`drawing`:`flowchart`,d=t=>{t.featureType===u&&String(t.fileId)===e.uid?u===`diagram`&&t.anchorId&&window.dispatchEvent(new CustomEvent(`erd-discussion-anchor-selected`,{detail:{fileId:e.uid,type:t.anchorType,id:t.anchorId}})):a(`/${{diagram:`diagrams`,note:`notes`,drawing:`drawings`,flowchart:`flowcharts`}[t.featureType]}/${encodeURIComponent(t.fileId)}`)},f=i.selectedEdgeId?{type:`relationship`,id:i.selectedEdgeId}:i.selectedNodeId?{type:`table`,id:i.selectedNodeId}:null;return(0,xb.createPortal)((0,W.jsx)(`span`,{hidden:!t,children:(0,W.jsx)(zb,{projectId:String(s),teamId:String(r),fileContext:{featureType:u,fileId:e.uid,label:o.title||o.name||e.title},userId:i.user?.id?String(i.user.id):void 0,userName:i.user?.name||i.user?.email,readOnly:i.getFileAccessRole(o)===`viewer`,anchorContext:f,onContextSelected:d,anchorPreview:u===`note`?e=>new DOMParser().parseFromString(o.content||``,`text/html`).querySelector(`[data-comment-anchor-id="${CSS.escape(e)}"]`)?.textContent?.trim()||null:void 0})}),n)}var Zde=(0,U.lazy)(()=>bi(()=>import(`./NoteEditorRoute-DbAY2OPi.js`).then(e=>({default:e.NoteEditorRoute})),__vite__mapDeps([8,5,9,10,11,12,7,13,14,15,16,17,6,18,19,20,21,4,1,22]))),Qde=(0,U.lazy)(()=>bi(()=>import(`./DiagramEditorRoute-gB1Tnc1O.js`).then(e=>({default:e.DiagramEditorRoute})),__vite__mapDeps([23,5,9,10,14,12,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),$de=(0,U.lazy)(()=>bi(()=>import(`./FlowchartEditorRoute-8E8F3Oi5.js`).then(e=>({default:e.FlowchartEditorRoute})),__vite__mapDeps([54,5,9,12,10,14,15,16,17,7,6,11,28,27,26,29,30,31,32,33,34,35,36,37,38,39,40,55,46,50,42,13,18,19,20,21,4,1,22,51,52,53]))),efe=(0,U.lazy)(()=>bi(()=>import(`./DrawingEditorRoute-DI8POPT9.js`).then(e=>({default:e.DrawingEditorRoute})),__vite__mapDeps([56,5,9,10,30,12,11,57,47,7,6,13,14,15,16,17,18,19,20,21,4,1,22])));function tfe({file:e,scope:t,root:n,discussionTarget:r,onUpdate:i,teamState:a}){let o=ia(),s=(0,U.useMemo)(()=>({...o,theme:n.theme,resolvedTheme:n.resolvedTheme,setTheme:n.setTheme,setIsSettingsOpen:n.setIsSettingsOpen,setSettingsTab:n.setSettingsTab}),[o,n.theme,n.resolvedTheme,n.setTheme,n.setIsSettingsOpen,n.setSettingsTab]),c=An(),l=Bi(),u=(0,U.useRef)(s),d=(0,U.useRef)(null);u.current=s;let f=(0,U.useMemo)(()=>()=>Qy(u.current,t.host.current??document),[t]);return(0,U.useEffect)(()=>{i(F(e),{file:e,scope:t,workspace:s,ai:c,canvas:l,flush:f})},[e,t,s,c,l,f,i]),(0,U.useEffect)(()=>{e.previewSchema&&d.current!==e&&!s.isERDItemLoading&&s.activeDiagram&&!s.isReadOnlyFile(s.activeDiagram)&&c.applyContent(e.previewSchema,`append`,`erd-generate-sql`)&&(d.current=e)},[e.previewSchema,s.isERDItemLoading,!!s.activeDiagram,c.applyContent]),(0,W.jsxs)(aa.Provider,{value:s,children:[(0,W.jsx)(Xde,{file:e,active:t.active.current,target:r,teamId:a?.activeTeamId}),(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{role:`status`,className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Loading editor…`}),children:(0,W.jsx)(m,{context:a})})]})}var nfe=(0,U.memo)(function({file:e,active:t,scope:n,root:r,mainAI:i,teamState:a,discussionTarget:o,onUpdate:s,onNavigate:c}){n.active.current=t;let l=(0,U.useContext)(v),u=(0,U.useRef)(c);u.current=c;let d=(0,U.useMemo)(()=>({...l,navigator:{...l.navigator,push:e=>u.current(typeof e==`string`?e:`${e.pathname??``}${e.search??``}`),replace:t=>{let n=typeof t==`string`?t:`${t.pathname??``}${t.search??``}`;n.split(`?`)[0]!==k(e).split(`?`)[0]&&u.current(n)}}}),[l,e.type,e.uid]);return(0,W.jsx)(j.Provider,{value:n,children:(0,W.jsx)(v.Provider,{value:d,children:(0,W.jsx)(S,{location:k(e),children:(0,W.jsxs)(x,{element:(e=>(0,W.jsx)(de,{children:(0,W.jsx)(Yi,{isPublicView:!1,publicData:null,isPublicLoading:!1,forbiddenDoc:null,fetchPublicDocument:void 0,setIsPublicView:r.setIsPublicView,handleLogout:async()=>{await r.handleLogout()},children:(0,W.jsx)(Wn,{panelMode:i.rightPanelMode,onPanelModeChange:i.setRightPanelMode,children:e})})}))((0,W.jsx)(tfe,{file:e,scope:n,root:r,discussionTarget:o,onUpdate:s,teamState:a})),children:[(0,W.jsx)(x,{path:`notes/:id`,element:(0,W.jsx)(hb,{capability:`notes`,children:(0,W.jsx)(Zde,{})})}),(0,W.jsx)(x,{path:`diagrams/:id`,element:(0,W.jsx)(hb,{capability:`erd_builder`,children:(0,W.jsx)(Qde,{})})}),(0,W.jsx)(x,{path:`flowcharts/:id`,element:(0,W.jsx)(hb,{capability:`flowcharts`,children:(0,W.jsx)($de,{})})}),(0,W.jsx)(x,{path:`drawings/:id`,element:(0,W.jsx)(hb,{capability:`drawings`,children:(0,W.jsx)(efe,{})})})]})})})})});function Bb({className:e,...t}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`button-group`,className:c(`inline-flex items-center rounded-lg shadow-xs [&>button:not(:first-child)]:rounded-l-none [&>button:not(:first-child)]:border-l-0 [&>button:not(:last-child)]:rounded-r-none`,e),...t})}function rfe({file:e,title:t,feature:n,icon:r,active:i,onSelect:a}){let o=Mt(),s=e&&o?.files.some(t=>F(t)===F(e)),c=o?.files.length?!!s:i;return(0,W.jsxs)(Bb,{"aria-label":t,children:[(0,W.jsxs)(H,{variant:c?`default`:`outline`,size:`sm`,"aria-current":c?`page`:void 0,"data-state":c?`active`:`inactive`,onClick:a,className:`max-w-44 border-input`,title:`${n}: ${t}`,children:[(0,W.jsx)(r,{"data-icon":`inline-start`}),(0,W.jsx)(`span`,{className:`truncate`,children:t})]}),o?.desktop&&o.canSplit&&e&&(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(H,{variant:c?`default`:`outline`,size:`icon-sm`,className:`rounded-r-lg! border border-input data-open:rounded-r-lg!`,"aria-label":`File options: ${t}`,children:(0,W.jsx)(on,{})})}),(0,W.jsx)(en,{align:`start`,className:`w-60`,children:(0,W.jsx)(Yt,{children:(0,W.jsx)(Kt,{className:`whitespace-nowrap`,disabled:o.files.length<2&&c,onClick:()=>s&&o.files.length===2?o.close(e):o.open(e),children:s&&o.files.length===2?`Close pane`:`Open side by side`})})})]})]})}var Vb=[{id:`notes`,label:`Notes`,icon:Nt,route:`/notes`},{id:`erd`,label:`ERD Builder`,icon:Ar,route:`/diagrams`},{id:`db-client`,label:`DB Client`,icon:jr,route:`/db-client`},{id:`flowchart`,label:`Flowchart`,icon:Ht,route:`/flowcharts`},{id:`drawings`,label:`Drawings`,icon:Mr,route:`/drawings`}],Hb=e=>e.title||e.name||`Untitled`,Ub=e=>e.uid||e.id,Wb=e=>new Date(e.created_at||e.createdAt||0).getTime(),ife=3e4,Gb=new Map,Kb=new Map,qb=(e,t)=>{let n=e?.uid??e?.id;return n==null?null:{type:t,uid:String(n),title:Hb(e),createdAt:e.created_at??e.createdAt}};function Jb(e,t){let n=t=>!t.is_deleted&&!t.isDeleted&&String(t.project_id??t.projectId)===String(e),r=(e,t)=>e.filter(n).map(e=>qb(e,t)).filter(e=>e!==null);return[...r(t.notes,`notes`),...r(t.diagrams.filter(e=>(e.source_type??e.sourceType)!==`production_db`),`erd`),...r(t.flowcharts,`flowchart`),...r(t.drawings,`drawings`)]}function afe(...e){return[...new Map(e.flatMap(e=>e.map(e=>[`${e.type}-${e.uid}`,e]))).values()].sort((e,t)=>Wb(e)-Wb(t))}async function ofe(e,t){let n=String(e),r=`${t}:${n}`,i=Gb.get(r);if(i&&i.expiresAt>Date.now())return i;let a=Kb.get(r);if(a)return a;let o=wi(`/api/projects/${encodeURIComponent(n)}/files`).then(async e=>{if(!e.ok)throw Error(`Failed to load project files`);let t=await e.json(),n={files:Array.isArray(t.data)?t.data:[]};return Gb.set(r,{...n,expiresAt:Date.now()+ife}),n}).finally(()=>Kb.delete(r));return Kb.set(r,o),o}function Yb({currentView:e,currentFile:t,host:n=!1}){let r=(0,U.useContext)(Vy),i=Mt(),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(`notes`),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)({projectKey:``,files:[]}),g=(0,U.useRef)(null),v=y(),[b]=_(),{user:x,isGuest:S,activeProjectId:C,notes:w,diagrams:T,drawings:E,flowcharts:D,activeDiagram:O,activeNote:k,activeDrawing:A,activeFlowchart:j,activeDiagramId:M,activeNoteUid:N,activeDrawingId:P,activeFlowchartId:F,handleDiagramSelect:I,handleSidebarDiagramCreate:L,handleSidebarNoteCreate:R,handleSidebarDrawingCreate:ee,handleSidebarFlowchartCreate:te}=ia();(0,U.useEffect)(()=>{a&&setTimeout(()=>g.current?.focus(),0)},[a,s]);let ne=(0,U.useMemo)(()=>{let n=t??(e===`notes`?k:e===`erd`?O:e===`flowchart`?j:A);return n?.project_id??n?.projectId??(C&&C!==`all`?C:b.get(`pid`))},[C,k,O,j,A,t,e,b]),re=ne==null?``:String(ne),ie=m.projectKey===re?m.files:[],z=(0,U.useMemo)(()=>ne?Jb(ne,{notes:w,diagrams:T,drawings:E,flowcharts:D}):[],[ne,w,T,E,D]);(0,U.useEffect)(()=>{if(!ne){h({projectKey:``,files:[]});return}if(!S&&x?.id==null)return;let e=!1,t=String(ne);return(async()=>{try{let n;if(S){let[e,t,r,i]=await Promise.all([ea.getAllResources(`notes`),ea.getAllResources(`erd`),ea.getAllResources(`flowchart`),ea.getAllResources(`drawings`)]);n=Jb(ne,{notes:e,diagrams:t,flowcharts:r,drawings:i})}else n=(await ofe(ne,x.id)).files;e||h({projectKey:t,files:n})}catch{e||h({projectKey:t,files:[]})}})(),()=>{e=!0}},[ne,S,x?.id]);let ae=(0,U.useMemo)(()=>{if(!ne)return[];let n=t??(e===`notes`?k:e===`erd`?O:e===`flowchart`?j:A),r=n?qb(n,e):null;return afe(ie,z,r?[r]:[]).map(e=>({file:e,type:e.type}))},[ne,ie,z,e,t,k,O,j,A]),oe=t?Ub(t):e===`notes`?N:e===`erd`?O?.uid||M:e===`flowchart`?j?.uid||F:A?.uid||P,se=(e,t)=>{if(i&&e!==`db-client`){i.select({type:e,uid:String(Ub(t)),title:Hb(t),projectId:String(ne)});return}if(e===`erd`){I(String(Ub(t)));return}let n=Vb.find(t=>t.id===e);if(!n)return;let r=new URLSearchParams({pid:String(ne)});v(`${n.route}/${Ub(t)}?${r}`)},ce=async()=>{let e=u.trim();if(e&&!f&&ne){p(!0);try{let t=String(ne);s===`notes`?await R(e,t):s===`erd`?await L(e,t):s===`flowchart`?await te(e,t):await ee(e,t),o(!1),d(``)}finally{p(!1)}}},le=(0,U.useRef)(null),[ue,de]=(0,U.useState)({before:!1,after:!1}),B=(0,U.useCallback)(()=>{let e=le.current;if(!e)return;let t=e.scrollLeft>1,n=e.scrollLeft+e.clientWidth<e.scrollWidth-1;de(e=>e.before===t&&e.after===n?e:{before:t,after:n})},[]);(0,U.useEffect)(()=>{let e=le.current;if(!e)return;let t=()=>{let t=e.querySelector(`[aria-current="page"]`);if(t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.left<r.left?e.scrollLeft-=r.left-n.left+8:n.right>r.right&&(e.scrollLeft+=Math.min(n.right-r.right+8,n.left-r.left))}B()};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[oe,ae.length,B,r]);let fe=e=>{let t=le.current;t&&t.scrollBy({left:e*Math.max(t.clientWidth*.6,160),behavior:`smooth`})};return!ne||i&&!n||!r?null:(0,xb.createPortal)((0,W.jsxs)(`nav`,{"aria-label":`Project files`,className:`flex w-full min-w-0 items-center gap-1 py-1`,children:[(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[ue.before&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>fe(-1),className:`absolute inset-y-0 left-0 z-10 flex items-center bg-gradient-to-r from-background from-60% to-transparent pl-0.5 pr-3 text-muted-foreground hover:text-foreground`,"aria-label":`Scroll files left`,children:(0,W.jsx)(vr,{className:`size-4`})}),ue.after&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>fe(1),className:`absolute inset-y-0 right-0 z-10 flex items-center bg-gradient-to-l from-background from-60% to-transparent pl-3 pr-0.5 text-muted-foreground hover:text-foreground`,"aria-label":`Scroll files right`,children:(0,W.jsx)(At,{className:`size-4`})}),(0,W.jsx)(`div`,{ref:le,onScroll:B,onWheel:e=>{Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(e.currentTarget.scrollLeft+=e.deltaY)},className:`overflow-x-auto scrollbar-hide`,children:(0,W.jsx)(`div`,{className:`flex w-max items-center justify-start gap-1 py-1`,children:ae.map(({file:t,type:n})=>{let r=Vb.find(e=>e.id===n),i=r.icon,a=Ub(t),o=n===`db-client`?null:{type:n,uid:String(a),title:Hb(t),projectId:String(ne)};return(0,W.jsx)(rfe,{file:o,title:Hb(t),feature:r.label,icon:i,active:e===n&&String(oe)===String(a),onSelect:()=>se(n,t)},`${n}-${a}`)})})})]}),(0,W.jsxs)(Ut,{open:a,onOpenChange:e=>{o(e),e||d(``)},children:[(0,W.jsx)(Pt,{children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(`span`,{className:`inline-flex shrink-0`}),children:(0,W.jsx)(Vt,{render:(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,"aria-label":`Create file`,children:(0,W.jsx)(zt,{})})})}),(0,W.jsx)(Wt,{side:`bottom`,children:`Create file`})]})}),(0,W.jsxs)(Rt,{align:`end`,className:`w-72 max-w-[calc(100vw-1rem)] overflow-hidden p-0`,children:[(0,W.jsx)(`div`,{className:`max-h-56 overflow-y-auto p-1`,children:Vb.filter(e=>e.id!==`db-client`).map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{onClick:()=>l(e.id),className:c(`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent`,s===e.id&&`bg-accent text-accent-foreground`),children:[(0,W.jsx)(t,{className:`size-4`}),(0,W.jsx)(`span`,{className:`flex-1`,children:e.label}),s===e.id&&(0,W.jsx)(an,{className:`size-4`})]},e.id)})}),(0,W.jsxs)(`div`,{className:`sticky bottom-0 flex gap-2 border-t bg-popover p-2`,children:[(0,W.jsx)(Oi,{ref:g,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ce(),e.key===`Escape`&&(o(!1),d(``))},placeholder:`New file name`,className:`h-8 text-xs`,disabled:f}),(0,W.jsx)(`button`,{onClick:ce,disabled:!u.trim()||f,className:`h-8 shrink-0 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:`Create`})]})]})]})]}),r)}function sfe({children:e,root:t,mainAI:n,teamState:r,discussionTarget:i,onFocusedSession:a,onPairChange:o,paneAIRef:s}){let c=h(),l=y(),[u,f]=(0,U.useState)(()=>window.matchMedia(`(min-width: 1024px)`).matches),[p,m]=(0,U.useState)([]),g=u&&p.length===2;(0,U.useLayoutEffect)(()=>(o(g),()=>o(!1)),[g,o]);let[_,v]=(0,U.useState)(``),b=(0,U.useRef)(_);b.current=_;let[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(!1),D=(0,U.useRef)(!1),O=(0,U.useRef)(c.pathname+c.search),A=(0,U.useRef)(null),j=(0,U.useRef)(new Map),M=(0,U.useRef)(new Map),N=(0,U.useRef)(null),[I,R]=(0,U.useState)(50),ee=(0,U.useRef)(!1),te=r,ne=(0,U.useMemo)(()=>({activeTeamId:te.activeTeamId,activeTeam:te.activeTeam,isLoading:te.isLoading}),[te.activeTeamId,te.activeTeam,te.isLoading]),re=c.pathname.match(/^\/(notes|diagrams|flowcharts|drawings)\/([^/]+)$/),ie={notes:`notes`,diagrams:`erd`,flowcharts:`flowchart`,drawings:`drawings`},z=re?ie[re[1]]:null,ae=z===`notes`?t.activeNote:z===`erd`?t.activeDiagram:z===`flowchart`?t.activeFlowchart:t.activeDrawing,oe=ae?.project_id??ae?.projectId,se=z&&ae&&oe!=null?{type:z,uid:String(ae.uid??ae.id),title:ae.title||ae.name||`Untitled`,projectId:String(oe)}:null,ce=se??p[0]??null,le=`${t.user?.id}:${t.teamScopeVersion}`;(0,U.useLayoutEffect)(()=>{if(s)return s.current=e=>p.some(t=>F(t)===e)?j.current.get(e)?.ai:void 0,()=>{s.current=null}},[s,p]);let ue=(0,U.useCallback)((e,t)=>{j.current.set(e,t),e===b.current&&a(t)},[a]);(0,U.useEffect)(()=>{a(j.current.get(_)??null)},[_,a]),(0,U.useEffect)(()=>()=>a(null),[a]),(0,U.useEffect)(()=>{m([]),S(null),v(``),j.current.clear(),M.current.clear(),a(null)},[le,a]),(0,U.useEffect)(()=>{t.isPublicView&&(m([]),S(null),v(``),a(null))},[t.isPublicView,a]),(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>f(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let de=(0,U.useCallback)(async e=>{let t=j.current.get(F(e));if(!t)throw Error(`Wait for the editor to finish loading.`);await t.flush()},[]);(0,U.useEffect)(()=>{let e=e=>{p.length&&e.detail.push(Promise.all(p.map(de)).then(()=>{}))};return window.addEventListener(P,e),()=>window.removeEventListener(P,e)},[p,de]);let B=async e=>{if(!D.current){D.current=!0,E(!0);try{await e()}catch(e){d.error(e instanceof Error?e.message:`Could not switch files.`)}finally{D.current=!1,E(!1)}}},fe=e=>{b.current=F(e),v(F(e)),a(j.current.get(F(e))??null)},pe=e=>{let n=p[0]??ce;(u||e.previewSchema)&&n&&L(p,n,e)!==`reject`&&(p.some(t=>F(t)===F(e))?(e.previewSchema&&m(t=>t.map(t=>F(t)===F(e)?e:t)),fe(e)):(p.length||F(n)!==F(e))&&(p.length===2?(S(e),w(``)):B(async()=>{p.length||await Qy(t),m([...p.length?p:[n],e]),fe(e)})))},me=e=>{p.some(t=>F(t)===F(e))?fe(e):p.length===2&&u?pe(e):B(async()=>{p.length?await Promise.all(p.map(de)):await Qy(t),m([]),v(``),a(null),l(k(e))})},he=e=>void B(async()=>{await de(e);let t=p.filter(t=>F(t)!==F(e));j.current.delete(F(e)),M.current.delete(F(e)),m(t),t[0]&&(fe(t[0]),c.pathname!==k(t[0]).split(`?`)[0]&&l(k(t[0]),{replace:!0}))}),ge=e=>{let n=e.match(/^\/(notes|diagrams|flowcharts|drawings)\/([^/?]+)/);if(n&&ce){let e=ie[n[1]],r=decodeURIComponent(n[2]),i=(e===`notes`?t.notes:e===`erd`?t.diagrams:e===`flowchart`?t.flowcharts:t.drawings).find(e=>String(e.uid)===r||String(e.id)===r)??[...j.current.values()].find(t=>t.file.type===e&&(String(t.workspace.activeDocument?.id)===r||t.file.uid===r))?.workspace.activeDocument;me({type:e,uid:String(i?.uid??i?.id??r),title:i?.title||i?.name||`Untitled`,projectId:String(i?.project_id??i?.projectId??ce.projectId)})}else B(async()=>{await Promise.all(p.map(de)),m([]),v(``),a(null),l(e)})},_e=(0,U.useRef)(pe),ve=(0,U.useRef)(ge);ve.current=ge;let V=(0,U.useCallback)(e=>ve.current(e),[]);_e.current=pe,(0,U.useEffect)(()=>{let e=c.pathname+c.search;if(!p.length){O.current=e;return}if(T||O.current===e||re&&(!se||se.uid!==decodeURIComponent(re[2])&&String(ae?.id)!==decodeURIComponent(re[2])))return;let t=O.current;O.current=e;let n=se&&p.find(e=>F(e)===F(se));re&&n?fe(n):re&&se&&p.length===2&&se.projectId===p[0].projectId?(A.current=t,S(se),w(``)):B(async()=>{try{await Promise.all(p.map(de)),m([]),v(``),a(null)}catch(e){throw O.current=t,l(t,{replace:!0}),e}})},[c.pathname,c.search,se?.uid,se?.projectId,p,T,de,l,a]);let be=()=>{T||(S(null),A.current&&=(O.current=A.current,l(A.current,{replace:!0}),null))};if((0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.file;ye(t)&&_e.current(t)};return window.addEventListener(Ee,e),()=>window.removeEventListener(Ee,e)},[]),(0,U.useEffect)(()=>{let e=e=>{if(!ee.current||!N.current)return;let t=N.current.getBoundingClientRect();R(Math.max(30,Math.min(70,(e.clientX-t.left)/t.width*100)))},t=()=>{ee.current=!1};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]),!ce||!re&&!p.length||t.isPublicView)return(0,W.jsx)(W.Fragment,{children:e});let xe=p.find(e=>F(e)===_)??ce,Se=j.current.get(F(xe))?.workspace.activeDocument??(se&&F(xe)===F(se)?ae:void 0),Ce=T?{inert:``}:{};return(0,W.jsxs)(It.Provider,{value:{files:p,focused:_,desktop:u,canSplit:!!(p[0]??ce),open:pe,select:me,close:he},children:[(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,W.jsx)(Yb,{host:!0,currentView:xe.type,currentFile:Se}),p.length?(0,W.jsx)(`div`,{ref:N,className:`flex min-h-0 flex-1 overflow-hidden`,"aria-label":`Open files`,children:p.map((e,r)=>{let a=F(e),o=M.current.get(a);return o||(o={active:{current:_===a},host:{current:null}},M.current.set(a,o)),(0,W.jsxs)(`div`,{className:g||_===a?`contents`:`hidden`,children:[g&&r===1&&(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize editors`,"aria-orientation":`vertical`,"aria-valuemin":30,"aria-valuemax":70,"aria-valuenow":Math.round(I),tabIndex:0,className:`w-2 shrink-0 cursor-col-resize touch-none border-x bg-muted/30 focus-visible:bg-accent`,onPointerDown:e=>{ee.current=!0,e.currentTarget.setPointerCapture(e.pointerId)},onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),R(t=>Math.max(30,Math.min(70,t+(e.key===`ArrowLeft`?-2:2)))))}}),(0,W.jsxs)(`section`,{"data-file-session":a,"data-active":_===a,"aria-label":e.title,...Ce,onPointerDownCapture:()=>fe(e),onFocusCapture:()=>{_!==a&&fe(e)},className:`relative flex min-h-0 min-w-0 flex-col overflow-hidden`,style:g?{width:r===0?`${I}%`:void 0,flex:r===1?1:void 0}:{flex:1},children:[g&&(0,W.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center justify-between gap-2 border-b px-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.title}),(0,W.jsx)(H,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close pane: ${e.title}`,disabled:T,onClick:()=>he(e),children:(0,W.jsx)(Gr,{})})]}),(0,W.jsx)(`div`,{ref:o.host,className:`relative isolate flex min-h-0 flex-1 flex-col overflow-hidden [transform:translateZ(0)]`,children:(0,W.jsx)(nfe,{file:e,active:_===a,scope:o,root:t,mainAI:n,teamState:ne,discussionTarget:i,onUpdate:ue,onNavigate:V})})]})]},a)})}):(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,...Ce,children:e})]}),(0,W.jsx)(gi,{open:!!x,onOpenChange:e=>{e||be()},children:(0,W.jsxs)(ai,{children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(_i,{children:`Replace an open file`}),(0,W.jsxs)(fi,{children:[`Choose the file to close before opening `,x?.title,`.`]})]}),(0,W.jsx)(mi,{className:`p-4`,children:(0,W.jsx)(Xy,{"aria-label":`File to replace`,value:C,onValueChange:e=>w(String(e)),className:`flex flex-col gap-2`,children:p.map(e=>(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-lg border p-3`,children:[(0,W.jsx)(qy,{value:F(e),className:`flex size-4 shrink-0 items-center justify-center rounded-full border border-input data-checked:border-primary focus-visible:ring-2 focus-visible:ring-ring`,children:(0,W.jsx)(Jy,{className:`size-2 rounded-full bg-primary`})}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate`,children:e.title}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:{notes:`Notes`,erd:`ERD Builder`,flowchart:`Flowchart`,drawings:`Drawings`}[e.type]})]})]},F(e)))})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(H,{variant:`outline`,disabled:T,onClick:be,children:`Cancel`}),(0,W.jsx)(H,{disabled:!C||T,onClick:()=>void B(async()=>{let e=p.find(e=>F(e)===C);x&&e&&(await de(e),j.current.delete(C),M.current.delete(C),m(p.map(e=>F(e)===C?x:e)),fe(x),S(null),A.current=null,se&&F(se)===F(e)&&l(k(x),{replace:!0}))}),children:`Replace file`})]})]})})]})}var Xb=U.createContext(void 0);function Zb(){let e=U.useContext(Xb);if(e===void 0)throw Error(Ne(13));return e}var Qb={imageLoadingStatus:()=>null},cfe=U.forwardRef(function(e,t){let{className:n,render:r,...i}=e,[a,o]=U.useState(`idle`),s={imageLoadingStatus:a},c=U.useMemo(()=>({imageLoadingStatus:a,setImageLoadingStatus:o}),[a,o]),l=Pe(`span`,e,{state:s,ref:t,props:i,stateAttributesMapping:Qb});return(0,W.jsx)(Xb.Provider,{value:c,children:l})});function lfe(e,{referrerPolicy:t,crossOrigin:n}){let[r,i]=U.useState(`idle`);return Oe(()=>{if(!e)return i(`error`),Ae;let r=!0,a=new window.Image,o=e=>()=>{r&&i(e)};return i(`loading`),a.onload=o(`loaded`),a.onerror=o(`error`),t&&(a.referrerPolicy=t),a.crossOrigin=n??null,a.src=e,()=>{r=!1}},[e,n,t]),r}var ufe={...Qb,...$e},dfe=U.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,referrerPolicy:a,crossOrigin:o,...s}=e,c=Zb(),l=lfe(e.src,{referrerPolicy:a,crossOrigin:o}),u=l===`loaded`,{mounted:d,transitionStatus:f,setMounted:p}=We(u),m=U.useRef(null),h=ke(e=>{i?.(e),c.setImageLoadingStatus(e)});Oe(()=>{l!==`idle`&&h(l)},[l,h]);let g={imageLoadingStatus:l,transitionStatus:f};Je({open:u,ref:m,onComplete(){u||p(!1)}});let _=Pe(`img`,e,{state:g,ref:[t,m],props:s,stateAttributesMapping:ufe,enabled:d});return d?_:null}),ffe=U.forwardRef(function(e,t){let{className:n,render:r,delay:i,...a}=e,{imageLoadingStatus:o}=Zb(),[s,c]=U.useState(i===void 0),l=ct();return U.useEffect(()=>(i!==void 0&&l.start(i,()=>c(!0)),l.clear),[l,i]),Pe(`span`,e,{state:{imageLoadingStatus:o},ref:t,props:a,stateAttributesMapping:Qb,enabled:o!==`loaded`&&s})}),$b=U.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,W.jsx)(cfe,{ref:r,"data-slot":`avatar`,"data-size":t,className:c(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n}));$b.displayName=`Avatar`;var ex=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(dfe,{ref:n,"data-slot":`avatar-image`,className:c(`aspect-square size-full rounded-full object-cover`,e),...t}));ex.displayName=`AvatarImage`;var tx=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(ffe,{ref:n,"data-slot":`avatar-fallback`,className:c(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t}));tx.displayName=`AvatarFallback`;function pfe({open:e,onOpenChange:t}){let[n,r]=(0,U.useState)(!1);return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-105 bg-background border-border/40 shadow-2xl`,children:[(0,W.jsx)(Jr,{className:`sr-only`,children:`Guest Data Backup`}),(0,W.jsx)(Ur,{className:`sr-only`,children:`Export your Guest Mode data as a JSON file for safe keeping or future import.`}),(0,W.jsxs)(`div`,{className:`p-2 space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`p-2.5 bg-amber-500/10 rounded-xl`,children:(0,W.jsx)(Qo,{className:`size-5 text-amber-500`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold text-base`,children:`Guest Mode`}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`You are browsing as a guest`})]})]}),(0,W.jsxs)(`div`,{className:`bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Ar,{className:`size-4 text-muted-foreground shrink-0 mt-0.5`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:(0,W.jsxs)(`p`,{children:[`Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a `,(0,W.jsx)(`code`,{className:`bg-muted px-1 rounded text-[11px]`,children:`.json`}),` `,`file so you can import it after signing in.`]})})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(Wa,{className:`size-4 text-muted-foreground shrink-0 mt-0.5`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:(0,W.jsxs)(`p`,{children:[`The export file can be imported into any ERD Builder Pro account via`,(0,W.jsx)(`strong`,{children:` Settings → Guest Data Import`}),`.`]})})]})]}),(0,W.jsx)(H,{onClick:async()=>{r(!0);try{await Ny(),d.success(`Data exported successfully!`)}catch(e){d.error(`Export failed: `+(e.message||`Unknown error`))}finally{r(!1)}},disabled:n,className:`w-full`,children:n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`size-4 mr-2 animate-spin`}),`Exporting…`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Yn,{className:`size-4 mr-2`}),`Export My Data`]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`span`,{className:`w-full border-t border-border/30`})}),(0,W.jsx)(`div`,{className:`relative flex justify-center text-xs`,children:(0,W.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`Need an account?`})})]}),(0,W.jsx)(`div`,{className:`text-center space-y-2`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Sign up or log in from the main page to import your backup.`})})]})]})})}function mfe({user:e,onLogout:t,onViewChange:n,isOnline:r,onOpenFeedback:i,compact:a=!1}){let{isMobile:o}=Pp(),{isGuest:s,setIsSettingsOpen:l,setSettingsTab:u,hasUpdate:d,latestVersion:f,isCheckingUpdate:p,isDownloadingUpdate:m,isWebOutdated:h,showOutdatedBadge:g,checkForUpdates:_,downloadUpdate:v}=ia(),y=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!e)return null;let b=e.email||``,x=e.name||e.user_metadata?.full_name||e.user_metadata?.name||b.split(`@`)[0]||`User`,S=e.user_metadata?.avatar_url||``,C=x.substring(0,2).toUpperCase(),w=e=>{u(e),l(!0)},[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(Gp,{size:`lg`,"aria-label":a?`Account menu for ${x}`:void 0,title:a?x:void 0,className:c(`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,a&&`!size-8 !justify-center !p-0`),children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsxs)($b,{className:`h-8 w-8 rounded-lg`,children:[(0,W.jsx)(ex,{src:S,alt:x}),(0,W.jsx)(tx,{className:`rounded-lg`,children:C})]}),g&&(0,W.jsx)(`span`,{className:`absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar`,title:d?`Update available: v${f}`:h?`New version available: v${f}. You're on v3.4.7-rc.39. Pull latest Docker image or update your install.`:``})]}),!a&&(0,W.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,W.jsx)(`span`,{className:`truncate font-semibold`,children:x}),(0,W.jsx)(`span`,{className:`truncate text-xs`,children:b})]}),!a&&(0,W.jsx)(Ea,{className:`ml-auto size-4`})]})}),(0,W.jsxs)(en,{className:`w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg`,side:o?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,W.jsx)(Yt,{children:(0,W.jsx)($t,{className:`p-0 font-normal`,children:(0,W.jsx)(Yt,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-left text-sm`,children:[(0,W.jsxs)($b,{className:`h-8 w-8 rounded-lg`,children:[(0,W.jsx)(ex,{src:S,alt:x}),(0,W.jsx)(tx,{className:`rounded-lg`,children:C})]}),(0,W.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,W.jsx)(`span`,{className:`truncate font-semibold`,children:x}),(0,W.jsx)(`span`,{className:`truncate text-xs`,children:b})]})]})})})}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Yt,{children:[(0,W.jsxs)(Kt,{onClick:()=>w(s||e.isSso?`appearance`:`account`),className:`cursor-pointer`,disabled:!s&&!r,children:[(0,W.jsx)(Ro,{className:`mr-2 size-4`}),`Settings`]}),s&&(0,W.jsxs)(Kt,{onClick:()=>E(!0),className:`cursor-pointer`,children:[(0,W.jsx)(Yn,{className:`mr-2 size-4`}),`Backup Data`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>O(!0),className:`cursor-pointer`,children:[d?(0,W.jsx)(Da,{className:`mr-2 size-4 text-emerald-400`}):h?(0,W.jsx)(_a,{className:`mr-2 size-4 text-amber-500`}):(0,W.jsx)(Dr,{className:`mr-2 size-4`}),`About`,g&&(0,W.jsx)(`span`,{className:`ml-auto flex size-2 rounded-full ${d?`bg-emerald-400`:`bg-amber-500`}`})]}),(0,W.jsxs)(Kt,{render:(0,W.jsx)(`a`,{href:`https://github.com/hadziqmtqn/erd-builder-pro`,target:`_blank`,rel:`noopener noreferrer`}),className:`cursor-pointer`,children:[(0,W.jsx)(to,{className:`mr-2 size-4`}),`Github`]}),(0,W.jsxs)(Kt,{onClick:i,className:`cursor-pointer`,children:[(0,W.jsx)(So,{className:`mr-2 size-4`}),`Feedback`]})]}),(0,W.jsx)(tn,{}),(0,W.jsx)(Yt,{children:(0,W.jsxs)(Kt,{onClick:()=>r&&n(`trash`),disabled:!r,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!r&&`opacity-50 cursor-not-allowed`}`,children:[(0,W.jsx)(ni,{className:`mr-2 size-4`}),`Trash`]})}),(0,W.jsx)(tn,{}),!y&&(0,W.jsxs)(Kt,{onClick:()=>r&&t(),disabled:!r,className:`cursor-pointer ${!r&&`opacity-50 cursor-not-allowed`}`,title:r?``:`Logging out while offline may cause data loss of unsynced changes`,children:[(0,W.jsx)(xo,{className:`mr-2 size-4`}),`Log out`]})]})]})})}),(0,W.jsx)(pfe,{open:T,onOpenChange:E}),(0,W.jsx)(By,{open:D,onOpenChange:O,hasUpdate:d,latestVersion:f,isChecking:p,isDownloading:m,onCheckUpdate:_,onDownload:v})]})}function nx({label:e,icon:t,active:n=!1,locked:r=!1,disabled:i=!1,onClick:a}){let o=r?`${e}. Paid Cloud plan required.`:e;return(0,W.jsx)(Wp,{children:(0,W.jsx)(Gp,{isActive:n,disabled:i,"aria-label":o,className:c(`relative mx-auto !size-8 !justify-center !p-0`,r&&`cursor-not-allowed`),tooltip:{children:r?`${e} · PRO`:e,hidden:!1},onClick:a,children:(0,W.jsx)(t,{"aria-hidden":`true`,className:r?`text-muted-foreground`:void 0})})})}function hfe({activeFeatureView:e,canManageInstance:t,cloudFeatureLocked:n,isOnline:r,isSelfHosted:i,onFeatureClick:a,onLogout:o,onOpenFeedback:s,onViewChange:c,ssoPortalUrl:l,user:u,showDbClient:d}){let f=h(),p=y(),{isMobile:m}=Pp(),g=()=>{if(l)try{window.location.assign(new URL(`/dashboard`,l).toString())}catch{}},_=async()=>{r&&(await c(`erd`,!0),p(`/table/db-client`))};return(0,W.jsxs)(Ip,{collapsible:`none`,className:`w-[calc(var(--sidebar-width-icon,3rem)+1px)]! shrink-0 border-r`,children:[(0,W.jsx)(Lp,{className:`items-center border-b border-sidebar-border p-2`,children:(0,W.jsxs)(`div`,{className:`flex size-8 items-center justify-center`,role:`img`,"aria-label":`ERD Builder Pro`,children:[(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Light-1.svg`,alt:``,className:`size-full dark:hidden`}),(0,W.jsx)(`img`,{src:`/img/ERD-Builder-Pro-Dark-1.svg`,alt:``,className:`hidden size-full dark:block`})]})}),(0,W.jsx)(zp,{className:`items-center overflow-y-auto px-1 py-3`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[(0,W.jsxs)(Up,{className:`gap-1`,children:[(0,W.jsx)(nx,{label:`Dashboard`,icon:fo,active:f.pathname===`/`,onClick:()=>p(`/`)}),u?.isSso&&l&&(0,W.jsx)(nx,{label:`Manage account & billing`,icon:za,onClick:g}),i&&t&&(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{openOnHover:!0,delay:0,closeDelay:120,render:(0,W.jsx)(Gp,{isActive:f.pathname===`/team-workspaces`||f.pathname===`/users`,"aria-label":`Instance Administration (Self-Host)`,title:`Instance Administration (Self-Host)`,className:`relative mx-auto !size-8 !justify-center !p-0`,children:(0,W.jsx)(Ho,{"aria-hidden":`true`})})}),(0,W.jsxs)(en,{side:m?`bottom`:`right`,align:`start`,sideOffset:8,children:[(0,W.jsxs)(Kt,{onClick:()=>p(`/team-workspaces`),children:[(0,W.jsx)(Qa,{"aria-hidden":`true`}),`Team`]}),(0,W.jsxs)(Kt,{onClick:()=>p(`/users`),children:[(0,W.jsx)($o,{"aria-hidden":`true`}),`Users`]})]})]})})]}),(0,W.jsx)(`div`,{className:`mx-auto h-px w-8 bg-sidebar-border`,"aria-hidden":`true`}),(0,W.jsxs)(Up,{className:`gap-1`,children:[(0,W.jsx)(nx,{label:`Notes`,icon:Nt,active:e===`notes`,locked:n(`notes`),onClick:()=>a(`Notes`,`notes`,()=>c(`notes`,!0))}),(0,W.jsx)(nx,{label:`ERD Builder`,icon:Ar,active:e===`erd`,locked:n(`erd_builder`),onClick:()=>a(`ERD Builder`,`erd_builder`,()=>c(`erd`,!0))}),d&&(0,W.jsx)(nx,{label:`DB Client`,icon:jr,active:e===`db-client`,disabled:!r,onClick:()=>{_()}}),(0,W.jsx)(nx,{label:`Flowchart`,icon:Eo,active:e===`flowchart`,locked:n(`flowcharts`),onClick:()=>a(`Flowchart`,`flowcharts`,()=>c(`flowchart`,!0))}),(0,W.jsx)(nx,{label:`Drawings`,icon:Mr,active:e===`drawings`,locked:n(`drawings`),onClick:()=>a(`Drawings`,`drawings`,()=>c(`drawings`,!0))})]}),u?.isSso&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mx-auto h-px w-8 bg-sidebar-border`,"aria-hidden":`true`}),(0,W.jsx)(Up,{className:`gap-1`,children:(0,W.jsx)(nx,{label:`Library`,icon:mo,active:f.pathname===`/library`,disabled:!r,onClick:()=>p(`/library`)})})]})]})}),(0,W.jsx)(Rp,{className:`items-center border-t border-sidebar-border p-2`,children:(0,W.jsx)(mfe,{user:u,onLogout:o,onViewChange:c,isOnline:r,onOpenFeedback:s,compact:!0})})]})}function gfe(e){try{let t=new URL(e);return t.searchParams.set(`utm_source`,`erdbuilderpro.com`),t.searchParams.set(`utm_medium`,`referral`),t.searchParams.set(`utm_campaign`,`sponsor`),t.toString()}catch{return e}}var _fe=[{logoOnLightSurfaceSrc:`https://s3.erdbuilderpro.com/sponsors/Sumopod-Light.png`,logoOnDarkSurfaceSrc:`https://s3.erdbuilderpro.com/sponsors/Sumopod-Dark.png`,logoAlt:`SumoPod`,title:`Deploy your App in 15 Seconds!`,description:`Seamless container deployment for businesses of all sizes.`,buttonText:`Get Started →`,buttonAction:`https://sumopod.com`}];function vfe(){let e=_fe[0];return(0,W.jsx)(`div`,{className:`px-2 pb-2`,children:(0,W.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-dashed border-zinc-700 bg-zinc-950 p-3 text-zinc-50 dark:border-zinc-300 dark:bg-zinc-100 dark:text-zinc-950`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[e.icon?(0,W.jsx)(e.icon,{className:`w-5 h-5 text-rose-500 shrink-0`}):e.logoOnDarkSurfaceSrc||e.logoOnLightSurfaceSrc?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`img`,{src:e.logoOnDarkSurfaceSrc??e.logoOnLightSurfaceSrc,alt:e.logoAlt??``,className:`h-8 w-auto max-w-full shrink-0 object-contain dark:hidden`}),e.logoOnLightSurfaceSrc&&(0,W.jsx)(`img`,{src:e.logoOnLightSurfaceSrc,alt:e.logoAlt??``,className:`hidden h-8 w-auto max-w-full shrink-0 object-contain dark:block`})]}):null,(0,W.jsx)(`p`,{className:`max-w-full truncate text-center text-xs font-semibold text-zinc-50 dark:text-zinc-950`,children:e.title}),(0,W.jsx)(`p`,{className:`wrap-break-word text-center text-[11px] leading-relaxed text-zinc-300 dark:text-zinc-600`,children:e.description}),(0,W.jsx)(H,{type:`button`,className:`mt-1 w-full bg-[#1a5fd4] text-white hover:bg-[#174ea6]`,onClick:()=>Hi(gfe(e.buttonAction)),children:e.buttonText})]})})})}function yfe({teams:e,activeTeamId:t,enabled:n,canManageTeams:r,onOpen:i,onSelect:a,onAdd:o,onManage:s}){let{isMobile:c}=Pp(),l=(e.find(e=>e.id===t)||null)?.name||(t?`Loading workspace…`:`Personal`),u=(0,W.jsxs)(Gp,{size:`lg`,"aria-label":`Switch workspace. Current workspace: ${l}`,title:`Workspace: ${l}`,className:`h-9 cursor-pointer px-2 transition-colors hover:bg-accent/50 active:bg-accent/70`,onClick:n?void 0:()=>a(null),children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left font-medium`,children:l}),n&&(0,W.jsx)(Ea,{className:`ml-auto size-4 shrink-0`})]});return n?(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:(0,W.jsxs)(nn,{onOpenChange:e=>{e&&i()},children:[(0,W.jsx)(Jt,{render:u}),(0,W.jsxs)(en,{className:`min-w-64 border border-border/70 p-1.5 shadow-xl`,side:c?`bottom`:`right`,align:`start`,sideOffset:6,children:[(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80`,children:`Team`}),(0,W.jsxs)(Kt,{onClick:()=>a(null),className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand ${t?``:`bg-brand/10 text-foreground [&>svg]:text-brand`}`,children:[(0,W.jsx)(Zo,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{children:`Personal`}),!t&&(0,W.jsx)(an,{className:`ml-auto size-4 text-brand`})]})]}),e.length>0&&(0,W.jsx)(tn,{className:`my-1.5`}),e.length>0&&(0,W.jsxs)(Yt,{children:[(0,W.jsx)($t,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80`,children:`Teams`}),e.map(e=>(0,W.jsxs)(Kt,{onClick:()=>a(e.id),className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand ${t===e.id?`bg-brand/10 text-foreground [&>svg]:text-brand`:``}`,children:[(0,W.jsx)($o,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[t===e.id&&(0,W.jsx)(an,{className:`size-4 text-brand`}),e.canManage&&(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Open Team Management for ${e.name}`,className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent bg-muted/50 text-muted-foreground transition-all hover:border-brand/40 hover:bg-brand hover:text-white hover:shadow-sm focus-visible:border-brand focus-visible:bg-brand focus-visible:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/40`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e)},children:(0,W.jsx)(Lo,{className:`size-3.5`})})}),(0,W.jsx)(Wt,{side:`top`,className:`text-xs`,children:`Manage team`})]})]})]},e.id))]}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{className:`my-1.5`}),(0,W.jsx)(Yt,{children:(0,W.jsxs)(Kt,{onClick:o,className:`cursor-pointer gap-2 px-2.5 py-2 transition-colors hover:bg-brand/10 hover:text-foreground focus:bg-brand/10 focus:text-foreground focus:[&>svg]:text-brand`,children:[(0,W.jsx)(zt,{className:`size-4 text-muted-foreground transition-colors`}),(0,W.jsx)(`span`,{children:`Add Team`})]})})]})]})]})})}):(0,W.jsx)(Up,{children:(0,W.jsx)(Wp,{children:u})})}function bfe(){if(typeof navigator>`u`)return`Ctrl+K`;let e=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad/i.test(e)?`⌘K`:`Ctrl+K`}function xfe({isLoading:e,isOnline:t,onQueryChange:n,onResultSelect:r,query:i,results:a,showDbClient:o}){let[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(`all`),d=(0,U.useRef)(null),f=bfe(),p=[{value:`all`,label:`All`},{value:`workspace`,label:`Projects`},{value:`erd`,label:`ERD Builder`},...o?[{value:`db-client`,label:`DB Client`}]:[],{value:`notes`,label:`Notes`},{value:`flowchart`,label:`Flowcharts`},{value:`drawings`,label:`Drawings`}],m=l===`all`?a:a.filter(e=>e.type===l);return(0,U.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),c(!0),d.current?.focus(),d.current?.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,U.useEffect)(()=>{s&&window.setTimeout(()=>{d.current?.focus(),d.current?.select()},0)},[s]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{type:`button`,onClick:()=>c(!0),disabled:!t,"aria-label":`Search files (${f})`,title:`Search files (${f})`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,children:(0,W.jsx)(Kr,{className:`size-4`,"aria-hidden":`true`})}),(0,W.jsx)($r,{open:s,onOpenChange:e=>{c(e),e||(u(`all`),n(``))},children:(0,W.jsxs)(qr,{size:`2xl`,showCloseButton:!1,className:`translate-y-0! max-h-[76vh] sm:max-w-2xl`,style:{top:`12vh`},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/60 px-4 py-3`,children:[(0,W.jsx)(Kr,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,W.jsx)(Oi,{ref:d,value:i,onChange:e=>n(e.target.value),placeholder:`Search files and projects`,"aria-label":`Spotlight file search`,className:`min-w-0 flex-1`}),(0,W.jsx)(`kbd`,{className:`rounded-lg border border-border/60 bg-muted/50 px-2.5 py-1.5 text-xs font-medium text-muted-foreground`,children:`ESC`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto border-b border-border/60 px-4 py-2.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Filter:`}),(0,W.jsx)(`div`,{className:`flex min-w-max items-center gap-1`,children:p.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(e.value),className:`min-h-10 rounded-md px-2.5 py-1 font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${l===e.value?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/60 hover:text-foreground`}`,children:e.label},e.value))})]}),(e||i.trim().length>=2)&&(0,W.jsx)(`div`,{className:`max-h-[min(26rem,60vh)] overflow-y-auto p-2`,children:e?(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,W.jsx)(vo,{className:`size-4 animate-spin`,"aria-hidden":`true`}),` Searching...`]}):m.length===0?(0,W.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No results found.`}):m.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),c(!1)},className:`group flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,W.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-muted`,children:e.type===`workspace`?(0,W.jsx)(Ya,{className:`size-4 text-muted-foreground`}):e.type===`erd`?(0,W.jsx)(Ar,{className:`size-4 text-muted-foreground`}):e.type===`db-client`?(0,W.jsx)(jr,{className:`size-4 text-muted-foreground`}):e.type===`notes`?(0,W.jsx)(Nt,{className:`size-4 text-muted-foreground`}):e.type===`flowchart`?(0,W.jsx)(Eo,{className:`size-4 text-muted-foreground`}):(0,W.jsx)(Mr,{className:`size-4 text-muted-foreground`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name||`(Untitled)`}),(0,W.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e.type===`workspace`?`Project`:e.type===`erd`?`ERD Builder`:e.type===`db-client`?`DB Client`:e.type===`flowchart`?`Flowchart`:e.type===`notes`?`Note`:`Drawing`,e.workspace?.name&&` · ${e.workspace.name}`]})]}),(0,W.jsx)(ha,{className:`size-4 shrink-0 text-muted-foreground/40 group-hover:text-primary`,"aria-hidden":`true`})]},`${e.type}-${e.uid??e.id}`))})]})})]})}var rx={owner:`Creator`,manager:`Manager`,editor:`Editor`,commenter:`Commenter`,viewer:`Viewer`},Sfe=[`editor`,`commenter`,`viewer`],Cfe={editor:`Can change the files.`,commenter:`Can read and comment (default).`,viewer:`Can read only.`};function wfe(e){return{userId:String(e.user_id??e.userId),name:e.name??null,email:e.email??null,teamRole:String(e.team_role??e.teamRole??`staff`),role:e.role,canChange:(e.can_change??e.canChange)===!0}}function Tfe({project:e,onOpenChange:t}){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),c=e?.id,l=(0,U.useCallback)(async()=>{if(c!==void 0){a(``);try{let e=await wi(`/api/projects/${encodeURIComponent(String(c))}/access`),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Could not load access.`);r((t.members??[]).map(wfe))}catch(e){r(null),a(e instanceof Error?e.message:`Could not load access.`)}}},[c]);(0,U.useEffect)(()=>{r(null),c!==void 0&&l()},[c,l]);let u=async(e,t)=>{if(t!==e.role&&c!==void 0){s(e.userId);try{let n=`/api/projects/${encodeURIComponent(String(c))}/access/${encodeURIComponent(e.userId)}`,i=t===`commenter`?await wi(n,{method:`DELETE`}):await wi(n,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:t})}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||`Could not change access.`);r(n=>n?.map(n=>n.userId===e.userId?{...n,role:t}:n)??n),d.success(`${e.name||e.email||`Member`} is now ${rx[t]}.`)}catch(e){d.error(e instanceof Error?e.message:`Could not change access.`),await l()}finally{s(null)}}};return(0,W.jsx)($r,{open:e!==null,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-lg`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Project access`}),(0,W.jsxs)(Ur,{children:[`Choose what each Team member can do in `,e?.name,`. The creator and Team Managers always have full access.`]})]}),(0,W.jsxs)(Yr,{children:[i&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i}),!i&&n===null&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,children:[(0,W.jsx)(vo,{className:`size-4 animate-spin`,"aria-hidden":`true`}),` Loading members…`]}),n&&n.length===0&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team has no other active members.`}),n&&n.length>0&&(0,W.jsx)(`ul`,{className:`divide-y rounded-lg border`,"aria-label":`Project members`,children:n.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name||e.email||`Member`}),e.name&&e.email&&(0,W.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.email})]}),e.canChange?(0,W.jsxs)(Er,{value:e.role,onValueChange:t=>{t&&u(e,t)},disabled:o===e.userId,children:[(0,W.jsx)(Cr,{className:`w-36`,"aria-label":`Access for ${e.name||e.email||`member`}`,children:(0,W.jsx)(Tr,{children:rx[e.role]})}),(0,W.jsx)(Sr,{className:`min-w-72`,children:(0,W.jsx)(wr,{children:Sfe.map(e=>(0,W.jsx)(xr,{value:e,children:(0,W.jsxs)(`span`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{children:rx[e]}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Cfe[e]})]})},e))})})]}):(0,W.jsx)(`span`,{className:`w-36 px-3 text-sm text-muted-foreground`,children:rx[e.role]})]},e.userId))})]})]})})}function Efe({activeTeamId:e,globalSearchQuery:t,globalSearchResults:n,isGlobalSearchLoading:r,isOnline:i,isProjectsLoading:a,onGlobalSearchChange:o,onGlobalSearchResultSelect:s,onTeamAdd:c,onTeamManage:l,onTeamSelect:u,onTeamsRefresh:d,onProjectCreate:f,onProjectDelete:p,onProjectUpdate:m,onWorkspaceFilter:h,projects:g,selectedWorkspaceUid:_,showDbClient:v,showSponsor:y,teams:b,teamsAvailable:x,user:S}){let[C,w]=(0,U.useState)(null),[T,E]=(0,U.useState)(``),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(null),[j,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(``),F=g.filter(e=>!e.is_deleted),I=(e,t)=>{h(e??(t==null?null:String(t)))};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ip,{collapsible:`none`,className:`min-w-0 flex-1`,children:[(0,W.jsxs)(Lp,{className:`gap-3.5 border-b border-sidebar-border px-2 py-4`,children:[(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(yfe,{teams:b,activeTeamId:e,enabled:x||b.length>0,canManageTeams:!!(S?.isSuperAdmin||S?.is_super_admin),onOpen:d,onSelect:u,onAdd:c,onManage:l})}),(0,W.jsx)(xfe,{query:t,results:n,isLoading:r,isOnline:i,showDbClient:v,onQueryChange:o,onResultSelect:s})]}),(0,W.jsxs)(H,{type:`button`,variant:`secondary`,className:`h-9 w-full justify-start gap-2`,onClick:()=>{P(``),M(!0)},children:[(0,W.jsx)(zt,{className:`size-4`}),`New Project`]})]}),(0,W.jsx)(zp,{children:(0,W.jsxs)(Bp,{className:`px-2`,children:[(0,W.jsx)(Vp,{children:`Projects`}),(0,W.jsx)(Hp,{children:(0,W.jsxs)(Up,{children:[(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{tooltip:`All Projects`,isActive:_===null||_===``,onClick:()=>I(null),children:[(0,W.jsx)(Ya,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:`All Projects`})]})}),a?(0,W.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground animate-pulse`,children:`Loading projects...`}):F.length===0?(0,W.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground`,children:`No projects yet`}):F.map(t=>(0,W.jsx)(Wp,{children:(0,W.jsxs)(Gp,{tooltip:t.name,isActive:_===t.uid||String(_??``)===String(t.id??``),onClick:()=>I(t.uid,t.id),children:[(0,W.jsx)(Ya,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:t.name}),(0,W.jsx)(`span`,{className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsx)(`button`,{type:`button`,"aria-label":`Project options for ${t.name}`,className:`flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,children:(0,W.jsx)(Nr,{className:`size-4`})})}),(0,W.jsxs)(en,{align:`end`,className:`min-w-44`,children:[e&&(t.access_role===`owner`||t.access_role===`manager`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Kt,{onClick:()=>A({id:t.id,name:t.name}),children:[(0,W.jsx)(es,{className:`size-3.5`,"aria-hidden":`true`}),`Manage access`]}),(0,W.jsx)(tn,{})]}),ji(t,S?.id,S?.id===`guest`)?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Kt,{onClick:()=>{E(t.name),w(t)},children:[(0,W.jsx)(_r,{className:`size-3.5`,"aria-hidden":`true`}),`Rename`]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>O(t),children:[(0,W.jsx)(ni,{className:`size-3.5 text-destructive`,"aria-hidden":`true`}),`Delete`]})]}):(0,W.jsx)(Kt,{disabled:!0,children:`Only the creator can rename or delete`})]})]})})]})},t.uid??t.id))]})})]})}),y&&(0,W.jsx)(Rp,{className:`shrink-0 border-t border-sidebar-border p-2`,children:(0,W.jsx)(vfe,{})})]}),(0,W.jsx)(Tfe,{project:k,onOpenChange:e=>{e||A(null)}}),(0,W.jsx)($r,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Rename Project`})}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`rename-project-input`,children:`Name`}),(0,W.jsx)(Oi,{id:`rename-project-input`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T.trim()&&C&&(m(C.id,T.trim()),w(null))},autoFocus:!0})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{className:`h-9 px-6`,disabled:!T.trim(),onClick:()=>{C&&T.trim()&&(m(C.id,T.trim()),w(null))},children:`Save Changes`})]})]})}),(0,W.jsx)($r,{open:j,onOpenChange:M,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Create Project`})}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`create-project-input`,children:`Project name`}),(0,W.jsx)(Oi,{id:`create-project-input`,value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N.trim()&&(f(N.trim()),M(!1),P(``))},autoFocus:!0})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Cancel`}),(0,W.jsx)(H,{className:`h-9 px-6`,disabled:!N.trim(),onClick:()=>{N.trim()&&(f(N.trim()),M(!1),P(``))},children:`Create`})]})]})}),(0,W.jsx)(db,{isOpen:D!==null,onOpenChange:e=>{e||O(null)},mode:`move-to-trash`,view:`project`,activeDocument:D?{id:D.id,name:D.name}:void 0,deleteProject:p,onAfterDelete:()=>O(null)})]})}function Dfe({open:e,onOpenChange:t,onCreate:n,onCreated:r}){let[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{e||(a(``),s(``),l(!1))},[e]),(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsx)(qr,{size:`md`,children:(0,W.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),s(``),l(!0);try{let e=await n({name:i});t(!1),r?.(e)}catch(e){s(e?.message||`Team could not be created.`)}finally{l(!1)}},children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Add Team`}),(0,W.jsx)(Ur,{children:`Create a Team using this installation's active license.`})]}),(0,W.jsxs)(Yr,{className:`space-y-4`,children:[(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`team-name`,children:`Team name`}),(0,W.jsx)(Oi,{id:`team-name`,value:i,onChange:e=>a(e.target.value),placeholder:`Acme Engineering`,maxLength:100,required:!0,autoFocus:!0})]}),o&&(0,W.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:o})]}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(H,{type:`button`,variant:`outline`,onClick:()=>t(!1),disabled:c,children:`Cancel`}),(0,W.jsx)(H,{type:`submit`,disabled:c||!i.trim(),children:c?`Creating…`:`Add Team`})]})]})})})}var Ofe=U.memo(({projects:e,activeFeatureView:t,globalSearchResults:n,isGlobalSearchLoading:r,onGlobalSearchResultSelect:i,onViewChange:a,onProjectCreate:o,onProjectUpdate:s,onProjectDelete:l,onLogout:u,onWorkspaceFilter:d,selectedWorkspaceUid:f,globalSearchQuery:p,onGlobalSearchChange:m,isProjectsLoading:h,user:g,isOnline:_,onOpenFeedback:v,teams:y,teamsAvailable:b,licenseRequired:x,activeTeamId:S,onTeamsRefresh:C,onTeamSelect:w,onTeamManage:T,onTeamCreate:E,onTeamCreated:D,ssoPortalUrl:O,...k})=>{let[A,j]=(0,U.useState)(!1),[M,N]=(0,U.useState)(null),P=Ei(),F=!P&&!g?.isSso&&(g?.isSuperAdmin!==void 0||g?.is_super_admin!==void 0),I=g?.isSso===!0||P||F&&x,L=y.find(e=>e.id===S)||null,R=g?.isSso&&S&&b?L?.capabilities||{}:null,ee=e=>R!==null&&R[e]!==!0,te=()=>{if(O)try{window.location.assign(new URL(`/pricing#cloud-saas`,O).toString())}catch{}},ne=(e,t,n)=>{ee(t)?N(e):n()};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ip,{collapsible:`icon`,...k,className:c(`overflow-hidden *:data-[sidebar=sidebar]:flex-row`,k.className),children:(0,W.jsxs)(`div`,{"data-sidebar":`sidebar`,className:`flex h-full min-h-0 w-full`,children:[(0,W.jsx)(hfe,{activeFeatureView:t,canManageInstance:!!(g?.isSuperAdmin||g?.is_super_admin),cloudFeatureLocked:ee,isOnline:_,isSelfHosted:F,onFeatureClick:ne,onLogout:u,onOpenFeedback:v,onViewChange:a,ssoPortalUrl:O,user:g,showDbClient:P}),(0,W.jsx)(Efe,{activeTeamId:S,globalSearchQuery:p,globalSearchResults:n,isGlobalSearchLoading:r,isOnline:_,isProjectsLoading:h,onGlobalSearchChange:m,onGlobalSearchResultSelect:i,onTeamAdd:()=>j(!0),onTeamManage:T,onTeamSelect:w,onTeamsRefresh:C,onProjectCreate:o,onProjectDelete:l,onProjectUpdate:s,onWorkspaceFilter:d,projects:e,selectedWorkspaceUid:f,showDbClient:P,showSponsor:I,teams:y,teamsAvailable:b,user:g})]})}),(0,W.jsx)(Dfe,{open:A,onOpenChange:j,onCreate:E,onCreated:D}),(0,W.jsx)($r,{open:M!==null,onOpenChange:e=>{e||N(null)},children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,W.jsx)(ti,{className:`size-4`,"aria-hidden":`true`})}),(0,W.jsxs)(Jr,{children:[`Unlock `,M]})]}),(0,W.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[M,` is available with a paid Cloud plan. Upgrade to keep using this feature in your Team workspace.`]})]}),(0,W.jsx)(Yr,{children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-primary/20 bg-primary/5 px-3.5 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Cloud workspace feature`}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Plans, limits, and checkout are managed in ERDBPro SaaS.`})]}),(0,W.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-[0.14em] text-primary`,children:`PRO`})]})}),(0,W.jsxs)(Xr,{children:[(0,W.jsx)(Zr,{render:(0,W.jsx)(H,{variant:`outline`,className:`h-9`}),children:`Not now`}),(0,W.jsxs)(H,{className:`h-9`,onClick:te,disabled:!O,children:[`View Cloud plans`,(0,W.jsx)(ha,{className:`size-4`})]})]})]})})]})});function kfe({isOpen:e,onOpenChange:t,documentType:n,documentUid:r,documentId:i,documentTitle:a,isPublicView:o=!1,initialSettings:s,onSettingsSaved:c}){let[l,u]=U.useState(s?.share_token||``),[f,p]=U.useState(!1),[m,h]=U.useState(s?.is_public||!1),[g,_]=U.useState(``),[v,y]=U.useState(!1);U.useEffect(()=>{if(s?.expiry_date){let e=new Date(s.expiry_date),t=new Date,n=e.getTime()-t.getTime(),r=Math.ceil(n/864e5);r>0&&_(r.toString())}u(s?.share_token||``),h(s?.is_public||!1)},[s]);let b={erd:`diagram`,notes:`note`,drawings:`drawing`,flowchart:`flowchart`}[n]||n,x=`${window.location.origin}/view/${b}/${r}`;return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-md`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:o?`Share Document`:`Share "${a}"`}),(0,W.jsx)(Ur,{children:o?`Share this link with others to view this document.`:m?`Anyone with this link can view this document. No account required.`:`This document is currently private. Only you can access it.`})]}),(0,W.jsxs)(Yr,{className:`space-y-4`,children:[!o&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50`,children:[(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m?(0,W.jsx)(no,{className:`w-4 h-4 text-primary`}):(0,W.jsx)(yo,{className:`w-4 h-4 text-muted-foreground`}),(0,W.jsx)(oa,{htmlFor:`public-status`,className:`text-sm font-bold`,children:`Public Access`})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Enable sharing via public link`})]}),(0,W.jsx)(pm,{id:`public-status`,checked:m,onCheckedChange:e=>h(e)})]}),(0,W.jsxs)(`div`,{className:`space-y-4 transition-all duration-300 ${m||o?`opacity-100`:`opacity-40 pointer-events-none grayscale-[0.5]`}`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(oa,{htmlFor:`share-link`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Public Link`}),(0,W.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,W.jsx)(Oi,{id:`share-link`,readOnly:!0,value:x,className:`flex-1 bg-muted/20 font-mono text-xs`}),(0,W.jsx)(H,{onClick:()=>{navigator.clipboard.writeText(x),p(!0),d.success(`Link copied to clipboard!`),setTimeout(()=>p(!1),2e3)},size:`icon`,variant:`outline`,className:`shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors`,disabled:!m&&!o,children:f?(0,W.jsx)(an,{className:`w-4 h-4 text-green-500`}):(0,W.jsx)(La,{className:`w-4 h-4`})})]})]}),!o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(oa,{htmlFor:`access-token`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Access Token (Optional)`}),(0,W.jsxs)(H,{variant:`link`,size:`sm`,onClick:()=>{let e=Math.random().toString(36).substring(2,10).toUpperCase();u(e),d.info(`Secure token generated`)},className:`h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline`,disabled:!m,children:[(0,W.jsx)(Hr,{className:`w-3 h-3 mr-1`}),`Generate`]})]}),(0,W.jsx)(Oi,{id:`access-token`,placeholder:`Enter or generate a token...`,value:l,onChange:e=>u(e.target.value),disabled:!m,className:`font-mono text-xs`})]}),(0,W.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,W.jsx)(oa,{htmlFor:`valid-until`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Duration (Days)`}),(0,W.jsx)(Oi,{id:`valid-until`,type:`number`,placeholder:`Forever`,value:g,onChange:e=>_(e.target.value),disabled:!m,className:`text-xs`})]})]})]})]}),(0,W.jsx)(Xr,{className:`flex flex-col sm:flex-row gap-2 sm:justify-end`,children:o?(0,W.jsx)(H,{type:`button`,onClick:()=>t(!1),className:`cursor-pointer w-full sm:w-auto font-bold`,children:`Close`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{variant:`ghost`,onClick:()=>t(!1),className:`cursor-pointer order-2 sm:order-1 font-semibold`,disabled:v,children:`Cancel`}),(0,W.jsx)(H,{type:`button`,onClick:async()=>{y(!0);try{let e=n===`erd`?`diagrams`:n===`flowchart`?`flowcharts`:n,r=null;if(g&&!isNaN(parseInt(g))){let e=new Date;e.setDate(e.getDate()+parseInt(g)),r=e.toISOString()}if(!(await wi(`/api/${e}/${i}/share`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({is_public:m,share_token:l,expiry_date:r})})).ok)throw Error(`Failed to save settings`);d.success(`Sharing settings updated!`),c&&c(),t(!1)}catch(e){d.error(e.message||`Something went wrong`)}finally{y(!1)}},className:`cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]`,disabled:v,children:v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Hr,{className:`w-4 h-4 mr-2 animate-spin`}),`Saving...`]}):`Save Changes`})]})})]})})}function Afe({open:e,onOpenChange:t}){return(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{size:`2xl`,className:`max-h-[82vh]`,children:[(0,W.jsx)(Qr,{children:(0,W.jsx)(Jr,{children:`Table Calculation Guide`})}),(0,W.jsxs)(Yr,{className:`space-y-5 overflow-y-auto pr-1 text-sm leading-6`,children:[(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`How it works`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Type a formula command in a table cell, then leave the cell. The editor replaces the command with the calculated result. Hover the result cell to see the Excel-style source range used for that value.`})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Vertical formulas`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Vertical formulas calculate numeric values in the same column. They are intended for header or footer rows.`}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted/30 p-3`,children:[(0,W.jsx)(`code`,{children:`=SUM`}),(0,W.jsx)(`code`,{children:`=SUMV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sum values vertically, for example: SUMV(B2:B5).`}),(0,W.jsx)(`code`,{children:`=AVG`}),(0,W.jsx)(`code`,{children:`=AVGV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Average values vertically, for example: AVGV(C2:C5).`}),(0,W.jsx)(`code`,{children:`=MUL`}),(0,W.jsx)(`code`,{children:`=PRODUCT`}),(0,W.jsx)(`code`,{children:`=MULV`}),(0,W.jsx)(`code`,{children:`=PRODUCTV`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Multiply values vertically, for example: PRODUCTV(D2:D5).`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Horizontal formulas`}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Horizontal formulas calculate numeric values to the left of the formula cell in the same row.`}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted/30 p-3`,children:[(0,W.jsx)(`code`,{children:`=SUMH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sum values horizontally, for example: SUMH(B2:C2).`}),(0,W.jsx)(`code`,{children:`=AVGH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Average values horizontally, for example: AVGH(B2:D2).`}),(0,W.jsx)(`code`,{children:`=MULH`}),(0,W.jsx)(`code`,{children:`=PRODUCTH`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Multiply values horizontally, for example: PRODUCTH(B2:C2).`})]})]}),(0,W.jsxs)(`section`,{className:`space-y-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Examples`}),(0,W.jsx)(`div`,{className:`rounded-md border overflow-hidden`,children:(0,W.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,W.jsx)(`thead`,{className:`bg-muted/50`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Item`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Qty`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Price`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Total`})]})}),(0,W.jsxs)(`tbody`,{children:[(0,W.jsxs)(`tr`,{className:`border-t`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`Hosting`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`12`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`90.000`}),(0,W.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,W.jsx)(`code`,{children:`=MULH`}),` becomes 1.080.000`]})]}),(0,W.jsxs)(`tr`,{className:`border-t`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`Setup`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`100.000`}),(0,W.jsx)(`td`,{className:`px-3 py-2`,children:`50.000`}),(0,W.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,W.jsx)(`code`,{children:`=SUMH`}),` becomes 150.000`]})]})]})]})}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Text cells are skipped. Indonesian number formatting such as 1.080.000 and decimal commas is accepted. Currency symbols are ignored when possible.`})]})]})]})})}var jfe=({onShare:e,onCopyPath:t,onRename:n,onDelete:r,onDuplicate:i,onExportAll:a,onExportMarkdown:o,onCopyMarkdown:s,onImportMarkdown:c,onExportImage:l,isOnline:u,isPublicView:f=!1,isPublic:p=!1,activeFileUid:m,documentType:h,noteContent:g,historyEnabled:_=!1,onOpenHistory:v,onRefresh:y,isRefreshing:b=!1})=>{let[x,S]=(0,U.useState)(!1),C=e=>e.replace(/<[^>]+>/g,``).replace(/&[^;]+;/g,` `).trim(),w=(e=>{let t=e?C(e):``;return t?{words:t.split(/\s+/).filter(Boolean).length,sentences:t.split(/[.!?]+(?:\s|$)/).filter(e=>e.trim().length>0).length,paragraphs:e&&(e.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||t.split(/\n\s*\n/).filter(Boolean).length,characters:t.replace(/\s/g,``).length}:{words:0,sentences:0,paragraphs:0,characters:0}})(g),T=()=>{if(!m){d.error(`Document link not available`);return}let e={erd:`diagram`,notes:`note`,drawings:`drawing`,flowchart:`flowchart`}[h]||h,t=`${window.location.origin}/view/${e}/${m}`;navigator.clipboard.writeText(t),d.success(`Public share link copied to clipboard`)};return(0,W.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[(0,W.jsxs)(nn,{children:[(0,W.jsx)(Jt,{render:(0,W.jsxs)(H,{"aria-label":`Actions`,variant:`ghost`,size:`sm`,className:`h-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200`,children:[(0,W.jsx)(`span`,{className:`hidden sm:inline mr-1.5 text-xs font-medium`,children:`Actions`}),(0,W.jsx)(Nr,{className:`h-4 w-4`})]})}),(0,W.jsxs)(en,{align:`end`,className:`w-56`,children:[f?(0,W.jsxs)(Kt,{onClick:T,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Public Link`})]}):(0,W.jsxs)(W.Fragment,{children:[t&&(0,W.jsxs)(Kt,{onClick:t,children:[(0,W.jsx)(La,{className:`text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Path`})]}),e&&(0,W.jsxs)(Kt,{disabled:!u,onClick:e,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(zo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Share`})]}),p&&(0,W.jsxs)(Kt,{disabled:!u,onClick:T,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(er,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Public Link`})]}),(0,W.jsx)(tn,{}),n&&(0,W.jsxs)(Kt,{disabled:!u,onClick:n,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Mo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Edit`})]}),y&&(0,W.jsxs)(Kt,{disabled:!u||b,onClick:()=>y(),className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Hr,{className:`h-4 w-4 text-muted-foreground ${b?`animate-spin`:``}`}),(0,W.jsx)(`span`,{children:`Refresh`})]}),v&&(0,W.jsxs)(Kt,{disabled:!_,onClick:()=>v(),className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(oo,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Version History`})]}),r&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{disabled:!u,onClick:r,className:`gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer`,children:[(0,W.jsx)(ni,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:`Move to Trash`})]})]})]}),(h===`notes`||h===`drawings`)&&!f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{disabled:!u,onClick:i,className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(La,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Duplicate`})]})]}),h===`erd`&&!f&&a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(qt,{children:[(0,W.jsxs)(rn,{className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Export All`})]}),(0,W.jsxs)(Xt,{className:`w-48`,children:[(0,W.jsx)(Kt,{onClick:a,className:`gap-2 cursor-pointer`,children:(0,W.jsx)(`span`,{children:`Export Schemas`})}),(0,W.jsx)(Kt,{onClick:l,className:`gap-2 cursor-pointer`,children:(0,W.jsx)(`span`,{children:`Download SVG`})})]})]})]}),h===`notes`&&!f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tn,{}),(0,W.jsxs)(Kt,{onClick:()=>S(!0),children:[(0,W.jsx)(Sa,{className:`text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Calculation Guide`})]}),(0,W.jsx)(Kt,{disabled:!u,onClick:s,className:`gap-2 cursor-pointer flex items-center`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(La,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Copy Markdown`})]})}),c&&(0,W.jsxs)(Kt,{disabled:!u,onClick:c,className:`gap-2 cursor-pointer flex items-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(sr,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Import`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 text-muted-foreground/60`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⌘`}),(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⇧`}),(0,W.jsx)(`span`,{className:`text-[15px] font-mono font-bold mt-0.5`,children:`I`})]})]}),(0,W.jsxs)(Kt,{disabled:!u,onClick:o,className:`gap-2 cursor-pointer flex items-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,W.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Export`})]}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 text-muted-foreground/60`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⌘`}),(0,W.jsx)(`span`,{className:`text-[13px] font-sans leading-none`,children:`⇧`}),(0,W.jsx)(`span`,{className:`text-[15px] font-mono font-bold mt-0.5`,children:`E`})]})]}),(0,W.jsx)(tn,{}),(0,W.jsxs)(qt,{children:[(0,W.jsxs)(rn,{className:`gap-2 cursor-pointer`,children:[(0,W.jsx)(Ca,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{children:`Text Stats`})]}),(0,W.jsx)(Xt,{className:`w-52 p-1`,children:(0,W.jsxs)(`div`,{className:`px-3 py-1.5 space-y-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Words`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.words.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Sentences`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.sentences.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Paragraphs`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.paragraphs.toLocaleString()})]}),(0,W.jsx)(tn,{className:`my-1.5`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Characters`}),(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:w.characters.toLocaleString()})]})]})})]})]})]})]}),h===`notes`&&(0,W.jsx)(Afe,{open:x,onOpenChange:S})]})},Mfe=U.memo(({featureLabel:e,documentPath:t,sidebarDisabled:n=!1,activeProjectName:r,activeFileName:i,view:a,hasActiveItem:o,syncError:s,isSyncing:c,isRefreshing:l,isLocalSaving:u=!1,hasPendingSyncs:f,activeFileUid:p,activeFileId:m,initialShareSettings:g,onSettingsSaved:_,isPublicView:v=!1,isOnline:y,updatedAt:b,onDelete:x,onRename:S,onSave:C,onExportAll:w,onExportSQL:T,onExportImage:E,onExportMarkdown:D,onCopyMarkdown:O,onImportMarkdown:k,onDuplicate:A,isGuest:j=!1,breadcrumbLabel:M,noteContent:N,historyAvailable:P=!0,canManage:F=!0,onRefresh:I,discussionPanel:L,tabsRef:R})=>{let ee=h(),[te,ne]=U.useState(!1),{setRightPanelMode:re}=An(),ie=!(!P||a!==`erd`&&a!==`flowchart`&&(a!==`notes`&&a!==`drawings`||!a)||!p||j||v||!y||u||c||f),z=U.useCallback(()=>re(`history`),[re]),ae=U.useCallback(e=>{navigator.clipboard.writeText(`${e} > ${r||`No Workspace`} > ${i}`).then(()=>d.success(`File path copied`)).catch(()=>d.error(`Failed to copy file path`))},[i,r]),oe=t??ee.pathname,se=!v&&/^\/(notes|diagrams|drawings|flowcharts|db-client)\/[^/]+$/.test(oe);return(0,W.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 w-full overflow-hidden border-b bg-background/50 backdrop-blur-sm`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 px-2 sm:px-4`,children:[!v&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(nie,{className:`-ml-1 shrink-0`,disabled:n}),(0,W.jsx)(Ep,{orientation:`vertical`,className:`h-4 shrink-0 bg-border/50`})]}),(0,W.jsx)(`div`,{ref:R,className:se?`flex min-w-0 flex-1 items-center`:`hidden`}),!se&&(0,W.jsx)(Kp,{className:`min-w-0 flex items-center`,children:(0,W.jsx)(qp,{className:`min-w-0 flex-nowrap items-center`,children:!v&&(()=>{let n=t??ee.pathname;if(n===`/`)return(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:`Dashboard`})});if(n.startsWith(`/table/`)){let e={notes:`Notes`,erd:`ERD Builder`,"db-client":`DB Client`,drawings:`Drawings`,flowchart:`Flowcharts`},t=n.match(/^\/table\/([^/]+)$/)?.[1],r=t?e[t]||t:`Unknown`;return(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:r})})}return n.startsWith(`/trash`)?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:`Trash`})}):n.startsWith(`/library`)?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-foreground`,children:`Library`})}):n.startsWith(`/teams/`)?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Jp,{className:`shrink-0 text-muted-foreground`,children:`Teams`}),(0,W.jsx)(Xp,{}),(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:M||`Team management`})})]}):M?(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-semibold text-foreground`,children:M})}):(0,W.jsx)(Jp,{className:`shrink-0`,children:(0,W.jsx)(Yp,{className:`font-medium text-muted-foreground`,children:e})})})()})})]}),!y&&!v&&(0,W.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 px-3 py-1 rounded-full bg-destructive/10 border border-destructive/20 text-destructive animate-in fade-in slide-in-from-top-1 duration-500`,children:[(0,W.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-destructive animate-pulse`}),(0,W.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:`Offline Mode: Navigation Disabled`})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 pr-2 sm:pr-4`,children:!!ee.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[!v&&s&&(0,W.jsxs)(`span`,{role:`status`,title:`Changes saved locally, but cloud sync failed. We'll retry automatically.`,className:`flex shrink-0 items-center gap-1 text-destructive`,children:[(0,W.jsx)(Na,{className:`size-4`}),(0,W.jsx)(`span`,{className:`hidden lg:inline text-xs`,children:`Sync Failed`})]}),!v&&g?.is_public&&(0,W.jsxs)(tm,{variant:`outline`,title:`This document is shared publicly via a secret link.`,className:`shrink-0 gap-1`,children:[(0,W.jsx)(no,{className:`size-3`}),(0,W.jsx)(`span`,{className:`hidden lg:inline`,children:`Public`})]}),L,(0,W.jsx)(jfe,{onCopyPath:v?void 0:()=>ae(new URLSearchParams(ee.search).get(`feature`)===`db-client`?`DB Client`:{notes:`Notes`,erd:`ERD Builder`,flowchart:`Flowcharts`,drawings:`Drawings`}[a]||e),onShare:F?()=>y&&ne(!0):void 0,onDelete:x,onRename:S,onDuplicate:A,onExportAll:w,onExportSQL:T,onExportImage:E,onExportMarkdown:D,onCopyMarkdown:O,onImportMarkdown:k,isOnline:y,isPublicView:v,isPublic:g?.is_public,activeFileUid:p,documentType:a,noteContent:N,historyEnabled:ie,onOpenHistory:j||v?void 0:z,onRefresh:j||v?void 0:I,isRefreshing:l}),p&&m&&y&&(0,W.jsx)(kfe,{isOpen:te,onOpenChange:ne,documentType:a,documentUid:p,documentId:m,documentTitle:i||`Untitled`,isPublicView:v,initialSettings:g,onSettingsSaved:_})]})})]})}),ix=`(max-width: 1023px)`;function Nfe(){let[e,t]=(0,U.useState)(()=>typeof window>`u`||!window.matchMedia(ix).matches);return(0,U.useEffect)(()=>{let e=window.matchMedia(ix),n=e=>t(!e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),{open:e,onOpenChange:t}}var Pfe=`https://api.erdbuilderpro.com/api/feedback`;function Ffe(){return Pfe}function Ife({open:e,onOpenChange:t}){let[n,r]=U.useState(!1),[i,a]=U.useState(``),[o,s]=U.useState(`suggestion`),[c,l]=U.useState(``);return(0,W.jsx)($r,{open:e,onOpenChange:e=>{t(e),e||a(``)},children:(0,W.jsx)(qr,{className:`sm:max-w-106.25 border-border bg-popover/95 backdrop-blur-xl shadow-2xl`,children:(0,W.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),i.trim()){r(!0);try{if((await fetch(Ffe(),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`omit`,body:JSON.stringify({content:i,category:o,email:c,url:window.location.href,browser:navigator.userAgent})})).ok)d.success(`Feedback terkirim! Terima kasih masukannya.`),t(!1),a(``);else throw Error()}catch{d.error(`Gagal mengirim feedback. Coba lagi nanti.`)}finally{r(!1)}}},className:`flex flex-col max-h-[inherit]`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{className:`text-xl font-bold`,children:`Kirim Masukan`}),(0,W.jsx)(Ur,{className:`text-sm text-muted-foreground`,children:`Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!`})]}),(0,W.jsxs)(Yr,{className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`category`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Tipe Masukan`}),(0,W.jsxs)(Er,{value:o,onValueChange:e=>e&&s(e),children:[(0,W.jsx)(Cr,{id:`category`,className:`bg-white/5 border-white/10 focus:ring-primary/50`,children:(0,W.jsx)(Tr,{placeholder:`Pilih tipe`,children:o===`suggestion`?`Saran Fitur`:o===`bug`?`Lapor Bug`:o===`other`?`Kritik / Lainnya`:o})}),(0,W.jsxs)(Sr,{className:`bg-popover border-border text-popover-foreground`,children:[(0,W.jsx)(xr,{value:`suggestion`,className:`focus:bg-muted`,children:`Saran Fitur`}),(0,W.jsx)(xr,{value:`bug`,className:`focus:bg-muted text-destructive`,children:`Lapor Bug`}),(0,W.jsx)(xr,{value:`other`,className:`focus:bg-muted`,children:`Kritik / Lainnya`})]})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`content`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Pesan`}),(0,W.jsx)(`textarea`,{id:`content`,autoComplete:`off`,className:`flex min-h-35 w-full rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm ring-offset-background placeholder:text-muted-foreground/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-all resize-none`,placeholder:`Tuliskan masukan Anda di sini...`,value:i,onChange:e=>a(e.target.value),maxLength:3e3,required:!0})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(oa,{htmlFor:`email`,className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Email (Opsional)`}),(0,W.jsx)(Oi,{id:`email`,type:`email`,autoComplete:`off`,placeholder:`email@contoh.com`,className:`bg-muted/50 border-border focus:ring-primary/50 h-10 px-4`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,W.jsxs)(Xr,{className:`gap-3`,children:[(0,W.jsx)(H,{variant:`ghost`,type:`button`,onClick:()=>t(!1),className:`hover:bg-muted`,children:`Batal`}),(0,W.jsx)(H,{type:`submit`,disabled:n,className:`bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20`,children:n?`Mengirim...`:`Kirim Masukan`})]})]})})})}var Lfe=({isOpen:e,onOpenChange:t,selectedEntity:n,deleteEntity:r,setSelectedNodeId:i})=>(0,W.jsx)(gi,{open:e,onOpenChange:t,children:(0,W.jsxs)(ai,{size:`sm`,className:`max-w-[400px]`,children:[(0,W.jsxs)(si,{children:[(0,W.jsx)(ui,{className:`bg-destructive/10`,children:(0,W.jsx)(ri,{className:`w-5 h-5 text-destructive`})}),(0,W.jsx)(_i,{children:`Delete Table`})]}),(0,W.jsx)(mi,{children:(0,W.jsxs)(fi,{children:[`Are you sure you want to delete the table `,(0,W.jsx)(`strong`,{children:n?.name}),`? This action cannot be undone.`]})}),(0,W.jsxs)(hi,{children:[(0,W.jsx)(li,{onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(di,{onClick:()=>{n&&(r(n.id),i(null),t(!1))},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})}),Rfe=({isOpen:e,onOpenChange:t,view:n,duplicateName:r,setDuplicateName:i,executeDuplicate:a,isRefreshing:o})=>(0,W.jsx)($r,{open:e,onOpenChange:t,children:(0,W.jsxs)(qr,{className:`sm:max-w-sm`,children:[(0,W.jsxs)(Qr,{children:[(0,W.jsx)(Jr,{children:`Duplicate Document`}),(0,W.jsxs)(Ur,{children:[`Create a copy of this `,n===`erd`?`diagram`:n===`notes`?`note`:n===`drawings`?`drawing`:`flowchart`,`.`]})]}),(0,W.jsx)(Yr,{children:(0,W.jsx)(`div`,{className:`space-y-4`,children:(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`duplicate-input`,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1`,children:`New Name`}),(0,W.jsx)(Oi,{id:`duplicate-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r.trim()&&a()},autoFocus:!0})]})})}),(0,W.jsxs)(Xr,{className:`gap-2 sm:gap-0`,children:[(0,W.jsx)(H,{variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,W.jsx)(H,{onClick:a,disabled:!r.trim()||o,children:o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vo,{className:`mr-2 h-4 w-4 animate-spin`}),`Duplicating...`]}):`Duplicate`})]})]})}),zfe=r(he(),1);function ax(){return ax=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ax.apply(null,arguments)}function Bfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ox=[],sx=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?sx:ox).push(n+=e[t])})();function Vfe(e){if(e<768)return!1;for(let t=0,n=ox.length;;){let r=t+n>>1;if(e<ox[r])n=r;else if(e>=sx[r])t=r+1;else return!0;if(t==n)return!1}}function cx(e){return e>=127462&&e<=127487}var lx=8205;function Hfe(e,t,n=!0,r=!0){return(n?ux:Ufe)(e,t,r)}function ux(e,t,n){if(t==e.length)return t;t&&fx(e.charCodeAt(t))&&px(e.charCodeAt(t-1))&&t--;let r=dx(e,t);for(t+=mx(r);t<e.length;){let i=dx(e,t);if(r==lx||i==lx||n&&Vfe(i))t+=mx(i),r=i;else if(cx(i)){let n=0,r=t-2;for(;r>=0&&cx(dx(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Ufe(e,t,n){for(;t>0;){let r=ux(e,t-2,n);if(r<t)return r;t--}return 0}function dx(e,t){let n=e.charCodeAt(t);if(!px(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return fx(r)?(n-55296<<10)+(r-56320)+65536:n}function fx(e){return e>=56320&&e<57344}function px(e){return e>=55296&&e<56320}function mx(e){return e<65536?1:2}var hx=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Cx(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),_x.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Cx(this,e,t);let n=[];return this.decompose(e,t,n,0),_x.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new bx(this),i=new bx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new bx(this,e)}iterRange(e,t=this.length){return new xx(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Sx(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new gx(t):_x.from(gx.split(t,[]))}},gx=class e extends hx{constructor(e,t=Wfe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Gfe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(yx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=vx(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Cx(this,t,n);let i=vx(this.text,vx(r.text,yx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):_x.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
49
49
|
`){[e,t]=Cx(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},_x=class e extends hx{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=Cx(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
50
50
|
`){[e,t]=Cx(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new gx(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof gx&&c&&(n=u[u.length-1])instanceof gx&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new gx(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};hx.empty=new gx([``],0);function Wfe(e){let t=-1;for(let n of e)t+=n.length+1;return t}function vx(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function yx(e,t,n){return vx(e,[``],t,n)}var bx=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof gx?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof gx?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
51
51
|
`,this;e--}else if(r instanceof gx){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof gx?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},xx=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new bx(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},Sx=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(hx.prototype[Symbol.iterator]=function(){return this.iter()},bx.prototype[Symbol.iterator]=xx.prototype[Symbol.iterator]=Sx.prototype[Symbol.iterator]=function(){return this});var Gfe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Cx(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function wx(e,t,n=!0,r=!0){return Hfe(e,t,n,r)}function Kfe(e){return e>=56320&&e<57344}function qfe(e){return e>=55296&&e<56320}function Tx(e,t){let n=e.charCodeAt(t);if(!qfe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Kfe(r)?(n-55296<<10)+(r-56320)+65536:n}function Ex(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Dx(e){return e<65536?1:2}var Ox=/\r\n?|\n/,kx=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(kx||={}),Ax=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Px(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Ix(this,e)}mapDesc(e,t=!1){return e.empty?this:Fx(this,e,t)}mapPos(e,t=-1,n=kx.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=kx.Simple&&c>=e&&(n==kx.TrackDel&&r<e&&c>e||n==kx.TrackBefore&&r<e||n==kx.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},jx=class e extends Ax{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Px(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Fx(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(hx.empty);r.push(a?t.slice(i,i+a):hx.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Ix(this,e,!0)}map(e,t=!1){return e.empty?this:Fx(this,e,t,!0)}iterChanges(e,t=!1){Px(this,e,t)}get desc(){return Ax.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Lx(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);Mx(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;Mx(n,e,t),t>0&&Nx(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);Mx(n,e,-1),Mx(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:Ax.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&Mx(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?hx.of(l.split(r||Ox)):l:hx.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&Mx(i,e-o,-1),Mx(i,s-e,d),Nx(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(hx.empty);r[e]=hx.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function Mx(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Nx(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(hx.empty);e.push(n)}}function Px(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=hx.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function Fx(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Lx(e),s=new Lx(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);Mx(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(Mx(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(Mx(i,0,o.ins),a&&Nx(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;Mx(i,t,e<o.i?o.ins:0),a&&e<o.i&&Nx(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?jx.createSet(i,a):Ax.create(i);else throw Error(`Mismatched change set lengths`)}function Ix(e,t,n=!1){let r=[],i=n?[]:null,a=new Lx(e),o=new Lx(t);for(let e=!1;;)if(a.done&&o.done)return i?jx.createSet(r,i):Ax.create(r);else if(a.ins==0)Mx(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)Mx(r,0,o.ins,e),i&&Nx(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;Mx(r,t,n,e),i&&n&&Nx(i,r,o.text)}else o.ins==-1?(Mx(r,a.off?0:a.len,t,e),i&&Nx(i,r,a.textBit(t))):(Mx(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&Nx(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var Lx=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?hx.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?hx.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Rx=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return zx.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return zx.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return zx.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},zx=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Rx.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Rx.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?Rx.create(t,e,48|a):Rx.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Bx(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Vx=0,Hx=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Vx++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ux),!!t.static,t.enables)}of(e){return new Wx([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Wx(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Wx(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ux(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Wx=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Vx++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Kx(e,c)){let r=t(e);if(a?!Gx(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=rS(o,c);if(this.dependencies.every(t=>t instanceof Hx?o.facet(t)===e.facet(t):t instanceof Jx?o.field(t,!1)==e.field(t,!1):!0)||(a?Gx(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Gx(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Kx(e,t){let n=!1;for(let r of t)nS(e,r)&1&&(n=!0);return n}function Jfe(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=rS(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)nS(e,t);return e.values[o]=s(e),1},update(e,n){if(!Kx(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Kx(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Ux(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var qx=Hx.define({static:!0}),Jx=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Vx++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(qx).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(qx),i=n.facet(qx),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,qx.of({field:this,create:e})]}get extension(){return this}},Yx={lowest:4,low:3,default:2,high:1,highest:0};function Xx(e){return t=>new Qx(t,e)}var Zx={highest:Xx(Yx.highest),high:Xx(Yx.high),default:Xx(Yx.default),low:Xx(Yx.low),lowest:Xx(Yx.lowest)},Qx=class{constructor(e,t){this.inner=e,this.prec=t}},$x=class e{of(e){return new eS(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},eS=class{constructor(e,t){this.compartment=e,this.inner=t}},tS=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Yfe(t,n,o))e instanceof Jx?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Ux(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Jfe(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Yfe(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof eS&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof eS){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Qx)a(e.inner,e.prec);else if(e instanceof Jx)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Wx)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Yx.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Yx.default),r.reduce((e,t)=>e.concat(t))}function nS(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function rS(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var iS=Hx.define(),aS=Hx.define({combine:e=>e.some(e=>e),static:!0}),oS=Hx.define({combine:e=>e.length?e[0]:void 0,static:!0}),sS=Hx.define(),cS=Hx.define(),lS=Hx.define(),uS=Hx.define({combine:e=>e.length?e[0]:!1}),dS=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Xfe}},Xfe=class{of(e){return new dS(this,e)}},Zfe=class{constructor(e){this.map=e}of(e){return new fS(this,e)}},fS=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Zfe(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};fS.reconfigure=fS.define(),fS.appendConfig=fS.define();var pS=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Bx(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};pS.time=dS.define(),pS.userEvent=dS.define(),pS.addToHistory=dS.define(),pS.remote=dS.define();function Qfe(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function mS(e,t,n){let r,i,a;return n?(r=t.changes,i=jx.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:fS.mapEffects(e.effects,r).concat(fS.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function hS(e,t,n){let r=t.selection,i=_S(t.annotations);return t.userEvent&&(i=i.concat(pS.userEvent.of(t.userEvent))),{changes:t.changes instanceof jx?t.changes:jx.of(t.changes||[],n,e.facet(oS)),selection:r&&(r instanceof zx?r:zx.single(r.anchor,r.head)),effects:_S(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function gS(e,t,n){let r=hS(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=mS(r,hS(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=pS.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return epe(n?$fe(i):i)}function $fe(e){let t=e.startState,n=!0;for(let r of t.facet(sS)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Qfe(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=jx.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=pS.create(t,r,e.selection&&e.selection.map(i),fS.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(cS);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof pS?i:Array.isArray(i)&&i.length==1&&i[0]instanceof pS?i[0]:gS(t,_S(i),!1)}return e}function epe(e){let t=e.startState,n=t.facet(lS),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=mS(r,hS(t,a,e.changes.newLength),!0))}return r==e?e:pS.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var tpe=[];function _S(e){return e==null?tpe:Array.isArray(e)?e:[e]}var vS=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(vS||={}),npe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,yS;try{yS=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function rpe(e){if(yS)return yS.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||npe.test(n)))return!0}return!1}function ipe(e){return t=>{if(!/\S/.test(t))return vS.Space;if(rpe(t))return vS.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return vS.Word;return vS.Other}}var bS=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)nS(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`)}else return nS(this,n),rS(this,n)}update(...e){return gS(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is($x.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(fS.reconfigure)?(n=null,r=e.value):e.is(fS.appendConfig)&&(n=null,r=_S(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=tS.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(aS)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:zx.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=_S(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=fS.mapEffects(a,c).concat(fS.mapEffects(_S(o.effects),l))}return{changes:r,selection:zx.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof jx?t:jx.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return hx.of(t.split(this.facet(e.lineSeparator)||Ox))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(nS(this,t),rS(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Jx&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:zx.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=tS.resolve(t.extensions||[],new Map),r=t.doc instanceof hx?t.doc:hx.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||Ox)),i=t.selection?t.selection instanceof zx?t.selection:zx.single(t.selection.anchor,t.selection.head):zx.single(0);return Bx(i,r.length),n.staticFacet(aS)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -895,4 +895,4 @@ Table users {
|
|
|
895
895
|
|
|
896
896
|
`);return{...ne(e),dbml:e,warnings:[]}}let n=t.map(e=>e.content).join(`
|
|
897
897
|
|
|
898
|
-
`),r=we(n);return{...r,dbml:_e(r.nodes,r.edges),warnings:[]}}var S9=e=>e.trim().toLowerCase(),C9=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``)||``;function w9(e,t,n,r){let i=new Map(e.map(e=>[S9(e.data.name),e])),a=new Map,o=new Map,s=n.map((e,t)=>{let n=i.get(S9(e.data.name));if(!n)return{...e,position:e.position||{x:t%4*320+50,y:Math.floor(t/4)*320+50}};a.set(e.id,n.id);let r=e.data.columns.map(t=>{let r=n.data.columns.find(e=>S9(e.name)===S9(t.name));return r&&o.set(`${e.id}:${t.id}`,r.id),r?{...t,id:r.id}:t}),s=(t=[])=>t.map(t=>o.get(`${e.id}:${t}`)||t);return{...e,id:n.id,position:n.position,data:{...e.data,id:n.data.id,x:n.data.x,y:n.data.y,color:n.data.color,collapsed:n.data.collapsed,hidden_columns:n.data.hidden_columns,columns:r,constraints:(e.data.constraints||[]).map(e=>({...e,entity_id:n.data.id,column_ids:s(e.column_ids)})),indexes:(e.data.indexes||[]).map(e=>({...e,entity_id:n.data.id,column_ids:s(e.column_ids)}))}}});return{nodes:s,edges:r.map(e=>{let r=n.find(t=>t.id===e.source),i=n.find(t=>t.id===e.target),o=a.get(e.source)||e.source,c=a.get(e.target)||e.target,l=r?.data.columns.find(t=>t.id===C9(e.sourceHandle)),u=i?.data.columns.find(t=>t.id===C9(e.targetHandle)),d=s.find(e=>e.id===o),f=s.find(e=>e.id===c),p=d?.data.columns.find(e=>S9(e.name)===S9(l?.name||``)),m=f?.data.columns.find(e=>S9(e.name)===S9(u?.name||``)),h=p?`col-${p.id}-${(d?.position.x||0)<(f?.position.x||0)?`source`:`source-l`}`:void 0,g=m?`col-${m.id}-${(d?.position.x||0)<(f?.position.x||0)?`target`:`target-r`}`:void 0,_=Se(t,o,c,h,g);return{...e,id:_?.id||e.id,source:o,target:c,sourceHandle:_?.sourceHandle||h,targetHandle:_?.targetHandle||g}})}}var T9=`erd-builder:repository-preview`,E9=`erd-builder:repository-applied`;function D9(e){window.dispatchEvent(new CustomEvent(T9,{detail:e}))}function O9(){window.dispatchEvent(new CustomEvent(T9))}var k9=`WORKTREE`;async function A9(e,t){let n=await wi(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`Repository request failed`);return r}async function j9(e,t,n){let r=await wi(e,{method:t,...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify({repository_path:n.repositoryPath,ref:n.ref,source_id:n.sourceId})}:{}}),i=r.status===204?null:await r.json().catch(()=>({}));if(!r.ok)throw Error(i?.error||`Repository link request failed`);return i}function m3e({diagramUid:e,nodes:t,edges:n,onClose:r}){let i=`erdbpro:repository-link:${e}`,a=`/api/repositories/link/${encodeURIComponent(e)}`,[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),[u,f]=(0,U.useState)(k9),[p,m]=(0,U.useState)(``),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)([]),[y,b]=(0,U.useState)(null),x=(0,U.useRef)(null),S=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),C=(0,U.useCallback)(e=>{let t=JSON.stringify(e);x.current!==t&&(localStorage.setItem(i,JSON.stringify(e)),j9(a,`PUT`,e).then(()=>{x.current=t,localStorage.removeItem(i)}).catch(()=>{}))},[a,i]),w=(0,U.useCallback)(async(e,t,n=``)=>{let r=await A9(`/api/repositories/inspect`,{repository_path:e,ref:t}),i=r.sources.find(e=>e.id===n)?.id||r.sources[0]?.id||``;return s(r.root),l(r),f(t),g(i),m(e=>e||r.current_ref||r.refs.find(e=>e.current)?.value||``),i&&C({repositoryPath:r.root,ref:t,sourceId:i}),r},[C]);(0,U.useEffect)(()=>{b(`connect`),j9(a,`GET`).then(e=>{if(e?.repositoryPath)return x.current=JSON.stringify(e),e;try{return JSON.parse(localStorage.getItem(i)||`null`)}catch{return null}}).then(e=>e?.repositoryPath?w(e.repositoryPath,e.ref||k9,e.sourceId):void 0).catch(e=>d.error(e.message)).finally(()=>b(null))},[w,a,i]),(0,U.useEffect)(()=>()=>O9(),[]);let T=(0,U.useMemo)(()=>c?[{value:k9,label:`Working tree`},...c.refs.map(e=>({value:e.value,label:`${e.name}${e.current?` (current)`:``}`})),...c.commits.map(e=>({value:e.value,label:`${e.short} · ${e.subject}`}))]:[],[c]),E=c?.sources.find(e=>e.id===h),D=async()=>{if(o.trim()){b(`connect`),v([]);try{(await w(o.trim(),k9)).sources.length?d.success(`Repository connected`):d.info(`Repository connected, but no supported schema source was found`)}catch(e){d.error(e.message)}finally{b(null)}}},O=async e=>{if(c){b(`connect`),v([]);try{await w(c.root,e,h)}catch(e){d.error(e.message)}finally{b(null)}}},k=async e=>{if(!c||!h)throw Error(`Select a schema source first`);let t=await A9(`/api/repositories/read`,{repository_path:c.root,ref:e,source_id:h}),n=p3e(t.source.kind,t.files);if(!n.nodes.length)throw Error(`No tables could be parsed from this schema source`);return{...t,...n}},A=async()=>{b(`preview`),v([]);try{let e=await k(u),r=w9(t,n,e.nodes,e.edges);v(e.warnings),D9({proposedNodes:r.nodes,proposedEdges:r.edges,sourceLabel:N9(u,T),commit:e.commit,dbmlSource:e.dbml,canApply:!0}),C({repositoryPath:c.root,ref:u,sourceId:h}),d.info(`Repository schema preview opened on the canvas`)}catch(e){d.error(e.message)}finally{b(null)}},j=async()=>{if(p&&p!==u){b(`compare`),v([]);try{let[e,t]=await Promise.all([k(p),k(u)]),n=w9(e.nodes,e.edges,t.nodes,t.edges);v([...e.warnings,...t.warnings]),D9({originalNodes:e.nodes,originalEdges:e.edges,proposedNodes:n.nodes,proposedEdges:n.edges,sourceLabel:`${N9(p,T)} → ${N9(u,T)}`,commit:t.commit,canApply:!1}),d.info(`Git ref comparison opened on the canvas`)}catch(e){d.error(e.message)}finally{b(null)}}},M=async()=>{let{open:e}=await bi(async()=>{let{open:e}=await Promise.resolve().then(()=>gm);return{open:e}},void 0),t=await e({directory:!0,multiple:!1,title:`Select Git repository`});typeof t==`string`&&s(t)};return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b p-4`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{className:`font-semibold`,children:`Repository Schema`}),(0,W.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:c?.root||`Link this ERD to a local Git repository`})]}),(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>{O9(),r()},"aria-label":`Close repository panel`,children:(0,W.jsx)(Gr,{className:`size-4`})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Schema source`}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:async()=>{try{await j9(a,`DELETE`),x.current=null,localStorage.removeItem(i),O9(),l(null),g(``),v([])}catch(e){d.error(e.message)}},children:[(0,W.jsx)(Xo,{className:`size-3.5`}),`Disconnect`]})]}),(0,W.jsx)(M9,{label:`Git ref`,children:(0,W.jsx)(cr,{value:u,onChange:e=>void O(e),items:T,disabled:y!==null,placeholder:`Select Git ref`,searchPlaceholder:`Search branch or commit...`,emptyMessage:`No Git ref found`,className:`h-9 text-sm`,getItemValue:e=>e.value,getItemLabel:e=>e.label,filterItem:(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())})}),(0,W.jsx)(M9,{label:`Schema`,children:(0,W.jsxs)(Er,{value:h,disabled:y!==null||!c.sources.length,onValueChange:e=>{e&&(g(e),C({repositoryPath:c.root,ref:u,sourceId:e}))},children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{placeholder:`Select schema`,children:E?.label})}),(0,W.jsx)(Sr,{children:c.sources.map(e=>(0,W.jsx)(xr,{value:e.id,children:e.label},e.id))})]})}),!c.sources.length&&(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supported sources: Laravel migrations, DBML, and SQL schema/migration files.`}),(0,W.jsxs)(H,{className:`w-full`,disabled:!h||y!==null,onClick:()=>void A(),children:[y===`preview`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(Hr,{className:`size-4`}),`Preview against current ERD`]})]}),(0,W.jsxs)(`section`,{className:`space-y-3 border-t pt-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-medium`,children:`Compare Git refs`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Compare branches or commits without checking them out. This preview cannot modify the current ERD.`})]}),(0,W.jsx)(M9,{label:`Base ref`,children:(0,W.jsx)(cr,{value:p,onChange:m,items:T.filter(e=>e.value!==k9),disabled:y!==null,placeholder:`Select base ref`,searchPlaceholder:`Search branch or commit...`,emptyMessage:`No Git ref found`,className:`h-9 text-sm`,getItemValue:e=>e.value,getItemLabel:e=>e.label,filterItem:(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())})}),(0,W.jsxs)(H,{variant:`outline`,className:`w-full`,disabled:!h||!p||p===u||y!==null,onClick:()=>void j(),children:[y===`compare`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(eo,{className:`size-4`}),`Compare with selected ref`]})]})]}):(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-lg bg-muted`,children:(0,W.jsx)(gr,{className:`size-5 text-muted-foreground`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-medium`,children:`Connect a repository`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Only supported schema files are read. The repository and active branch are never modified.`})]}),(0,W.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{value:o,onChange:e=>s(e.target.value),placeholder:`/path/to/project`,onKeyDown:e=>{e.key===`Enter`&&D()}}),S&&(0,W.jsx)(H,{variant:`outline`,size:`icon`,onClick:()=>void M(),"aria-label":`Browse repository`,children:(0,W.jsx)(Za,{className:`size-4`})})]})]}),(0,W.jsxs)(H,{className:`w-full`,disabled:!o.trim()||y!==null,onClick:()=>void D(),children:[y===`connect`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(gr,{className:`size-4`}),`Connect repository`]})]}),_.length>0&&(0,W.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/5 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-amber-700 dark:text-amber-400`,children:[(0,W.jsx)(ri,{className:`size-4`}),_.length,` migration statement`,_.length===1?``:`s`,` need review`]}),(0,W.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:_.slice(0,8).map(e=>(0,W.jsx)(`li`,{className:`break-words`,children:e},e))})]})]})]})}function M9({label:e,children:t}){return(0,W.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium`,children:e}),t]})}function N9(e,t){return t.find(t=>t.value===e)?.label||e.slice(0,12)}function P9(e,t){return e&&e.replace(/^(col-)([\w-]+)(-source|-target)(-[lr])?$/,(e,n,r,i,a)=>{let o=t.get(r);return o?`${n}${o}${i}${a||``}`:e})}function h3e(e,t,n,r){let i=new Map,a=t.map(e=>({...e})),o=e.map(e=>{let t=n.find(t=>t.data.name.toLowerCase()===e.data.name.toLowerCase());if(t){i.set(e.id,t.id);let n=new Map;e.data.columns=e.data.columns.map(e=>{let r=t.data.columns.find(t=>t.name.toLowerCase()===e.name.toLowerCase());return r?(n.set(e.id,r.id),{...e,id:r.id,name:r.name,enum_name:e.enum_name||r.enum_name,enum_values:e.enum_values||r.enum_values,comment:e.comment||r.comment,max_length:e.max_length??r.max_length,numeric_precision:e.numeric_precision??r.numeric_precision,numeric_scale:e.numeric_scale??r.numeric_scale,type:r.type.toUpperCase()===`ENUM`&&r.enum_values&&e.type.toUpperCase()!==`ENUM`?r.type:e.type}):e}),e.data.constraints=(e.data.constraints||[]).map(e=>({...e,entity_id:t.id,column_ids:(e.column_ids||[]).map(e=>n.get(e)||e)})),e.data.indexes=(e.data.indexes||[]).map(e=>({...e,entity_id:t.id,column_ids:(e.column_ids||[]).map(e=>n.get(e)||e)}));for(let t of a)t.source===e.id&&(t.sourceHandle=P9(t.sourceHandle,n)),t.target===e.id&&(t.targetHandle=P9(t.targetHandle,n));return{...e,id:t.id,position:t.position,data:{...e.data,name:t.data.name,comment:e.data.comment??t.data.comment,id:t.data.id,x:t.data.x,y:t.data.y,color:t.data.color,collapsed:t.data.collapsed,hidden_columns:t.data.hidden_columns,note:t.data.note}}}return e}),s=a.map(e=>{let t=i.get(e.source)||e.source,n=i.get(e.target)||e.target,a=e.sourceHandle?.replace(/^col-/,``).replace(/-(source|target)(-[lr])?$/,``)||``,s=e.targetHandle?.replace(/^col-/,``).replace(/-(source|target)(-[lr])?$/,``)||``,c=Se(r,t,n,e.sourceHandle,e.targetHandle);if(c)return{...e,id:c.id,source:t,target:n,sourceHandle:c.sourceHandle,targetHandle:c.targetHandle};let l=o.find(e=>e.id===t),u=o.find(e=>e.id===n),d=l?.position.x??0,f=u?.position.x??0,p=d<f?`source`:`source-l`,m=d<f?`target`:`target-r`;return{...e,source:t,target:n,sourceHandle:a?`col-${a}-${p}`:void 0,targetHandle:s?`col-${s}-${m}`:void 0}});return{nodes:D(o),edges:s}}function g3e(e,t){switch(e){case`chat`:return t.aiChat;case`dbml`:return t.dbml;case`properties`:return t.diagramProperties;case`history`:return t.history;case`repository`:return t.repository;default:return!1}}var _3e=({isOpen:e,onClick:t,raised:n})=>e?null:(0,W.jsx)(Pt,{children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{"aria-label":`Open AI Assistant`,onClick:t,className:`fixed right-6 ${n?`bottom-16`:`bottom-4`} z-50 size-12 rounded-full shadow-lg shadow-primary/20 hover:shadow-xl hover:shadow-primary/30 transition-all duration-200 hover:scale-105 active:scale-95`,size:`icon`,children:(0,W.jsx)(ti,{className:`size-5`})})}),(0,W.jsx)(Wt,{side:`left`,children:`AI Assistant`})]})}),v3e=`erd-production-db-tabs:`,F9=new Map,I9=new Map,L9=new Map;function y3e(e){let t=F9.get(e);return t||(t=new Map,F9.set(e,t),F9.size>5&&F9.delete(F9.keys().next().value)),t}var b3e=e=>I9.get(e),x3e=(e,t)=>{I9.set(e,t),I9.size>5&&I9.delete(I9.keys().next().value)},S3e=e=>I9.delete(e),R9=e=>L9.get(String(e)),z9=e=>{e?.id!=null&&L9.set(String(e.id),e),e?.uid&&L9.set(String(e.uid),e),L9.size>10&&L9.delete(L9.keys().next().value)},C3e=(e=``)=>({id:crypto.randomUUID(),enabled:!0,column:e,operator:`CONTAINS`,value:``,value2:``}),B9=`ERD Builder Pro`;function w3e({pathname:e,activeFileName:t,breadcrumbLabel:n,featureLabel:r,searchFeature:i}){let a=e.replace(/\/+$/,``)||`/`;return/^\/(?:notes|diagrams|db-client|flowcharts|drawings)\/[^/]+$/.test(a)&&t?`${t} | ${B9}`:a===`/`?`Dashboard | ${B9}`:a===`/trash`?`Trash | ${B9}`:a===`/library`?`Library | ${B9}`:a===`/team-workspaces`?`Team Workspaces | ${B9}`:a===`/users`?`User Management | ${B9}`:a.startsWith(`/teams/`)?`${n||`Team management`} | ${B9}`:a===`/table/db-client`?`DB Client | ${B9}`:a.startsWith(`/table/`)?`${n||r||`Tables`} | ${B9}`:a.startsWith(`/notes/`)?`Notes | ${B9}`:a.startsWith(`/diagrams/`)?`${i===`db-client`?`DB Client`:`Diagram`} | ${B9}`:a.startsWith(`/db-client/`)?`${n||`DB Client`} | ${B9}`:a.startsWith(`/flowcharts/`)?`Flowchart | ${B9}`:a.startsWith(`/drawings/`)?`Drawing | ${B9}`:B9}function T3e(e){if(!e.trim())return!1;try{return ne(e),!0}catch{return!1}}function V9(e){return JSON.stringify({name:e.name,columns:e.columns.map(e=>({name:e.name,type:e.type,is_pk:e.is_pk,is_nullable:e.is_nullable,default_value:e.default_value||null,is_unique:!!e.is_unique,comment:e.comment||``,max_length:e.max_length??null,numeric_precision:e.numeric_precision??null,numeric_scale:e.numeric_scale??null})),comment:e.comment||``,constraints:(e.constraints||[]).map(t=>({kind:t.kind,name:t.name||``,columns:(t.column_ids||[]).map(t=>e.columns.find(e=>e.id===t)?.name||t).sort(),expression:t.expression||``})).sort((e,t)=>JSON.stringify(e).localeCompare(JSON.stringify(t))),indexes:(e.indexes||[]).map(t=>({name:t.name,is_unique:!!t.is_unique,algorithm:t.algorithm||``,columns:(t.column_ids||[]).map(t=>e.columns.find(e=>e.id===t)?.name||t).sort()})).sort((e,t)=>JSON.stringify(e).localeCompare(JSON.stringify(t)))})}function E3e({root:e,session:t,mainAI:n,paired:r,onPairChange:i,onFocusedSession:a}){let o=h(),s=y(),[l,u]=(0,U.useState)(null),f=(0,U.useRef)(null),p=(0,U.useCallback)(e=>f.current?.(e),[]),[g,v]=(0,U.useState)(null),[b]=_(),[x,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(!1),[T,E]=(0,U.useState)(null),[D,O]=(0,U.useState)(null),[M,N]=(0,U.useState)(``),P=(0,U.useRef)(``),F=(0,U.useRef)(!1),I=(0,U.useRef)(null),{rightPanelMode:L,setRightPanelMode:R,pendingPrompt:ee,clearPrompt:te,pendingAction:ne,clearPendingAction:re}=An(),ie=(0,U.useCallback)(e=>{P.current=e,N(e)},[]),z=(0,U.useMemo)(()=>{let e=(t?k(t.file).split(`?`)[0]:o.pathname).match(/^\/(notes|diagrams|flowcharts|drawings|db-client)\/([^/]+)$/);return e?{entityType:{notes:`note`,diagrams:`diagram`,flowcharts:`flowchart`,drawings:`drawing`,"db-client":`dbClient`}[e[1]],entityUid:e[2]}:null},[o.pathname,t?.file.type,t?.file.uid]),ae=z?.entityType===`diagram`,oe=z?.entityType===`diagram`?`diagrams`:z?.entityType===`flowchart`?`flowcharts`:z?.entityType===`note`?`notes`:z?.entityType===`drawing`?`drawings`:null;(0,U.useEffect)(()=>{if(z?.entityType!==`dbClient`){O(null);return}let e=R9(z.entityUid);if(e){O(e);return}let t=!1;return wi(`/api/db-clients/${encodeURIComponent(z.entityUid)}`).then(e=>e.ok?e.json():null).then(e=>{e&&z9(e),t||O(e)}).catch(()=>{t||O(null)}),()=>{t=!0}},[z]);let{view:se,sidebarView:ce,isPublicView:le,isOnline:ue,projects:de,user:B,isProjectsLoading:fe,handleLogout:pe,handleViewChange:me,handleNoteSelect:he,handleDrawingSelect:ge,refreshActiveDocument:ve,handleSidebarProjectCreate:V,handleSidebarProjectUpdate:ye,handleSidebarProjectDelete:be,handleWorkspaceFilter:xe,selectedWorkspaceUid:Se,handleHeaderDelete:Ce,handleHeaderRename:we,handleHeaderSettingsSaved:Te,handleHeaderExportSQL:Ee,handleHeaderExportImage:De,handleOpenImportModal:Oe,isImportModalOpen:ke,setIsImportModalOpen:Ae,handleExportMarkdown:je,handleCopyMarkdown:Me,handleImportMarkdown:Ne,executeImportMarkdown:Pe,handleDuplicate:Fe,syncError:Ie,isSyncing:Le,isLocalSaving:Re,isRefreshing:ze,hasPendingSyncs:Be,syncDrafts:Ve,activeFileUid:He,currentActiveId:Ue,initialShareSettings:We,activeDocument:Ge,isGuest:Ke,isReadOnlyFile:qe,getFileAccessRole:Je,featureLabel:Ye,activeProjectName:Xe,activeFileName:Ze,hasActiveItem:Qe,activeNote:$e,activeDrawing:et,activeFlowchart:tt,activeDiagram:nt,notes:rt,diagrams:it,flowcharts:at,drawings:ot,setNodes:st,setEdges:ct,activeDiagramId:lt,takeSnapshot:ut,saveDiagram:dt,triggerDebouncedSync:ft,broadcastMessage:pt,setIsLocalSaving:mt,viewportRef:ht,lastLoadedDiagramIdRef:gt,fetchTrash:_t,triggerTableRefresh:vt,setTableLoadingState:yt,setIsSettingsOpen:bt,selectedNodeId:xt,setSelectedNodeId:St,selectedEdgeId:Ct,setSelectedEdgeId:wt,selectedEntity:Tt,deleteEntity:Et,deleteEdge:Dt,updateDiagram:Ot,updateNote:kt,updateDrawing:At,updateFlowchart:jt,moveDiagramToProject:Mt,moveNoteToProject:Nt,moveDrawingToProject:Pt,moveFlowchartToProject:Ft,deleteDiagram:It,deleteNote:Lt,deleteDrawing:Rt,deleteFlowchart:zt,handleEntityUpdate:Bt,handleSidebarDiagramCreate:Vt,handleSidebarNoteCreate:Ht,handleSidebarDrawingCreate:Ut,handleSidebarFlowchartCreate:Wt,isMoveToTrashAlertOpen:Gt,setIsMoveToTrashAlertOpen:Kt,isDeleteAlertOpen:qt,setIsDeleteAlertOpen:Jt,isRenameDialogOpen:Yt,setIsRenameDialogOpen:Xt,isDuplicateDialogOpen:Zt,setIsDuplicateDialogOpen:Qt,isPermanentDeleteConfirmOpen:$t,setIsPermanentDeleteConfirmOpen:en,isImportNoteModalOpen:tn,setIsImportNoteModalOpen:nn,isExportNoteModalOpen:rn,setIsExportNoteModalOpen:an,newName:on,setNewName:sn,renameProjectId:cn,setRenameProjectId:ln,duplicateName:un,setDuplicateName:dn,itemToDelete:fn,createDialogOpen:pn,setCreateDialogOpen:mn,createDialogView:hn,editDialogNote:gn,setEditDialogNote:_n,tableDeleteDoc:vn,setTableDeleteDoc:yn,executeDuplicate:bn,confirmPermanentDelete:xn,handleEdgeUpdate:Sn,handleEdgeFlip:Cn,breadcrumbLabel:wn,refreshTeamScope:Tn,flushPendingSaves:En,teamScopeVersion:Dn,isTeamScopeRefreshing:On}=ia(),{nodes:kn,edges:jn}=Bi(),[Mn,Nn]=(0,U.useState)(``),[Pn,Fn]=(0,U.useState)([]),[In,Ln]=(0,U.useState)(!1),[Rn,zn]=(0,U.useState)([]);B?.isSuperAdmin||B?.is_super_admin;let Bn=(0,U.useCallback)(()=>{Nn(``),Fn([]),zn([]),R(`closed`),En().catch(()=>{}),Tn()},[En,Tn,R]),Vn=g1e(Ke,!!B?.isSso,Bn);(0,U.useEffect)(()=>{if(Ke){zn([]);return}let e=!1;return wi(`/api/projects/selectable`).then(e=>e.ok?e.json():{data:[]}).then(t=>{e||zn(Array.isArray(t.data)?t.data:[])}).catch(()=>{e||zn([])}),()=>{e=!0}},[pn,Ke,Yt,Vn.activeTeamId]);let Hn=(0,U.useRef)(!1),Un=(0,U.useCallback)(async e=>{if(!(Hn.current||e===Vn.activeTeamId)){Hn.current=!0;try{await Zy(En,Ve,{type:se,id:Ue,uid:He}),Vn.selectTeam(e),Nn(``),Fn([]),R(`closed`),await Tn()}catch{d.error(`Could not switch workspaces. Check that your changes are saved and retry.`)}finally{Hn.current=!1}}},[He,Ue,En,Tn,R,Ve,Vn.activeTeamId,Vn.selectTeam,se]),Wn=(0,U.useCallback)(async e=>(await Zy(En,Ve,{type:se,id:Ue,uid:He}),Vn.createTeam(e)),[He,Ue,En,Ve,Vn.createTeam,se]),Gn=(0,U.useCallback)(e=>{e.manageUrl?window.location.assign(e.manageUrl):s(`/teams/${e.id}`)},[s]),Kn=(0,U.useCallback)(async e=>{await Tn(),s(`/teams/${e.id}`)},[s,Tn]),qn=o.pathname===`/table/db-client`||o.pathname.startsWith(`/db-client/`)||o.pathname.startsWith(`/diagrams/`)&&b.get(`feature`)===`db-client`,Jn=qn||/^\/(table\/(erd|notes|drawings|flowchart)|(notes|diagrams|drawings|flowcharts)\/)/.test(o.pathname);(0,U.useEffect)(()=>{let e=Mn.trim();if(e.length<2){Fn([]),Ln(!1);return}let t=!1,n=window.setTimeout(async()=>{Ln(!0);try{if(Ke){let n=e.toLowerCase(),r=new Map(de.map(e=>[String(e.id),e])),i=[...it.filter(e=>(e.source_type??e.sourceType)!==`production_db`).map(e=>({...e,type:`erd`,name:e.name})),...rt.map(e=>({...e,type:`notes`,name:e.title})),...ot.map(e=>({...e,type:`drawings`,name:e.title})),...at.map(e=>({...e,type:`flowchart`,name:e.title}))],a=[...de.filter(e=>e.name?.toLowerCase().includes(n)).map(e=>({...e,type:`workspace`})),...i.filter(e=>e.name?.toLowerCase().includes(n)).map(e=>({...e,workspace:r.get(String(e.project_id))}))].slice(0,20);t||Fn(a);return}let n=await wi(`/api/search?q=${encodeURIComponent(e)}`),r=n.ok?await n.json():{data:[]};t||Fn(Array.isArray(r.data)?r.data:[])}catch{t||Fn([])}finally{t||Ln(!1)}},220);return()=>{t=!0,window.clearTimeout(n)}},[Mn,Ke,de,it,rt,ot,at]);let Yn=(0,U.useCallback)(e=>{if(Nn(``),e.type===`workspace`){me(`erd`,!0,e.uid??e.id);return}let t=e.uid??e.id,n={erd:`/diagrams/${t}`,"db-client":`/db-client/${t}`,notes:`/notes/${t}`,drawings:`/drawings/${t}`,flowchart:`/flowcharts/${t}`}[e.type];n&&s(n)},[me,s]),Xn=ae&&(nt?.source_type??nt?.sourceType)===`production_db`,Zn=ji(Ge,B?.id,Ke),Qn=!qe(Ge),$n=Zn,er=Je(Ge),tr=vn??Ge,nr=(tr?.source_type??tr?.sourceType)===`production_db`,rr=(0,U.useMemo)(()=>{let e=kn.find(e=>e.id===xt)??kn.find(e=>e.id===g);return e?e.data.id===e.id?e.data:{...e.data,id:e.id}:null},[kn,g,xt]),ir=z?.entityType===`diagram`?`erd-builder-dbml:${z.entityUid}`:null,ar=nt?.dbml_source??nt?.dbmlSource??``;(0,U.useEffect)(()=>{let e=I.current!==ir;if(e&&(I.current=ir,F.current=!1),!ir)ie(``);else if(ar)!e&&F.current&&P.current.trim()||ie(ar);else if(e||!F.current)try{let e=localStorage.getItem(ir)||``;ie(e)}catch{ie(``)}},[ir,ar,ie]);let or=(0,U.useCallback)((e,t=!1)=>{ie(e),F.current=!t,t&&T3e(e)&&dt(kn,jn,ht.current,{dbmlSource:e}).then(()=>{Ke||ft()})},[dt,kn,jn,ht,Ke,ft,ie]),sr=(0,U.useCallback)(()=>{if((nt?.source_type??nt?.sourceType)!==`production_db`&&ae&&(R(`dbml`),!M.trim()&&kn.length!==0))try{let e=_e(kn,jn);e.trim()&&ie(e)}catch{}},[nt,ae,R,M,kn,jn,ie]);(0,U.useEffect)(()=>{if(L===`dbml`&&ae&&kn.length>0&&!M.trim())try{let e=_e(kn,jn);e.trim()&&ie(e)}catch{}},[L,ae,kn,jn,M,ie]);let cr=(0,U.useMemo)(()=>{let e=z;if(!e)return null;switch(e.entityType){case`note`:return $e?O6(`note`,{title:$e.title,content:A(String($e.content||``))}):null;case`diagram`:if(!nt||L!==`chat`)return null;let e=O6(`diagram`,{title:nt.name,nodes:kn,edges:jn});return(nt.source_type??nt.sourceType)===`production_db`?`[Current feature: DB Client]\nSource: live production database metadata\nCurrent tab: ${b.get(`tab`)||`data`}\n\n${e||``}`:e;case`flowchart`:if(!tt)return null;let t=[],n=[];try{let e=JSON.parse(tt.data||`{}`);t=e.nodes&&e.nodes.length>0?e.nodes:Ii,n=e.edges&&e.edges.length>0?e.edges:Fi}catch{t=Ii,n=Fi}return O6(`flowchart`,{title:tt.title,nodes:t,edges:n});case`drawing`:return et?O6(`drawing`,{title:et.title}):null;default:return null}},[z,$e,nt,tt,et,kn,jn,b,L]),lr=z?.entityType===`dbClient`||ae&&(nt?.source_type??nt?.sourceType)===`production_db`,ur=(0,U.useMemo)(()=>B?.isSso&&Vn.activeTeam?.capabilities?.ai_assistant!==!0||z===null||le||!Qn||z.entityType===`drawing`?!1:lr?!0:(b.get(`tab`)||`erd`)===`erd`,[z,le,Qn,lr,b,Vn.activeTeam,B?.isSso]),dr=ae&&Qn&&(nt?.source_type??nt?.sourceType)!==`production_db`,fr=(0,U.useMemo)(()=>{let e=z?.entityType===`dbClient`?D:$e||nt||tt||et;return e?.project_id??e?.projectId??null},[z,D,$e,nt,tt,et]),pr=(0,U.useMemo)(()=>{if(le||Ke||!z||!Ze||lr)return null;let e=z.entityType===`diagram`?`diagram`:z.entityType===`note`?`note`:z.entityType===`drawing`?`drawing`:z.entityType===`flowchart`?`flowchart`:null,t=He||Ue||z.entityUid;return e&&t?{featureType:e,fileId:String(t),label:Ze}:null},[Ze,He,Ue,z,lr,Ke,le]),mr=de.find(e=>String(e.id)===String(fr)),hr=mr?.team_id??mr?.teamId,gr=pr&&!le&&!Ke&&hr&&String(hr)===String(Vn.activeTeamId)?String(Vn.activeTeamId):void 0,vr=(0,U.useMemo)(()=>Ct&&jn.some(e=>e.id===Ct)?{type:`relationship`,id:Ct}:xt&&kn.some(e=>e.id===xt)?{type:`table`,id:xt}:null,[jn,kn,Ct,xt]),yr=(0,U.useCallback)((e,t)=>{window.dispatchEvent(new CustomEvent(`erd-discussion-anchor-selected`,{detail:{type:e,id:t}}))},[]),br=(0,U.useCallback)(e=>{if(!pr)return;if(e.featureType===pr.featureType&&String(e.fileId)===pr.fileId){e.featureType===`diagram`&&e.anchorType!==`general`&&e.anchorId&&yr(e.anchorType,e.anchorId);return}let t={diagram:it,note:rt,drawing:ot,flowchart:at}[e.featureType]?.find(t=>String(t.uid??t.id)===String(e.fileId)||String(t.id)===String(e.fileId));t&&(s(`${{diagram:`/diagrams`,note:`/notes`,drawing:`/drawings`,flowchart:`/flowcharts`}[e.featureType]}/${t.uid??t.id}`),e.featureType===`diagram`&&e.anchorType!==`general`&&e.anchorId&&window.setTimeout(()=>yr(e.anchorType,e.anchorId),0))},[it,pr,at,yr,s,rt,ot]),xr=(0,U.useCallback)(e=>$e?.content&&new DOMParser().parseFromString(String($e.content),`text/html`).querySelector(`[data-comment-anchor-id="${CSS.escape(e)}"]`)?.textContent?.trim()||null,[$e?.content]),Sr=fr&&pr&&gr?(0,W.jsx)(zb,{projectId:String(fr),teamId:gr,userId:B?.id?String(B.id):void 0,userName:B?.name||B?.email,fileContext:pr,anchorContext:vr,readOnly:er===`viewer`,onContextSelected:br,anchorPreview:pr.featureType===`note`?xr:void 0},`${gr}:${fr}:${pr.featureType}:${pr.fileId}`):null;(0,U.useEffect)(()=>{document.title=w3e({pathname:o.pathname,activeFileName:Ze,breadcrumbLabel:wn,featureLabel:Ye,searchFeature:b.get(`feature`)})},[Ze,Ye,wn,o.pathname,b]),(0,U.useEffect)(()=>{if(typeof window>`u`||!(window.__TAURI__||window.__TAURI_INTERNALS__))return;let e=e=>{let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(navigator.platform.toLowerCase().includes(`mac`)?e.metaKey:e.ctrlKey)&&e.key===`,`&&(e.preventDefault(),bt(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[bt]);let Cr=g3e(L,{aiChat:ur,dbml:dr,diagramProperties:ae&&!Xn,history:!!(oe&&z),repository:ae&&!Xn}),wr=(0,U.useCallback)((...e)=>(L===`repository`&&(O9(),R(`closed`)),me(...e)),[me,L,R]);(0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.dbmlSource;t&&ie(t)};return window.addEventListener(E9,e),()=>window.removeEventListener(E9,e)},[ie]);let Tr=(0,U.useCallback)((e,t,n)=>{let{nodes:r,edges:i}=h3e(e,t,kn,jn),a=r.length===kn.length&&r.every((e,t)=>{let n=kn.find(t=>t.id===e.id);return!n||e.data.name!==n.data.name?!1:V9(e.data)===V9(n.data)}),o=e=>JSON.stringify({source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,label:e.label,data:e.data}),s=i.map(o).sort(),c=jn.map(o).sort(),l=JSON.stringify(s)===JSON.stringify(c);a&&l?(dt(kn,jn,ht.current,{dbmlSource:n}).then(()=>ft()),F.current=!1):(ut?.(kn,jn),st(r),ct(i),F.current=!1,dt?.(r,i,ht?.current,{dbmlSource:n})?.then(()=>ft?.()))},[kn,jn,st,ct,ut,dt,ht,ft]),{setOpen:Er,open:Dr}=Pp(),Or=(0,U.useRef)(Dr);(0,U.useEffect)(()=>{Cr?(Or.current=Dr,Er(!1)):Or.current&&Er(!0)},[Cr]),(0,U.useEffect)(()=>{(!z||L===`chat`&&!ur)&&R(`closed`)},[z,L,ur,R]);let kr=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=z?`${z.entityType}:${z.entityUid}`:null,t=kr.current!==null&&kr.current!==e;kr.current=e,t&&v(null),L===`properties`&&(!ae||t||Xn||!Qn)&&R(`closed`)},[z,ae,L,Xn,Qn,R]),(0,U.useEffect)(()=>{L===`properties`&&xt&&v(xt)},[L,xt]),(0,U.useEffect)(()=>{L===`dbml`&&!dr&&R(ur?`chat`:`closed`)},[L,dr,ur,R]),(0,U.useEffect)(()=>{L===`repository`&&(!ae||Xn)&&R(`closed`)},[L,ae,Xn,R]),(0,W.jsxs)(W.Fragment,{children:[!ue&&!le&&(0,W.jsx)(h1e,{}),!le&&(0,W.jsx)(Ofe,{activeFeatureView:qn?`db-client`:Jn?ce:null,globalSearchResults:Pn,isGlobalSearchLoading:In,onGlobalSearchResultSelect:Yn,projects:de,onViewChange:wr,onProjectCreate:V,onProjectUpdate:ye,onProjectDelete:be,onLogout:pe,onWorkspaceFilter:xe,selectedWorkspaceUid:Se,globalSearchQuery:Mn,onGlobalSearchChange:Nn,user:B,isOnline:ue,isProjectsLoading:fe,onOpenFeedback:()=>S(!0),teams:Vn.teams,teamsAvailable:Vn.isAvailable,licenseRequired:Vn.licenseRequired,activeTeamId:Vn.activeTeamId,onTeamsRefresh:()=>{Vn.fetchTeams()},onTeamSelect:Un,onTeamManage:Gn,onTeamCreate:Wn,onTeamCreated:Kn,ssoPortalUrl:B?.isSso?B.ssoPortalUrl??B.sso_portal_url:null}),(0,W.jsx)(Vy.Provider,{value:l,children:(0,W.jsxs)(rie,{className:c(le?`w-full`:``,Cr&&`mr-90 transition-[margin] duration-200`),children:[(0,W.jsx)(j.Provider,{value:t?.scope??null,children:(0,W.jsx)(Mfe,{tabsRef:u,documentPath:t?k(t.file).split(`?`)[0]:void 0,sidebarDisabled:r,featureLabel:Ye,activeProjectName:z?.entityType===`dbClient`?D?.project?.name:Xe,activeFileName:z?.entityType===`dbClient`?wn||``:Ze,view:se,hasActiveItem:le?!0:Qe,syncError:Ie,isSyncing:Le,isLocalSaving:Re,isRefreshing:ze,hasPendingSyncs:Be,onSave:Ve,activeFileUid:He,activeFileId:Ue,initialShareSettings:We,isPublicView:le,onSettingsSaved:Te,isOnline:ue,updatedAt:Ge?.updated_at,onDelete:Zn?Ce:void 0,onRename:Qn?we:void 0,canManage:$n,onRefresh:ve,onExportAll:Xn?void 0:()=>w(!0),onExportSQL:Ee,onExportImage:De,onExportMarkdown:je,onCopyMarkdown:Me,onImportMarkdown:Qn?Ne:void 0,onDuplicate:Fe,isGuest:Ke,breadcrumbLabel:wn,noteContent:$e?.content,historyAvailable:!!oe,discussionPanel:t?(0,W.jsx)(`span`,{ref:E,className:`contents`}):Sr})}),!le&&!Qn&&(0,W.jsxs)(`div`,{className:`mx-4 mt-3 flex flex-wrap items-center gap-2 rounded-lg border bg-muted/40 px-3 py-2 text-sm`,role:`status`,children:[(0,W.jsx)(Ba,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:Ai(er,Ge?.user?.name||Ge?.user?.email||`another member`)}),(0,W.jsxs)(H,{type:`button`,variant:`outline`,size:`sm`,disabled:ze,onClick:ve,children:[(0,W.jsx)(Hr,{className:`size-3.5 ${ze?`animate-spin`:``}`,"aria-hidden":`true`}),`Refresh`]}),!Ke&&(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`sm`,onClick:Fe,children:`Duplicate to edit`})]}),(0,W.jsx)(`div`,{className:`relative flex flex-1 flex-col gap-4 p-4 pt-4 min-h-0 overflow-hidden`,style:{isolation:`isolate`},children:On?(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center rounded-xl border bg-muted/10`,role:`status`,"aria-live":`polite`,children:[(0,W.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),(0,W.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground`,children:`Loading workspace…`})]}):(0,W.jsx)(sfe,{root:e,mainAI:n,teamState:Vn,discussionTarget:T,onFocusedSession:a,onPairChange:i,paneAIRef:f,children:(0,W.jsx)(m,{context:Vn},Dn)})}),(0,W.jsx)(vTe,{isOpen:tn,onClose:()=>nn(!1),onImport:Pe}),(0,W.jsx)(yTe,{isOpen:rn,onClose:()=>an(!1),onExport:(e,t,n)=>{$e&&(e===`markdown`||(e===`pdf`?w6.exportToPDF($e,t,n,Xe||void 0):e===`print`?w6.printNote($e,t,Xe||void 0):e===`word`&&w6.exportToWord($e,t,Xe||void 0)))}}),(0,W.jsx)(Ife,{open:x,onOpenChange:S}),(0,W.jsx)(db,{isOpen:$t,onOpenChange:en,mode:`permanent-delete`,itemType:fn?.type||``,onConfirm:xn,onAfterDelete:void 0}),!le&&(0,W.jsx)(pb,{isOpen:Yt,onOpenChange:e=>{Xt(e),e||_n(null)},view:se,activeDocument:gn??Ge,canMoveProject:ji(gn??Ge,B?.id,Ke),newName:on,setNewName:sn,projects:Rn,requireProject:!!Vn.activeTeamId,selectedProjectId:cn,setSelectedProjectId:ln,updateDiagram:Ot,updateNote:kt,updateDrawing:At,updateFlowchart:jt,onMoveDiagramToProject:Mt,onMoveNoteToProject:Nt,onMoveDrawingToProject:Pt,onMoveFlowchartToProject:Ft,onRenameSuccess:void 0}),!le&&(0,W.jsx)(pb,{isOpen:pn,onOpenChange:e=>{mn(e)},mode:`create`,view:hn,activeDocument:null,newName:on,setNewName:sn,projects:Rn,requireProject:!!Vn.activeTeamId,selectedProjectId:cn,setSelectedProjectId:ln,onProjectCreate:async e=>{let t=await V(e);return t&&zn(e=>[t,...e.filter(e=>String(e.id)!==String(t.id))]),t},onCreate:(e,t)=>{let n=hn;n===`notes`?Ht(e,t):n===`erd`?Vt(e,t):n===`drawings`?Ut(e,t):n===`flowchart`&&Wt(e,t)},onRenameSuccess:void 0}),(0,W.jsx)(db,{isOpen:Gt,onOpenChange:e=>{Kt(e),e||yn(null)},activeDocument:tr,view:se,deleteDiagram:It,deleteNote:Lt,deleteDrawing:Rt,deleteFlowchart:zt,fetchTrash:_t,onAfterDelete:()=>{yn(null),nr?s(`/table/db-client`,{replace:!0}):me(se,!0),yt(`loading`),vt()}}),!le&&(0,W.jsx)(ZF,{isOpen:!!Ct,onOpenChange:e=>{e||wt(null)},selectedEdge:jn.find(e=>e.id===Ct)||null,nodes:kn,handleEdgeUpdate:Sn,handleEdgeFlip:Cn,deleteEdge:Dt,moveOnly:Xn}),(0,W.jsx)(Lfe,{isOpen:qt,onOpenChange:Jt,selectedEntity:Tt,deleteEntity:Et,setSelectedNodeId:St}),(0,W.jsx)(Rfe,{isOpen:Zt,onOpenChange:Qt,view:se,duplicateName:un,setDuplicateName:dn,executeDuplicate:bn,isRefreshing:ze}),se===`erd`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(pTe,{open:C,onOpenChange:w,nodes:kn,edges:jn,fileName:Ze||`Untitled`}),(0,W.jsx)(hTe,{isOpen:ke,onOpenChange:Ae,nodes:kn,edges:jn,setNodes:st,setEdges:ct,activeDiagramId:lt,takeSnapshot:ut,saveDiagram:dt,triggerDebouncedSync:ft,broadcastMessage:pt,setIsLocalSaving:mt,viewportRef:ht,lastLoadedDiagramIdRef:gt})]}),Cr&&(0,W.jsx)(_1e,{children:L===`repository`&&z?.entityType===`diagram`?(0,W.jsx)(m3e,{diagramUid:z.entityUid,nodes:kn,edges:jn,onClose:()=>R(`closed`)},z.entityUid):L===`history`&&oe&&z?(0,W.jsx)(t3e,{entityType:oe,entityUid:z.entityUid,documentTitle:Ze||`Untitled`,onClose:()=>R(`closed`),onRestored:ve,canRestore:$n},`${oe}:${z.entityUid}`):(0,W.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 flex items-center border-b border-border bg-muted/20`,children:[(0,W.jsxs)(`div`,{className:`flex-1 flex`,children:[ae&&!le&&Qn&&!Xn&&(0,W.jsxs)(`button`,{onClick:()=>R(`properties`),className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`properties`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(_r,{className:`size-3.5`}),`Properties`]}),dr&&(0,W.jsxs)(`button`,{onClick:sr,className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`dbml`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(Ar,{className:`size-3.5`}),`DBML`]}),ur&&(0,W.jsxs)(`button`,{onClick:()=>R(`chat`),className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`chat`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(ti,{className:`size-3.5`}),`AI Chat`]})]}),(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`size-8 mr-1`,onClick:()=>R(`closed`),title:`Close panel`,children:(0,W.jsx)(Ao,{className:`size-3.5`})})]}),(0,W.jsxs)(`div`,{className:`flex-1 min-h-0`,children:[ur&&(0,W.jsx)(`div`,{className:c(`h-full`,L!==`chat`&&`hidden`),children:(0,W.jsx)(t4e,{onClose:()=>R(`closed`),entityType:z.entityType,entityUid:z.entityUid,entityTitle:z.entityType===`dbClient`?D?.name||wn:z.entityType===`note`?$e?.title:z.entityType===`diagram`?nt?.name:z.entityType===`flowchart`?tt?.title:null,entityContextText:cr,viewType:lr?`db-client`:void 0,projectId:fr,pendingPrompt:ee,onPromptUsed:te,pendingAction:ne,onClearPendingAction:re,notes:rt,diagrams:it,flowcharts:at,drawings:ot,activeNoteContent:z?.entityType===`note`?$e?.content:void 0,getPaneAI:p})}),L===`dbml`&&dr&&(0,W.jsx)(S4e,{value:M,onChange:or,onApply:Tr,nodes:kn,edges:jn,onSelectTable:e=>{let t=kn.find(t=>t.data.name.toLowerCase()===e.toLowerCase());t&&St(t.id)}}),L===`properties`&&!Xn&&(rr?(0,W.jsx)(M4e,{selectedEntity:rr,onUpdateEntity:Bt,onBackToTables:()=>{St(null),v(null)},onDeleteEntity:e=>{Et(e),St(null),R(`closed`)}},rr.id):(0,W.jsx)(w4e,{nodes:kn,onEdit:e=>{v(e),St(e)}}))]})]})}),ur&&!Cr&&(0,W.jsx)(_3e,{isOpen:!1,raised:z?.entityType===`dbClient`,onClick:()=>R(`chat`)})]})})]})}function D3e({paired:e,onPairChange:t}){let n=ia(),r=An(),i=Bi(),[a,o]=(0,U.useState)(null),s=(0,U.useMemo)(()=>a?{...a.workspace,setIsSettingsOpen:n.setIsSettingsOpen,setSettingsTab:n.setSettingsTab,refreshTeamScope:n.refreshTeamScope,teamScopeVersion:n.teamScopeVersion,isTeamScopeRefreshing:n.isTeamScopeRefreshing,flushPendingSaves:n.flushPendingSaves,handleLogout:n.handleLogout}:n,[a,n]),c=(0,U.useMemo)(()=>a?{...a.ai,rightPanelMode:r.rightPanelMode,setRightPanelMode:r.setRightPanelMode}:r,[a,r]);return(0,W.jsx)(aa.Provider,{value:s,children:(0,W.jsx)(Ln,{value:c,children:(0,W.jsx)(Ki,{value:a?.canvas??i,children:(0,W.jsx)(qi,{value:a?.canvas??i,children:(0,W.jsx)(E3e,{root:n,session:a,mainAI:r,paired:e,onPairChange:t,onFocusedSession:o})})})})})}function O3e(){let e=Nfe(),[t,n]=(0,U.useState)(!1);return(0,W.jsx)(Fp,{open:!t&&e.open,onOpenChange:e.onOpenChange,className:`h-svh overflow-hidden`,style:{"--sidebar-width":`320px`},children:(0,W.jsx)(Wn,{children:(0,W.jsx)(D3e,{paired:t,onPairChange:n})})})}function k3e(){let e=y();return(0,W.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center max-w-md`,children:[(0,W.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,W.jsx)(ri,{className:`h-6 w-6 text-muted-foreground`})}),(0,W.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`404`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The page you're looking for doesn't exist.`}),(0,W.jsxs)(`button`,{onClick:()=>e(`/table/tables`),className:`inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow hover:bg-primary/90 transition-colors`,children:[(0,W.jsx)(pa,{className:`h-4 w-4`}),`Back to Home`]})]})})}var H9=[{key:`notes`,label:`Notes`,createLabel:`Note`,icon:Nt,color:`text-amber-500`,bg:`bg-amber-500/10`,route:`/table/notes`,createFn:`handleSidebarNoteCreate`,totalKey:`notesTotal`},{key:`diagrams`,label:`ERD Builder`,createLabel:`ERD Builder`,icon:Ar,color:`text-cyan-400`,bg:`bg-cyan-500/20`,route:`/table/erd`,createFn:`handleSidebarDiagramCreate`,totalKey:`diagramsTotal`},{key:`drawings`,label:`Drawings`,createLabel:`Drawing`,icon:Mr,color:`text-violet-500`,bg:`bg-violet-500/10`,route:`/table/drawings`,createFn:`handleSidebarDrawingCreate`,totalKey:`drawingsTotal`},{key:`flowcharts`,label:`Flowcharts`,createLabel:`Flowchart`,icon:Eo,color:`text-emerald-500`,bg:`bg-emerald-500/10`,route:`/table/flowcharts`,createFn:`handleSidebarFlowchartCreate`,totalKey:`flowchartsTotal`}];function A3e(){let e=new Date().getHours();return e<12?`Good morning`:e<17?`Good afternoon`:`Good evening`}function U9(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toLocaleDateString(`en-US`)}function W9(e){switch(e){case`diagrams`:return(0,W.jsx)(Ar,{className:`h-4 w-4 text-blue-500`});case`notes`:return(0,W.jsx)(Nt,{className:`h-4 w-4 text-amber-500`});case`drawings`:return(0,W.jsx)(Mr,{className:`h-4 w-4 text-violet-500`});case`flowcharts`:return(0,W.jsx)(Eo,{className:`h-4 w-4 text-emerald-500`});case`db-client`:return(0,W.jsx)(jr,{className:`h-4 w-4 text-cyan-400`});default:return null}}function G9(e){return(e.source_type??e.sourceType)===`production_db`}function K9(e){return e?._group===`db-client`||e?._type===`db-client`||G9(e)}function q9(e){switch(e._type){case`diagrams`:return K9(e)?`DB Client`:`ERD Builder`;case`notes`:return`Note`;case`drawings`:return`Drawing`;case`flowcharts`:return`Flowchart`;case`db-client`:return`DB Client`;default:return``}}function J9(e,t){let n=t.uid||t.id;if(K9(t))return`/db-client/${n}`;switch(e){case`diagrams`:return`/diagrams/${n}`;case`notes`:return`/notes/${n}`;case`drawings`:return`/drawings/${n}`;case`flowcharts`:return`/flowcharts/${n}`;case`db-client`:return`/db-client/${n}`;default:return`/`}}function j3e(){let e=y(),t=ia(),n=Ei(),r=w(),i=!!(t.user?.isSso&&r.activeTeamId),a=e=>e===`diagrams`?`erd_builder`:e,o=e=>!i||r.isAvailable&&r.activeTeam?.capabilities?.[a(e)]===!0,s=H9.filter(e=>o(e.key)),c=t.user,l=c?.user_metadata?.full_name||c?.user_metadata?.name||c?.email?.split(`@`)[0]||``,[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1);(0,U.useEffect)(()=>{if(t.isGuest||!c){d(null),p(!0);return}let e=!1;return d(null),p(!1),(async()=>{try{let t=await wi(`/api/search/recent`);if(!t.ok)return;let n=await t.json();e||d(Array.isArray(n.data)?n.data:[])}catch{}finally{e||p(!0)}})(),()=>{e=!0}},[t.isGuest,t.teamScopeVersion,c]);let m=(0,U.useMemo)(()=>{if(u)return u.map(e=>({...e,_type:e.type,_group:e.group,_workspace:e.workspace?.name||e.project?.name||`—`,updated_at:e.updated_at??e.updatedAt}));let e=new Map((t.projects||[]).map(e=>[String(e.id),e.name])),n=t=>{let n=t.project_id??t.projectId;return t.projects?.name||t.project?.name||(n?e.get(String(n)):null)||`—`};return[...(t.diagrams||[]).filter(e=>!G9(e)).map(e=>({...e,_type:`diagrams`,_group:G9(e)?`db-client`:`diagrams`,_workspace:n(e)})),...(t.notes||[]).map(e=>({...e,_type:`notes`,_group:`notes`,_workspace:n(e)})),...(t.drawings||[]).map(e=>({...e,_type:`drawings`,_group:`drawings`,_workspace:n(e)})),...(t.flowcharts||[]).map(e=>({...e,_type:`flowcharts`,_group:`flowcharts`,_workspace:n(e)}))].filter(e=>!e.is_deleted).sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,10)},[t.diagrams,t.notes,t.drawings,t.flowcharts,t.projects,u]),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`all`),b=(0,U.useMemo)(()=>{let e=h.trim().toLowerCase();return m.filter(t=>{let n=_===`all`||t._group===_,r=t.name||t.title||``;return n&&(!e||`${r} ${t._workspace}`.toLowerCase().includes(e))})},[m,_,h]),x=(0,U.useMemo)(()=>(t.diagrams||[]).filter(e=>!e.is_deleted&&!G9(e)).length+(t.notes||[]).filter(e=>!e.is_deleted).length+(t.drawings||[]).filter(e=>!e.is_deleted).length+(t.flowcharts||[]).filter(e=>!e.is_deleted).length,[t.diagrams,t.notes,t.drawings,t.flowcharts]),[S,C]=(0,U.useState)({});(0,U.useEffect)(()=>C({}),[t.teamScopeVersion]);let T=(0,U.useMemo)(()=>(t.projects||[]).filter(e=>!e.is_deleted).map(e=>{let t=S[String(e.id)]||{};return{...e,notesCount:t.notes??0,diagramsCount:t.diagrams??0,drawingsCount:t.drawings??0,flowchartsCount:t.flowcharts??0,dbClientsCount:t.db_clients??0,totalDocs:(t.notes??0)+(t.diagrams??0)+(t.drawings??0)+(t.flowcharts??0)+(t.db_clients??0)}}).sort((e,t)=>t.totalDocs-e.totalDocs).slice(0,4),[t.projects,S]);(0,U.useEffect)(()=>{let e=(t.projects||[]).filter(e=>!e.is_deleted).slice(0,4);if(e.length===0)return;let r=!1;return(async()=>{let t={};for(let i of e)try{let e=await wi(`/api/projects/${i.id}/summary?include_db_client=${n}`);e.ok&&!r&&(t[String(i.id)]=await e.json())}catch{}r||C(t)})(),()=>{r=!0}},[t.projects,n]);let[E,D]=(0,U.useState)(!1),O=t.isLoading||t.isProjectsLoading;(0,U.useEffect)(()=>{O||D(!0)},[O]);let k=!O&&f,A=k&&x===0&&!u?.length,j=k&&!A&&E,M=e=>{o(e.key)&&t.handleOpenCreateDocument?.(e.key===`diagrams`?`erd`:e.key===`flowcharts`?`flowchart`:e.key)},N=m[0];return(0,W.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-y-auto`,children:[l&&(0,W.jsx)(`div`,{className:`border-b border-border/60 px-5 py-5`,children:(0,W.jsxs)(`div`,{className:`flex items-end justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:[A3e(),`,`]}),(0,W.jsx)(`h1`,{className:`mt-0.5 text-xl font-semibold tracking-tight`,children:l}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Pick up where you left off.`})]}),j&&o(`diagrams`)&&(0,W.jsxs)(`button`,{onClick:()=>M(H9[1]),className:`hidden h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 sm:inline-flex`,children:[(0,W.jsx)(zt,{className:`size-3.5`}),`New ERD Builder`]})]})}),A&&(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center justify-center px-6 py-20 text-center`,children:[(0,W.jsx)(`div`,{className:`size-16 rounded-2xl bg-primary/10 border border-primary/20 flex items-center justify-center mb-5`,children:(0,W.jsx)(ti,{className:`size-7 text-primary`})}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Let's get started`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5 max-w-md`,children:`Create your first document — notes, ERD Builder, flowcharts, or drawings — and start building your workspace.`}),(0,W.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 mt-5`,children:s.map(e=>(0,W.jsxs)(`button`,{onClick:()=>M(e),className:`inline-flex items-center gap-2 rounded-lg border px-4 py-2.5 text-sm font-medium transition-all hover:shadow-sm ${e.key===`diagrams`?`border-cyan-400/50`:`border-border/60`} ${e.bg} hover:scale-[1.02]`,children:[(0,W.jsx)(e.icon,{className:`h-4 w-4 ${e.color}`}),`New `,e.createLabel]},e.key))})]}),j&&(0,W.jsxs)(`main`,{className:`flex w-full flex-col gap-5 px-5 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1.35fr)_minmax(250px,0.65fr)]`,children:[(0,W.jsxs)(`section`,{className:`relative overflow-hidden rounded-xl border border-primary/25 bg-linear-to-br from-primary/10 via-card to-card p-4`,children:[(0,W.jsxs)(`div`,{className:`relative z-10 flex h-full min-h-32 flex-col justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-primary`,children:`Continue working`}),N?(0,W.jsxs)(`div`,{className:`mt-3 flex items-start gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-background/80 shadow-sm`,children:W9(N._type)}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{className:`truncate text-lg font-semibold`,children:N.name||N.title||`(Untitled)`}),(0,W.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[q9(N),` · `,N._workspace,` · `,U9(N.updated_at)]})]})]}):(0,W.jsx)(`h2`,{className:`mt-4 text-xl font-semibold`,children:`Create your first document`})]}),(0,W.jsxs)(`button`,{onClick:()=>N?e(J9(N._type,N)):M(H9[1]),className:`inline-flex h-8 w-fit items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground transition-colors hover:bg-primary/90`,children:[N?`Open document`:`Create ERD Builder`,(0,W.jsx)(ha,{className:`size-3.5`})]})]}),(0,W.jsx)(ti,{className:`absolute -bottom-8 -right-5 size-36 text-primary/10`})]}),(0,W.jsxs)(`section`,{className:`rounded-xl border border-border/60 bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Create something new`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Start with the format you need.`})]}),(0,W.jsx)(zt,{className:`size-4 text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2`,children:s.map(e=>(0,W.jsxs)(`button`,{onClick:()=>M(e),className:`group flex min-h-14 flex-col items-start justify-between rounded-lg border border-border/60 bg-background px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/40`,children:[(0,W.jsx)(e.icon,{className:`size-4 ${e.color}`}),(0,W.jsxs)(`span`,{className:`text-xs font-medium`,children:[`New `,e.createLabel]})]},e.key))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(250px,0.65fr)]`,children:[(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2.5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Ma,{className:`size-4 text-muted-foreground`}),`Recent files`]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Jump back into your latest work.`})]}),(0,W.jsxs)(`div`,{className:`relative w-full sm:w-52`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-2.5 size-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`Search files`,"aria-label":`Search recent files`,className:`h-8 w-full rounded-lg border border-border/60 bg-card pl-8 pr-3 text-xs outline-none placeholder:text-muted-foreground/60 focus:border-primary/50`})]})]}),(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 overflow-x-auto pb-0.5`,children:[(0,W.jsx)(`button`,{onClick:()=>v(`all`),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===`all`?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:`All`}),H9.map(e=>(0,W.jsx)(`button`,{onClick:()=>v(e.key),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===e.key?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:e.label},e.key)),n&&(0,W.jsx)(`button`,{onClick:()=>v(`db-client`),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===`db-client`?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:`DB Client`})]}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-card`,children:b.length===0?(0,W.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No matching files.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`hidden grid-cols-[minmax(0,1fr)_minmax(7rem,0.7fr)_auto_auto] gap-2.5 border-b border-border/50 px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:grid`,children:[(0,W.jsx)(`span`,{children:`File`}),(0,W.jsx)(`span`,{children:`Workspace`}),(0,W.jsx)(`span`,{children:`Updated`}),(0,W.jsx)(`span`,{"aria-hidden":`true`})]}),b.map(t=>(0,W.jsxs)(`button`,{onClick:()=>e(J9(t._type,t)),className:`group grid w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2.5 border-b border-border/50 px-3 py-2.5 text-left last:border-0 hover:bg-accent/30 sm:grid-cols-[minmax(0,1fr)_minmax(7rem,0.7fr)_auto_auto]`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-background`,children:W9(t._type)}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:t.name||t.title||`(Untitled)`}),(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:q9(t)})]})]}),(0,W.jsx)(`span`,{className:`hidden min-w-0 truncate text-xs text-muted-foreground sm:block`,children:t._workspace}),(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:U9(t.updated_at)}),(0,W.jsx)(ha,{className:`size-3.5 shrink-0 text-muted-foreground/30 transition-colors group-hover:text-primary`})]},`${t._type}-${t.id}`))]})})]}),T.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Xa,{className:`size-4 text-muted-foreground`}),`Workspaces`]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Your projects at a glance.`})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:T.map(e=>(0,W.jsxs)(`button`,{onClick:()=>t.onViewChange?.(`erd`,!0,e.uid??e.id),className:`group flex w-full items-center gap-2.5 rounded-lg border border-border/60 bg-card p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-accent/30`,children:[(0,W.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/10`,children:(0,W.jsx)(Xa,{className:`size-3.5 text-primary`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,W.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[e.totalDocs,` `,e.totalDocs===1?`file`:`files`]})]}),(0,W.jsx)(ha,{className:`size-4 text-muted-foreground/30 transition-colors group-hover:text-primary`})]},e.id))})]})]})]})]})}function M3e(){let e=new URLSearchParams(window.location.search).get(`authorization_id`)||``,[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(e?``:`Authorization ID is missing.`),[a,o]=(0,U.useState)(!!e),[s,c]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&wi(`/api/oauth/authorizations/${encodeURIComponent(e)}`,{cache:`no-store`}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Authorization request could not be loaded.`);t.redirect_url?window.location.assign(t.redirect_url):n(t)}).catch(e=>i(e instanceof Error?e.message:`Authorization request could not be loaded.`)).finally(()=>o(!1))},[e]);async function l(t){c(!0),i(``);try{let n=await wi(`/api/oauth/authorizations/${encodeURIComponent(e)}/${t}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.redirect_url)throw Error(r.error||`Authorization decision failed.`);window.location.assign(r.redirect_url)}catch(e){i(e instanceof Error?e.message:`Authorization decision failed.`),c(!1)}}return(0,W.jsx)(`main`,{className:`flex min-h-svh items-center justify-center bg-muted/30 p-6`,children:(0,W.jsxs)(is,{className:`w-full max-w-lg`,children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(`div`,{className:`mb-2 flex size-10 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,W.jsx)(Vo,{className:`size-5`,"aria-hidden":`true`})}),(0,W.jsx)(os,{children:`Authorize MCP access`}),(0,W.jsx)(ss,{children:t?`${t.client.name} wants read-only access to your ERD Builder Pro Web App workspace.`:`Reviewing the authorization request…`})]}),(0,W.jsxs)(ls,{className:`space-y-4 text-sm`,children:[a&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading authorization details…`}),r&&(0,W.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/30 bg-destructive/10 p-3 text-destructive`,children:r}),t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Requesting client`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t.client.name}),(0,W.jsxs)(`p`,{className:`mt-1 break-all font-mono text-xs text-muted-foreground`,children:[`Redirect: `,t.redirect_uri]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`This client can read`}),(0,W.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Projects, regular ERDs, Notes, Flowcharts, Drawings, and document history in the Personal workspace and active Teams accessible to `,t.user.email,`. This authorization covers all permitted workspaces and follows your current access permissions.`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`It cannot access`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`DB Client, production database diagrams, SQL execution, database credentials, local files, or write operations.`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`OAuth scopes`}),(0,W.jsx)(`p`,{className:`mt-1 break-words font-mono text-xs text-muted-foreground`,children:t.scope||`email`})]})]})]}),t&&(0,W.jsxs)(us,{className:`justify-end gap-2`,children:[(0,W.jsx)(H,{variant:`outline`,disabled:s,onClick:()=>l(`deny`),children:`Deny`}),(0,W.jsx)(H,{disabled:s,onClick:()=>l(`approve`),children:s?`Submitting…`:`Allow read-only access`})]})]})})}function N3e({user:e,onComplete:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1),[u,f]=(0,U.useState)(!1),p=async r=>{if(r.preventDefault(),!(i.length<8||i!==o)){f(!0);try{let r=await wi(`/api/account`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPassword:n,newPassword:i})}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.error||`Unable to change password.`);t({...e,...a.user,mustChangePassword:!1}),d.success(`Password updated`)}catch(e){d.error(e?.message||`Unable to change password.`)}finally{f(!1)}}},m=c?`text`:`password`,h=(0,W.jsx)(`button`,{type:`button`,"aria-label":c?`Hide passwords`:`Show passwords`,onClick:()=>l(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:c?(0,W.jsx)(Lr,{className:`size-4`}):(0,W.jsx)(Ba,{className:`size-4`})});return(0,W.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-6`,children:(0,W.jsxs)(`form`,{onSubmit:p,className:`flex w-full max-w-sm flex-col gap-5 rounded-xl border bg-card p-6 shadow-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(co,{className:`size-6 text-primary`}),(0,W.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Change your password`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Use the temporary password provided by your Team administrator, then set a new password before continuing.`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`temporary-password`,children:`Temporary password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`temporary-password`,type:m,className:`pr-10`,value:n,onChange:e=>r(e.target.value),required:!0}),h]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`new-password`,children:`New password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`new-password`,type:m,className:`pr-10`,minLength:8,value:i,onChange:e=>a(e.target.value),required:!0}),h]}),(0,W.jsx)(Ir,{children:`At least 8 characters.`})]}),(0,W.jsxs)(zr,{"data-invalid":o.length>0&&o!==i,children:[(0,W.jsx)(Fr,{htmlFor:`confirm-password`,children:`Confirm new password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`confirm-password`,type:m,className:`pr-10`,minLength:8,value:o,onChange:e=>s(e.target.value),"aria-invalid":o.length>0&&o!==i,required:!0}),h]})]}),(0,W.jsxs)(H,{type:`submit`,disabled:u||i.length<8||i!==o,children:[u&&(0,W.jsx)(vo,{className:`animate-spin`}),` Save new password`]})]})})}var P3e=(0,U.lazy)(()=>bi(()=>import(`./NoteEditorRoute-BwHXTyYF.js`).then(e=>({default:e.NoteEditorRoute})),__vite__mapDeps([8,5,9,10,11,12,7,13,14,15,16,17,6,18,19,20,21,4,1,22]))),F3e=(0,U.lazy)(()=>bi(()=>import(`./DiagramEditorRoute-CLADDbwI.js`).then(e=>({default:e.DiagramEditorRoute})),__vite__mapDeps([23,5,9,10,14,12,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),I3e=(0,U.lazy)(()=>bi(()=>import(`./DbClientEditorRoute-DLLxQwb9.js`).then(e=>({default:e.DbClientEditorRoute})),__vite__mapDeps([58,5,9,12,10,14,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),L3e=(0,U.lazy)(()=>bi(()=>import(`./DrawingEditorRoute-Cx5d1LPX.js`).then(e=>({default:e.DrawingEditorRoute})),__vite__mapDeps([56,5,9,10,30,12,11,57,47,7,6,13,14,15,16,17,18,19,20,21,4,1,22]))),R3e=(0,U.lazy)(()=>bi(()=>import(`./FlowchartEditorRoute-Ddyctcrx.js`).then(e=>({default:e.FlowchartEditorRoute})),__vite__mapDeps([54,5,9,12,10,14,15,16,17,7,6,11,28,27,26,29,30,31,32,33,34,35,36,37,38,39,40,55,46,50,42,13,18,19,20,21,4,1,22,51,52,53]))),z3e=(0,U.lazy)(()=>bi(()=>import(`./TeamManagementRoute-DjVvQqbb.js`).then(e=>({default:e.TeamManagementRoute})),__vite__mapDeps([59,5,9,12,10,11,29,27,26,30,31,32,33,35,36,37,38,45,48,39,60,6,7,42,20,22,51]))),B3e=(0,U.lazy)(()=>bi(()=>import(`./TeamInventoryRoute-DsDOchEM.js`).then(e=>({default:e.TeamInventoryRoute})),__vite__mapDeps([61,5,9,12,10,11,36,37,27,48,6,7,20]))),V3e=(0,U.lazy)(()=>bi(()=>import(`./LibraryRoute-Cu8kc4Uq.js`).then(e=>({default:e.LibraryRoute})),__vite__mapDeps([62,5,9,12,10,11,26,27,43,35,30,31,32,36,37,63,48,40,50,6,7]))),H3e=(0,U.lazy)(()=>bi(()=>import(`./UserManagementRoute-BAENUAIi.js`).then(e=>({default:e.UserManagementRoute})),__vite__mapDeps([64,5,9,12,10,11,26,27,43,36,37,48,39,65,6,7,42,32,20]))),U3e=(0,U.lazy)(()=>bi(()=>import(`./AdminRoute-L67IOqL6.js`).then(e=>({default:e.AdminRoute})),__vite__mapDeps([66,5,9,10,7,13,12,14,15,16,17,6,18,19,20,21,4,1,22])));function Y9(e){return(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs text-muted-foreground`,children:`Opening file…`}),children:e})}function W3e(){let{isAuthenticated:e,user:t,setUser:n,isGuest:r,handleLogin:i,handleGuestLogin:a,handleLogout:o}=ta(),s=y(),c=h(),[l,u]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e,t;return typeof window>`u`||!window.__TAURI__&&!window.__TAURI_INTERNALS__?void 0:((async()=>{let{listen:n}=await bi(async()=>{let{listen:e}=await import(`./event-DtFyPu7u.js`);return{listen:e}},__vite__mapDeps([0,1]));e=await n(`menu-about`,()=>{u(!0)}),t=await n(`menu-check-update`,()=>{window.dispatchEvent(new CustomEvent(`menu-check-update`,{detail:{}}))})})(),()=>{e?.(),t?.()})},[]);let d=(0,U.useRef)(!1);(0,U.useEffect)(()=>{e===!1?d.current=!0:e===!0&&d.current&&(d.current=!1,c.pathname!==`/oauth/consent`&&s(`/`))},[e,c.pathname,s]);let{isPublicView:f,setIsPublicView:p,publicData:m,isPublicLoading:g,forbiddenDoc:_,fetchPublicDocument:v}=Jue(()=>{}),b=Ji();return e===null&&!b?(0,W.jsx)(Sp,{type:`init`}):g?(0,W.jsx)(Sp,{type:`public`}):_?(0,W.jsx)(Jre,{title:_.title,message:_.message,statusCode:_.status,documentUid:b?.uid,onSubmitToken:async e=>{if(b){if(await v(b.type,b.uid,void 0,void 0,e))sessionStorage.setItem(`share_token_${b.uid}`,e);else throw Error(`Invalid token`)}},onReturn:()=>window.location.href=`/`}):!e&&!b?(0,W.jsx)(vs,{onLogin:e=>i(e),onGuestLogin:a}):c.pathname===`/oauth/consent`?(0,W.jsx)(M3e,{}):t?.mustChangePassword?(0,W.jsx)(N3e,{user:t,onComplete:n}):(0,W.jsxs)(Yi,{isPublicView:f,publicData:m,isPublicLoading:g,forbiddenDoc:_,fetchPublicDocument:v,setIsPublicView:p,handleLogout:o,children:[(0,W.jsx)(S,{children:(0,W.jsxs)(x,{element:(0,W.jsx)(O3e,{}),children:[(0,W.jsx)(x,{path:`table/:feature`,element:(0,W.jsx)(kde,{})}),(0,W.jsx)(x,{path:`notes/:id`,element:(0,W.jsx)(hb,{capability:`notes`,children:Y9((0,W.jsx)(P3e,{}))})}),(0,W.jsx)(x,{path:`diagrams/:id`,element:(0,W.jsx)(hb,{capability:`erd_builder`,children:Y9((0,W.jsx)(F3e,{}))})}),(0,W.jsx)(x,{path:`db-client/:id`,element:(0,W.jsx)(hb,{capability:`desktop_only`,children:Y9((0,W.jsx)(I3e,{}))})}),(0,W.jsx)(x,{path:`drawings/:id`,element:(0,W.jsx)(hb,{capability:`drawings`,children:Y9((0,W.jsx)(L3e,{}))})}),(0,W.jsx)(x,{path:`flowcharts/:id`,element:(0,W.jsx)(hb,{capability:`flowcharts`,children:Y9((0,W.jsx)(R3e,{}))})}),(0,W.jsx)(x,{path:`trash`,element:Y9((0,W.jsx)(U3e,{}))}),(0,W.jsx)(x,{path:`library`,element:Y9((0,W.jsx)(V3e,{}))}),(0,W.jsx)(x,{path:`teams/:id`,element:Y9((0,W.jsx)(z3e,{}))}),(0,W.jsx)(x,{path:`team-workspaces`,element:Y9((0,W.jsx)(B3e,{}))}),(0,W.jsx)(x,{path:`users`,element:Y9((0,W.jsx)(H3e,{}))}),(0,W.jsx)(x,{index:!0,element:(0,W.jsx)(j3e,{})}),(0,W.jsx)(x,{path:`*`,element:(0,W.jsx)(k3e,{})})]})}),(0,W.jsx)(Kue,{}),(0,W.jsx)(By,{open:l,onOpenChange:u})]})}function G3e(){return(0,W.jsx)(W3e,{})}var K3e=e=>typeof e==`string`?new URL(e,window.location.href).pathname:e?.pathname??window.location.pathname,X9=()=>Number(window.history.state?.idx??0),Z9=e=>{e.index=X9(),e.path=window.location.pathname},Q9=null,$9=!1;typeof window<`u`&&window.addEventListener(`popstate`,e=>{if($9){$9=!1,e.stopImmediatePropagation();return}let t=Q9;t&&(window.location.pathname===t.path||window.confirm(t.message)?Z9(t):(e.stopImmediatePropagation(),$9=!0,window.history.go(t.index-X9())))},!0);function q3e(e,t){let n={message:t,index:X9(),path:window.location.pathname},{push:r,replace:i}=e,a=e=>K3e(e)===window.location.pathname||window.confirm(t);e.push=(e,...t)=>{a(e)&&(r(e,...t),Z9(n))},e.replace=(e,...t)=>{a(e)&&(i(e,...t),Z9(n))};let o=e=>{e.preventDefault(),e.returnValue=``};return Q9=n,window.addEventListener(`beforeunload`,o),()=>{e.push=r,e.replace=i,Q9===n&&(Q9=null),window.removeEventListener(`beforeunload`,o)}}function J3e(e,t){let{navigator:n}=(0,U.useContext)(v);(0,U.useEffect)(()=>e?q3e(n,t):void 0,[e,t,n])}typeof window<`u`&&`__TAURI_INTERNALS__`in window&&document.body.setAttribute(`data-tauri`,`true`);var Y3e=window.fetch;window.fetch=async(...e)=>{let t=await Y3e(...e),n=typeof e[0]==`string`?e[0]:e[0]instanceof Request?e[0].url:typeof e[0]==`object`&&`href`in e[0]?e[0].href:``,r=n.includes(`/api/login`)||n.includes(`/api/logout`)||n.includes(`/api/me`);n.includes(`supabase.co`);let i=xi(),a=(n.startsWith(`/api/`)||i&&n.startsWith(i))&&!n.includes(`supabase.co`),o=sessionStorage.getItem(`auth_mode`)===`guest`;return t.status===401&&a&&!r&&navigator.onLine&&!o&&(Ci(),window.dispatchEvent(new Event(`auth:unauthorized`))),t},`serviceWorker`in navigator&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`?navigator.serviceWorker.getRegistrations().then(e=>{e.forEach(e=>e.unregister())}):window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})})),(0,sa.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(U.StrictMode,{children:(0,W.jsx)(C,{children:(0,W.jsx)(de,{children:(0,W.jsx)(Pt,{children:(0,W.jsxs)(na,{children:[(0,W.jsx)(G3e,{}),(0,W.jsx)(rs,{position:`top-center`})]})})})})}));export{wm as $,wa as $n,To as $t,f0e as A,qa as An,Jo as At,yE as B,La as Bn,Ro as Bt,x8 as C,eo as Cn,ts as Ct,b0e as D,Xa as Dn,Zo as Dt,x0e as E,Za as En,Qo as Et,_L as F,Ha as Fn,Uo as Ft,Tb as G,Ma as Gn,No as Gt,ax as H,Fa as Hn,Io as Ht,ZF as I,Va as In,Ho as It,Cb as J,ka as Jn,Ao as Jt,Sb as K,ja as Kn,Mo as Kt,YN as L,Ba as Ln,Vo as Lt,r8 as M,Ga as Mn,Ko as Mt,mL as N,Wa as Nn,Go as Nt,b8 as O,Ya as On,Xo as Ot,hL as P,Ua as Pn,Wo as Pt,xm as Q,Ta as Qn,Eo as Qt,iN as R,za as Rn,Bo as Rt,C8 as S,to as Sn,ns as St,S0e as T,Qa as Tn,$o as Tt,Yb as U,Pa as Un,Fo as Ut,Zx as V,Ia as Vn,Lo as Vt,Bb as W,Na as Wn,Po as Wt,Pie as X,Da as Xn,Oo as Xt,wb as Y,Oa as Yn,ko as Yt,ym as Z,Ea as Zn,Do as Zt,w0e as _,oo as _n,ls as _t,y3e as a,yo as an,va as ar,tm as at,E8 as b,ro as bn,as as bt,z9 as c,go as cn,ha as cr,Dp as ct,T9 as d,po as dn,fa as dr,Ap as dt,wo as en,Ca as er,Cm as et,Z7 as f,fo as fn,Ep as ft,S5 as g,so as gn,is as gt,C7 as h,co as hn,Ms as ht,R9 as i,bo as in,ya as ir,pm as it,p8 as j,Ka as jn,qo as jt,h8 as k,Ja as kn,Yo as kt,x3e as l,ho as ln,ma as lr,Op as lt,P7 as m,lo as mn,xp as mt,v3e as n,So as nn,xa as nr,Sm as nt,b3e as o,vo as on,_a as or,Zp as ot,$4e as p,uo as pn,Tp as pt,Bde as q,Aa as qn,jo as qt,S3e as r,xo as rn,ba as rr,xie as rt,C3e as s,_o as sn,ga as sr,Mp as st,J3e as t,Co as tn,Sa as tr,bm as tt,E9 as u,mo as un,pa as ur,kp as ut,D8 as v,ao as vn,ss as vt,S8 as w,$a as wn,es as wt,w8 as x,no as xn,os as xt,T8 as y,io as yn,us as yt,eN as z,Ra as zn,zo as zt};
|
|
898
|
+
`),r=we(n);return{...r,dbml:_e(r.nodes,r.edges),warnings:[]}}var S9=e=>e.trim().toLowerCase(),C9=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``)||``;function w9(e,t,n,r){let i=new Map(e.map(e=>[S9(e.data.name),e])),a=new Map,o=new Map,s=n.map((e,t)=>{let n=i.get(S9(e.data.name));if(!n)return{...e,position:e.position||{x:t%4*320+50,y:Math.floor(t/4)*320+50}};a.set(e.id,n.id);let r=e.data.columns.map(t=>{let r=n.data.columns.find(e=>S9(e.name)===S9(t.name));return r&&o.set(`${e.id}:${t.id}`,r.id),r?{...t,id:r.id}:t}),s=(t=[])=>t.map(t=>o.get(`${e.id}:${t}`)||t);return{...e,id:n.id,position:n.position,data:{...e.data,id:n.data.id,x:n.data.x,y:n.data.y,color:n.data.color,collapsed:n.data.collapsed,hidden_columns:n.data.hidden_columns,columns:r,constraints:(e.data.constraints||[]).map(e=>({...e,entity_id:n.data.id,column_ids:s(e.column_ids)})),indexes:(e.data.indexes||[]).map(e=>({...e,entity_id:n.data.id,column_ids:s(e.column_ids)}))}}});return{nodes:s,edges:r.map(e=>{let r=n.find(t=>t.id===e.source),i=n.find(t=>t.id===e.target),o=a.get(e.source)||e.source,c=a.get(e.target)||e.target,l=r?.data.columns.find(t=>t.id===C9(e.sourceHandle)),u=i?.data.columns.find(t=>t.id===C9(e.targetHandle)),d=s.find(e=>e.id===o),f=s.find(e=>e.id===c),p=d?.data.columns.find(e=>S9(e.name)===S9(l?.name||``)),m=f?.data.columns.find(e=>S9(e.name)===S9(u?.name||``)),h=p?`col-${p.id}-${(d?.position.x||0)<(f?.position.x||0)?`source`:`source-l`}`:void 0,g=m?`col-${m.id}-${(d?.position.x||0)<(f?.position.x||0)?`target`:`target-r`}`:void 0,_=Se(t,o,c,h,g);return{...e,id:_?.id||e.id,source:o,target:c,sourceHandle:_?.sourceHandle||h,targetHandle:_?.targetHandle||g}})}}var T9=`erd-builder:repository-preview`,E9=`erd-builder:repository-applied`;function D9(e){window.dispatchEvent(new CustomEvent(T9,{detail:e}))}function O9(){window.dispatchEvent(new CustomEvent(T9))}var k9=`WORKTREE`;async function A9(e,t){let n=await wi(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`Repository request failed`);return r}async function j9(e,t,n){let r=await wi(e,{method:t,...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify({repository_path:n.repositoryPath,ref:n.ref,source_id:n.sourceId})}:{}}),i=r.status===204?null:await r.json().catch(()=>({}));if(!r.ok)throw Error(i?.error||`Repository link request failed`);return i}function m3e({diagramUid:e,nodes:t,edges:n,onClose:r}){let i=`erdbpro:repository-link:${e}`,a=`/api/repositories/link/${encodeURIComponent(e)}`,[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),[u,f]=(0,U.useState)(k9),[p,m]=(0,U.useState)(``),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)([]),[y,b]=(0,U.useState)(null),x=(0,U.useRef)(null),S=typeof window<`u`&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),C=(0,U.useCallback)(e=>{let t=JSON.stringify(e);x.current!==t&&(localStorage.setItem(i,JSON.stringify(e)),j9(a,`PUT`,e).then(()=>{x.current=t,localStorage.removeItem(i)}).catch(()=>{}))},[a,i]),w=(0,U.useCallback)(async(e,t,n=``)=>{let r=await A9(`/api/repositories/inspect`,{repository_path:e,ref:t}),i=r.sources.find(e=>e.id===n)?.id||r.sources[0]?.id||``;return s(r.root),l(r),f(t),g(i),m(e=>e||r.current_ref||r.refs.find(e=>e.current)?.value||``),i&&C({repositoryPath:r.root,ref:t,sourceId:i}),r},[C]);(0,U.useEffect)(()=>{b(`connect`),j9(a,`GET`).then(e=>{if(e?.repositoryPath)return x.current=JSON.stringify(e),e;try{return JSON.parse(localStorage.getItem(i)||`null`)}catch{return null}}).then(e=>e?.repositoryPath?w(e.repositoryPath,e.ref||k9,e.sourceId):void 0).catch(e=>d.error(e.message)).finally(()=>b(null))},[w,a,i]),(0,U.useEffect)(()=>()=>O9(),[]);let T=(0,U.useMemo)(()=>c?[{value:k9,label:`Working tree`},...c.refs.map(e=>({value:e.value,label:`${e.name}${e.current?` (current)`:``}`})),...c.commits.map(e=>({value:e.value,label:`${e.short} · ${e.subject}`}))]:[],[c]),E=c?.sources.find(e=>e.id===h),D=async()=>{if(o.trim()){b(`connect`),v([]);try{(await w(o.trim(),k9)).sources.length?d.success(`Repository connected`):d.info(`Repository connected, but no supported schema source was found`)}catch(e){d.error(e.message)}finally{b(null)}}},O=async e=>{if(c){b(`connect`),v([]);try{await w(c.root,e,h)}catch(e){d.error(e.message)}finally{b(null)}}},k=async e=>{if(!c||!h)throw Error(`Select a schema source first`);let t=await A9(`/api/repositories/read`,{repository_path:c.root,ref:e,source_id:h}),n=p3e(t.source.kind,t.files);if(!n.nodes.length)throw Error(`No tables could be parsed from this schema source`);return{...t,...n}},A=async()=>{b(`preview`),v([]);try{let e=await k(u),r=w9(t,n,e.nodes,e.edges);v(e.warnings),D9({proposedNodes:r.nodes,proposedEdges:r.edges,sourceLabel:N9(u,T),commit:e.commit,dbmlSource:e.dbml,canApply:!0}),C({repositoryPath:c.root,ref:u,sourceId:h}),d.info(`Repository schema preview opened on the canvas`)}catch(e){d.error(e.message)}finally{b(null)}},j=async()=>{if(p&&p!==u){b(`compare`),v([]);try{let[e,t]=await Promise.all([k(p),k(u)]),n=w9(e.nodes,e.edges,t.nodes,t.edges);v([...e.warnings,...t.warnings]),D9({originalNodes:e.nodes,originalEdges:e.edges,proposedNodes:n.nodes,proposedEdges:n.edges,sourceLabel:`${N9(p,T)} → ${N9(u,T)}`,commit:t.commit,canApply:!1}),d.info(`Git ref comparison opened on the canvas`)}catch(e){d.error(e.message)}finally{b(null)}}},M=async()=>{let{open:e}=await bi(async()=>{let{open:e}=await Promise.resolve().then(()=>gm);return{open:e}},void 0),t=await e({directory:!0,multiple:!1,title:`Select Git repository`});typeof t==`string`&&s(t)};return(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b p-4`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{className:`font-semibold`,children:`Repository Schema`}),(0,W.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:c?.root||`Link this ERD to a local Git repository`})]}),(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>{O9(),r()},"aria-label":`Close repository panel`,children:(0,W.jsx)(Gr,{className:`size-4`})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Schema source`}),(0,W.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:async()=>{try{await j9(a,`DELETE`),x.current=null,localStorage.removeItem(i),O9(),l(null),g(``),v([])}catch(e){d.error(e.message)}},children:[(0,W.jsx)(Xo,{className:`size-3.5`}),`Disconnect`]})]}),(0,W.jsx)(M9,{label:`Git ref`,children:(0,W.jsx)(cr,{value:u,onChange:e=>void O(e),items:T,disabled:y!==null,placeholder:`Select Git ref`,searchPlaceholder:`Search branch or commit...`,emptyMessage:`No Git ref found`,className:`h-9 text-sm`,getItemValue:e=>e.value,getItemLabel:e=>e.label,filterItem:(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())})}),(0,W.jsx)(M9,{label:`Schema`,children:(0,W.jsxs)(Er,{value:h,disabled:y!==null||!c.sources.length,onValueChange:e=>{e&&(g(e),C({repositoryPath:c.root,ref:u,sourceId:e}))},children:[(0,W.jsx)(Cr,{children:(0,W.jsx)(Tr,{placeholder:`Select schema`,children:E?.label})}),(0,W.jsx)(Sr,{children:c.sources.map(e=>(0,W.jsx)(xr,{value:e.id,children:e.label},e.id))})]})}),!c.sources.length&&(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supported sources: Laravel migrations, DBML, and SQL schema/migration files.`}),(0,W.jsxs)(H,{className:`w-full`,disabled:!h||y!==null,onClick:()=>void A(),children:[y===`preview`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(Hr,{className:`size-4`}),`Preview against current ERD`]})]}),(0,W.jsxs)(`section`,{className:`space-y-3 border-t pt-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-medium`,children:`Compare Git refs`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Compare branches or commits without checking them out. This preview cannot modify the current ERD.`})]}),(0,W.jsx)(M9,{label:`Base ref`,children:(0,W.jsx)(cr,{value:p,onChange:m,items:T.filter(e=>e.value!==k9),disabled:y!==null,placeholder:`Select base ref`,searchPlaceholder:`Search branch or commit...`,emptyMessage:`No Git ref found`,className:`h-9 text-sm`,getItemValue:e=>e.value,getItemLabel:e=>e.label,filterItem:(e,t)=>e.label.toLowerCase().includes(t.toLowerCase())})}),(0,W.jsxs)(H,{variant:`outline`,className:`w-full`,disabled:!h||!p||p===u||y!==null,onClick:()=>void j(),children:[y===`compare`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(eo,{className:`size-4`}),`Compare with selected ref`]})]})]}):(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-lg bg-muted`,children:(0,W.jsx)(gr,{className:`size-5 text-muted-foreground`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-medium`,children:`Connect a repository`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Only supported schema files are read. The repository and active branch are never modified.`})]}),(0,W.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(Oi,{value:o,onChange:e=>s(e.target.value),placeholder:`/path/to/project`,onKeyDown:e=>{e.key===`Enter`&&D()}}),S&&(0,W.jsx)(H,{variant:`outline`,size:`icon`,onClick:()=>void M(),"aria-label":`Browse repository`,children:(0,W.jsx)(Za,{className:`size-4`})})]})]}),(0,W.jsxs)(H,{className:`w-full`,disabled:!o.trim()||y!==null,onClick:()=>void D(),children:[y===`connect`?(0,W.jsx)(vo,{className:`size-4 animate-spin`}):(0,W.jsx)(gr,{className:`size-4`}),`Connect repository`]})]}),_.length>0&&(0,W.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/5 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-amber-700 dark:text-amber-400`,children:[(0,W.jsx)(ri,{className:`size-4`}),_.length,` migration statement`,_.length===1?``:`s`,` need review`]}),(0,W.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:_.slice(0,8).map(e=>(0,W.jsx)(`li`,{className:`break-words`,children:e},e))})]})]})]})}function M9({label:e,children:t}){return(0,W.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium`,children:e}),t]})}function N9(e,t){return t.find(t=>t.value===e)?.label||e.slice(0,12)}function P9(e,t){return e&&e.replace(/^(col-)([\w-]+)(-source|-target)(-[lr])?$/,(e,n,r,i,a)=>{let o=t.get(r);return o?`${n}${o}${i}${a||``}`:e})}function h3e(e,t,n,r){let i=new Map,a=t.map(e=>({...e})),o=e.map(e=>{let t=n.find(t=>t.data.name.toLowerCase()===e.data.name.toLowerCase());if(t){i.set(e.id,t.id);let n=new Map;e.data.columns=e.data.columns.map(e=>{let r=t.data.columns.find(t=>t.name.toLowerCase()===e.name.toLowerCase());return r?(n.set(e.id,r.id),{...e,id:r.id,name:r.name,enum_name:e.enum_name||r.enum_name,enum_values:e.enum_values||r.enum_values,comment:e.comment||r.comment,max_length:e.max_length??r.max_length,numeric_precision:e.numeric_precision??r.numeric_precision,numeric_scale:e.numeric_scale??r.numeric_scale,type:r.type.toUpperCase()===`ENUM`&&r.enum_values&&e.type.toUpperCase()!==`ENUM`?r.type:e.type}):e}),e.data.constraints=(e.data.constraints||[]).map(e=>({...e,entity_id:t.id,column_ids:(e.column_ids||[]).map(e=>n.get(e)||e)})),e.data.indexes=(e.data.indexes||[]).map(e=>({...e,entity_id:t.id,column_ids:(e.column_ids||[]).map(e=>n.get(e)||e)}));for(let t of a)t.source===e.id&&(t.sourceHandle=P9(t.sourceHandle,n)),t.target===e.id&&(t.targetHandle=P9(t.targetHandle,n));return{...e,id:t.id,position:t.position,data:{...e.data,name:t.data.name,comment:e.data.comment??t.data.comment,id:t.data.id,x:t.data.x,y:t.data.y,color:t.data.color,collapsed:t.data.collapsed,hidden_columns:t.data.hidden_columns,note:t.data.note}}}return e}),s=a.map(e=>{let t=i.get(e.source)||e.source,n=i.get(e.target)||e.target,a=e.sourceHandle?.replace(/^col-/,``).replace(/-(source|target)(-[lr])?$/,``)||``,s=e.targetHandle?.replace(/^col-/,``).replace(/-(source|target)(-[lr])?$/,``)||``,c=Se(r,t,n,e.sourceHandle,e.targetHandle);if(c)return{...e,id:c.id,source:t,target:n,sourceHandle:c.sourceHandle,targetHandle:c.targetHandle};let l=o.find(e=>e.id===t),u=o.find(e=>e.id===n),d=l?.position.x??0,f=u?.position.x??0,p=d<f?`source`:`source-l`,m=d<f?`target`:`target-r`;return{...e,source:t,target:n,sourceHandle:a?`col-${a}-${p}`:void 0,targetHandle:s?`col-${s}-${m}`:void 0}});return{nodes:D(o),edges:s}}function g3e(e,t){switch(e){case`chat`:return t.aiChat;case`dbml`:return t.dbml;case`properties`:return t.diagramProperties;case`history`:return t.history;case`repository`:return t.repository;default:return!1}}var _3e=({isOpen:e,onClick:t,raised:n})=>e?null:(0,W.jsx)(Pt,{children:(0,W.jsxs)(Lt,{children:[(0,W.jsx)(Ft,{render:(0,W.jsx)(H,{"aria-label":`Open AI Assistant`,onClick:t,className:`fixed right-6 ${n?`bottom-16`:`bottom-4`} z-50 size-12 rounded-full shadow-lg shadow-primary/20 hover:shadow-xl hover:shadow-primary/30 transition-all duration-200 hover:scale-105 active:scale-95`,size:`icon`,children:(0,W.jsx)(ti,{className:`size-5`})})}),(0,W.jsx)(Wt,{side:`left`,children:`AI Assistant`})]})}),v3e=`erd-production-db-tabs:`,F9=new Map,I9=new Map,L9=new Map;function y3e(e){let t=F9.get(e);return t||(t=new Map,F9.set(e,t),F9.size>5&&F9.delete(F9.keys().next().value)),t}var b3e=e=>I9.get(e),x3e=(e,t)=>{I9.set(e,t),I9.size>5&&I9.delete(I9.keys().next().value)},S3e=e=>I9.delete(e),R9=e=>L9.get(String(e)),z9=e=>{e?.id!=null&&L9.set(String(e.id),e),e?.uid&&L9.set(String(e.uid),e),L9.size>10&&L9.delete(L9.keys().next().value)},C3e=(e=``)=>({id:crypto.randomUUID(),enabled:!0,column:e,operator:`CONTAINS`,value:``,value2:``}),B9=`ERD Builder Pro`;function w3e({pathname:e,activeFileName:t,breadcrumbLabel:n,featureLabel:r,searchFeature:i}){let a=e.replace(/\/+$/,``)||`/`;return/^\/(?:notes|diagrams|db-client|flowcharts|drawings)\/[^/]+$/.test(a)&&t?`${t} | ${B9}`:a===`/`?`Dashboard | ${B9}`:a===`/trash`?`Trash | ${B9}`:a===`/library`?`Library | ${B9}`:a===`/team-workspaces`?`Team Workspaces | ${B9}`:a===`/users`?`User Management | ${B9}`:a.startsWith(`/teams/`)?`${n||`Team management`} | ${B9}`:a===`/table/db-client`?`DB Client | ${B9}`:a.startsWith(`/table/`)?`${n||r||`Tables`} | ${B9}`:a.startsWith(`/notes/`)?`Notes | ${B9}`:a.startsWith(`/diagrams/`)?`${i===`db-client`?`DB Client`:`Diagram`} | ${B9}`:a.startsWith(`/db-client/`)?`${n||`DB Client`} | ${B9}`:a.startsWith(`/flowcharts/`)?`Flowchart | ${B9}`:a.startsWith(`/drawings/`)?`Drawing | ${B9}`:B9}function T3e(e){if(!e.trim())return!1;try{return ne(e),!0}catch{return!1}}function V9(e){return JSON.stringify({name:e.name,columns:e.columns.map(e=>({name:e.name,type:e.type,is_pk:e.is_pk,is_nullable:e.is_nullable,default_value:e.default_value||null,is_unique:!!e.is_unique,comment:e.comment||``,max_length:e.max_length??null,numeric_precision:e.numeric_precision??null,numeric_scale:e.numeric_scale??null})),comment:e.comment||``,constraints:(e.constraints||[]).map(t=>({kind:t.kind,name:t.name||``,columns:(t.column_ids||[]).map(t=>e.columns.find(e=>e.id===t)?.name||t).sort(),expression:t.expression||``})).sort((e,t)=>JSON.stringify(e).localeCompare(JSON.stringify(t))),indexes:(e.indexes||[]).map(t=>({name:t.name,is_unique:!!t.is_unique,algorithm:t.algorithm||``,columns:(t.column_ids||[]).map(t=>e.columns.find(e=>e.id===t)?.name||t).sort()})).sort((e,t)=>JSON.stringify(e).localeCompare(JSON.stringify(t)))})}function E3e({root:e,session:t,mainAI:n,paired:r,onPairChange:i,onFocusedSession:a}){let o=h(),s=y(),[l,u]=(0,U.useState)(null),f=(0,U.useRef)(null),p=(0,U.useCallback)(e=>f.current?.(e),[]),[g,v]=(0,U.useState)(null),[b]=_(),[x,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(!1),[T,E]=(0,U.useState)(null),[D,O]=(0,U.useState)(null),[M,N]=(0,U.useState)(``),P=(0,U.useRef)(``),F=(0,U.useRef)(!1),I=(0,U.useRef)(null),{rightPanelMode:L,setRightPanelMode:R,pendingPrompt:ee,clearPrompt:te,pendingAction:ne,clearPendingAction:re}=An(),ie=(0,U.useCallback)(e=>{P.current=e,N(e)},[]),z=(0,U.useMemo)(()=>{let e=(t?k(t.file).split(`?`)[0]:o.pathname).match(/^\/(notes|diagrams|flowcharts|drawings|db-client)\/([^/]+)$/);return e?{entityType:{notes:`note`,diagrams:`diagram`,flowcharts:`flowchart`,drawings:`drawing`,"db-client":`dbClient`}[e[1]],entityUid:e[2]}:null},[o.pathname,t?.file.type,t?.file.uid]),ae=z?.entityType===`diagram`,oe=z?.entityType===`diagram`?`diagrams`:z?.entityType===`flowchart`?`flowcharts`:z?.entityType===`note`?`notes`:z?.entityType===`drawing`?`drawings`:null;(0,U.useEffect)(()=>{if(z?.entityType!==`dbClient`){O(null);return}let e=R9(z.entityUid);if(e){O(e);return}let t=!1;return wi(`/api/db-clients/${encodeURIComponent(z.entityUid)}`).then(e=>e.ok?e.json():null).then(e=>{e&&z9(e),t||O(e)}).catch(()=>{t||O(null)}),()=>{t=!0}},[z]);let{view:se,sidebarView:ce,isPublicView:le,isOnline:ue,projects:de,user:B,isProjectsLoading:fe,handleLogout:pe,handleViewChange:me,handleNoteSelect:he,handleDrawingSelect:ge,refreshActiveDocument:ve,handleSidebarProjectCreate:V,handleSidebarProjectUpdate:ye,handleSidebarProjectDelete:be,handleWorkspaceFilter:xe,selectedWorkspaceUid:Se,handleHeaderDelete:Ce,handleHeaderRename:we,handleHeaderSettingsSaved:Te,handleHeaderExportSQL:Ee,handleHeaderExportImage:De,handleOpenImportModal:Oe,isImportModalOpen:ke,setIsImportModalOpen:Ae,handleExportMarkdown:je,handleCopyMarkdown:Me,handleImportMarkdown:Ne,executeImportMarkdown:Pe,handleDuplicate:Fe,syncError:Ie,isSyncing:Le,isLocalSaving:Re,isRefreshing:ze,hasPendingSyncs:Be,syncDrafts:Ve,activeFileUid:He,currentActiveId:Ue,initialShareSettings:We,activeDocument:Ge,isGuest:Ke,isReadOnlyFile:qe,getFileAccessRole:Je,featureLabel:Ye,activeProjectName:Xe,activeFileName:Ze,hasActiveItem:Qe,activeNote:$e,activeDrawing:et,activeFlowchart:tt,activeDiagram:nt,notes:rt,diagrams:it,flowcharts:at,drawings:ot,setNodes:st,setEdges:ct,activeDiagramId:lt,takeSnapshot:ut,saveDiagram:dt,triggerDebouncedSync:ft,broadcastMessage:pt,setIsLocalSaving:mt,viewportRef:ht,lastLoadedDiagramIdRef:gt,fetchTrash:_t,triggerTableRefresh:vt,setTableLoadingState:yt,setIsSettingsOpen:bt,selectedNodeId:xt,setSelectedNodeId:St,selectedEdgeId:Ct,setSelectedEdgeId:wt,selectedEntity:Tt,deleteEntity:Et,deleteEdge:Dt,updateDiagram:Ot,updateNote:kt,updateDrawing:At,updateFlowchart:jt,moveDiagramToProject:Mt,moveNoteToProject:Nt,moveDrawingToProject:Pt,moveFlowchartToProject:Ft,deleteDiagram:It,deleteNote:Lt,deleteDrawing:Rt,deleteFlowchart:zt,handleEntityUpdate:Bt,handleSidebarDiagramCreate:Vt,handleSidebarNoteCreate:Ht,handleSidebarDrawingCreate:Ut,handleSidebarFlowchartCreate:Wt,isMoveToTrashAlertOpen:Gt,setIsMoveToTrashAlertOpen:Kt,isDeleteAlertOpen:qt,setIsDeleteAlertOpen:Jt,isRenameDialogOpen:Yt,setIsRenameDialogOpen:Xt,isDuplicateDialogOpen:Zt,setIsDuplicateDialogOpen:Qt,isPermanentDeleteConfirmOpen:$t,setIsPermanentDeleteConfirmOpen:en,isImportNoteModalOpen:tn,setIsImportNoteModalOpen:nn,isExportNoteModalOpen:rn,setIsExportNoteModalOpen:an,newName:on,setNewName:sn,renameProjectId:cn,setRenameProjectId:ln,duplicateName:un,setDuplicateName:dn,itemToDelete:fn,createDialogOpen:pn,setCreateDialogOpen:mn,createDialogView:hn,editDialogNote:gn,setEditDialogNote:_n,tableDeleteDoc:vn,setTableDeleteDoc:yn,executeDuplicate:bn,confirmPermanentDelete:xn,handleEdgeUpdate:Sn,handleEdgeFlip:Cn,breadcrumbLabel:wn,refreshTeamScope:Tn,flushPendingSaves:En,teamScopeVersion:Dn,isTeamScopeRefreshing:On}=ia(),{nodes:kn,edges:jn}=Bi(),[Mn,Nn]=(0,U.useState)(``),[Pn,Fn]=(0,U.useState)([]),[In,Ln]=(0,U.useState)(!1),[Rn,zn]=(0,U.useState)([]);B?.isSuperAdmin||B?.is_super_admin;let Bn=(0,U.useCallback)(()=>{Nn(``),Fn([]),zn([]),R(`closed`),En().catch(()=>{}),Tn()},[En,Tn,R]),Vn=g1e(Ke,!!B?.isSso,Bn);(0,U.useEffect)(()=>{if(Ke){zn([]);return}let e=!1;return wi(`/api/projects/selectable`).then(e=>e.ok?e.json():{data:[]}).then(t=>{e||zn(Array.isArray(t.data)?t.data:[])}).catch(()=>{e||zn([])}),()=>{e=!0}},[pn,Ke,Yt,Vn.activeTeamId]);let Hn=(0,U.useRef)(!1),Un=(0,U.useCallback)(async e=>{if(!(Hn.current||e===Vn.activeTeamId)){Hn.current=!0;try{await Zy(En,Ve,{type:se,id:Ue,uid:He}),Vn.selectTeam(e),Nn(``),Fn([]),R(`closed`),await Tn()}catch{d.error(`Could not switch workspaces. Check that your changes are saved and retry.`)}finally{Hn.current=!1}}},[He,Ue,En,Tn,R,Ve,Vn.activeTeamId,Vn.selectTeam,se]),Wn=(0,U.useCallback)(async e=>(await Zy(En,Ve,{type:se,id:Ue,uid:He}),Vn.createTeam(e)),[He,Ue,En,Ve,Vn.createTeam,se]),Gn=(0,U.useCallback)(e=>{e.manageUrl?window.location.assign(e.manageUrl):s(`/teams/${e.id}`)},[s]),Kn=(0,U.useCallback)(async e=>{await Tn(),s(`/teams/${e.id}`)},[s,Tn]),qn=o.pathname===`/table/db-client`||o.pathname.startsWith(`/db-client/`)||o.pathname.startsWith(`/diagrams/`)&&b.get(`feature`)===`db-client`,Jn=qn||/^\/(table\/(erd|notes|drawings|flowchart)|(notes|diagrams|drawings|flowcharts)\/)/.test(o.pathname);(0,U.useEffect)(()=>{let e=Mn.trim();if(e.length<2){Fn([]),Ln(!1);return}let t=!1,n=window.setTimeout(async()=>{Ln(!0);try{if(Ke){let n=e.toLowerCase(),r=new Map(de.map(e=>[String(e.id),e])),i=[...it.filter(e=>(e.source_type??e.sourceType)!==`production_db`).map(e=>({...e,type:`erd`,name:e.name})),...rt.map(e=>({...e,type:`notes`,name:e.title})),...ot.map(e=>({...e,type:`drawings`,name:e.title})),...at.map(e=>({...e,type:`flowchart`,name:e.title}))],a=[...de.filter(e=>e.name?.toLowerCase().includes(n)).map(e=>({...e,type:`workspace`})),...i.filter(e=>e.name?.toLowerCase().includes(n)).map(e=>({...e,workspace:r.get(String(e.project_id))}))].slice(0,20);t||Fn(a);return}let n=await wi(`/api/search?q=${encodeURIComponent(e)}`),r=n.ok?await n.json():{data:[]};t||Fn(Array.isArray(r.data)?r.data:[])}catch{t||Fn([])}finally{t||Ln(!1)}},220);return()=>{t=!0,window.clearTimeout(n)}},[Mn,Ke,de,it,rt,ot,at]);let Yn=(0,U.useCallback)(e=>{if(Nn(``),e.type===`workspace`){me(`erd`,!0,e.uid??e.id);return}let t=e.uid??e.id,n={erd:`/diagrams/${t}`,"db-client":`/db-client/${t}`,notes:`/notes/${t}`,drawings:`/drawings/${t}`,flowchart:`/flowcharts/${t}`}[e.type];n&&s(n)},[me,s]),Xn=ae&&(nt?.source_type??nt?.sourceType)===`production_db`,Zn=ji(Ge,B?.id,Ke),Qn=!qe(Ge),$n=Zn,er=Je(Ge),tr=vn??Ge,nr=(tr?.source_type??tr?.sourceType)===`production_db`,rr=(0,U.useMemo)(()=>{let e=kn.find(e=>e.id===xt)??kn.find(e=>e.id===g);return e?e.data.id===e.id?e.data:{...e.data,id:e.id}:null},[kn,g,xt]),ir=z?.entityType===`diagram`?`erd-builder-dbml:${z.entityUid}`:null,ar=nt?.dbml_source??nt?.dbmlSource??``;(0,U.useEffect)(()=>{let e=I.current!==ir;if(e&&(I.current=ir,F.current=!1),!ir)ie(``);else if(ar)!e&&F.current&&P.current.trim()||ie(ar);else if(e||!F.current)try{let e=localStorage.getItem(ir)||``;ie(e)}catch{ie(``)}},[ir,ar,ie]);let or=(0,U.useCallback)((e,t=!1)=>{ie(e),F.current=!t,t&&T3e(e)&&dt(kn,jn,ht.current,{dbmlSource:e}).then(()=>{Ke||ft()})},[dt,kn,jn,ht,Ke,ft,ie]),sr=(0,U.useCallback)(()=>{if((nt?.source_type??nt?.sourceType)!==`production_db`&&ae&&(R(`dbml`),!M.trim()&&kn.length!==0))try{let e=_e(kn,jn);e.trim()&&ie(e)}catch{}},[nt,ae,R,M,kn,jn,ie]);(0,U.useEffect)(()=>{if(L===`dbml`&&ae&&kn.length>0&&!M.trim())try{let e=_e(kn,jn);e.trim()&&ie(e)}catch{}},[L,ae,kn,jn,M,ie]);let cr=(0,U.useMemo)(()=>{let e=z;if(!e)return null;switch(e.entityType){case`note`:return $e?O6(`note`,{title:$e.title,content:A(String($e.content||``))}):null;case`diagram`:if(!nt||L!==`chat`)return null;let e=O6(`diagram`,{title:nt.name,nodes:kn,edges:jn});return(nt.source_type??nt.sourceType)===`production_db`?`[Current feature: DB Client]\nSource: live production database metadata\nCurrent tab: ${b.get(`tab`)||`data`}\n\n${e||``}`:e;case`flowchart`:if(!tt)return null;let t=[],n=[];try{let e=JSON.parse(tt.data||`{}`);t=e.nodes&&e.nodes.length>0?e.nodes:Ii,n=e.edges&&e.edges.length>0?e.edges:Fi}catch{t=Ii,n=Fi}return O6(`flowchart`,{title:tt.title,nodes:t,edges:n});case`drawing`:return et?O6(`drawing`,{title:et.title}):null;default:return null}},[z,$e,nt,tt,et,kn,jn,b,L]),lr=z?.entityType===`dbClient`||ae&&(nt?.source_type??nt?.sourceType)===`production_db`,ur=(0,U.useMemo)(()=>B?.isSso&&Vn.activeTeam?.capabilities?.ai_assistant!==!0||z===null||le||!Qn||z.entityType===`drawing`?!1:lr?!0:(b.get(`tab`)||`erd`)===`erd`,[z,le,Qn,lr,b,Vn.activeTeam,B?.isSso]),dr=ae&&Qn&&(nt?.source_type??nt?.sourceType)!==`production_db`,fr=(0,U.useMemo)(()=>{let e=z?.entityType===`dbClient`?D:$e||nt||tt||et;return e?.project_id??e?.projectId??null},[z,D,$e,nt,tt,et]),pr=(0,U.useMemo)(()=>{if(le||Ke||!z||!Ze||lr)return null;let e=z.entityType===`diagram`?`diagram`:z.entityType===`note`?`note`:z.entityType===`drawing`?`drawing`:z.entityType===`flowchart`?`flowchart`:null,t=He||Ue||z.entityUid;return e&&t?{featureType:e,fileId:String(t),label:Ze}:null},[Ze,He,Ue,z,lr,Ke,le]),mr=de.find(e=>String(e.id)===String(fr)),hr=mr?.team_id??mr?.teamId,gr=pr&&!le&&!Ke&&hr&&String(hr)===String(Vn.activeTeamId)?String(Vn.activeTeamId):void 0,vr=(0,U.useMemo)(()=>Ct&&jn.some(e=>e.id===Ct)?{type:`relationship`,id:Ct}:xt&&kn.some(e=>e.id===xt)?{type:`table`,id:xt}:null,[jn,kn,Ct,xt]),yr=(0,U.useCallback)((e,t)=>{window.dispatchEvent(new CustomEvent(`erd-discussion-anchor-selected`,{detail:{type:e,id:t}}))},[]),br=(0,U.useCallback)(e=>{if(!pr)return;if(e.featureType===pr.featureType&&String(e.fileId)===pr.fileId){e.featureType===`diagram`&&e.anchorType!==`general`&&e.anchorId&&yr(e.anchorType,e.anchorId);return}let t={diagram:it,note:rt,drawing:ot,flowchart:at}[e.featureType]?.find(t=>String(t.uid??t.id)===String(e.fileId)||String(t.id)===String(e.fileId));t&&(s(`${{diagram:`/diagrams`,note:`/notes`,drawing:`/drawings`,flowchart:`/flowcharts`}[e.featureType]}/${t.uid??t.id}`),e.featureType===`diagram`&&e.anchorType!==`general`&&e.anchorId&&window.setTimeout(()=>yr(e.anchorType,e.anchorId),0))},[it,pr,at,yr,s,rt,ot]),xr=(0,U.useCallback)(e=>$e?.content&&new DOMParser().parseFromString(String($e.content),`text/html`).querySelector(`[data-comment-anchor-id="${CSS.escape(e)}"]`)?.textContent?.trim()||null,[$e?.content]),Sr=fr&&pr&&gr?(0,W.jsx)(zb,{projectId:String(fr),teamId:gr,userId:B?.id?String(B.id):void 0,userName:B?.name||B?.email,fileContext:pr,anchorContext:vr,readOnly:er===`viewer`,onContextSelected:br,anchorPreview:pr.featureType===`note`?xr:void 0},`${gr}:${fr}:${pr.featureType}:${pr.fileId}`):null;(0,U.useEffect)(()=>{document.title=w3e({pathname:o.pathname,activeFileName:Ze,breadcrumbLabel:wn,featureLabel:Ye,searchFeature:b.get(`feature`)})},[Ze,Ye,wn,o.pathname,b]),(0,U.useEffect)(()=>{if(typeof window>`u`||!(window.__TAURI__||window.__TAURI_INTERNALS__))return;let e=e=>{let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(navigator.platform.toLowerCase().includes(`mac`)?e.metaKey:e.ctrlKey)&&e.key===`,`&&(e.preventDefault(),bt(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[bt]);let Cr=g3e(L,{aiChat:ur,dbml:dr,diagramProperties:ae&&!Xn,history:!!(oe&&z),repository:ae&&!Xn}),wr=(0,U.useCallback)((...e)=>(L===`repository`&&(O9(),R(`closed`)),me(...e)),[me,L,R]);(0,U.useEffect)(()=>{let e=e=>{let t=e.detail?.dbmlSource;t&&ie(t)};return window.addEventListener(E9,e),()=>window.removeEventListener(E9,e)},[ie]);let Tr=(0,U.useCallback)((e,t,n)=>{let{nodes:r,edges:i}=h3e(e,t,kn,jn),a=r.length===kn.length&&r.every((e,t)=>{let n=kn.find(t=>t.id===e.id);return!n||e.data.name!==n.data.name?!1:V9(e.data)===V9(n.data)}),o=e=>JSON.stringify({source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,label:e.label,data:e.data}),s=i.map(o).sort(),c=jn.map(o).sort(),l=JSON.stringify(s)===JSON.stringify(c);a&&l?(dt(kn,jn,ht.current,{dbmlSource:n}).then(()=>ft()),F.current=!1):(ut?.(kn,jn),st(r),ct(i),F.current=!1,dt?.(r,i,ht?.current,{dbmlSource:n})?.then(()=>ft?.()))},[kn,jn,st,ct,ut,dt,ht,ft]),{setOpen:Er,open:Dr}=Pp(),Or=(0,U.useRef)(Dr);(0,U.useEffect)(()=>{Cr?(Or.current=Dr,Er(!1)):Or.current&&Er(!0)},[Cr]),(0,U.useEffect)(()=>{(!z||L===`chat`&&!ur)&&R(`closed`)},[z,L,ur,R]);let kr=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=z?`${z.entityType}:${z.entityUid}`:null,t=kr.current!==null&&kr.current!==e;kr.current=e,t&&v(null),L===`properties`&&(!ae||t||Xn||!Qn)&&R(`closed`)},[z,ae,L,Xn,Qn,R]),(0,U.useEffect)(()=>{L===`properties`&&xt&&v(xt)},[L,xt]),(0,U.useEffect)(()=>{L===`dbml`&&!dr&&R(ur?`chat`:`closed`)},[L,dr,ur,R]),(0,U.useEffect)(()=>{L===`repository`&&(!ae||Xn)&&R(`closed`)},[L,ae,Xn,R]),(0,W.jsxs)(W.Fragment,{children:[!ue&&!le&&(0,W.jsx)(h1e,{}),!le&&(0,W.jsx)(Ofe,{activeFeatureView:qn?`db-client`:Jn?ce:null,globalSearchResults:Pn,isGlobalSearchLoading:In,onGlobalSearchResultSelect:Yn,projects:de,onViewChange:wr,onProjectCreate:V,onProjectUpdate:ye,onProjectDelete:be,onLogout:pe,onWorkspaceFilter:xe,selectedWorkspaceUid:Se,globalSearchQuery:Mn,onGlobalSearchChange:Nn,user:B,isOnline:ue,isProjectsLoading:fe,onOpenFeedback:()=>S(!0),teams:Vn.teams,teamsAvailable:Vn.isAvailable,licenseRequired:Vn.licenseRequired,activeTeamId:Vn.activeTeamId,onTeamsRefresh:()=>{Vn.fetchTeams()},onTeamSelect:Un,onTeamManage:Gn,onTeamCreate:Wn,onTeamCreated:Kn,ssoPortalUrl:B?.isSso?B.ssoPortalUrl??B.sso_portal_url:null}),(0,W.jsx)(Vy.Provider,{value:l,children:(0,W.jsxs)(rie,{className:c(le?`w-full`:``,Cr&&`mr-90 transition-[margin] duration-200`),children:[(0,W.jsx)(j.Provider,{value:t?.scope??null,children:(0,W.jsx)(Mfe,{tabsRef:u,documentPath:t?k(t.file).split(`?`)[0]:void 0,sidebarDisabled:r,featureLabel:Ye,activeProjectName:z?.entityType===`dbClient`?D?.project?.name:Xe,activeFileName:z?.entityType===`dbClient`?wn||``:Ze,view:se,hasActiveItem:le?!0:Qe,syncError:Ie,isSyncing:Le,isLocalSaving:Re,isRefreshing:ze,hasPendingSyncs:Be,onSave:Ve,activeFileUid:He,activeFileId:Ue,initialShareSettings:We,isPublicView:le,onSettingsSaved:Te,isOnline:ue,updatedAt:Ge?.updated_at,onDelete:Zn?Ce:void 0,onRename:Qn?we:void 0,canManage:$n,onRefresh:ve,onExportAll:Xn?void 0:()=>w(!0),onExportSQL:Ee,onExportImage:De,onExportMarkdown:je,onCopyMarkdown:Me,onImportMarkdown:Qn?Ne:void 0,onDuplicate:Fe,isGuest:Ke,breadcrumbLabel:wn,noteContent:$e?.content,historyAvailable:!!oe,discussionPanel:t?(0,W.jsx)(`span`,{ref:E,className:`contents`}):Sr})}),!le&&!Qn&&(0,W.jsxs)(`div`,{className:`mx-4 mt-3 flex flex-wrap items-center gap-2 rounded-lg border bg-muted/40 px-3 py-2 text-sm`,role:`status`,children:[(0,W.jsx)(Ba,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:Ai(er,Ge?.user?.name||Ge?.user?.email||`another member`)}),(0,W.jsxs)(H,{type:`button`,variant:`outline`,size:`sm`,disabled:ze,onClick:ve,children:[(0,W.jsx)(Hr,{className:`size-3.5 ${ze?`animate-spin`:``}`,"aria-hidden":`true`}),`Refresh`]}),!Ke&&(0,W.jsx)(H,{type:`button`,variant:`outline`,size:`sm`,onClick:Fe,children:`Duplicate to edit`})]}),(0,W.jsx)(`div`,{className:`relative flex flex-1 flex-col gap-4 p-4 pt-4 min-h-0 overflow-hidden`,style:{isolation:`isolate`},children:On?(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center rounded-xl border bg-muted/10`,role:`status`,"aria-live":`polite`,children:[(0,W.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),(0,W.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground`,children:`Loading workspace…`})]}):(0,W.jsx)(sfe,{root:e,mainAI:n,teamState:Vn,discussionTarget:T,onFocusedSession:a,onPairChange:i,paneAIRef:f,children:(0,W.jsx)(m,{context:Vn},Dn)})}),(0,W.jsx)(vTe,{isOpen:tn,onClose:()=>nn(!1),onImport:Pe}),(0,W.jsx)(yTe,{isOpen:rn,onClose:()=>an(!1),onExport:(e,t,n)=>{$e&&(e===`markdown`||(e===`pdf`?w6.exportToPDF($e,t,n,Xe||void 0):e===`print`?w6.printNote($e,t,Xe||void 0):e===`word`&&w6.exportToWord($e,t,Xe||void 0)))}}),(0,W.jsx)(Ife,{open:x,onOpenChange:S}),(0,W.jsx)(db,{isOpen:$t,onOpenChange:en,mode:`permanent-delete`,itemType:fn?.type||``,onConfirm:xn,onAfterDelete:void 0}),!le&&(0,W.jsx)(pb,{isOpen:Yt,onOpenChange:e=>{Xt(e),e||_n(null)},view:se,activeDocument:gn??Ge,canMoveProject:ji(gn??Ge,B?.id,Ke),newName:on,setNewName:sn,projects:Rn,requireProject:!!Vn.activeTeamId,selectedProjectId:cn,setSelectedProjectId:ln,updateDiagram:Ot,updateNote:kt,updateDrawing:At,updateFlowchart:jt,onMoveDiagramToProject:Mt,onMoveNoteToProject:Nt,onMoveDrawingToProject:Pt,onMoveFlowchartToProject:Ft,onRenameSuccess:void 0}),!le&&(0,W.jsx)(pb,{isOpen:pn,onOpenChange:e=>{mn(e)},mode:`create`,view:hn,activeDocument:null,newName:on,setNewName:sn,projects:Rn,requireProject:!!Vn.activeTeamId,selectedProjectId:cn,setSelectedProjectId:ln,onProjectCreate:async e=>{let t=await V(e);return t&&zn(e=>[t,...e.filter(e=>String(e.id)!==String(t.id))]),t},onCreate:(e,t)=>{let n=hn;n===`notes`?Ht(e,t):n===`erd`?Vt(e,t):n===`drawings`?Ut(e,t):n===`flowchart`&&Wt(e,t)},onRenameSuccess:void 0}),(0,W.jsx)(db,{isOpen:Gt,onOpenChange:e=>{Kt(e),e||yn(null)},activeDocument:tr,view:se,deleteDiagram:It,deleteNote:Lt,deleteDrawing:Rt,deleteFlowchart:zt,fetchTrash:_t,onAfterDelete:()=>{yn(null),nr?s(`/table/db-client`,{replace:!0}):me(se,!0),yt(`loading`),vt()}}),!le&&(0,W.jsx)(ZF,{isOpen:!!Ct,onOpenChange:e=>{e||wt(null)},selectedEdge:jn.find(e=>e.id===Ct)||null,nodes:kn,handleEdgeUpdate:Sn,handleEdgeFlip:Cn,deleteEdge:Dt,moveOnly:Xn}),(0,W.jsx)(Lfe,{isOpen:qt,onOpenChange:Jt,selectedEntity:Tt,deleteEntity:Et,setSelectedNodeId:St}),(0,W.jsx)(Rfe,{isOpen:Zt,onOpenChange:Qt,view:se,duplicateName:un,setDuplicateName:dn,executeDuplicate:bn,isRefreshing:ze}),se===`erd`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(pTe,{open:C,onOpenChange:w,nodes:kn,edges:jn,fileName:Ze||`Untitled`}),(0,W.jsx)(hTe,{isOpen:ke,onOpenChange:Ae,nodes:kn,edges:jn,setNodes:st,setEdges:ct,activeDiagramId:lt,takeSnapshot:ut,saveDiagram:dt,triggerDebouncedSync:ft,broadcastMessage:pt,setIsLocalSaving:mt,viewportRef:ht,lastLoadedDiagramIdRef:gt})]}),Cr&&(0,W.jsx)(_1e,{children:L===`repository`&&z?.entityType===`diagram`?(0,W.jsx)(m3e,{diagramUid:z.entityUid,nodes:kn,edges:jn,onClose:()=>R(`closed`)},z.entityUid):L===`history`&&oe&&z?(0,W.jsx)(t3e,{entityType:oe,entityUid:z.entityUid,documentTitle:Ze||`Untitled`,onClose:()=>R(`closed`),onRestored:ve,canRestore:$n},`${oe}:${z.entityUid}`):(0,W.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 flex items-center border-b border-border bg-muted/20`,children:[(0,W.jsxs)(`div`,{className:`flex-1 flex`,children:[ae&&!le&&Qn&&!Xn&&(0,W.jsxs)(`button`,{onClick:()=>R(`properties`),className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`properties`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(_r,{className:`size-3.5`}),`Properties`]}),dr&&(0,W.jsxs)(`button`,{onClick:sr,className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`dbml`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(Ar,{className:`size-3.5`}),`DBML`]}),ur&&(0,W.jsxs)(`button`,{onClick:()=>R(`chat`),className:`flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium border-b-2 -mb-px transition-colors ${L===`chat`?`border-primary text-primary bg-background/50`:`border-transparent text-muted-foreground hover:text-foreground hover:bg-muted/30`}`,children:[(0,W.jsx)(ti,{className:`size-3.5`}),`AI Chat`]})]}),(0,W.jsx)(H,{variant:`ghost`,size:`icon`,className:`size-8 mr-1`,onClick:()=>R(`closed`),title:`Close panel`,children:(0,W.jsx)(Ao,{className:`size-3.5`})})]}),(0,W.jsxs)(`div`,{className:`flex-1 min-h-0`,children:[ur&&(0,W.jsx)(`div`,{className:c(`h-full`,L!==`chat`&&`hidden`),children:(0,W.jsx)(t4e,{onClose:()=>R(`closed`),entityType:z.entityType,entityUid:z.entityUid,entityTitle:z.entityType===`dbClient`?D?.name||wn:z.entityType===`note`?$e?.title:z.entityType===`diagram`?nt?.name:z.entityType===`flowchart`?tt?.title:null,entityContextText:cr,viewType:lr?`db-client`:void 0,projectId:fr,pendingPrompt:ee,onPromptUsed:te,pendingAction:ne,onClearPendingAction:re,notes:rt,diagrams:it,flowcharts:at,drawings:ot,activeNoteContent:z?.entityType===`note`?$e?.content:void 0,getPaneAI:p})}),L===`dbml`&&dr&&(0,W.jsx)(S4e,{value:M,onChange:or,onApply:Tr,nodes:kn,edges:jn,onSelectTable:e=>{let t=kn.find(t=>t.data.name.toLowerCase()===e.toLowerCase());t&&St(t.id)}}),L===`properties`&&!Xn&&(rr?(0,W.jsx)(M4e,{selectedEntity:rr,onUpdateEntity:Bt,onBackToTables:()=>{St(null),v(null)},onDeleteEntity:e=>{Et(e),St(null),R(`closed`)}},rr.id):(0,W.jsx)(w4e,{nodes:kn,onEdit:e=>{v(e),St(e)}}))]})]})}),ur&&!Cr&&(0,W.jsx)(_3e,{isOpen:!1,raised:z?.entityType===`dbClient`,onClick:()=>R(`chat`)})]})})]})}function D3e({paired:e,onPairChange:t}){let n=ia(),r=An(),i=Bi(),[a,o]=(0,U.useState)(null),s=(0,U.useMemo)(()=>a?{...a.workspace,setIsSettingsOpen:n.setIsSettingsOpen,setSettingsTab:n.setSettingsTab,refreshTeamScope:n.refreshTeamScope,teamScopeVersion:n.teamScopeVersion,isTeamScopeRefreshing:n.isTeamScopeRefreshing,flushPendingSaves:n.flushPendingSaves,handleLogout:n.handleLogout}:n,[a,n]),c=(0,U.useMemo)(()=>a?{...a.ai,rightPanelMode:r.rightPanelMode,setRightPanelMode:r.setRightPanelMode}:r,[a,r]);return(0,W.jsx)(aa.Provider,{value:s,children:(0,W.jsx)(Ln,{value:c,children:(0,W.jsx)(Ki,{value:a?.canvas??i,children:(0,W.jsx)(qi,{value:a?.canvas??i,children:(0,W.jsx)(E3e,{root:n,session:a,mainAI:r,paired:e,onPairChange:t,onFocusedSession:o})})})})})}function O3e(){let e=Nfe(),[t,n]=(0,U.useState)(!1);return(0,W.jsx)(Fp,{open:!t&&e.open,onOpenChange:e.onOpenChange,className:`h-svh overflow-hidden`,style:{"--sidebar-width":`320px`},children:(0,W.jsx)(Wn,{children:(0,W.jsx)(D3e,{paired:t,onPairChange:n})})})}function k3e(){let e=y();return(0,W.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center max-w-md`,children:[(0,W.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,W.jsx)(ri,{className:`h-6 w-6 text-muted-foreground`})}),(0,W.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`404`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The page you're looking for doesn't exist.`}),(0,W.jsxs)(`button`,{onClick:()=>e(`/table/tables`),className:`inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow hover:bg-primary/90 transition-colors`,children:[(0,W.jsx)(pa,{className:`h-4 w-4`}),`Back to Home`]})]})})}var H9=[{key:`notes`,label:`Notes`,createLabel:`Note`,icon:Nt,color:`text-amber-500`,bg:`bg-amber-500/10`,route:`/table/notes`,createFn:`handleSidebarNoteCreate`,totalKey:`notesTotal`},{key:`diagrams`,label:`ERD Builder`,createLabel:`ERD Builder`,icon:Ar,color:`text-cyan-400`,bg:`bg-cyan-500/20`,route:`/table/erd`,createFn:`handleSidebarDiagramCreate`,totalKey:`diagramsTotal`},{key:`drawings`,label:`Drawings`,createLabel:`Drawing`,icon:Mr,color:`text-violet-500`,bg:`bg-violet-500/10`,route:`/table/drawings`,createFn:`handleSidebarDrawingCreate`,totalKey:`drawingsTotal`},{key:`flowcharts`,label:`Flowcharts`,createLabel:`Flowchart`,icon:Eo,color:`text-emerald-500`,bg:`bg-emerald-500/10`,route:`/table/flowcharts`,createFn:`handleSidebarFlowchartCreate`,totalKey:`flowchartsTotal`}];function A3e(){let e=new Date().getHours();return e<12?`Good morning`:e<17?`Good afternoon`:`Good evening`}function U9(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toLocaleDateString(`en-US`)}function W9(e){switch(e){case`diagrams`:return(0,W.jsx)(Ar,{className:`h-4 w-4 text-blue-500`});case`notes`:return(0,W.jsx)(Nt,{className:`h-4 w-4 text-amber-500`});case`drawings`:return(0,W.jsx)(Mr,{className:`h-4 w-4 text-violet-500`});case`flowcharts`:return(0,W.jsx)(Eo,{className:`h-4 w-4 text-emerald-500`});case`db-client`:return(0,W.jsx)(jr,{className:`h-4 w-4 text-cyan-400`});default:return null}}function G9(e){return(e.source_type??e.sourceType)===`production_db`}function K9(e){return e?._group===`db-client`||e?._type===`db-client`||G9(e)}function q9(e){switch(e._type){case`diagrams`:return K9(e)?`DB Client`:`ERD Builder`;case`notes`:return`Note`;case`drawings`:return`Drawing`;case`flowcharts`:return`Flowchart`;case`db-client`:return`DB Client`;default:return``}}function J9(e,t){let n=t.uid||t.id;if(K9(t))return`/db-client/${n}`;switch(e){case`diagrams`:return`/diagrams/${n}`;case`notes`:return`/notes/${n}`;case`drawings`:return`/drawings/${n}`;case`flowcharts`:return`/flowcharts/${n}`;case`db-client`:return`/db-client/${n}`;default:return`/`}}function j3e(){let e=y(),t=ia(),n=Ei(),r=w(),i=!!(t.user?.isSso&&r.activeTeamId),a=e=>e===`diagrams`?`erd_builder`:e,o=e=>!i||r.isAvailable&&r.activeTeam?.capabilities?.[a(e)]===!0,s=H9.filter(e=>o(e.key)),c=t.user,l=c?.user_metadata?.full_name||c?.user_metadata?.name||c?.email?.split(`@`)[0]||``,[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1);(0,U.useEffect)(()=>{if(t.isGuest||!c){d(null),p(!0);return}let e=!1;return d(null),p(!1),(async()=>{try{let t=await wi(`/api/search/recent`);if(!t.ok)return;let n=await t.json();e||d(Array.isArray(n.data)?n.data:[])}catch{}finally{e||p(!0)}})(),()=>{e=!0}},[t.isGuest,t.teamScopeVersion,c]);let m=(0,U.useMemo)(()=>{if(u)return u.map(e=>({...e,_type:e.type,_group:e.group,_workspace:e.workspace?.name||e.project?.name||`—`,updated_at:e.updated_at??e.updatedAt}));let e=new Map((t.projects||[]).map(e=>[String(e.id),e.name])),n=t=>{let n=t.project_id??t.projectId;return t.projects?.name||t.project?.name||(n?e.get(String(n)):null)||`—`};return[...(t.diagrams||[]).filter(e=>!G9(e)).map(e=>({...e,_type:`diagrams`,_group:G9(e)?`db-client`:`diagrams`,_workspace:n(e)})),...(t.notes||[]).map(e=>({...e,_type:`notes`,_group:`notes`,_workspace:n(e)})),...(t.drawings||[]).map(e=>({...e,_type:`drawings`,_group:`drawings`,_workspace:n(e)})),...(t.flowcharts||[]).map(e=>({...e,_type:`flowcharts`,_group:`flowcharts`,_workspace:n(e)}))].filter(e=>!e.is_deleted).sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,10)},[t.diagrams,t.notes,t.drawings,t.flowcharts,t.projects,u]),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`all`),b=(0,U.useMemo)(()=>{let e=h.trim().toLowerCase();return m.filter(t=>{let n=_===`all`||t._group===_,r=t.name||t.title||``;return n&&(!e||`${r} ${t._workspace}`.toLowerCase().includes(e))})},[m,_,h]),x=(0,U.useMemo)(()=>(t.diagrams||[]).filter(e=>!e.is_deleted&&!G9(e)).length+(t.notes||[]).filter(e=>!e.is_deleted).length+(t.drawings||[]).filter(e=>!e.is_deleted).length+(t.flowcharts||[]).filter(e=>!e.is_deleted).length,[t.diagrams,t.notes,t.drawings,t.flowcharts]),[S,C]=(0,U.useState)({});(0,U.useEffect)(()=>C({}),[t.teamScopeVersion]);let T=(0,U.useMemo)(()=>(t.projects||[]).filter(e=>!e.is_deleted).map(e=>{let t=S[String(e.id)]||{};return{...e,notesCount:t.notes??0,diagramsCount:t.diagrams??0,drawingsCount:t.drawings??0,flowchartsCount:t.flowcharts??0,dbClientsCount:t.db_clients??0,totalDocs:(t.notes??0)+(t.diagrams??0)+(t.drawings??0)+(t.flowcharts??0)+(t.db_clients??0)}}).sort((e,t)=>t.totalDocs-e.totalDocs).slice(0,4),[t.projects,S]);(0,U.useEffect)(()=>{let e=(t.projects||[]).filter(e=>!e.is_deleted).slice(0,4);if(e.length===0)return;let r=!1;return(async()=>{let t={};for(let i of e)try{let e=await wi(`/api/projects/${i.id}/summary?include_db_client=${n}`);e.ok&&!r&&(t[String(i.id)]=await e.json())}catch{}r||C(t)})(),()=>{r=!0}},[t.projects,n]);let[E,D]=(0,U.useState)(!1),O=t.isLoading||t.isProjectsLoading;(0,U.useEffect)(()=>{O||D(!0)},[O]);let k=!O&&f,A=k&&x===0&&!u?.length,j=k&&!A&&E,M=e=>{o(e.key)&&t.handleOpenCreateDocument?.(e.key===`diagrams`?`erd`:e.key===`flowcharts`?`flowchart`:e.key)},N=m[0];return(0,W.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-y-auto`,children:[l&&(0,W.jsx)(`div`,{className:`border-b border-border/60 px-5 py-5`,children:(0,W.jsxs)(`div`,{className:`flex items-end justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:[A3e(),`,`]}),(0,W.jsx)(`h1`,{className:`mt-0.5 text-xl font-semibold tracking-tight`,children:l}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Pick up where you left off.`})]}),j&&o(`diagrams`)&&(0,W.jsxs)(`button`,{onClick:()=>M(H9[1]),className:`hidden h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 sm:inline-flex`,children:[(0,W.jsx)(zt,{className:`size-3.5`}),`New ERD Builder`]})]})}),A&&(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center justify-center px-6 py-20 text-center`,children:[(0,W.jsx)(`div`,{className:`size-16 rounded-2xl bg-primary/10 border border-primary/20 flex items-center justify-center mb-5`,children:(0,W.jsx)(ti,{className:`size-7 text-primary`})}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Let's get started`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5 max-w-md`,children:`Create your first document — notes, ERD Builder, flowcharts, or drawings — and start building your workspace.`}),(0,W.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 mt-5`,children:s.map(e=>(0,W.jsxs)(`button`,{onClick:()=>M(e),className:`inline-flex items-center gap-2 rounded-lg border px-4 py-2.5 text-sm font-medium transition-all hover:shadow-sm ${e.key===`diagrams`?`border-cyan-400/50`:`border-border/60`} ${e.bg} hover:scale-[1.02]`,children:[(0,W.jsx)(e.icon,{className:`h-4 w-4 ${e.color}`}),`New `,e.createLabel]},e.key))})]}),j&&(0,W.jsxs)(`main`,{className:`flex w-full flex-col gap-5 px-5 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1.35fr)_minmax(250px,0.65fr)]`,children:[(0,W.jsxs)(`section`,{className:`relative overflow-hidden rounded-xl border border-primary/25 bg-linear-to-br from-primary/10 via-card to-card p-4`,children:[(0,W.jsxs)(`div`,{className:`relative z-10 flex h-full min-h-32 flex-col justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-primary`,children:`Continue working`}),N?(0,W.jsxs)(`div`,{className:`mt-3 flex items-start gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-background/80 shadow-sm`,children:W9(N._type)}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{className:`truncate text-lg font-semibold`,children:N.name||N.title||`(Untitled)`}),(0,W.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[q9(N),` · `,N._workspace,` · `,U9(N.updated_at)]})]})]}):(0,W.jsx)(`h2`,{className:`mt-4 text-xl font-semibold`,children:`Create your first document`})]}),(0,W.jsxs)(`button`,{onClick:()=>N?e(J9(N._type,N)):M(H9[1]),className:`inline-flex h-8 w-fit items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground transition-colors hover:bg-primary/90`,children:[N?`Open document`:`Create ERD Builder`,(0,W.jsx)(ha,{className:`size-3.5`})]})]}),(0,W.jsx)(ti,{className:`absolute -bottom-8 -right-5 size-36 text-primary/10`})]}),(0,W.jsxs)(`section`,{className:`rounded-xl border border-border/60 bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Create something new`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Start with the format you need.`})]}),(0,W.jsx)(zt,{className:`size-4 text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2`,children:s.map(e=>(0,W.jsxs)(`button`,{onClick:()=>M(e),className:`group flex min-h-14 flex-col items-start justify-between rounded-lg border border-border/60 bg-background px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/40`,children:[(0,W.jsx)(e.icon,{className:`size-4 ${e.color}`}),(0,W.jsxs)(`span`,{className:`text-xs font-medium`,children:[`New `,e.createLabel]})]},e.key))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(250px,0.65fr)]`,children:[(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2.5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Ma,{className:`size-4 text-muted-foreground`}),`Recent files`]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Jump back into your latest work.`})]}),(0,W.jsxs)(`div`,{className:`relative w-full sm:w-52`,children:[(0,W.jsx)(Kr,{className:`pointer-events-none absolute left-2.5 top-2.5 size-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`Search files`,"aria-label":`Search recent files`,className:`h-8 w-full rounded-lg border border-border/60 bg-card pl-8 pr-3 text-xs outline-none placeholder:text-muted-foreground/60 focus:border-primary/50`})]})]}),(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 overflow-x-auto pb-0.5`,children:[(0,W.jsx)(`button`,{onClick:()=>v(`all`),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===`all`?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:`All`}),H9.map(e=>(0,W.jsx)(`button`,{onClick:()=>v(e.key),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===e.key?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:e.label},e.key)),n&&(0,W.jsx)(`button`,{onClick:()=>v(`db-client`),className:`rounded-md px-2.5 py-1 text-xs font-medium ${_===`db-client`?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:`DB Client`})]}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-card`,children:b.length===0?(0,W.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No matching files.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`hidden grid-cols-[minmax(0,1fr)_minmax(7rem,0.7fr)_auto_auto] gap-2.5 border-b border-border/50 px-3 py-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:grid`,children:[(0,W.jsx)(`span`,{children:`File`}),(0,W.jsx)(`span`,{children:`Workspace`}),(0,W.jsx)(`span`,{children:`Updated`}),(0,W.jsx)(`span`,{"aria-hidden":`true`})]}),b.map(t=>(0,W.jsxs)(`button`,{onClick:()=>e(J9(t._type,t)),className:`group grid w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2.5 border-b border-border/50 px-3 py-2.5 text-left last:border-0 hover:bg-accent/30 sm:grid-cols-[minmax(0,1fr)_minmax(7rem,0.7fr)_auto_auto]`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-background`,children:W9(t._type)}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:t.name||t.title||`(Untitled)`}),(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:q9(t)})]})]}),(0,W.jsx)(`span`,{className:`hidden min-w-0 truncate text-xs text-muted-foreground sm:block`,children:t._workspace}),(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:U9(t.updated_at)}),(0,W.jsx)(ha,{className:`size-3.5 shrink-0 text-muted-foreground/30 transition-colors group-hover:text-primary`})]},`${t._type}-${t.id}`))]})})]}),T.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Xa,{className:`size-4 text-muted-foreground`}),`Workspaces`]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Your projects at a glance.`})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:T.map(e=>(0,W.jsxs)(`button`,{onClick:()=>t.onViewChange?.(`erd`,!0,e.uid??e.id),className:`group flex w-full items-center gap-2.5 rounded-lg border border-border/60 bg-card p-2.5 text-left transition-colors hover:border-primary/40 hover:bg-accent/30`,children:[(0,W.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/10`,children:(0,W.jsx)(Xa,{className:`size-3.5 text-primary`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,W.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[e.totalDocs,` `,e.totalDocs===1?`file`:`files`]})]}),(0,W.jsx)(ha,{className:`size-4 text-muted-foreground/30 transition-colors group-hover:text-primary`})]},e.id))})]})]})]})]})}function M3e(){let e=new URLSearchParams(window.location.search).get(`authorization_id`)||``,[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(e?``:`Authorization ID is missing.`),[a,o]=(0,U.useState)(!!e),[s,c]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&wi(`/api/oauth/authorizations/${encodeURIComponent(e)}`,{cache:`no-store`}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||`Authorization request could not be loaded.`);t.redirect_url?window.location.assign(t.redirect_url):n(t)}).catch(e=>i(e instanceof Error?e.message:`Authorization request could not be loaded.`)).finally(()=>o(!1))},[e]);async function l(t){c(!0),i(``);try{let n=await wi(`/api/oauth/authorizations/${encodeURIComponent(e)}/${t}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.redirect_url)throw Error(r.error||`Authorization decision failed.`);window.location.assign(r.redirect_url)}catch(e){i(e instanceof Error?e.message:`Authorization decision failed.`),c(!1)}}return(0,W.jsx)(`main`,{className:`flex min-h-svh items-center justify-center bg-muted/30 p-6`,children:(0,W.jsxs)(is,{className:`w-full max-w-lg`,children:[(0,W.jsxs)(as,{children:[(0,W.jsx)(`div`,{className:`mb-2 flex size-10 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,W.jsx)(Vo,{className:`size-5`,"aria-hidden":`true`})}),(0,W.jsx)(os,{children:`Authorize MCP access`}),(0,W.jsx)(ss,{children:t?`${t.client.name} wants read-only access to your ERD Builder Pro Web App workspace.`:`Reviewing the authorization request…`})]}),(0,W.jsxs)(ls,{className:`space-y-4 text-sm`,children:[a&&(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading authorization details…`}),r&&(0,W.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/30 bg-destructive/10 p-3 text-destructive`,children:r}),t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`Requesting client`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:t.client.name}),(0,W.jsxs)(`p`,{className:`mt-1 break-all font-mono text-xs text-muted-foreground`,children:[`Redirect: `,t.redirect_uri]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`This client can read`}),(0,W.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Projects, regular ERDs, Notes, Flowcharts, Drawings, and document history in the Personal workspace and active Teams accessible to `,t.user.email,`. This authorization covers all permitted workspaces and follows your current access permissions.`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`It cannot access`}),(0,W.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`DB Client, production database diagrams, SQL execution, database credentials, local files, or write operations.`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium`,children:`OAuth scopes`}),(0,W.jsx)(`p`,{className:`mt-1 break-words font-mono text-xs text-muted-foreground`,children:t.scope||`email`})]})]})]}),t&&(0,W.jsxs)(us,{className:`justify-end gap-2`,children:[(0,W.jsx)(H,{variant:`outline`,disabled:s,onClick:()=>l(`deny`),children:`Deny`}),(0,W.jsx)(H,{disabled:s,onClick:()=>l(`approve`),children:s?`Submitting…`:`Allow read-only access`})]})]})})}function N3e({user:e,onComplete:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1),[u,f]=(0,U.useState)(!1),p=async r=>{if(r.preventDefault(),!(i.length<8||i!==o)){f(!0);try{let r=await wi(`/api/account`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPassword:n,newPassword:i})}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.error||`Unable to change password.`);t({...e,...a.user,mustChangePassword:!1}),d.success(`Password updated`)}catch(e){d.error(e?.message||`Unable to change password.`)}finally{f(!1)}}},m=c?`text`:`password`,h=(0,W.jsx)(`button`,{type:`button`,"aria-label":c?`Hide passwords`:`Show passwords`,onClick:()=>l(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:c?(0,W.jsx)(Lr,{className:`size-4`}):(0,W.jsx)(Ba,{className:`size-4`})});return(0,W.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-6`,children:(0,W.jsxs)(`form`,{onSubmit:p,className:`flex w-full max-w-sm flex-col gap-5 rounded-xl border bg-card p-6 shadow-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(co,{className:`size-6 text-primary`}),(0,W.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Change your password`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Use the temporary password provided by your Team administrator, then set a new password before continuing.`})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`temporary-password`,children:`Temporary password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`temporary-password`,type:m,className:`pr-10`,value:n,onChange:e=>r(e.target.value),required:!0}),h]})]}),(0,W.jsxs)(zr,{children:[(0,W.jsx)(Fr,{htmlFor:`new-password`,children:`New password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`new-password`,type:m,className:`pr-10`,minLength:8,value:i,onChange:e=>a(e.target.value),required:!0}),h]}),(0,W.jsx)(Ir,{children:`At least 8 characters.`})]}),(0,W.jsxs)(zr,{"data-invalid":o.length>0&&o!==i,children:[(0,W.jsx)(Fr,{htmlFor:`confirm-password`,children:`Confirm new password`}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(Oi,{id:`confirm-password`,type:m,className:`pr-10`,minLength:8,value:o,onChange:e=>s(e.target.value),"aria-invalid":o.length>0&&o!==i,required:!0}),h]})]}),(0,W.jsxs)(H,{type:`submit`,disabled:u||i.length<8||i!==o,children:[u&&(0,W.jsx)(vo,{className:`animate-spin`}),` Save new password`]})]})})}var P3e=(0,U.lazy)(()=>bi(()=>import(`./NoteEditorRoute-DbAY2OPi.js`).then(e=>({default:e.NoteEditorRoute})),__vite__mapDeps([8,5,9,10,11,12,7,13,14,15,16,17,6,18,19,20,21,4,1,22]))),F3e=(0,U.lazy)(()=>bi(()=>import(`./DiagramEditorRoute-gB1Tnc1O.js`).then(e=>({default:e.DiagramEditorRoute})),__vite__mapDeps([23,5,9,10,14,12,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),I3e=(0,U.lazy)(()=>bi(()=>import(`./DbClientEditorRoute-BQsu2RPO.js`).then(e=>({default:e.DbClientEditorRoute})),__vite__mapDeps([58,5,9,12,10,14,15,16,17,7,6,24,11,13,18,19,20,21,4,1,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]))),L3e=(0,U.lazy)(()=>bi(()=>import(`./DrawingEditorRoute-DI8POPT9.js`).then(e=>({default:e.DrawingEditorRoute})),__vite__mapDeps([56,5,9,10,30,12,11,57,47,7,6,13,14,15,16,17,18,19,20,21,4,1,22]))),R3e=(0,U.lazy)(()=>bi(()=>import(`./FlowchartEditorRoute-8E8F3Oi5.js`).then(e=>({default:e.FlowchartEditorRoute})),__vite__mapDeps([54,5,9,12,10,14,15,16,17,7,6,11,28,27,26,29,30,31,32,33,34,35,36,37,38,39,40,55,46,50,42,13,18,19,20,21,4,1,22,51,52,53]))),z3e=(0,U.lazy)(()=>bi(()=>import(`./TeamManagementRoute-wh96POof.js`).then(e=>({default:e.TeamManagementRoute})),__vite__mapDeps([59,5,9,12,10,11,29,27,26,30,31,32,33,35,36,37,38,45,48,39,60,6,7,42,20,22,51]))),B3e=(0,U.lazy)(()=>bi(()=>import(`./TeamInventoryRoute-uTpVstiC.js`).then(e=>({default:e.TeamInventoryRoute})),__vite__mapDeps([61,5,9,12,10,11,36,37,27,48,6,7,20]))),V3e=(0,U.lazy)(()=>bi(()=>import(`./LibraryRoute-Dyzti-IB.js`).then(e=>({default:e.LibraryRoute})),__vite__mapDeps([62,5,9,12,10,11,26,27,43,35,30,31,32,36,37,63,48,40,50,6,7]))),H3e=(0,U.lazy)(()=>bi(()=>import(`./UserManagementRoute-HIUP43af.js`).then(e=>({default:e.UserManagementRoute})),__vite__mapDeps([64,5,9,12,10,11,26,27,43,36,37,48,39,65,6,7,42,32,20]))),U3e=(0,U.lazy)(()=>bi(()=>import(`./AdminRoute-DtQxECkH.js`).then(e=>({default:e.AdminRoute})),__vite__mapDeps([66,5,9,10,7,13,12,14,15,16,17,6,18,19,20,21,4,1,22])));function Y9(e){return(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs text-muted-foreground`,children:`Opening file…`}),children:e})}function W3e(){let{isAuthenticated:e,user:t,setUser:n,isGuest:r,handleLogin:i,handleGuestLogin:a,handleLogout:o}=ta(),s=y(),c=h(),[l,u]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e,t;return typeof window>`u`||!window.__TAURI__&&!window.__TAURI_INTERNALS__?void 0:((async()=>{let{listen:n}=await bi(async()=>{let{listen:e}=await import(`./event-DtFyPu7u.js`);return{listen:e}},__vite__mapDeps([0,1]));e=await n(`menu-about`,()=>{u(!0)}),t=await n(`menu-check-update`,()=>{window.dispatchEvent(new CustomEvent(`menu-check-update`,{detail:{}}))})})(),()=>{e?.(),t?.()})},[]);let d=(0,U.useRef)(!1);(0,U.useEffect)(()=>{e===!1?d.current=!0:e===!0&&d.current&&(d.current=!1,c.pathname!==`/oauth/consent`&&s(`/`))},[e,c.pathname,s]);let{isPublicView:f,setIsPublicView:p,publicData:m,isPublicLoading:g,forbiddenDoc:_,fetchPublicDocument:v}=Jue(()=>{}),b=Ji();return e===null&&!b?(0,W.jsx)(Sp,{type:`init`}):g?(0,W.jsx)(Sp,{type:`public`}):_?(0,W.jsx)(Jre,{title:_.title,message:_.message,statusCode:_.status,documentUid:b?.uid,onSubmitToken:async e=>{if(b){if(await v(b.type,b.uid,void 0,void 0,e))sessionStorage.setItem(`share_token_${b.uid}`,e);else throw Error(`Invalid token`)}},onReturn:()=>window.location.href=`/`}):!e&&!b?(0,W.jsx)(vs,{onLogin:e=>i(e),onGuestLogin:a}):c.pathname===`/oauth/consent`?(0,W.jsx)(M3e,{}):t?.mustChangePassword?(0,W.jsx)(N3e,{user:t,onComplete:n}):(0,W.jsxs)(Yi,{isPublicView:f,publicData:m,isPublicLoading:g,forbiddenDoc:_,fetchPublicDocument:v,setIsPublicView:p,handleLogout:o,children:[(0,W.jsx)(S,{children:(0,W.jsxs)(x,{element:(0,W.jsx)(O3e,{}),children:[(0,W.jsx)(x,{path:`table/:feature`,element:(0,W.jsx)(kde,{})}),(0,W.jsx)(x,{path:`notes/:id`,element:(0,W.jsx)(hb,{capability:`notes`,children:Y9((0,W.jsx)(P3e,{}))})}),(0,W.jsx)(x,{path:`diagrams/:id`,element:(0,W.jsx)(hb,{capability:`erd_builder`,children:Y9((0,W.jsx)(F3e,{}))})}),(0,W.jsx)(x,{path:`db-client/:id`,element:(0,W.jsx)(hb,{capability:`desktop_only`,children:Y9((0,W.jsx)(I3e,{}))})}),(0,W.jsx)(x,{path:`drawings/:id`,element:(0,W.jsx)(hb,{capability:`drawings`,children:Y9((0,W.jsx)(L3e,{}))})}),(0,W.jsx)(x,{path:`flowcharts/:id`,element:(0,W.jsx)(hb,{capability:`flowcharts`,children:Y9((0,W.jsx)(R3e,{}))})}),(0,W.jsx)(x,{path:`trash`,element:Y9((0,W.jsx)(U3e,{}))}),(0,W.jsx)(x,{path:`library`,element:Y9((0,W.jsx)(V3e,{}))}),(0,W.jsx)(x,{path:`teams/:id`,element:Y9((0,W.jsx)(z3e,{}))}),(0,W.jsx)(x,{path:`team-workspaces`,element:Y9((0,W.jsx)(B3e,{}))}),(0,W.jsx)(x,{path:`users`,element:Y9((0,W.jsx)(H3e,{}))}),(0,W.jsx)(x,{index:!0,element:(0,W.jsx)(j3e,{})}),(0,W.jsx)(x,{path:`*`,element:(0,W.jsx)(k3e,{})})]})}),(0,W.jsx)(Kue,{}),(0,W.jsx)(By,{open:l,onOpenChange:u})]})}function G3e(){return(0,W.jsx)(W3e,{})}var K3e=e=>typeof e==`string`?new URL(e,window.location.href).pathname:e?.pathname??window.location.pathname,X9=()=>Number(window.history.state?.idx??0),Z9=e=>{e.index=X9(),e.path=window.location.pathname},Q9=null,$9=!1;typeof window<`u`&&window.addEventListener(`popstate`,e=>{if($9){$9=!1,e.stopImmediatePropagation();return}let t=Q9;t&&(window.location.pathname===t.path||window.confirm(t.message)?Z9(t):(e.stopImmediatePropagation(),$9=!0,window.history.go(t.index-X9())))},!0);function q3e(e,t){let n={message:t,index:X9(),path:window.location.pathname},{push:r,replace:i}=e,a=e=>K3e(e)===window.location.pathname||window.confirm(t);e.push=(e,...t)=>{a(e)&&(r(e,...t),Z9(n))},e.replace=(e,...t)=>{a(e)&&(i(e,...t),Z9(n))};let o=e=>{e.preventDefault(),e.returnValue=``};return Q9=n,window.addEventListener(`beforeunload`,o),()=>{e.push=r,e.replace=i,Q9===n&&(Q9=null),window.removeEventListener(`beforeunload`,o)}}function J3e(e,t){let{navigator:n}=(0,U.useContext)(v);(0,U.useEffect)(()=>e?q3e(n,t):void 0,[e,t,n])}typeof window<`u`&&`__TAURI_INTERNALS__`in window&&document.body.setAttribute(`data-tauri`,`true`);var Y3e=window.fetch;window.fetch=async(...e)=>{let t=await Y3e(...e),n=typeof e[0]==`string`?e[0]:e[0]instanceof Request?e[0].url:typeof e[0]==`object`&&`href`in e[0]?e[0].href:``,r=n.includes(`/api/login`)||n.includes(`/api/logout`)||n.includes(`/api/me`);n.includes(`supabase.co`);let i=xi(),a=(n.startsWith(`/api/`)||i&&n.startsWith(i))&&!n.includes(`supabase.co`),o=sessionStorage.getItem(`auth_mode`)===`guest`;return t.status===401&&a&&!r&&navigator.onLine&&!o&&(Ci(),window.dispatchEvent(new Event(`auth:unauthorized`))),t},`serviceWorker`in navigator&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`?navigator.serviceWorker.getRegistrations().then(e=>{e.forEach(e=>e.unregister())}):window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})})),(0,sa.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(U.StrictMode,{children:(0,W.jsx)(C,{children:(0,W.jsx)(de,{children:(0,W.jsx)(Pt,{children:(0,W.jsxs)(na,{children:[(0,W.jsx)(G3e,{}),(0,W.jsx)(rs,{position:`top-center`})]})})})})}));export{wm as $,wa as $n,To as $t,f0e as A,qa as An,Jo as At,yE as B,La as Bn,Ro as Bt,x8 as C,eo as Cn,ts as Ct,b0e as D,Xa as Dn,Zo as Dt,x0e as E,Za as En,Qo as Et,_L as F,Ha as Fn,Uo as Ft,Tb as G,Ma as Gn,No as Gt,ax as H,Fa as Hn,Io as Ht,ZF as I,Va as In,Ho as It,Cb as J,ka as Jn,Ao as Jt,Sb as K,ja as Kn,Mo as Kt,YN as L,Ba as Ln,Vo as Lt,r8 as M,Ga as Mn,Ko as Mt,mL as N,Wa as Nn,Go as Nt,b8 as O,Ya as On,Xo as Ot,hL as P,Ua as Pn,Wo as Pt,xm as Q,Ta as Qn,Eo as Qt,iN as R,za as Rn,Bo as Rt,C8 as S,to as Sn,ns as St,S0e as T,Qa as Tn,$o as Tt,Yb as U,Pa as Un,Fo as Ut,Zx as V,Ia as Vn,Lo as Vt,Bb as W,Na as Wn,Po as Wt,Pie as X,Da as Xn,Oo as Xt,wb as Y,Oa as Yn,ko as Yt,ym as Z,Ea as Zn,Do as Zt,w0e as _,oo as _n,ls as _t,y3e as a,yo as an,va as ar,tm as at,E8 as b,ro as bn,as as bt,z9 as c,go as cn,ha as cr,Dp as ct,T9 as d,po as dn,fa as dr,Ap as dt,wo as en,Ca as er,Cm as et,Z7 as f,fo as fn,Ep as ft,S5 as g,so as gn,is as gt,C7 as h,co as hn,Ms as ht,R9 as i,bo as in,ya as ir,pm as it,p8 as j,Ka as jn,qo as jt,h8 as k,Ja as kn,Yo as kt,x3e as l,ho as ln,ma as lr,Op as lt,P7 as m,lo as mn,xp as mt,v3e as n,So as nn,xa as nr,Sm as nt,b3e as o,vo as on,_a as or,Zp as ot,$4e as p,uo as pn,Tp as pt,Bde as q,Aa as qn,jo as qt,S3e as r,xo as rn,ba as rr,xie as rt,C3e as s,_o as sn,ga as sr,Mp as st,J3e as t,Co as tn,Sa as tr,bm as tt,E9 as u,mo as un,pa as ur,kp as ut,D8 as v,ao as vn,ss as vt,S8 as w,$a as wn,es as wt,w8 as x,no as xn,os as xt,T8 as y,io as yn,us as yt,eN as z,Ra as zn,zo as zt};
|