@object-ui/console 3.1.4 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/assets/ActionParamDialog-FoHiwOv1.js +1 -0
  2. package/dist/assets/AdapterProvider-BMMNYOio.js +1 -0
  3. package/dist/assets/AddressField-cixYGlNB.js +1 -0
  4. package/dist/assets/AdvancedChartImpl-BWWiRBQV.js +7 -0
  5. package/dist/assets/AppManagementPage-bOyAnjhU.js +1 -0
  6. package/dist/assets/AuditLogPage-CYbk9eg-.js +1 -0
  7. package/dist/assets/AuthPageLayout-BxIX5ebE.js +1 -0
  8. package/dist/assets/AutoNumberField-ZhMKpjBg.js +1 -0
  9. package/dist/assets/AvatarField-CyFyTMU0.js +1 -0
  10. package/dist/assets/BooleanField-BfvYM6AV.js +1 -0
  11. package/dist/assets/ChartImpl-DC6hwSlw.js +1 -0
  12. package/dist/assets/CodeField-E_gkep6y.js +1 -0
  13. package/dist/assets/ColorField-Cx-A5Lt0.js +1 -0
  14. package/dist/assets/CreateAppPage-BWPsgJjt.js +1 -0
  15. package/dist/assets/CurrencyField-De8eUBZn.js +1 -0
  16. package/dist/assets/DashboardDesignPage-D5PK-DCt.js +1 -0
  17. package/dist/assets/DashboardView-DHicI3QF.js +1 -0
  18. package/dist/assets/DateField-DEX8P85a.js +1 -0
  19. package/dist/assets/DateTimeField-7-OLEv75.js +1 -0
  20. package/dist/assets/EditAppPage-D5zTwJlk.js +1 -0
  21. package/dist/assets/EmailField-PxbTAuYC.js +1 -0
  22. package/dist/assets/FileField-BgYkkxBp.js +1 -0
  23. package/dist/assets/ForgotPasswordPage-B-SC0EDQ.js +1 -0
  24. package/dist/assets/FormulaField-DtcAppqd.js +1 -0
  25. package/dist/assets/GeolocationField-C8Vv3Q9T.js +1 -0
  26. package/dist/assets/GridField-HGVRXmPw.js +1 -0
  27. package/dist/assets/HomeLayout-DiAhEUcQ.js +1 -0
  28. package/dist/assets/HomePage-D0mu1KhN.js +1 -0
  29. package/dist/assets/ImageField-DonGxYyR.js +1 -0
  30. package/dist/assets/KanbanEnhanced-dVJHM0Vq.js +1 -0
  31. package/dist/assets/KanbanImpl-Du7bmAIp.js +1 -0
  32. package/dist/assets/LocationField-y31Q9OYm.js +1 -0
  33. package/dist/assets/LoginPage-CK-e0NKb.js +1 -0
  34. package/dist/assets/LookupField-cs9NaWXw.js +1 -0
  35. package/dist/assets/MarkdownImpl-DLQW-V1y.js +1 -0
  36. package/dist/assets/MasterDetailField-BI3uiZgR.js +1 -0
  37. package/dist/assets/MetadataDetailPage-C7MBEpTZ.js +1 -0
  38. package/dist/assets/MetadataFormDialog-C6kZu-tl.js +1 -0
  39. package/dist/assets/MetadataInspector-DAb5pYOH.js +1 -0
  40. package/dist/assets/MetadataManagerPage-KqCTlrFw.js +1 -0
  41. package/dist/assets/MetadataProvider-B6Zo_H9g.js +1 -0
  42. package/dist/assets/NumberField-CAPsyF5_.js +1 -0
  43. package/dist/assets/ObjectField-BXs-P94B.js +1 -0
  44. package/dist/assets/OrgManagementPage-Bd5hFjFA.js +1 -0
  45. package/dist/assets/PageDesignPage-CQKuBMSG.js +1 -0
  46. package/dist/assets/PageView-DzAF-4xC.js +2 -0
  47. package/dist/assets/PasswordField-66M8i1cP.js +1 -0
  48. package/dist/assets/PercentField-B4-Z2cl-.js +1 -0
  49. package/dist/assets/PermissionManagementPage-BohlfBZM.js +1 -0
  50. package/dist/assets/PhoneField-CbEqbBrO.js +1 -0
  51. package/dist/assets/ProfilePage-B2B5Vwiv.js +1 -0
  52. package/dist/assets/QRCodeField-BMVgCKPB.js +1 -0
  53. package/dist/assets/RatingField-DT67gTVp.js +1 -0
  54. package/dist/assets/RecordDetailView-KuRefR4o.js +1 -0
  55. package/dist/assets/RegisterPage-BR28zo3Z.js +1 -0
  56. package/dist/assets/ReportView-Dud74EeY.js +1 -0
  57. package/dist/assets/RichTextField-BJ3qOJu3.js +1 -0
  58. package/dist/assets/RoleManagementPage-CSrM1CTg.js +1 -0
  59. package/dist/assets/SearchResultsPage-CziEvfRB.js +1 -0
  60. package/dist/assets/SelectField-BIh8RBU2.js +1 -0
  61. package/dist/assets/SignatureField-DeTRlABT.js +1 -0
  62. package/dist/assets/SliderField-DZ4Q6eTl.js +1 -0
  63. package/dist/assets/SummaryField-DIOlQfN3.js +1 -0
  64. package/dist/assets/SystemHubPage-CT0edisJ.js +1 -0
  65. package/dist/assets/SystemObjectViewPage-D2qKWQRW.js +1 -0
  66. package/dist/assets/TextAreaField-C4XjBoOs.js +1 -0
  67. package/dist/assets/TextField-BcXMv3xe.js +1 -0
  68. package/dist/assets/TimeField-CHh1ZLFD.js +1 -0
  69. package/dist/assets/UrlField-DiTncT6s.js +1 -0
  70. package/dist/assets/UserField-mFk7qkDu.js +1 -0
  71. package/dist/assets/UserManagementPage-CicLMv53.js +1 -0
  72. package/dist/assets/VectorField-BsaAAFSl.js +1 -0
  73. package/dist/assets/data-adapter-DPqgzJ64.js +39 -0
  74. package/dist/assets/framework-B0ex8RpF.js +2 -0
  75. package/dist/assets/getIcon-DUhh_MlU.js +1 -0
  76. package/dist/assets/index-KDzKK6UM.js +26 -0
  77. package/dist/assets/index-jP1vuxyn.css +2 -0
  78. package/dist/assets/infrastructure-88EEJ8ZY.js +3 -0
  79. package/dist/assets/lib-CQxQAzx9.js +29 -0
  80. package/dist/assets/maplibre-gl-tCaFQWyX.js +748 -0
  81. package/dist/assets/metadataTypeRegistry-D4RkPQA-.js +1 -0
  82. package/dist/assets/plugins-core-B8C8BUw8.js +135 -0
  83. package/dist/assets/plugins-core-Dpq2d-QS.css +2 -0
  84. package/dist/assets/plugins-views-Csz847hc.js +62 -0
  85. package/dist/assets/{skeletons-DcGqw3b1.js → skeletons-Dxs6Di3L.js} +1 -1
  86. package/dist/assets/src-BY3UmUTR.js +1 -0
  87. package/dist/assets/src-CZnjIqJM.js +1 -0
  88. package/dist/assets/src-ZtN-VRcF.js +1 -0
  89. package/dist/assets/ui-layout-CvxBdH1V.js +3 -0
  90. package/dist/assets/useFavorites--Hq-4pMF.js +1 -0
  91. package/dist/assets/useMetadataService-CC_uGGZw.js +1 -0
  92. package/dist/assets/useResponsiveSidebar-DB8TNfQv.js +1 -0
  93. package/dist/assets/utils-auqIw3t-.js +1 -0
  94. package/dist/assets/vendor-charts-7pRhwWOA.js +3 -0
  95. package/dist/assets/vendor-objectstack-C8-rZ_sh.js +1 -0
  96. package/dist/assets/{vendor-react-BwtAzZZ3.js → vendor-react-DmY3YWtk.js} +2 -2
  97. package/dist/assets/vendor-zod-Cu1XCR5v.js +1 -0
  98. package/dist/index.html +25 -13
  99. package/dist/mockServiceWorker.js +1 -1
  100. package/package.json +50 -47
  101. package/plugin.js +2 -2
  102. package/plugin.ts +2 -2
  103. package/dist/assets/AddressField-BLYuFwUv.js +0 -1
  104. package/dist/assets/AdvancedChartImpl-Dvg6YIfN.js +0 -7
  105. package/dist/assets/AppManagementPage-C3hg63SY.js +0 -1
  106. package/dist/assets/AuditLogPage-BQ8vLOcD.js +0 -1
  107. package/dist/assets/AuthPageLayout-DDjJTsQ6.js +0 -1
  108. package/dist/assets/AutoNumberField-DLmi_0fk.js +0 -1
  109. package/dist/assets/AvatarField-BfoEDA_D.js +0 -1
  110. package/dist/assets/BooleanField-W3_x7RAZ.js +0 -1
  111. package/dist/assets/ChartImpl-Cwo6IWnY.js +0 -1
  112. package/dist/assets/CodeField-BWFqblAU.js +0 -1
  113. package/dist/assets/ColorField-Y8WM1wXE.js +0 -1
  114. package/dist/assets/CreateAppPage-Do3sVvxx.js +0 -1
  115. package/dist/assets/CurrencyField-BeuE1bRa.js +0 -1
  116. package/dist/assets/DashboardDesignPage-B2PH_3Ly.js +0 -1
  117. package/dist/assets/DashboardView-DxTi63mN.js +0 -1
  118. package/dist/assets/DateField-2Lf9jstN.js +0 -1
  119. package/dist/assets/DateTimeField-BkMuhOZJ.js +0 -1
  120. package/dist/assets/EditAppPage-j0L1x2UT.js +0 -1
  121. package/dist/assets/EmailField-CP_O7tmo.js +0 -1
  122. package/dist/assets/FileField-CcczwlRk.js +0 -1
  123. package/dist/assets/ForgotPasswordPage-Slo6CHvD.js +0 -1
  124. package/dist/assets/FormulaField-DLdg1ImO.js +0 -1
  125. package/dist/assets/GeolocationField-DqeMjnyo.js +0 -1
  126. package/dist/assets/GridField-DaWMYyuc.js +0 -1
  127. package/dist/assets/ImageField-DAn05d1y.js +0 -1
  128. package/dist/assets/KanbanEnhanced-Dj7Qccu2.js +0 -1
  129. package/dist/assets/KanbanImpl-D9BbG_RT.js +0 -1
  130. package/dist/assets/LocationField-DYHVF_gq.js +0 -1
  131. package/dist/assets/LoginPage-D2CqpSi0.js +0 -1
  132. package/dist/assets/LookupField-BF9vCmht.js +0 -1
  133. package/dist/assets/MarkdownImpl-B0Iew7iJ.js +0 -29
  134. package/dist/assets/MasterDetailField-Dw4RRQ5W.js +0 -1
  135. package/dist/assets/NumberField-BKuVHBrN.js +0 -1
  136. package/dist/assets/ObjectField-z00gmFEc.js +0 -1
  137. package/dist/assets/OrgManagementPage-BTNWvRHI.js +0 -1
  138. package/dist/assets/PageDesignPage-B62v76Qo.js +0 -1
  139. package/dist/assets/PageView-CzF68bdQ.js +0 -2
  140. package/dist/assets/PasswordField-B_rXL4g9.js +0 -1
  141. package/dist/assets/PercentField-Bn_SIbNe.js +0 -1
  142. package/dist/assets/PermissionManagementPage-PWrxdXgQ.js +0 -1
  143. package/dist/assets/PhoneField-DuheMaUR.js +0 -1
  144. package/dist/assets/ProfilePage-CUo-xIgl.js +0 -1
  145. package/dist/assets/QRCodeField-IPS2Rpmi.js +0 -1
  146. package/dist/assets/RatingField-M6qZlpA4.js +0 -1
  147. package/dist/assets/RecordDetailView-FkYkjMEZ.js +0 -1
  148. package/dist/assets/RegisterPage-D7PJIabW.js +0 -1
  149. package/dist/assets/ReportView-pQJYBCo1.js +0 -1
  150. package/dist/assets/RichTextField-CDGy9V9x.js +0 -1
  151. package/dist/assets/RoleManagementPage-cNU9Z5K1.js +0 -1
  152. package/dist/assets/SearchResultsPage-DJU7W1Zx.js +0 -1
  153. package/dist/assets/SelectField-F6UDlyvf.js +0 -1
  154. package/dist/assets/SignatureField-CHN7xBII.js +0 -1
  155. package/dist/assets/SliderField-BOfEMQyU.js +0 -1
  156. package/dist/assets/SummaryField-CZ8KzmBZ.js +0 -1
  157. package/dist/assets/SystemHubPage-BxKsLijB.js +0 -1
  158. package/dist/assets/TextAreaField-1E39zZ_x.js +0 -1
  159. package/dist/assets/TextField-CwuU0Crc.js +0 -1
  160. package/dist/assets/TimeField-CEWXxhLE.js +0 -1
  161. package/dist/assets/UrlField-BtUImn9B.js +0 -1
  162. package/dist/assets/UserField-DSSEoy5L.js +0 -1
  163. package/dist/assets/UserManagementPage-D2qUebpD.js +0 -1
  164. package/dist/assets/VectorField-BjfQeTZT.js +0 -1
  165. package/dist/assets/data-adapter-wZ81OFjZ.js +0 -39
  166. package/dist/assets/framework-DJlDX9E6.js +0 -1
  167. package/dist/assets/index-D9-L0QBO.css +0 -2
  168. package/dist/assets/index-RiB5-8aY.js +0 -8
  169. package/dist/assets/infrastructure-C6Ph6Ug0.js +0 -3
  170. package/dist/assets/maplibre-gl-DsUGuDud.js +0 -756
  171. package/dist/assets/plugins-core-Cfhp_BXE.css +0 -2
  172. package/dist/assets/plugins-core-PiAAytWV.js +0 -136
  173. package/dist/assets/plugins-views-CE0VP3vl.js +0 -62
  174. package/dist/assets/src-oeWLmiqa.js +0 -1
  175. package/dist/assets/systemObjects-5--4zaiX.js +0 -1
  176. package/dist/assets/ui-layout-DdDX0gzI.js +0 -3
  177. package/dist/assets/vendor-charts-Bl5l0H2K.js +0 -3
  178. package/dist/assets/vendor-objectstack-BtztJIHv.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{M as t,N as n,t as r,w as i,y as a}from"./framework-DJlDX9E6.js";import{$c as o,$o as s,Ac as c,As as l,Bc as u,Bs as d,Cc as f,Dc as p,Fc as m,Fs as h,Gc as g,Gs as _,Hc as v,Ic as y,Js as b,Kc as x,Ks as S,Mc as C,Ms as w,Nc as T,Oc as E,Pc as D,Qc as O,Qo as k,Rs as A,Sl as j,Uc as M,Vc as N,Vs as P,Xs as F,Ys as I,Zs as L,_c as R,_s as z,ac as ee,al as B,bs as te,cl as V,cs as ne,ds as H,ec as re,el as U,fc as ie,gc as ae,gs as oe,hc as se,il as ce,is as le,jc as ue,kc as de,ls as fe,mc as pe,nl as me,oc as he,ol as ge,os as W,pc as _e,qs as ve,rc as ye,rl as be,ss as xe,tc as Se,tl as G,ts as Ce,us as we,xl as K,yc as Te,zc as Ee}from"./plugins-core-PiAAytWV.js";import{p as De}from"./infrastructure-C6Ph6Ug0.js";var q=e(n(),1);function Oe(e,t={}){let{maxHistory:n=50}=t,[r,i]=(0,q.useState)(e),a=(0,q.useRef)([]),o=(0,q.useRef)([]),s=(0,q.useCallback)(e=>{i(t=>(a.current=[...a.current.slice(-(n-1)),t],o.current=[],e))},[n]),c=(0,q.useCallback)(()=>{a.current.length!==0&&i(e=>{let t=[...a.current],n=t.pop();return a.current=t,o.current=[e,...o.current],n})},[]),l=(0,q.useCallback)(()=>{o.current.length!==0&&i(e=>{let t=[...o.current],n=t.shift();return o.current=t,a.current=[...a.current,e],n})},[]),u=(0,q.useCallback)(e=>{a.current=[],o.current=[],i(e)},[]);return{current:r,canUndo:a.current.length>0,canRedo:o.current.length>0,undoCount:a.current.length,redoCount:o.current.length,push:s,undo:c,redo:l,reset:u}}function ke(){let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(``),o=(0,q.useRef)(null);return{isOpen:e,title:n,message:i,confirm:(0,q.useCallback)((e,n)=>(r(e),a(n),t(!0),new Promise(e=>{o.current=e})),[]),onConfirm:(0,q.useCallback)(()=>{t(!1),o.current?.(!0),o.current=null},[]),onCancel:(0,q.useCallback)(()=>{t(!1),o.current?.(!1),o.current=null},[])}}function Ae(){let[e,t]=(0,q.useState)(new Set);return{selectedIds:e,toggle:(0,q.useCallback)((e,n=!1)=>{t(t=>{let r=new Set(n?t:[]);return t.has(e)&&n?r.delete(e):r.add(e),r})},[]),selectOne:(0,q.useCallback)(e=>{t(new Set([e]))},[]),selectMany:(0,q.useCallback)(e=>{t(new Set(e))},[]),clearSelection:(0,q.useCallback)(()=>{t(new Set)},[]),isSelected:(0,q.useCallback)(t=>e.has(t),[e]),count:e.size}}function je(){let[e,t]=(0,q.useState)(null);return{clipboard:e,copy:(0,q.useCallback)(e=>{t(structuredClone(e))},[]),paste:(0,q.useCallback)(()=>e?structuredClone(e):null,[e]),hasContent:e!==null}}function Me(e={}){let{minZoom:t=.25,maxZoom:n=3,zoomStep:r=.1,initialZoom:i=1}=e,[a,o]=(0,q.useState)(i),[s,c]=(0,q.useState)({x:0,y:0}),l=(0,q.useRef)(!1),u=(0,q.useRef)({x:0,y:0}),d=(0,q.useCallback)(e=>Math.min(n,Math.max(t,+e.toFixed(2))),[t,n]);return{zoom:a,panOffset:s,zoomIn:(0,q.useCallback)(()=>o(e=>d(e+r)),[d,r]),zoomOut:(0,q.useCallback)(()=>o(e=>d(e-r)),[d,r]),resetZoom:(0,q.useCallback)(()=>{o(1),c({x:0,y:0})},[]),setZoom:(0,q.useCallback)(e=>o(d(e)),[d]),handleWheel:(0,q.useCallback)(e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-r:r;o(e=>d(e+t))}},[d,r]),startPan:(0,q.useCallback)(e=>{if(e.button===1||e.button===0&&e.altKey){e.preventDefault(),l.current=!0,u.current={x:e.clientX,y:e.clientY};let t=e=>{if(!l.current)return;let t=e.clientX-u.current.x,n=e.clientY-u.current.y;u.current={x:e.clientX,y:e.clientY},c(e=>({x:e.x+t,y:e.y+n}))},n=()=>{l.current=!1,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)}},[]),transformStyle:{transform:`translate(${s.x}px, ${s.y}px) scale(${a})`,transformOrigin:`0 0`}}}var J=i();function Ne(...e){return K(j(e))}function Pe({isOpen:e,title:t,message:n,confirmLabel:r=`Delete`,cancelLabel:i=`Cancel`,destructive:a=!0,onConfirm:o,onCancel:s}){let c=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let t=c.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),e?(0,J.jsx)(`dialog`,{ref:c,className:`fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50`,onClose:s,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-message`,children:(0,J.jsxs)(`div`,{className:`w-80 p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[a&&(0,J.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10`,children:(0,J.jsx)(fe,{className:`h-5 w-5 text-destructive`})}),(0,J.jsx)(`h2`,{id:`confirm-title`,className:`text-lg font-semibold`,children:t})]}),(0,J.jsx)(`p`,{id:`confirm-message`,className:`text-sm text-muted-foreground mb-6`,children:n}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{onClick:s,className:`px-4 py-2 text-sm rounded-md border hover:bg-accent`,children:i}),(0,J.jsx)(`button`,{onClick:o,className:Ne(`px-4 py-2 text-sm rounded-md font-medium`,a?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`),autoFocus:!0,children:r})]})]})}):null}function Fe(...e){return K(j(e))}function Ie({title:e=`Properties`,fields:t,onChange:n,className:r}){let[i,a]=(0,q.useState)(new Set),s=(0,q.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),c=t.reduce((e,t)=>{let n=t.group??`General`;return e[n]||(e[n]=[]),e[n].push(t),e},{});return(0,J.jsxs)(`div`,{className:Fe(`flex flex-col`,r),role:`region`,"aria-label":e,children:[(0,J.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:e}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[Object.entries(c).map(([e,t])=>(0,J.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,J.jsxs)(`button`,{onClick:()=>s(e),className:`w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50`,children:[i.has(e)?(0,J.jsx)(o,{className:`h-3 w-3`}):(0,J.jsx)(G,{className:`h-3 w-3`}),e]}),!i.has(e)&&(0,J.jsx)(`div`,{className:`px-3 pb-2 space-y-2`,children:t.map(e=>(0,J.jsx)(Le,{field:e,onChange:n},e.name))})]},e)),t.length===0&&(0,J.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`Select an element to edit its properties`})]})]})}function Le({field:e,onChange:t}){let n=n=>{t(e.name,n)};return(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:e.label}),e.type===`text`&&(0,J.jsx)(`input`,{type:`text`,value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`number`&&(0,J.jsx)(`input`,{type:`number`,value:Number(e.value??0),onChange:e=>n(Number(e.target.value)),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`boolean`&&(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:!!e.value,onChange:e=>n(e.target.checked),className:`rounded`}),(0,J.jsx)(`span`,{className:`text-xs`,children:e.value?`Yes`:`No`})]}),e.type===`select`&&(0,J.jsx)(`select`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`,children:e.options?.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))}),e.type===`color`&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`color`,value:String(e.value??`#000000`),onChange:e=>n(e.target.value),className:`h-6 w-6 rounded border cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs font-mono`,children:String(e.value??`#000000`)})]}),e.type===`textarea`&&(0,J.jsx)(`textarea`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background resize-y`,rows:3}),e.description&&(0,J.jsx)(`p`,{className:`text-[0.65rem] text-muted-foreground/70`,children:e.description})]})}function Re(...e){return K(j(e))}function ze({items:e,canvasWidth:t,canvasHeight:n,position:r=`bottom-right`,size:i=150,className:a}){let o=Math.min(i/t,i/n),s=t*o,c=n*o;return(0,J.jsx)(`div`,{className:Re(`absolute border rounded bg-background/90 shadow-sm overflow-hidden`,{"top-left":`top-2 left-2`,"top-right":`top-2 right-2`,"bottom-left":`bottom-2 left-2`,"bottom-right":`bottom-2 right-2`}[r],a),role:`img`,"aria-label":`Canvas minimap`,children:(0,J.jsxs)(`svg`,{width:s,height:c,viewBox:`0 0 ${t} ${n}`,children:[(0,J.jsx)(`rect`,{width:t,height:n,fill:`hsl(var(--muted))`,opacity:`0.3`}),e.map(e=>(0,J.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:e.selected?`hsl(var(--primary))`:e.color??`hsl(var(--foreground) / 0.3)`,rx:`2`},e.id))]})})}var Be=(0,q.createContext)(null);Be.displayName=`CollaborationContext`;function Ve(){return(0,q.useContext)(Be)}function Y(...e){return K(j(e))}function He({canvas:e={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:t=[],palette:n=Ue,showComponentTree:r=!0,undoRedo:i=!0,propertyEditor:a=!0,readOnly:o=!1,showMinimap:s=!1,onChange:c,className:l}){let u=Oe(t),f=u.current,h=(0,q.useCallback)(e=>{u.push(e),c?.(e)},[u,c]),g=Me({initialZoom:e.zoom??1}),{zoom:_}=g,y=Ae(),S=(0,q.useMemo)(()=>{let e=Array.from(y.selectedIds);return e.length>0?e[0]:null},[y.selectedIds]),C=(0,q.useMemo)(()=>f.find(e=>e.id===S),[f,S]),w=je(),T=ke(),E=Ve(),D=(0,q.useCallback)(e=>{E&&E.sendOperation({...e,userId:E.currentUserId??``})},[E]),[O,k]=(0,q.useState)(!0),[j,M]=(0,q.useState)(!0),[N,P]=(0,q.useState)(s),I=(0,q.useRef)(null),L=(0,q.useRef)(null),z=(0,q.useCallback)(t=>!e.snapToGrid||!e.gridSize?t:Math.round(t/e.gridSize)*e.gridSize,[e.snapToGrid,e.gridSize]),B=(0,q.useCallback)((e,t)=>{if(o)return;let r=n.flatMap(e=>e.items).find(t=>t.type===e),i=r?.defaultSize,a={id:`comp-${Date.now()}`,type:e,label:t,position:{x:100,y:100,width:i?.width??200,height:i?.height??100},props:r?.defaultProps??{}};h([...f,a]),y.selectOne(a.id),D({type:`insert`,elementId:a.id,data:{component:a}})},[f,o,n,h,y,D]),te=(0,q.useCallback)(e=>{o||(h(f.filter(t=>t.id!==e)),y.isSelected(e)&&y.clearSelection(),D({type:`delete`,elementId:e,data:{}}))},[f,o,h,y,D]),V=(0,q.useCallback)(async()=>{if(o||y.count===0||!await T.confirm(`Delete components`,`Are you sure you want to delete ${y.count} component${y.count>1?`s`:``}?`))return;let e=y.selectedIds;h(f.filter(t=>!e.has(t.id))),y.clearSelection(),e.forEach(e=>{D({type:`delete`,elementId:e,data:{}})})},[o,y,T,f,h,D]),ne=(0,q.useCallback)((e,t)=>{o||!S||(h(f.map(n=>n.id===S?e===`label`?{...n,label:String(t)}:e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,props:{...n.props,[e]:t}}:n)),D({type:`update`,elementId:S,data:{[e]:t}}))},[o,S,f,h,D]),re=(0,q.useCallback)(()=>{let e=y.selectedIds;if(e.size===0)return;let t=f.filter(t=>e.has(t.id));w.copy(t)},[y,f,w]),U=(0,q.useCallback)(()=>{if(o)return;let e=w.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`comp-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}}));h([...f,...n]),y.selectMany(n.map(e=>e.id)),n.forEach(e=>{D({type:`insert`,elementId:e.id,data:{component:e}})})},[o,w,f,h,y,D]),ie=(0,q.useCallback)((e,t)=>{o||(I.current={id:t.id,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[o]),ae=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),oe=(0,q.useCallback)(e=>{e.preventDefault();let t=I.current;if(!t||o)return;let n=(e.clientX-t.startX)/_,r=(e.clientY-t.startY)/_;h(f.map(e=>e.id===t.id?{...e,position:{...e.position,x:z(e.position.x+n),y:z(e.position.y+r)}}:e)),D({type:`move`,elementId:t.id,data:{}}),I.current=null},[o,_,f,h,z,D]),se=(0,q.useMemo)(()=>C?[{name:`label`,label:`Label`,type:`text`,value:C.label??``,group:`General`},{name:`x`,label:`X`,type:`number`,value:C.position.x,group:`Position`},{name:`y`,label:`Y`,type:`number`,value:C.position.y,group:`Position`},{name:`width`,label:`Width`,type:`number`,value:C.position.width,group:`Size`},{name:`height`,label:`Height`,type:`number`,value:C.position.height,group:`Size`}]:[],[C]),ce=(0,q.useMemo)(()=>f.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:typeof e.position.width==`number`?e.position.width:100,height:typeof e.position.height==`number`?e.position.height:50,selected:y.isSelected(e.id)})),[f,y]);return(0,q.useEffect)(()=>{let e=L.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&y.count>0&&!t){e.preventDefault(),V();return}if(e.key===`Escape`){y.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&i&&!o){e.preventDefault(),u.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&i&&!o){e.preventDefault(),u.redo();return}if(n&&e.key===`c`){e.preventDefault(),re();return}if(n&&e.key===`v`&&!o){e.preventDefault(),U();return}if(n&&e.key===`a`){e.preventDefault(),y.selectMany(f.map(e=>e.id));return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[y,V,i,o,u,re,U,f]),(0,J.jsxs)(`div`,{ref:L,tabIndex:0,className:Y(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,l),children:[!o&&(0,J.jsx)(`div`,{className:Y(`border-r bg-muted/30 flex flex-col transition-[width] duration-200`,O?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component palette`,children:O&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:`Components`}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:n.map(e=>(0,J.jsxs)(`div`,{className:`mb-3`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-2 py-1 uppercase`,children:e.label}),e.items.map(e=>(0,J.jsxs)(`button`,{onClick:()=>B(e.type,e.label),className:`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),e.label]},e.type))]},e.name))})]})}),(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Designer toolbar`,children:[!o&&(0,J.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:O?`Collapse palette`:`Expand palette`,"aria-label":O?`Collapse palette`:`Expand palette`,onClick:()=>k(e=>!e),children:(0,J.jsx)(F,{className:Y(`h-4 w-4`,!O&&`rotate-180`)})}),i&&!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!u.canUndo&&`opacity-40 pointer-events-none`),title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,disabled:!u.canUndo,onClick:()=>u.undo(),children:(0,J.jsx)(xe,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!u.canRedo&&`opacity-40 pointer-events-none`),title:`Redo (Ctrl+Shift+Z)`,"aria-label":`Redo`,disabled:!u.canRedo,onClick:()=>u.redo(),children:(0,J.jsx)(A,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,y.count===0&&`opacity-40 pointer-events-none`),title:`Copy (Ctrl+C)`,"aria-label":`Copy`,disabled:y.count===0,onClick:re,children:(0,J.jsx)(v,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!w.hasContent&&`opacity-40 pointer-events-none`),title:`Paste (Ctrl+V)`,"aria-label":`Paste`,disabled:!w.hasContent,onClick:U,children:(0,J.jsx)(x,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!o&&(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,y.count===0&&`opacity-40 pointer-events-none`),title:`Delete selected`,"aria-label":`Delete selected`,disabled:y.count===0,onClick:V,children:(0,J.jsx)(H,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:`Preview`,"aria-label":`Preview`,children:(0,J.jsx)(m,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,N&&`bg-accent`),title:`Toggle minimap`,"aria-label":`Toggle minimap`,onClick:()=>P(e=>!e),children:(0,J.jsx)(he,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom out`,onClick:g.zoomOut,children:(0,J.jsx)(ye,{className:`h-3 w-3`})}),(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground w-10 text-center`,children:[Math.round(_*100),`%`]}),(0,J.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom in`,onClick:g.zoomIn,children:(0,J.jsx)(d,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Reset zoom`,onClick:g.resetZoom,children:(0,J.jsx)(ee,{className:`h-3 w-3`})})]}),r&&(0,J.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:j?`Collapse panel`:`Expand panel`,"aria-label":j?`Collapse panel`:`Expand panel`,onClick:()=>M(e=>!e),children:(0,J.jsx)(b,{className:Y(`h-4 w-4`,!j&&`rotate-180`)})})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,role:`region`,"aria-label":`Design canvas`,onWheel:g.handleWheel,onMouseDown:g.startPan,onDragOver:ae,onDrop:oe,children:(0,J.jsxs)(`div`,{className:`relative bg-background border rounded shadow-sm mx-auto`,style:{width:e.width*_,height:e.height*_,transform:`translate(${g.panOffset.x}px, ${g.panOffset.y}px)`,backgroundImage:e.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:e.showGrid&&e.gridSize?`${e.gridSize*_}px ${e.gridSize*_}px`:void 0},children:[f.map(e=>{let t=y.isSelected(e.id);return(0,J.jsxs)(`div`,{draggable:!o,onDragStart:t=>ie(t,e),className:Y(`absolute border rounded cursor-move select-none transition-shadow`,t?`border-primary ring-2 ring-primary/20 shadow-md`:`border-border hover:border-primary/50`),style:{left:e.position.x*_,top:e.position.y*_,width:typeof e.position.width==`number`?e.position.width*_:e.position.width,height:typeof e.position.height==`number`?e.position.height*_:e.position.height},onClick:t=>y.toggle(e.id,t.shiftKey),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b`,children:[(0,J.jsx)(p,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.label??e.type}),!o&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),te(e.id)},className:`ml-auto p-0.5 rounded hover:bg-destructive/10`,"aria-label":`Delete ${e.label??e.type}`,children:(0,J.jsx)(H,{className:`h-3 w-3 text-destructive`})})]}),(0,J.jsx)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:e.type})]},e.id)}),N&&(0,J.jsx)(ze,{items:ce,canvasWidth:e.width,canvasHeight:e.height})]})})]}),r&&(0,J.jsx)(`div`,{className:Y(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,j?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component tree`,children:j&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,J.jsx)(R,{className:`h-4 w-4`}),`Component Tree`]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:f.length===0?(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No components added yet. Click a component in the palette to add it to the canvas.`}):f.map(e=>(0,J.jsx)(`button`,{onClick:t=>y.toggle(e.id,t.shiftKey),className:Y(`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left`,y.isSelected(e.id)?`bg-accent`:`hover:bg-accent/50`),children:(0,J.jsx)(`span`,{className:`truncate`,children:e.label??e.type})},e.id))}),a&&C?(0,J.jsx)(`div`,{className:`border-t`,children:(0,J.jsx)(Ie,{title:`Properties – ${C.label??C.type}`,fields:se,onChange:ne})}):C&&(0,J.jsxs)(`div`,{className:`border-t p-3`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium mb-2`,children:`Properties`}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,J.jsxs)(`div`,{children:[`Type: `,C.type]}),(0,J.jsxs)(`div`,{children:[`ID: `,C.id]}),(0,J.jsxs)(`div`,{children:[`Position: `,C.position.x,`,`,` `,C.position.y]}),(0,J.jsxs)(`div`,{children:[`Size: `,C.position.width,` ×`,` `,C.position.height]})]})]})]})}),(0,J.jsx)(Pe,{isOpen:T.isOpen,title:T.title,message:T.message,onConfirm:T.onConfirm,onCancel:T.onCancel})]})}var Ue=[{name:`layout`,label:`Layout`,items:[{type:`container`,label:`Container`,defaultSize:{width:400,height:300}},{type:`flex`,label:`Flex`,defaultSize:{width:400,height:200}},{type:`grid`,label:`Grid`,defaultSize:{width:400,height:300}},{type:`card`,label:`Card`,defaultSize:{width:300,height:200}},{type:`tabs`,label:`Tabs`,defaultSize:{width:400,height:300}}]},{name:`form`,label:`Form`,items:[{type:`input`,label:`Input`,defaultSize:{width:300,height:60}},{type:`textarea`,label:`Textarea`,defaultSize:{width:300,height:120}},{type:`select`,label:`Select`,defaultSize:{width:300,height:60}},{type:`checkbox`,label:`Checkbox`,defaultSize:{width:200,height:40}},{type:`button`,label:`Button`,defaultSize:{width:120,height:40}}]},{name:`data`,label:`Data`,items:[{type:`table`,label:`Table`,defaultSize:{width:600,height:400}},{type:`chart`,label:`Chart`,defaultSize:{width:400,height:300}},{type:`list`,label:`List`,defaultSize:{width:300,height:400}},{type:`statistic`,label:`Statistic`,defaultSize:{width:200,height:100}}]}];function We(e,t={}){return Oe(e,t)}function Ge(...e){return K(j(e))}var Ke=[`text`,`number`,`boolean`,`date`,`datetime`,`uuid`,`email`,`url`,`phone`,`json`,`integer`,`float`,`decimal`,`currency`,`percent`,`textarea`,`select`,`multiselect`,`lookup`,`attachment`,`formula`,`autonumber`];function qe(e,t=4,n=280,r=250,i=50,a=50){return e.map((e,o)=>({...e,position:{x:i+o%t*n,y:a+Math.floor(o/t)*r}}))}function Je({entities:e=[],relationships:t=[],canvas:n={width:1200,height:800,showGrid:!0},showRelationshipLabels:r=!0,readOnly:i=!1,onEntitiesChange:a,onRelationshipsChange:c,className:l}){let u=(0,q.useRef)(null),f=We({entities:e,relationships:t},{maxHistory:50}),{entities:p,relationships:m}=f.current,g=(0,q.useCallback)(e=>{f.push(e),a?.(e.entities),c?.(e.relationships)},[f,a,c]),_=ke(),y=Ae(),b=y.count>0?Array.from(y.selectedIds)[0]:null,S=je(),C=Me({minZoom:.25,maxZoom:3,zoomStep:.1}),w=Ve(),[T,D]=(0,q.useState)(!0),[O,j]=(0,q.useState)(!0),[M,P]=(0,q.useState)(null),[F,I]=(0,q.useState)(``),[L,R]=(0,q.useState)(null),[z,ee]=(0,q.useState)(``),B=(0,q.useRef)(null),te=(0,q.useCallback)(()=>{if(i)return;let e=f.current,t={id:`entity-${Date.now()}`,name:`new_entity_${e.entities.length+1}`,label:`New Entity ${e.entities.length+1}`,fields:[{name:`id`,type:`uuid`,primaryKey:!0,required:!0},{name:`created_at`,type:`datetime`,required:!0},{name:`updated_at`,type:`datetime`,required:!0}],position:{x:50+e.entities.length%4*280,y:50+Math.floor(e.entities.length/4)*250}};g({entities:[...e.entities,t],relationships:e.relationships}),y.selectOne(t.id),w?.sendOperation({type:`insert`,userId:w?.currentUserId??``,elementId:t.id,data:{name:t.name,label:t.label}})},[i,f,g,y,w]),V=(0,q.useCallback)(async e=>{if(i)return;let t=p.find(t=>t.id===e);if(!await _.confirm(`Delete Entity`,`Are you sure you want to delete "${t?.label??e}"? This action cannot be undone.`))return;let n=f.current;g({entities:n.entities.filter(t=>t.id!==e),relationships:n.relationships.filter(t=>t.sourceEntity!==e&&t.targetEntity!==e)}),y.isSelected(e)&&y.clearSelection(),w?.sendOperation({type:`delete`,userId:w?.currentUserId??``,elementId:e,data:{}})},[i,p,_,f,g,y,w]),ne=(0,q.useCallback)(async()=>{if(i||y.count===0)return;let e=Array.from(y.selectedIds);if(!await _.confirm(`Delete Entities`,`Are you sure you want to delete ${e.length} selected entity(s)? This action cannot be undone.`))return;let t=f.current,n=new Set(e);g({entities:t.entities.filter(e=>!n.has(e.id)),relationships:t.relationships.filter(e=>!n.has(e.sourceEntity)&&!n.has(e.targetEntity))}),y.clearSelection()},[i,y,_,f,g]),re=(0,q.useCallback)(()=>{if(i)return;let e=f.current;g({entities:qe(e.entities),relationships:e.relationships})},[i,f,g]),U=(0,q.useCallback)(()=>{let e=p.filter(e=>y.isSelected(e.id));e.length>0&&S.copy(e)},[p,y,S]),ie=(0,q.useCallback)(()=>{if(i)return;let e=S.paste();if(!e||e.length===0)return;let t=f.current,n=e.map((e,t)=>({...e,id:`entity-${Date.now()}-${t}`,name:`${e.name}_copy`,label:`${e.label} (Copy)`,position:{x:e.position.x+30,y:e.position.y+30}}));g({entities:[...t.entities,...n],relationships:t.relationships}),y.selectMany(n.map(e=>e.id))},[i,S,f,g,y]),ae=(0,q.useCallback)(e=>{if(i)return;let t=f.current;g({entities:t.entities.map(t=>{if(t.id!==e)return t;let n={name:`field_${t.fields.length+1}`,type:`text`,required:!1};return{...t,fields:[...t.fields,n]}}),relationships:t.relationships})},[i,f,g]),oe=(0,q.useCallback)((e,t,n)=>{i||(P({entityId:e,fieldIndex:t}),I(n))},[i]),se=(0,q.useCallback)(()=>{if(!M)return;let e=F.trim();if(e===``){P(null);return}let t=f.current;g({entities:t.entities.map(t=>{if(t.id!==M.entityId)return t;let n=t.fields.map((t,n)=>n===M.fieldIndex?{...t,name:e}:t);return{...t,fields:n}}),relationships:t.relationships}),P(null)},[M,F,f,g]),ce=(0,q.useCallback)(()=>{P(null)},[]),ue=(0,q.useCallback)((e,t)=>{i||(R(e),ee(t))},[i]),de=(0,q.useCallback)(()=>{if(!L)return;let e=z.trim();if(e===``){R(null);return}let t=f.current;g({entities:t.entities.map(t=>t.id===L?{...t,label:e}:t),relationships:t.relationships}),R(null)},[L,z,f,g]),fe=(0,q.useCallback)(()=>{R(null)},[]),pe=(0,q.useCallback)((e,t,n)=>{if(i)return;let r=f.current;g({entities:r.entities.map(r=>{if(r.id!==e)return r;let i=r.fields.map((e,r)=>r===t?{...e,type:n}:e);return{...r,fields:i}}),relationships:r.relationships})},[i,f,g]),me=(0,q.useCallback)((e,t)=>{if(i||!p.find(e=>e.id===t))return;let n=e.target.getBoundingClientRect();B.current={entityId:t,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[i,p]),he=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),ge=(0,q.useCallback)(e=>{if(e.preventDefault(),!B.current)return;let t=e.currentTarget.getBoundingClientRect(),n=C.zoom,r=(e.clientX-t.left-C.panOffset.x)/n-B.current.offsetX,i=(e.clientY-t.top-C.panOffset.y)/n-B.current.offsetY,a=f.current;g({entities:a.entities.map(e=>e.id===B.current.entityId?{...e,position:{x:Math.max(0,Math.round(r)),y:Math.max(0,Math.round(i))}}:e),relationships:a.relationships}),B.current=null},[C.zoom,C.panOffset,f,g]),W=b?p.find(e=>e.id===b):null,ve=W?[{name:`name`,label:`Name`,type:`text`,value:W.name,group:`General`},{name:`label`,label:`Label`,type:`text`,value:W.label,group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:W.description??``,group:`General`},{name:`color`,label:`Color`,type:`color`,value:W.color??`#3b82f6`,group:`Appearance`},{name:`position.x`,label:`X Position`,type:`number`,value:W.position.x,group:`Position`},{name:`position.y`,label:`Y Position`,type:`number`,value:W.position.y,group:`Position`}]:[],ye=(0,q.useCallback)((e,t)=>{if(!b)return;let n=f.current;g({entities:n.entities.map(n=>n.id===b?e===`position.x`?{...n,position:{...n.position,x:Number(t)}}:e===`position.y`?{...n,position:{...n.position,y:Number(t)}}:{...n,[e]:t}:n),relationships:n.relationships})},[b,f,g]);(0,q.useEffect)(()=>{let e=u.current;if(!e)return;let t=e=>{let t=e.target.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;n&&e.key===`z`?(e.preventDefault(),f.undo()):n&&(e.key===`y`||e.shiftKey&&e.key===`Z`)?(e.preventDefault(),f.redo()):n&&e.key===`c`?(e.preventDefault(),U()):n&&e.key===`v`?(e.preventDefault(),ie()):(e.key===`Delete`||e.key===`Backspace`)&&y.count>0?(e.preventDefault(),ne()):e.key===`Escape`&&(y.clearSelection(),P(null),R(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[f,U,ie,ne,y]);let be=p.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:240,height:40+e.fields.length*24,color:e.color,selected:y.isSelected(e.id)}));return(0,J.jsxs)(`div`,{ref:u,tabIndex:0,className:Ge(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,l),children:[(0,J.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{role:`toolbar`,"aria-label":`Designer toolbar`,className:`flex items-center gap-2 p-2 border-b bg-muted/20 flex-wrap`,children:[(0,J.jsx)(N,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:`Data Model Designer`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 ml-2 border-l pl-2`,children:[(0,J.jsx)(`button`,{onClick:()=>f.undo(),disabled:!f.canUndo,"aria-label":`Undo`,title:`Undo (Ctrl+Z)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,J.jsx)(xe,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{onClick:()=>f.redo(),disabled:!f.canRedo,"aria-label":`Redo`,title:`Redo (Ctrl+Y)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,J.jsx)(A,{className:`h-3.5 w-3.5`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,J.jsx)(`button`,{onClick:C.zoomOut,"aria-label":`Zoom Out`,title:`Zoom Out`,className:`p-1 rounded hover:bg-accent`,children:(0,J.jsx)(k,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-center`,children:[Math.round(C.zoom*100),`%`]}),(0,J.jsx)(`button`,{onClick:C.zoomIn,"aria-label":`Zoom In`,title:`Zoom In`,className:`p-1 rounded hover:bg-accent`,children:(0,J.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{onClick:C.resetZoom,"aria-label":`Reset Zoom`,title:`Reset Zoom`,className:`p-1 rounded hover:bg-accent`,children:(0,J.jsx)(h,{className:`h-3 w-3`})})]}),!i&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,J.jsx)(`button`,{onClick:U,disabled:y.count===0,"aria-label":`Copy`,title:`Copy (Ctrl+C)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,J.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{onClick:ie,disabled:!S.hasContent,"aria-label":`Paste`,title:`Paste (Ctrl+V)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,J.jsx)(x,{className:`h-3.5 w-3.5`})})]}),!i&&(0,J.jsxs)(`button`,{onClick:re,"aria-label":`Auto Layout`,title:`Auto Layout`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded border hover:bg-accent`,children:[(0,J.jsx)(E,{className:`h-3 w-3`}),` Auto Layout`]}),(0,J.jsx)(`div`,{className:`flex-1`}),w?.isConnected&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,J.jsx)(le,{className:`h-3 w-3`}),(0,J.jsxs)(`span`,{children:[w.users.length,` user`,w.users.length===1?``:`s`]})]}),y.count>1&&(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[y.count,` selected`]}),!i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{onClick:te,"aria-label":`Add Entity`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),` Add Entity`]}),(0,J.jsxs)(`button`,{"aria-label":`Add Relationship`,title:`Add Relationship (coming soon)`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-secondary text-secondary-foreground hover:bg-secondary/80`,children:[(0,J.jsx)(_e,{className:`h-3 w-3`}),` Add Relationship`]})]})]}),(0,J.jsxs)(`div`,{role:`region`,"aria-label":`Canvas`,className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,onWheel:C.handleWheel,onMouseDown:C.startPan,onDragOver:he,onDrop:ge,children:[(0,J.jsxs)(`div`,{className:`relative`,style:{width:n.width,minHeight:n.height,...C.transformStyle,backgroundImage:n.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:n.showGrid?`20px 20px`:void 0},children:[(0,J.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:n.width,height:n.height,children:m.map(e=>{let t=p.find(t=>t.id===e.sourceEntity),n=p.find(t=>t.id===e.targetEntity);return!t||!n?null:(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:t.position.x+120,y1:t.position.y+50,x2:n.position.x+120,y2:n.position.y+50,stroke:`hsl(var(--primary))`,strokeWidth:`2`,strokeDasharray:e.type===`many-to-many`?`5,5`:void 0}),r&&e.label&&(0,J.jsx)(`text`,{x:(t.position.x+n.position.x)/2+120,y:(t.position.y+n.position.y)/2+50-8,textAnchor:`middle`,className:`text-xs fill-muted-foreground`,children:e.label})]},e.id)})}),p.length===0&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground text-sm`,children:`No entities in the model. Click 'Add Entity' to create your first entity.`}),p.map(e=>(0,J.jsxs)(`div`,{role:`group`,"aria-label":e.label,draggable:!i,onDragStart:t=>me(t,e.id),className:Ge(`absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing`,y.isSelected(e.id)?`border-primary ring-2 ring-primary/20`:`border-border hover:border-primary/50`),style:{left:e.position.x,top:e.position.y},onClick:t=>y.toggle(e.id,t.shiftKey),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm`,style:{backgroundColor:e.color??`hsl(var(--primary) / 0.1)`},children:[(0,J.jsx)(N,{className:`h-3.5 w-3.5`}),L===e.id?(0,J.jsx)(`input`,{type:`text`,value:z,onChange:e=>ee(e.target.value),onBlur:de,onKeyDown:e=>{e.key===`Enter`&&de(),e.key===`Escape`&&fe()},className:`text-sm font-medium px-1 py-0 border rounded bg-background w-32 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation(),"data-testid":`entity-label-input-${e.id}`}):(0,J.jsx)(`span`,{className:`truncate cursor-text`,onDoubleClick:t=>{t.stopPropagation(),ue(e.id,e.label)},title:`Double-click to edit label`,"data-testid":`entity-label-${e.id}`,children:e.label}),!i&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),V(e.id)},"aria-label":`Delete ${e.label}`,className:`ml-auto p-0.5 rounded hover:bg-destructive/20`,children:(0,J.jsx)(H,{className:`h-3 w-3 text-destructive`})})]}),(0,J.jsx)(`div`,{className:`px-3 py-1 divide-y`,children:e.fields.map((t,n)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs`,children:[M&&M.entityId===e.id&&M.fieldIndex===n?(0,J.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),onBlur:se,onKeyDown:e=>{e.key===`Enter`&&se(),e.key===`Escape`&&ce()},className:`font-mono text-xs px-1 py-0 border rounded bg-background w-24 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation()}):(0,J.jsxs)(`span`,{className:Ge(`font-mono cursor-text`,t.primaryKey&&`font-bold text-primary`),onClick:r=>{r.stopPropagation(),oe(e.id,n,t.name)},title:`Click to edit field name`,children:[t.primaryKey&&(0,J.jsx)(`span`,{className:`text-[0.65rem] font-semibold text-primary mr-0.5`,children:`PK`}),t.name]}),i?(0,J.jsx)(`span`,{className:`text-muted-foreground ml-auto`,children:t.type}):(0,J.jsx)(`select`,{value:t.type,onChange:t=>{t.stopPropagation(),pe(e.id,n,t.target.value)},onClick:e=>e.stopPropagation(),className:`text-xs text-muted-foreground ml-auto bg-transparent border-none focus:ring-1 focus:ring-primary rounded cursor-pointer p-0`,"data-testid":`field-type-${e.id}-${n}`,children:Ke.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))}),t.required&&(0,J.jsx)(`span`,{className:`text-destructive`,children:`*`})]},`${t.name}-${n}`))}),!i&&(0,J.jsx)(`div`,{className:`px-3 py-1 border-t`,children:(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),ae(e.id)},"aria-label":`Add field to ${e.label}`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),` Add Field`]})})]},e.id))]}),O&&p.length>0&&(0,J.jsx)(ze,{items:be,canvasWidth:n.width,canvasHeight:n.height,position:`bottom-right`,size:150})]})]}),(0,J.jsxs)(`div`,{className:`w-64 border-l flex flex-col bg-background shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,J.jsxs)(`button`,{onClick:()=>D(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 border-b`,"aria-expanded":T,"aria-controls":`property-editor-panel`,children:[T?(0,J.jsx)(G,{className:`h-3 w-3`}):(0,J.jsx)(o,{className:`h-3 w-3`}),`Properties`]}),T&&(0,J.jsx)(`div`,{id:`property-editor-panel`,className:`flex-1 overflow-y-auto`,children:(0,J.jsx)(Ie,{title:W?W.label:`Properties`,fields:ve,onChange:ye})})]}),(0,J.jsx)(`div`,{className:`border-t`,children:(0,J.jsxs)(`button`,{onClick:()=>j(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 w-full`,"aria-expanded":O,children:[O?(0,J.jsx)(G,{className:`h-3 w-3`}):(0,J.jsx)(o,{className:`h-3 w-3`}),`Minimap`]})})]}),(0,J.jsx)(Pe,{isOpen:_.isOpen,title:_.title,message:_.message,onConfirm:_.onConfirm,onCancel:_.onCancel,destructive:!0})]})}function Ye(...e){return K(j(e))}var Xe=120,Ze=50;function Qe(e,t){if(e.length===0)return e;let n=new Map,r=new Map;for(let t of e)n.set(t.id,0),r.set(t.id,[]);for(let e of t)n.set(e.target,(n.get(e.target)??0)+1),r.get(e.source)?.push(e.target);let i=[],a=new Set,o=e.filter(e=>(n.get(e.id)??0)===0).map(e=>e.id);for(o.length===0&&(o=[e[0].id]);o.length>0;){i.push(o);for(let e of o)a.add(e);let e=new Set;for(let t of o)for(let n of r.get(t)??[])a.has(n)||e.add(n);o=Array.from(e)}let s=e.filter(e=>!a.has(e.id)).map(e=>e.id);s.length>0&&i.push(s);let c=new Map;for(let e=0;e<i.length;e++){let t=i[e];for(let n=0;n<t.length;n++)c.set(t[n],{x:80+e*200,y:80+n*100})}return e.map(e=>({...e,position:c.get(e.id)??e.position}))}function $e({processName:e=`New Process`,nodes:t=[],edges:n=[],lanes:r,canvas:i={width:1400,height:800,showGrid:!0},showMinimap:a=!0,showToolbar:o=!0,readOnly:l=!1,onNodesChange:d,onEdgesChange:f,className:p}){let m=Oe({nodes:t,edges:n},{maxHistory:50}),g=m.current.nodes,_=m.current.edges,y=(0,q.useCallback)((e,t)=>{m.push({nodes:e,edges:t}),d?.(e),f?.(t)},[m,d,f]),C=ke(),w=Ae(),T=je(),E=Me({initialZoom:1}),D=Ve(),[O,j]=(0,q.useState)(null),[M,N]=(0,q.useState)(!1),[F,I]=(0,q.useState)(null),[L,R]=(0,q.useState)(null),[z,ee]=(0,q.useState)(!0),[B,V]=(0,q.useState)(null),[ne,re]=(0,q.useState)({x:0,y:0}),U=(0,q.useRef)(null),ae=(0,q.useRef)(d),oe=(0,q.useRef)(f);ae.current=d,oe.current=f,(0,q.useEffect)(()=>{ae.current?.(g),oe.current?.(_)},[m.current]);let se=(0,q.useCallback)((e,t)=>{if(l)return;let n={id:`node-${Date.now()}`,type:e,label:t,position:{x:200+g.length*160,y:200}};y([...g,n],_),j(n.id),w.selectOne(n.id),D?.sendOperation({type:`insert`,elementId:n.id,data:{label:t},userId:D.currentUserId??``})},[g,_,l,y,w,D]),ce=(0,q.useCallback)(async e=>{if(l)return;let t=g.find(t=>t.id===e);await C.confirm(`Delete Node`,`Are you sure you want to delete "${t?.label??e}"? This will also remove all connected edges.`)&&(y(g.filter(t=>t.id!==e),_.filter(t=>t.source!==e&&t.target!==e)),O===e&&j(null),w.clearSelection(),D?.sendOperation({type:`delete`,elementId:e,data:{},userId:D.currentUserId??``}))},[g,_,O,l,y,C,w,D]),le=(0,q.useCallback)(async()=>{if(l||w.count===0||!await C.confirm(`Delete Selected Nodes`,`Are you sure you want to delete ${w.count} selected node(s) and their connected edges?`))return;let e=w.selectedIds;y(g.filter(t=>!e.has(t.id)),_.filter(t=>!e.has(t.source)&&!e.has(t.target))),j(null),w.clearSelection()},[g,_,l,y,C,w]),ue=(0,q.useCallback)(()=>{let e=w.count>0?w.selectedIds:O?new Set([O]):new Set;if(e.size===0)return;let t=g.filter(t=>e.has(t.id));T.copy(t)},[g,O,w,T]),de=(0,q.useCallback)(()=>{if(l)return;let e=T.paste();if(!e||e.length===0)return;let t=e.map(e=>({...e,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:e.position.x+40,y:e.position.y+40}}));y([...g,...t],_),w.selectMany(t.map(e=>e.id)),j(t[0].id)},[l,g,_,T,y,w]),fe=(0,q.useCallback)(()=>{N(e=>e?(I(null),!1):!0)},[]),pe=(0,q.useCallback)(e=>{if(!M)return!1;if(!F)return I(e),!0;if(F===e)return!0;let t={id:`edge-${Date.now()}`,source:F,target:e};return y(g,[..._,t]),I(null),N(!1),D?.sendOperation({type:`insert`,elementId:t.id,data:{source:F,target:e},userId:D.currentUserId??``}),!0},[M,F,g,_,y,D]),me=(0,q.useCallback)(()=>{l||g.length===0||y(Qe(g,_),_)},[g,_,l,y]),he=(0,q.useCallback)((e,t)=>{if(l||!g.find(e=>e.id===t))return;V(t);let n=e.target.getBoundingClientRect();re({x:e.clientX-n.left,y:e.clientY-n.top}),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[l,g]),ge=(0,q.useCallback)(e=>{if(e.preventDefault(),l||!B)return;let t=e.currentTarget.getBoundingClientRect(),n=E.zoom,r=(e.clientX-t.left-E.panOffset.x)/n-ne.x,i=(e.clientY-t.top-E.panOffset.y)/n-ne.y,a=Math.max(0,Math.round(r/20)*20),o=Math.max(0,Math.round(i/20)*20);y(g.map(e=>e.id===B?{...e,position:{x:a,y:o}}:e),_),V(null)},[l,B,ne,g,_,E.zoom,E.panOffset,y]),W=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),_e=(0,q.useMemo)(()=>g.find(e=>e.id===O)??null,[g,O]),ye=(0,q.useMemo)(()=>_e?[{name:`label`,label:`Name`,type:`text`,value:_e.label,group:`General`},{name:`type`,label:`Type`,type:`select`,value:_e.type,options:[{label:`Start Event`,value:`start-event`},{label:`End Event`,value:`end-event`},{label:`User Task`,value:`user-task`},{label:`Service Task`,value:`service-task`},{label:`Script Task`,value:`script-task`},{label:`Exclusive Gateway`,value:`exclusive-gateway`},{label:`Parallel Gateway`,value:`parallel-gateway`},{label:`Inclusive Gateway`,value:`inclusive-gateway`}],group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:_e.description??``,group:`General`}]:[],[_e]),be=(0,q.useCallback)((e,t)=>{l||!O||y(g.map(n=>n.id===O?{...n,[e]:t}:n),_)},[l,O,g,_,y]),Se=e=>{switch(e){case`start-event`:return`rounded-full bg-green-100 border-green-500 text-green-700`;case`end-event`:return`rounded-full bg-red-100 border-red-500 text-red-700`;case`exclusive-gateway`:case`parallel-gateway`:case`inclusive-gateway`:case`event-based-gateway`:return`rotate-45 bg-yellow-100 border-yellow-500 text-yellow-700`;case`user-task`:return`rounded bg-blue-100 border-blue-500 text-blue-700`;case`service-task`:case`script-task`:return`rounded bg-purple-100 border-purple-500 text-purple-700`;default:return`rounded bg-gray-100 border-gray-500 text-gray-700`}},G=(0,q.useMemo)(()=>g.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:Xe,height:Ze,selected:w.isSelected(e.id)||e.id===O})),[g,w,O]);(0,q.useEffect)(()=>{let e=U.current;if(!e)return;let t=e=>{let t=e.target?.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`z`&&!e.shiftKey){e.preventDefault(),m.undo();return}if(n&&e.key===`y`||n&&e.key===`z`&&e.shiftKey){e.preventDefault(),m.redo();return}if(n&&e.key===`c`){e.preventDefault(),ue();return}if(n&&e.key===`v`){e.preventDefault(),de();return}if(e.key===`Delete`||e.key===`Backspace`){w.count>0?(e.preventDefault(),le()):O&&(e.preventDefault(),ce(O));return}if(e.key===`Escape`){M?(N(!1),I(null)):(j(null),w.clearSelection());return}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[O,M,w,m,ue,de,ce,le]);let Ce=(0,q.useCallback)(e=>{e.target===e.currentTarget&&(j(null),w.clearSelection(),M&&(N(!1),I(null)))},[M,w]);return(0,J.jsxs)(`div`,{ref:U,tabIndex:0,className:Ye(`flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background`,p),children:[(0,J.jsx)(Pe,{isOpen:C.isOpen,title:C.title,message:C.message,onConfirm:C.onConfirm,onCancel:C.onCancel,destructive:!0}),o&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Process toolbar`,children:[(0,J.jsx)(c,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`font-medium text-sm`,"aria-label":`Process name`,children:e}),D?.isConnected&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),D.users.length,` user`,D.users.length===1?``:`s`]}),(0,J.jsx)(`div`,{className:`flex-1`}),!l&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`button`,{onClick:()=>m.undo(),disabled:!m.canUndo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,children:(0,J.jsx)(xe,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:()=>m.redo(),disabled:!m.canRedo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Redo (Ctrl+Y)`,"aria-label":`Redo`,children:(0,J.jsx)(A,{className:`h-3 w-3`})}),(0,J.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,J.jsx)(`button`,{onClick:ue,disabled:w.count===0&&!O,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Copy (Ctrl+C)`,"aria-label":`Copy`,children:(0,J.jsx)(v,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:de,disabled:!T.hasContent,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Paste (Ctrl+V)`,"aria-label":`Paste`,children:(0,J.jsx)(x,{className:`h-3 w-3`})}),(0,J.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,J.jsxs)(`button`,{onClick:fe,className:Ye(`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,M&&`bg-primary text-primary-foreground`),title:`Connect nodes`,"aria-label":`Connect nodes`,"aria-pressed":M,children:[(0,J.jsx)(ie,{className:`h-3 w-3`}),` Connect`]}),(0,J.jsxs)(`button`,{onClick:me,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Auto layout`,"aria-label":`Auto layout`,children:[(0,J.jsx)(S,{className:`h-3 w-3`}),` Layout`]}),(0,J.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,J.jsx)(`button`,{onClick:E.zoomIn,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom in`,"aria-label":`Zoom in`,children:(0,J.jsx)(s,{className:`h-3 w-3`})}),(0,J.jsxs)(`span`,{className:`text-xs tabular-nums min-w-[3ch] text-center`,"aria-label":`Zoom level`,children:[Math.round(E.zoom*100),`%`]}),(0,J.jsx)(`button`,{onClick:E.zoomOut,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom out`,"aria-label":`Zoom out`,children:(0,J.jsx)(k,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:E.resetZoom,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Reset zoom`,"aria-label":`Reset zoom`,children:(0,J.jsx)(h,{className:`h-3 w-3`})}),(0,J.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,J.jsxs)(`button`,{onClick:()=>se(`start-event`,`Start`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Start Event`,"aria-label":`Add Start Event`,children:[(0,J.jsx)(P,{className:`h-3 w-3 text-green-600`}),` Start`]}),(0,J.jsxs)(`button`,{onClick:()=>se(`user-task`,`User Task`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add User Task`,"aria-label":`Add User Task`,children:[(0,J.jsx)(te,{className:`h-3 w-3 text-blue-600`}),` Task`]}),(0,J.jsxs)(`button`,{onClick:()=>se(`exclusive-gateway`,`Decision`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Gateway`,"aria-label":`Add Gateway`,children:[(0,J.jsx)(u,{className:`h-3 w-3 text-yellow-600`}),` Gateway`]}),(0,J.jsxs)(`button`,{onClick:()=>se(`end-event`,`End`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add End Event`,"aria-label":`Add End Event`,children:[(0,J.jsx)(te,{className:`h-3 w-3 text-red-600`}),` End`]}),(0,J.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,J.jsx)(`button`,{onClick:()=>ee(e=>!e),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:z?`Hide properties`:`Show properties`,"aria-label":z?`Hide property panel`:`Show property panel`,"aria-expanded":z,children:z?(0,J.jsx)(b,{className:`h-3 w-3`}):(0,J.jsx)(ve,{className:`h-3 w-3`})})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4`,role:`region`,"aria-label":`Process canvas`,onWheel:E.handleWheel,onMouseDown:E.startPan,children:(0,J.jsxs)(`div`,{className:`relative`,style:{...E.transformStyle,width:i.width,minHeight:i.height,backgroundImage:i.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:i.showGrid?`20px 20px`:void 0},onClick:Ce,onDrop:ge,onDragOver:W,children:[(0,J.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:i.width,height:i.height,children:[(0,J.jsx)(`defs`,{children:(0,J.jsx)(`marker`,{id:`arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`10`,refY:`3.5`,orient:`auto`,children:(0,J.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground))`})})}),_.map(e=>{let t=g.find(t=>t.id===e.source),n=g.find(t=>t.id===e.target);if(!t||!n)return null;t.position.x+Xe/2;let r=t.position.y+Ze/2;n.position.x+Xe/2;let i=n.position.y+Ze/2,a=t.position.x+Xe,o=r,s=n.position.x,c=i;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`path`,{d:`M ${a} ${o} Q ${(a+s)/2} ${o}, ${(a+s)/2} ${(o+c)/2} T ${s} ${c}`,fill:`none`,stroke:`hsl(var(--foreground) / 0.5)`,strokeWidth:`2`,markerEnd:`url(#arrowhead)`}),e.label&&(0,J.jsx)(`text`,{x:(a+s)/2,y:(o+c)/2-8,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,children:e.label})]},e.id)})]}),g.length===0&&(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full min-h-[200px] text-muted-foreground text-sm`,children:`No nodes in the process. Use the toolbar buttons to add start events, tasks, gateways, and end events.`}),g.map(e=>{let t=w.isSelected(e.id)||O===e.id,n=F===e.id,r=L===e.id,i=M||r;return(0,J.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},role:`group`,"aria-label":e.label,draggable:!l&&!M,onDragStart:t=>he(t,e.id),onMouseEnter:()=>R(e.id),onMouseLeave:()=>R(null),onClick:t=>{pe(e.id)||(t.shiftKey?w.toggle(e.id,!0):(j(e.id),w.selectOne(e.id)))},children:[(0,J.jsx)(`div`,{className:Ye(`flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow`,Se(e.type),t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,M&&!n&&`cursor-crosshair`),children:(0,J.jsx)(`span`,{className:Ye(`text-xs font-medium`,(e.type===`exclusive-gateway`||e.type===`parallel-gateway`||e.type===`inclusive-gateway`||e.type===`event-based-gateway`)&&`-rotate-45`),children:e.label})}),i&&!l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{left:-6,top:Ze/2-6},title:`Input port`,onClick:t=>{t.stopPropagation(),pe(e.id)}}),(0,J.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{right:-6,top:Ze/2-6},title:`Output port`,onClick:t=>{t.stopPropagation(),M?pe(e.id):(N(!0),I(e.id))}}),(0,J.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:Xe/2-6,top:-6},title:`Port`,onClick:t=>{t.stopPropagation(),pe(e.id)}}),(0,J.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:Xe/2-6,bottom:-6},title:`Port`,onClick:t=>{t.stopPropagation(),pe(e.id)}})]}),!l&&t&&!M&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ce(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":`Delete node`,children:(0,J.jsx)(H,{className:`h-3 w-3`})})]},e.id)}),a&&g.length>0&&(0,J.jsx)(ze,{items:G,canvasWidth:i.width??1400,canvasHeight:i.height??800,position:`bottom-right`})]})}),z&&!l&&(0,J.jsx)(`div`,{className:`w-64 border-l bg-background overflow-y-auto flex-shrink-0`,role:`complementary`,"aria-label":`Property panel`,children:(0,J.jsx)(Ie,{title:_e?`Properties: ${_e.label}`:`Properties`,fields:ye,onChange:be})})]})]})}function X(...e){return K(j(e))}var Z={untitledReport:`Untitled Report`,reportCanvas:`Report canvas`,properties:`Properties`,propertiesPanel:`Properties panel`,designerToolbar:`Report designer toolbar`,selectElementPrompt:`Select an element to edit its properties`,addElementsPrompt:`Add elements using the buttons above`,addText:`Add Text`,addField:`Add Field`,addImage:`Add Image`,addChart:`Add Chart`,addTable:`Add Table`,undo:`Undo`,undoShortcut:`Undo (Ctrl+Z)`,redo:`Redo`,redoShortcut:`Redo (Ctrl+Shift+Z)`,copy:`Copy`,copyShortcut:`Copy (Ctrl+C)`,paste:`Paste`,pasteShortcut:`Paste (Ctrl+V)`,deleteSelected:`Delete selected`,deleteElement:`Delete element`,deleteElementsTitle:`Delete elements`,deleteElementMessage:e=>`Are you sure you want to delete ${e} element${e>1?`s`:``}?`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,collaborationConnected:`Connected`,sectionHeader:`Report Header`,sectionPageHeader:`Page Header`,sectionGroupHeader:`Group Header`,sectionDetail:`Detail`,sectionGroupFooter:`Group Footer`,sectionPageFooter:`Page Footer`,sectionFooter:`Report Footer`,elementText:`Text`,elementImage:`🖼 Image`,elementChart:`📊 Chart`,elementTable:`📋 Table`,propLabel:`Label`,propX:`X`,propY:`Y`,propWidth:`Width`,propHeight:`Height`,propText:`Text`,propField:`Field`,groupPosition:`Position`,groupSize:`Size`,groupContent:`Content`,groupGeneral:`General`},et={A4:{width:595,height:842},A3:{width:842,height:1191},Letter:{width:612,height:792},Legal:{width:612,height:1008},Tabloid:{width:792,height:1224}},tt=[{type:`header`,height:80,elements:[]},{type:`detail`,height:400,elements:[],repeat:!0},{type:`footer`,height:60,elements:[]}];function nt({reportName:e=Z.untitledReport,objectName:t,pageSize:n=`A4`,orientation:r=`portrait`,margins:i={top:40,right:40,bottom:40,left:40},sections:a=[],showToolbar:o=!0,showPropertyPanel:s=!0,readOnly:c=!1,onSectionsChange:l,className:u}){let p=Oe(a.length>0?a:tt),m=p.current,h=(0,q.useCallback)(e=>{p.push(e),l?.(e)},[p,l]),g=Ae(),_=(0,q.useMemo)(()=>{let e=Array.from(g.selectedIds);return e.length>0?e[0]:null},[g.selectedIds]),y=je(),S=ke(),C=Ve(),w=(0,q.useCallback)(e=>{C&&C.sendOperation({...e,userId:C.currentUserId??``})},[C]),[T,E]=(0,q.useState)(!0),O=(0,q.useRef)(null),k=(0,q.useRef)(null),j=et[n],M=r===`landscape`?j.height:j.width,N=r===`landscape`?j.width:j.height,P=e=>{switch(e){case`header`:return Z.sectionHeader;case`page-header`:return Z.sectionPageHeader;case`group-header`:return Z.sectionGroupHeader;case`detail`:return Z.sectionDetail;case`group-footer`:return Z.sectionGroupFooter;case`page-footer`:return Z.sectionPageFooter;case`footer`:return Z.sectionFooter;default:return e}},F=(0,q.useMemo)(()=>_?m.flatMap(e=>e.elements).find(e=>e.id===_):null,[_,m]),I=(0,q.useCallback)((e,t)=>{if(c)return;let n={id:`elem-${Date.now()}`,type:t,position:{x:i.left,y:10,width:200,height:30},properties:{text:t===`text`?`New Text`:void 0,field:t===`field`?`field_name`:void 0}};h(m.map((t,r)=>r===e?{...t,elements:[...t.elements,n]}:t)),g.selectOne(n.id),w({type:`insert`,elementId:n.id,data:{element:n}})},[m,i.left,c,h,g,w]),L=(0,q.useCallback)(e=>{c||(h(m.map(t=>({...t,elements:t.elements.filter(t=>t.id!==e)}))),g.isSelected(e)&&g.clearSelection(),w({type:`delete`,elementId:e,data:{}}))},[m,c,h,g,w]),R=(0,q.useCallback)(async()=>{if(c||g.count===0||!await S.confirm(Z.deleteElementsTitle,Z.deleteElementMessage(g.count)))return;let e=g.selectedIds;h(m.map(t=>({...t,elements:t.elements.filter(t=>!e.has(t.id))}))),g.clearSelection(),e.forEach(e=>{w({type:`delete`,elementId:e,data:{}})})},[c,g,S,m,h,w]),z=(0,q.useCallback)((e,t)=>{c||!_||(h(m.map(n=>({...n,elements:n.elements.map(n=>n.id===_?e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,properties:{...n.properties,[e]:t}}:n)}))),w({type:`update`,elementId:_,data:{[e]:t}}))},[c,_,m,h,w]),ee=(0,q.useCallback)(()=>{let e=g.selectedIds;if(e.size===0)return;let t=m.flatMap(e=>e.elements).filter(t=>e.has(t.id));y.copy(t)},[g,m,y]),B=(0,q.useCallback)(()=>{if(c)return;let e=y.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`elem-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}})),r=m.findIndex(e=>e.type===`detail`),i=r>=0?r:0;h(m.map((e,t)=>t===i?{...e,elements:[...e.elements,...n]}:e)),g.selectMany(n.map(e=>e.id)),n.forEach(e=>{w({type:`insert`,elementId:e.id,data:{element:e}})})},[c,y,m,h,g,w]),te=(0,q.useCallback)((e,t,n)=>{c||(O.current={id:t.id,sectionIndex:n,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[c]),V=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),re=(0,q.useCallback)((e,t)=>{e.preventDefault();let n=O.current;if(!n||c)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;if(n.sectionIndex===t)h(m.map((e,a)=>a===t?{...e,elements:e.elements.map(e=>e.id===n.id?{...e,position:{...e.position,x:Math.max(0,e.position.x+r),y:Math.max(0,(typeof e.position.y==`number`?e.position.y:0)+i)}}:e)}:e));else{let e=null,i=m.map((t,i)=>{if(i!==n.sectionIndex)return t;let a=t.elements.find(e=>e.id===n.id);return a&&(e={...a,position:{...a.position,x:Math.max(0,a.position.x+r),y:10}}),{...t,elements:t.elements.filter(e=>e.id!==n.id)}});e&&h(i.map((n,r)=>r===t?{...n,elements:[...n.elements,e]}:n))}w({type:`move`,elementId:n.id,data:{}}),O.current=null},[c,m,h,w]),U=(0,q.useMemo)(()=>{if(!F)return[];let e=[{name:`x`,label:Z.propX,type:`number`,value:F.position.x,group:Z.groupPosition},{name:`y`,label:Z.propY,type:`number`,value:F.position.y,group:Z.groupPosition},{name:`width`,label:Z.propWidth,type:`number`,value:F.position.width,group:Z.groupSize},{name:`height`,label:Z.propHeight,type:`number`,value:F.position.height,group:Z.groupSize}];return F.type===`text`&&e.push({name:`text`,label:Z.propText,type:`text`,value:F.properties.text??``,group:Z.groupContent}),F.type===`field`&&e.push({name:`field`,label:Z.propField,type:`text`,value:F.properties.field??``,group:Z.groupContent}),e},[F]);return(0,q.useEffect)(()=>{let e=k.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&g.count>0&&!t){e.preventDefault(),R();return}if(e.key===`Escape`){g.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&!c){e.preventDefault(),p.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&!c){e.preventDefault(),p.redo();return}if(n&&e.key===`c`){e.preventDefault(),ee();return}if(n&&e.key===`v`&&!c){e.preventDefault(),B();return}if(n&&e.key===`a`){e.preventDefault();let t=m.flatMap(e=>e.elements).map(e=>e.id);g.selectMany(t);return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g,R,c,p,ee,B,m]),(0,J.jsxs)(`div`,{ref:k,tabIndex:0,className:X(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,u),children:[(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[o&&(0,J.jsxs)(`div`,{role:`toolbar`,"aria-label":Z.designerToolbar,className:`flex items-center gap-2 p-2 border-b bg-muted/20`,children:[(0,J.jsx)(D,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{className:`font-medium text-sm`,children:e}),t&&(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t,`)`]}),!c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,J.jsx)(`button`,{className:X(`p-1.5 rounded hover:bg-accent`,!p.canUndo&&`opacity-40 pointer-events-none`),title:Z.undoShortcut,"aria-label":Z.undo,disabled:!p.canUndo,onClick:()=>p.undo(),children:(0,J.jsx)(xe,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:X(`p-1.5 rounded hover:bg-accent`,!p.canRedo&&`opacity-40 pointer-events-none`),title:Z.redoShortcut,"aria-label":Z.redo,disabled:!p.canRedo,onClick:()=>p.redo(),children:(0,J.jsx)(A,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{className:X(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:Z.copyShortcut,"aria-label":Z.copy,disabled:g.count===0,onClick:ee,children:(0,J.jsx)(v,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{className:X(`p-1.5 rounded hover:bg-accent`,!y.hasContent&&`opacity-40 pointer-events-none`),title:Z.pasteShortcut,"aria-label":Z.paste,disabled:!y.hasContent,onClick:B,children:(0,J.jsx)(x,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,J.jsx)(`button`,{className:X(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:Z.deleteSelected,"aria-label":Z.deleteSelected,disabled:g.count===0,onClick:R,children:(0,J.jsx)(H,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`flex-1`}),C?.isConnected&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),Z.collaborationConnected,C.users.length>1&&` (${C.users.length})`]}),(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` `,r]}),s&&(0,J.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:T?Z.collapsePanel:Z.expandPanel,"aria-label":T?Z.collapsePanel:Z.expandPanel,onClick:()=>E(e=>!e),children:(0,J.jsx)(b,{className:X(`h-4 w-4`,!T&&`rotate-180`)})})]}),(0,J.jsx)(`div`,{role:`region`,"aria-label":Z.reportCanvas,className:`flex-1 overflow-auto bg-muted/10 p-4 flex justify-center`,children:(0,J.jsx)(`div`,{className:`bg-white shadow-lg border`,style:{width:M,minHeight:N},children:m.map((e,t)=>(0,J.jsxs)(`div`,{className:`relative border-b border-dashed border-gray-300`,style:{minHeight:e.height},onDragOver:V,onDrop:e=>re(e,t),children:[(0,J.jsxs)(`div`,{className:`absolute left-0 top-0 px-2 py-0.5 bg-muted text-xs text-muted-foreground border-r border-b rounded-br`,children:[P(e.type),e.repeat&&` ↻`]}),!c&&(0,J.jsxs)(`div`,{className:`absolute right-1 top-0 flex items-center gap-0.5`,children:[(0,J.jsx)(`button`,{onClick:()=>I(t,`text`),className:`p-0.5 rounded hover:bg-accent`,title:Z.addText,"aria-label":Z.addText,children:(0,J.jsx)(ne,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:()=>I(t,`field`),className:`p-0.5 rounded hover:bg-accent`,title:Z.addField,"aria-label":Z.addField,children:(0,J.jsx)(d,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:()=>I(t,`image`),className:`p-0.5 rounded hover:bg-accent`,title:Z.addImage,"aria-label":Z.addImage,children:(0,J.jsx)(f,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:()=>I(t,`chart`),className:`p-0.5 rounded hover:bg-accent`,title:Z.addChart,"aria-label":Z.addChart,children:(0,J.jsx)(ge,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{onClick:()=>I(t,`table`),className:`p-0.5 rounded hover:bg-accent`,title:Z.addTable,"aria-label":Z.addTable,children:(0,J.jsx)(oe,{className:`h-3 w-3`})})]}),(0,J.jsxs)(`div`,{className:`relative`,style:{minHeight:e.height,paddingTop:24},children:[e.elements.length===0&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground text-center pt-4`,children:Z.addElementsPrompt}),e.elements.map(e=>{let n=g.isSelected(e.id);return(0,J.jsxs)(`div`,{draggable:!c,onDragStart:n=>te(n,e,t),className:X(`absolute border rounded px-2 py-1 text-xs cursor-pointer`,n?`border-primary ring-1 ring-primary/30 bg-primary/5`:`border-dashed border-gray-400 hover:border-primary/50`),style:{left:e.position.x,top:(typeof e.position.y==`number`?e.position.y:0)+24,width:e.position.width,height:e.position.height},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.type===`text`&&(e.properties.text??Z.elementText),e.type===`field`&&`{${e.properties.field??`field`}}`,e.type===`image`&&Z.elementImage,e.type===`chart`&&Z.elementChart,e.type===`table`&&Z.elementTable]}),!c&&n&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),L(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":Z.deleteElement,children:(0,J.jsx)(H,{className:`h-2.5 w-2.5`})})]},e.id)})]})]},`${e.type}-${t}`))})})]}),s&&(0,J.jsx)(`div`,{role:`region`,"aria-label":Z.propertiesPanel,className:X(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,T?`w-56`:`w-0 overflow-hidden`),children:T&&(_&&F?(0,J.jsx)(Ie,{title:`${Z.properties} – ${F.type}`,fields:U,onChange:z}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:Z.properties}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:Z.selectElementPrompt})})]}))}),(0,J.jsx)(Pe,{isOpen:S.isOpen,title:S.title,message:S.message,onConfirm:S.onConfirm,onCancel:S.onCancel})]})}var rt={"appDesigner.basicInfo":`Basic Info`,"appDesigner.objects":`Objects`,"appDesigner.navigation":`Navigation`,"appDesigner.branding":`Branding`,"appDesigner.stepBasicDesc":`Name, title, and layout`,"appDesigner.stepObjectsDesc":`Select business objects`,"appDesigner.stepNavigationDesc":`Build navigation tree`,"appDesigner.stepBrandingDesc":`Logo, colors, and favicon`,"appDesigner.appName":`App Name`,"appDesigner.appTitle":`Title`,"appDesigner.appDescription":`Description`,"appDesigner.appIcon":`Icon`,"appDesigner.template":`Template`,"appDesigner.layout":`Layout`,"appDesigner.layoutSidebar":`Sidebar`,"appDesigner.layoutHeader":`Header`,"appDesigner.layoutEmpty":`Empty`,"appDesigner.snakeCaseHint":`Must be snake_case (e.g. my_app)`,"appDesigner.searchObjects":`Search objects…`,"appDesigner.selectAll":`Select All`,"appDesigner.deselectAll":`Deselect All`,"appDesigner.noObjectsFound":`No objects found.`,"appDesigner.addGroup":`Add Group`,"appDesigner.addUrl":`Add URL`,"appDesigner.addSeparator":`Add Separator`,"appDesigner.noNavItemsHint":`No navigation items yet. Select objects in the previous step or add items manually.`,"appDesigner.separatorLabel":`— Separator —`,"appDesigner.newGroup":`New Group`,"appDesigner.newLink":`New Link`,"appDesigner.logoUrl":`Logo URL`,"appDesigner.primaryColor":`Primary Color`,"appDesigner.faviconUrl":`Favicon URL`,"appDesigner.preview":`Preview`,"common.cancel":`Cancel`,"common.back":`Back`,"common.next":`Next`,"common.close":`Close`,"appDesigner.complete":`Complete`,"appDesigner.saveDraft":`Save Draft`,"appDesigner.cancelConfirmTitle":`Discard changes?`,"appDesigner.cancelConfirmMessage":`You have unsaved changes. Are you sure you want to cancel?`,"appDesigner.confirmDiscard":`Discard`,"appDesigner.keepEditing":`Keep Editing`,"appDesigner.navNoItems":`No navigation items. Click buttons above to add items.`,"appDesigner.navNoPreviewItems":`No items`,"appDesigner.navLivePreview":`Live Preview`,"appDesigner.navCollapseGroup":`Collapse group`,"appDesigner.navExpandGroup":`Expand group`,"appDesigner.navAddChild":`Add child`,"appDesigner.navMoveUp":`Move up`,"appDesigner.navMoveDown":`Move down`,"appDesigner.navRemove":`Remove`,"appDesigner.navObjectPage":`Object Page`,"appDesigner.navDashboard":`Dashboard`,"appDesigner.navPage":`Page`,"appDesigner.navReport":`Report`,"appDesigner.navGroup":`Group`,"appDesigner.navUrl":`URL`,"appDesigner.navSeparator":`Separator`,"appDesigner.navTypeObject":`Object`,"appDesigner.navTypeDashboard":`Dashboard`,"appDesigner.navTypePage":`Page`,"appDesigner.navTypeReport":`Report`,"appDesigner.navTypeUrl":`URL`,"appDesigner.navTypeGroup":`Group`,"appDesigner.navTypeSeparator":`Separator`,"appDesigner.navTypeAction":`Action`,"appDesigner.navEditIcon":`Edit icon`,"appDesigner.navToggleVisible":`Toggle visibility`,"appDesigner.navHidden":`Hidden`,"appDesigner.navExportSchema":`Export JSON`,"appDesigner.navImportSchema":`Import JSON`,"appDesigner.navExportSuccess":`Navigation schema exported`,"appDesigner.navImportSuccess":`Navigation schema imported`,"appDesigner.navImportError":`Invalid navigation JSON`,"appDesigner.navIconPlaceholder":`Icon name (e.g. Users)`,"appDesigner.dashboardEditor":`Dashboard Editor`,"appDesigner.noWidgets":`No widgets. Click a button above to add one.`,"appDesigner.widgetLayoutSize":`Layout Size`,"appDesigner.widgetWidth":`Width`,"appDesigner.widgetHeight":`Height`,"appDesigner.dashboardPreview":`Dashboard Preview`,"appDesigner.noWidgetsPreview":`No widgets to preview`,"appDesigner.pageCanvasEditor":`Page Canvas Editor`,"appDesigner.emptyPage":`Empty page. Click a button above to add a component.`,"appDesigner.pagePreview":`Page Preview`,"appDesigner.noComponentsPreview":`No components to preview`,"appDesigner.modePage":`Page`,"appDesigner.modeDashboard":`Dashboard`,"appDesigner.undo":`Undo`,"appDesigner.redo":`Redo`,"appDesigner.brandingEditor":`Branding Editor`,"appDesigner.brandingExport":`Export JSON`,"appDesigner.brandingImport":`Import JSON`,"appDesigner.brandingPreview":`Preview`,"appDesigner.brandingSampleButton":`Sample Button`,"appDesigner.brandingSampleText":`This is how your brand theme will look.`,"appDesigner.colorPalette":`Color Palette`,"appDesigner.fontFamily":`Font Family`,"appDesigner.fontDefault":`Default (System)`,"appDesigner.modeLight":`Light`,"appDesigner.modeDark":`Dark`,"appDesigner.mobilePreview":`Mobile Preview`};function it(e){return(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}function at(){try{let e=De();return e.t(`appDesigner.basicInfo`)===`appDesigner.basicInfo`?{t:it(rt)}:{t:e.t}}catch{return{t:it(rt)}}}function Q(...e){return K(j(e))}var ot={name:``,title:``,description:``,icon:``,template:``,layout:`sidebar`,objects:[],navigation:[],branding:{logo:``,primaryColor:`#3b82f6`,favicon:``}};function st(e){return e.filter(e=>e.selected).map(e=>({id:e.name,type:`object`,label:e.label,icon:e.icon,objectName:e.name}))}var ct=0;function lt(e){return ct+=1,`${e}_${Date.now()}_${ct}`}function ut({steps:e,currentIndex:t,onStepClick:n}){return(0,J.jsx)(`nav`,{className:`flex items-center justify-center gap-0 px-4 py-6`,children:e.map((e,r)=>{let i=r<t,a=r===t;return(0,J.jsxs)(q.Fragment,{children:[r>0&&(0,J.jsx)(`div`,{className:Q(`h-0.5 w-12 sm:w-20`,i?`bg-blue-500`:`bg-gray-200`)}),(0,J.jsxs)(`button`,{type:`button`,"data-testid":`wizard-step-${e.id}`,onClick:()=>n(r),className:Q(`flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1`,a&&`cursor-default`,!a&&`cursor-pointer`),children:[(0,J.jsx)(`div`,{className:Q(`flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors`,i&&`bg-blue-500 text-white`,a&&`bg-blue-600 text-white ring-2 ring-blue-300`,!i&&!a&&`bg-gray-200 text-gray-500`),children:i?(0,J.jsx)(me,{className:`h-4 w-4`}):r+1}),(0,J.jsx)(`span`,{className:Q(`text-xs font-medium`,a?`text-blue-600`:`text-gray-500`),children:e.label})]})]},e.id)})})}function dt({draft:e,templates:t,readOnly:n,onChange:i,t:a}){let o=e.name.length>0&&!r(e.name);return(0,J.jsxs)(`div`,{"data-testid":`wizard-step-basic-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{htmlFor:`app-name`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appName`),` `,(0,J.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,J.jsx)(`input`,{id:`app-name`,"data-testid":`app-name-input`,type:`text`,value:e.name,onChange:e=>i({name:e.target.value}),placeholder:`my_app`,disabled:n,className:Q(`block w-full rounded-md border px-3 py-2 text-sm shadow-sm outline-none transition-colors`,`focus:border-blue-500 focus:ring-1 focus:ring-blue-500`,`disabled:cursor-not-allowed disabled:bg-gray-50`,o?`border-red-400`:`border-gray-300`)}),o&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:a(`appDesigner.snakeCaseHint`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{htmlFor:`app-title`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appTitle`),` `,(0,J.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,J.jsx)(`input`,{id:`app-title`,"data-testid":`app-title-input`,type:`text`,value:e.title,onChange:e=>i({title:e.target.value}),placeholder:`My Application`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`app-description`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appDescription`)}),(0,J.jsx)(`textarea`,{id:`app-description`,"data-testid":`app-description-input`,value:e.description??``,onChange:e=>i({description:e.target.value}),rows:3,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 resize-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`app-icon`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appIcon`)}),(0,J.jsx)(`input`,{id:`app-icon`,type:`text`,value:e.icon??``,onChange:e=>i({icon:e.target.value}),placeholder:`LayoutDashboard`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),t.length>0&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`app-template`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.template`)}),(0,J.jsxs)(`select`,{id:`app-template`,value:e.template??``,onChange:e=>i({template:e.target.value}),disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`,children:[(0,J.jsx)(`option`,{value:``,children:`None`}),t.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium text-gray-700`,children:a(`appDesigner.layout`)}),(0,J.jsx)(`div`,{className:`flex gap-3`,children:[{value:`sidebar`,labelKey:`appDesigner.layoutSidebar`,Icon:I},{value:`header`,labelKey:`appDesigner.layoutHeader`,Icon:S},{value:`empty`,labelKey:`appDesigner.layoutEmpty`,Icon:pe}].map(({value:t,labelKey:r,Icon:o})=>(0,J.jsxs)(`label`,{"data-testid":`app-layout-${t}`,className:Q(`flex flex-1 cursor-pointer flex-col items-center gap-1.5 rounded-lg border-2 p-3 transition-colors`,e.layout===t?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,n&&`pointer-events-none opacity-60`),children:[(0,J.jsx)(o,{className:`h-5 w-5 text-gray-600`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-gray-700`,children:a(r)}),(0,J.jsx)(`input`,{type:`radio`,name:`layout`,value:t,checked:e.layout===t,onChange:()=>i({layout:t}),disabled:n,className:`sr-only`})]},t))})]})]})}function ft({objects:e,readOnly:t,onToggle:n,onToggleAll:r,search:i,onSearchChange:a,t:o}){let s=(0,q.useMemo)(()=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.label.toLowerCase().includes(t))},[e,i]),c=e.length>0&&e.every(e=>e.selected);return e.every(e=>!e.selected),(0,J.jsxs)(`div`,{"data-testid":`wizard-step-objects-content`,className:`mx-auto max-w-2xl space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(w,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{"data-testid":`object-search`,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:o(`appDesigner.searchObjects`),className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(!c),disabled:t,className:`rounded-md border border-gray-300 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:o(c?`appDesigner.deselectAll`:`appDesigner.selectAll`)})]}),s.length===0?(0,J.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:o(`appDesigner.noObjectsFound`)}):(0,J.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:s.map(e=>(0,J.jsxs)(`button`,{type:`button`,"data-testid":`object-card-${e.name}`,disabled:t,onClick:()=>n(e.name),className:Q(`flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors`,e.selected?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,t&&`pointer-events-none opacity-60`),children:[(0,J.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,J.jsx)(`div`,{className:Q(`flex h-5 w-5 items-center justify-center rounded border transition-colors`,e.selected?`border-blue-500 bg-blue-500 text-white`:`border-gray-300`),children:e.selected&&(0,J.jsx)(me,{className:`h-3 w-3`})})]}),(0,J.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.name}),e.icon&&(0,J.jsx)(`span`,{className:`text-xs text-gray-400`,children:e.icon})]},e.name))})]})}var pt={object:`bg-green-100 text-green-700`,group:`bg-purple-100 text-purple-700`,url:`bg-sky-100 text-sky-700`,separator:`bg-gray-100 text-gray-600`,dashboard:`bg-amber-100 text-amber-700`,page:`bg-teal-100 text-teal-700`,report:`bg-rose-100 text-rose-700`,action:`bg-orange-100 text-orange-700`};function mt({items:e,readOnly:t,onAdd:n,onRemove:r,onReorder:i,t:o}){return(0,J.jsxs)(`div`,{"data-testid":`wizard-step-navigation-content`,className:`mx-auto max-w-lg space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,"data-testid":`add-group-btn`,onClick:()=>n(`group`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(T,{className:`h-3.5 w-3.5`}),o(`appDesigner.addGroup`)]}),(0,J.jsxs)(`button`,{type:`button`,"data-testid":`add-url-btn`,onClick:()=>n(`url`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(ie,{className:`h-3.5 w-3.5`}),o(`appDesigner.addUrl`)]}),(0,J.jsxs)(`button`,{type:`button`,"data-testid":`add-separator-btn`,onClick:()=>n(`separator`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(ye,{className:`h-3.5 w-3.5`}),o(`appDesigner.addSeparator`)]})]}),e.length===0?(0,J.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:o(`appDesigner.noNavItemsHint`)}):(0,J.jsx)(`ul`,{className:`space-y-1.5`,children:e.map((n,s)=>(0,J.jsxs)(`li`,{"data-testid":`nav-item-${n.id}`,className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2`,children:[n.icon&&(0,J.jsx)(`span`,{className:`text-xs text-gray-400`,children:n.icon}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-sm text-gray-800`,children:n.type===`separator`?o(`appDesigner.separatorLabel`):a(n.label)}),(0,J.jsx)(`span`,{className:Q(`rounded-full px-2 py-0.5 text-[10px] font-medium`,pt[n.type]??`bg-gray-100 text-gray-600`),children:n.type}),(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(n.id,`up`),disabled:t||s===0,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,J.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(n.id,`down`),disabled:t||s===e.length-1,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,J.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(n.id),disabled:t,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30`,"aria-label":`Remove`,children:(0,J.jsx)(H,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function ht({branding:e,title:t,readOnly:n,onChange:r,t:i}){return(0,J.jsxs)(`div`,{"data-testid":`wizard-step-branding-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`branding-logo`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.logoUrl`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(f,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`branding-logo`,"data-testid":`branding-logo-input`,type:`text`,value:e.logo??``,onChange:e=>r({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`branding-color`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.primaryColor`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(L,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`branding-color`,"data-testid":`branding-color-input`,type:`text`,value:e.primaryColor??`#3b82f6`,onChange:e=>r({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`branding-favicon`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.faviconUrl`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(de,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`branding-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:e.favicon??``,onChange:e=>r({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`span`,{className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.preview`)}),(0,J.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.logo?(0,J.jsx)(`img`,{src:e.logo,alt:`App logo`,className:`h-8 w-8 rounded object-contain`}):(0,J.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400`,children:`Logo`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:t||i(`appDesigner.appTitle`)})]}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:e.primaryColor||`#3b82f6`}}),(0,J.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.primaryColor||`#3b82f6`})]}),e.favicon&&(0,J.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,J.jsx)(`img`,{src:e.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-500`,children:`Favicon`})]})]})]})]})}function gt({availableObjects:e=[],templates:t=[],initialDraft:n,onComplete:i,onCancel:a,onSaveDraft:s,readOnly:c=!1,className:l}){let{t:u}=at(),d=ke(),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(()=>({...ot,objects:e.map(e=>({...e})),...n})),v=(0,q.useMemo)(()=>[{id:`basic`,label:u(`appDesigner.basicInfo`),description:u(`appDesigner.stepBasicDesc`),icon:`Settings`},{id:`objects`,label:u(`appDesigner.objects`),description:u(`appDesigner.stepObjectsDesc`),icon:`Database`},{id:`navigation`,label:u(`appDesigner.navigation`),description:u(`appDesigner.stepNavigationDesc`),icon:`Menu`},{id:`branding`,label:u(`appDesigner.branding`),description:u(`appDesigner.stepBrandingDesc`),icon:`Palette`}],[u]),y=f===0,b=f===v.length-1,x=(0,q.useMemo)(()=>g.name.length>0&&r(g.name)&&g.title.trim().length>0,[g.name,g.title]),S=(0,q.useMemo)(()=>f===0?x:!0,[f,x]),C=(0,q.useCallback)(e=>{_(t=>({...t,...e}))},[]),w=(0,q.useCallback)(e=>{_(t=>({...t,branding:{...t.branding,...e}}))},[]),T=(0,q.useCallback)(e=>{_(t=>({...t,objects:t.objects.map(t=>t.name===e?{...t,selected:!t.selected}:t)}))},[]),E=(0,q.useCallback)(e=>{_(t=>({...t,objects:t.objects.map(t=>({...t,selected:e}))}))},[]),D=(0,q.useCallback)(e=>{let t={id:lt(e),type:e,label:e===`separator`?``:e===`group`?`New Group`:`New Link`,...e===`group`?{children:[]}:{},...e===`url`?{url:``}:{}};_(e=>({...e,navigation:[...e.navigation,t]}))},[]),O=(0,q.useCallback)(e=>{_(t=>({...t,navigation:t.navigation.filter(t=>t.id!==e)}))},[]),k=(0,q.useCallback)((e,t)=>{_(n=>{let r=[...n.navigation],i=r.findIndex(t=>t.id===e);if(i<0)return n;let a=t===`up`?i-1:i+1;return a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,navigation:r})})},[]),A=(0,q.useCallback)(()=>{b||(f===1&&_(e=>({...e,navigation:st(e.objects)})),p(e=>e+1))},[f,b]),j=(0,q.useCallback)(()=>{y||p(e=>e-1)},[y]),M=(0,q.useCallback)(()=>{i?.(g)},[g,i]),N=(0,q.useCallback)(async()=>{(g.name.length>0||g.title.length>0)&&a?await d.confirm(u(`appDesigner.cancelConfirmTitle`),u(`appDesigner.cancelConfirmMessage`))&&a():a?.()},[g.name,g.title,a,d,u]),P=(0,q.useCallback)(()=>{s?.(g)},[g,s]),F=(0,q.useCallback)(e=>{e<=f?p(e):e===f+1&&S&&(f===1&&e===2&&_(e=>({...e,navigation:st(e.objects)})),p(e))},[f,S]);return(0,J.jsxs)(`div`,{className:Q(`flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm`,l),children:[d.isOpen&&(0,J.jsx)(`div`,{"data-testid":`cancel-confirm-dialog`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,"aria-modal":`true`,children:(0,J.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,J.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:d.title}),(0,J.jsx)(`button`,{type:`button`,onClick:d.onCancel,className:`rounded p-1 text-gray-400 hover:text-gray-600`,"aria-label":u(`common.close`),children:(0,J.jsx)(Ce,{className:`h-4 w-4`})})]}),(0,J.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:d.message}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-keep`,onClick:d.onCancel,className:`rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50`,children:u(`appDesigner.keepEditing`)}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-discard`,onClick:d.onConfirm,className:`rounded-md bg-red-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-red-700`,children:u(`appDesigner.confirmDiscard`)})]})]})}),(0,J.jsx)(`div`,{className:`border-b border-gray-100`,children:(0,J.jsx)(ut,{steps:v,currentIndex:f,onStepClick:F})}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[f===0&&(0,J.jsx)(dt,{draft:g,templates:t,readOnly:c,onChange:C,t:u}),f===1&&(0,J.jsx)(ft,{objects:g.objects,readOnly:c,onToggle:T,onToggleAll:E,search:m,onSearchChange:h,t:u}),f===2&&(0,J.jsx)(mt,{items:g.navigation,readOnly:c,onAdd:D,onRemove:O,onReorder:k,t:u}),f===3&&(0,J.jsx)(ht,{branding:g.branding,title:g.title,readOnly:c,onChange:w,t:u})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,"data-testid":`wizard-cancel`,onClick:N,disabled:c,className:`rounded-md px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50`,children:u(`common.cancel`)}),s&&(0,J.jsx)(`button`,{type:`button`,"data-testid":`wizard-save-draft`,onClick:P,disabled:c,className:`rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:u(`appDesigner.saveDraft`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!y&&(0,J.jsxs)(`button`,{type:`button`,"data-testid":`wizard-back`,onClick:j,disabled:c,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(U,{className:`h-4 w-4`}),u(`common.back`)]}),b?(0,J.jsxs)(`button`,{type:`button`,"data-testid":`wizard-complete`,onClick:M,disabled:c||!S,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(me,{className:`h-4 w-4`}),u(`appDesigner.complete`)]}):(0,J.jsxs)(`button`,{type:`button`,"data-testid":`wizard-next`,onClick:A,disabled:c||!S,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[u(`common.next`),(0,J.jsx)(o,{className:`h-4 w-4`})]})]})]})]})}function _t(...e){return K(j(e))}var vt=0;function yt(e){return vt+=1,`${e}_${Date.now()}_${vt}`}var bt={object:{labelKey:`appDesigner.navTypeObject`,color:`bg-green-100 text-green-700`,Icon:N},dashboard:{labelKey:`appDesigner.navTypeDashboard`,color:`bg-amber-100 text-amber-700`,Icon:se},page:{labelKey:`appDesigner.navTypePage`,color:`bg-teal-100 text-teal-700`,Icon:D},report:{labelKey:`appDesigner.navTypeReport`,color:`bg-rose-100 text-rose-700`,Icon:ge},url:{labelKey:`appDesigner.navTypeUrl`,color:`bg-sky-100 text-sky-700`,Icon:ie},group:{labelKey:`appDesigner.navTypeGroup`,color:`bg-purple-100 text-purple-700`,Icon:T},separator:{labelKey:`appDesigner.navTypeSeparator`,color:`bg-gray-100 text-gray-600`,Icon:ye},action:{labelKey:`appDesigner.navTypeAction`,color:`bg-orange-100 text-orange-700`,Icon:re}},xt=[{type:`object`,labelKey:`appDesigner.navObjectPage`},{type:`dashboard`,labelKey:`appDesigner.navDashboard`},{type:`page`,labelKey:`appDesigner.navPage`},{type:`report`,labelKey:`appDesigner.navReport`},{type:`group`,labelKey:`appDesigner.navGroup`},{type:`url`,labelKey:`appDesigner.navUrl`},{type:`separator`,labelKey:`appDesigner.navSeparator`}];function St({item:e,depth:t,index:n,total:r,readOnly:i,onRemove:s,onMoveUp:c,onMoveDown:l,onToggleExpand:u,onUpdateLabel:f,onUpdateIcon:h,onToggleVisible:g,onAddChild:v,expandedIds:b,t:x}){let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(a(e.label)??``),[E,D]=(0,q.useState)(!1),[k,A]=(0,q.useState)(e.icon||``),j=bt[e.type];e.type===`group`&&e.children&&e.children.length;let M=b.has(e.id),N=e.visible===!1,P=()=>{w.trim()?f(e.id,w.trim()):T(a(e.label)??``),C(!1)},F=()=>{h(e.id,k.trim()),D(!1)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`li`,{"data-testid":`nav-designer-item-${e.id}`,className:_t(`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50`,N&&`opacity-50`),style:{marginLeft:t*20},children:[(0,J.jsx)(p,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300`}),e.type===`group`?(0,J.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":x(M?`appDesigner.navCollapseGroup`:`appDesigner.navExpandGroup`),children:M?(0,J.jsx)(G,{className:`h-3.5 w-3.5`}):(0,J.jsx)(o,{className:`h-3.5 w-3.5`})}):(0,J.jsx)(`span`,{className:`w-5`}),E&&!i?(0,J.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),onBlur:F,onKeyDown:t=>{t.key===`Enter`&&F(),t.key===`Escape`&&(A(e.icon||``),D(!1))},autoFocus:!0,placeholder:x(`appDesigner.navIconPlaceholder`),"data-testid":`nav-designer-icon-input-${e.id}`,className:`w-24 rounded border border-blue-300 px-1 py-0.5 text-xs outline-none focus:ring-1 focus:ring-blue-400`}):(0,J.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,J.jsx)(j.Icon,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}),!i&&e.type!==`separator`&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>{A(e.icon||``),D(!0)},className:`rounded p-0.5 text-gray-300 hover:text-blue-500`,"aria-label":x(`appDesigner.navEditIcon`),"data-testid":`nav-designer-edit-icon-${e.id}`,children:(0,J.jsx)(_,{className:`h-2.5 w-2.5`})})]}),e.type===`separator`?(0,J.jsx)(`span`,{className:`flex-1 text-xs italic text-gray-400`,children:x(`appDesigner.separatorLabel`)}):S&&!i?(0,J.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),onBlur:P,onKeyDown:t=>{t.key===`Enter`&&P(),t.key===`Escape`&&(T(a(e.label)??``),C(!1))},autoFocus:!0,className:`flex-1 rounded border border-blue-300 px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-blue-400`}):(0,J.jsx)(`span`,{className:_t(`flex-1 truncate text-sm text-gray-800`,!i&&`cursor-text`),onDoubleClick:()=>{!i&&e.type!==`separator`&&(T(a(e.label)??``),C(!0))},children:a(e.label)}),(0,J.jsx)(`span`,{className:_t(`rounded-full px-2 py-0.5 text-[10px] font-medium`,j.color),children:x(j.labelKey)}),N&&(0,J.jsx)(`span`,{className:`rounded-full bg-gray-200 px-1.5 py-0.5 text-[10px] font-medium text-gray-500`,"data-testid":`nav-designer-hidden-badge-${e.id}`,children:x(`appDesigner.navHidden`)}),!i&&e.type!==`separator`&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>g(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-700`,"aria-label":x(`appDesigner.navToggleVisible`),"data-testid":`nav-designer-toggle-visible-${e.id}`,children:N?(0,J.jsx)(y,{className:`h-3.5 w-3.5`}):(0,J.jsx)(m,{className:`h-3.5 w-3.5`})}),e.type===`group`&&!i&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>v(e.id,`page`),className:`rounded p-0.5 text-gray-400 hover:text-blue-500`,"aria-label":x(`appDesigner.navAddChild`),"data-testid":`nav-designer-add-child-${e.id}`,children:(0,J.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:i||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":x(`appDesigner.navMoveUp`),children:(0,J.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:i||n===r-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":x(`appDesigner.navMoveDown`),children:(0,J.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),disabled:i,className:`rounded p-0.5 text-gray-400 hover:text-red-500 disabled:opacity-30`,"aria-label":x(`appDesigner.navRemove`),"data-testid":`nav-designer-remove-${e.id}`,children:(0,J.jsx)(H,{className:`h-3.5 w-3.5`})})]}),e.type===`group`&&M&&e.children&&(0,J.jsx)(J.Fragment,{children:e.children.map((n,r)=>(0,J.jsx)(St,{item:n,depth:t+1,index:r,total:e.children.length,readOnly:i,onRemove:s,onMoveUp:c,onMoveDown:l,onToggleExpand:u,onUpdateLabel:f,onUpdateIcon:h,onToggleVisible:g,onAddChild:v,expandedIds:b,t:x},n.id))})]})}function Ct({items:e,t}){return(0,J.jsxs)(`div`,{"data-testid":`nav-designer-preview`,className:`w-56 shrink-0 rounded-lg border border-gray-200 bg-gray-50 p-3`,children:[(0,J.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase text-gray-500`,children:t(`appDesigner.navLivePreview`)}),e.length===0?(0,J.jsx)(`p`,{className:`text-xs text-gray-400`,children:t(`appDesigner.navNoPreviewItems`)}):(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:e.map(e=>(0,J.jsx)(wt,{item:e,depth:0},e.id))})]})}function wt({item:e,depth:t}){let n=bt[e.type];return e.type===`separator`?(0,J.jsx)(`li`,{className:`my-1 border-t border-gray-200`,style:{marginLeft:t*12}}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded px-2 py-1 text-xs text-gray-700 hover:bg-gray-100`,style:{marginLeft:t*12},children:[(0,J.jsx)(n.Icon,{className:`h-3 w-3 text-gray-400`}),(0,J.jsx)(`span`,{className:`truncate`,children:a(e.label)})]}),e.type===`group`&&e.children?.map(e=>(0,J.jsx)(wt,{item:e,depth:t+1},e.id))]})}function Tt({items:e,onChange:t,readOnly:n=!1,showPreview:r=!0,className:i,onExport:a,onImport:o}){let{t:s}=at(),c=(0,q.useRef)(null),[l,u]=(0,q.useState)(()=>new Set(e.filter(e=>e.type===`group`).map(e=>e.id))),f=(0,q.useCallback)(n=>{function r(e){return e.filter(e=>e.id!==n).map(e=>e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),p=(0,q.useCallback)((n,r)=>{function i(e){let t=e.findIndex(e=>e.id===n);if(t>=0){let n=r===`up`?t-1:t+1;if(n>=0&&n<e.length){let r=[...e];return[r[t],r[n]]=[r[n],r[t]],r}return e}return e.map(e=>e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),m=(0,q.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,label:r}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),h=(0,q.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,icon:r||void 0}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),g=(0,q.useCallback)(n=>{function r(e){return e.map(e=>e.id===n?{...e,visible:e.visible===!1}:e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),_=(0,q.useCallback)((n,r)=>{let i={id:yt(r),type:r,label:r===`separator`?``:`New ${s(bt[r].labelKey)}`,...r===`group`?{children:[]}:{},...r===`url`?{url:``}:{}};function a(e){return e.map(e=>e.id===n&&e.type===`group`?{...e,children:[...e.children||[],i]}:e.children?{...e,children:a(e.children)}:e)}t(a(e)),u(e=>new Set(e).add(n))},[e,t]),v=(0,q.useCallback)(n=>{let r={id:yt(n),type:n,label:n===`separator`?``:`New ${s(bt[n].labelKey)}`,...n===`group`?{children:[]}:{},...n===`url`?{url:``}:{}};t([...e,r])},[e,t,s]),y=(0,q.useCallback)(e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),b=(0,q.useCallback)(()=>{if(a)a(e);else{let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`navigation-schema.json`,i.click(),URL.revokeObjectURL(r)}},[e,a]),x=(0,q.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);Array.isArray(n)&&(o?o(n):t(n))}catch{}},r.readAsText(n),c.current&&(c.current.value=``)},[t,o]);return(0,J.jsxs)(`div`,{"data-testid":`navigation-designer`,className:_t(`flex flex-col gap-4 sm:flex-row`,i),children:[(0,J.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[xt.map(({type:e,labelKey:t})=>{let{Icon:r,color:i}=bt[e];return(0,J.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-add-${e}`,onClick:()=>v(e),disabled:n,className:_t(`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,J.jsx)(d,{className:`h-3 w-3`}),s(t)]},e)}),(0,J.jsx)(`span`,{className:`mx-1 hidden h-4 w-px bg-gray-200 sm:block`}),(0,J.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-export`,onClick:b,className:`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50`,children:[(0,J.jsx)(Ee,{className:`h-3 w-3`}),s(`appDesigner.navExportSchema`)]}),(0,J.jsxs)(`label`,{"data-testid":`nav-designer-import`,className:_t(`inline-flex cursor-pointer items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50`,n&&`cursor-not-allowed opacity-50`),children:[(0,J.jsx)(W,{className:`h-3 w-3`}),s(`appDesigner.navImportSchema`),(0,J.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,onChange:x,disabled:n,"data-testid":`nav-designer-import-input`})]})]}),e.length===0?(0,J.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-400`,children:s(`appDesigner.navNoItems`)}):(0,J.jsx)(`ul`,{className:`space-y-1`,"data-testid":`nav-designer-tree`,children:e.map((t,r)=>(0,J.jsx)(St,{item:t,depth:0,index:r,total:e.length,readOnly:n,onRemove:f,onMoveUp:e=>p(e,`up`),onMoveDown:e=>p(e,`down`),onToggleExpand:y,onUpdateLabel:m,onUpdateIcon:h,onToggleVisible:g,onAddChild:_,expandedIds:l,t:s},t.id))})]}),r&&(0,J.jsx)(Ct,{items:e,t:s})]})}function Et(...e){return K(j(e))}var Dt=[{type:`metric`,label:`KPI Metric`,Icon:we},{type:`bar`,label:`Bar Chart`,Icon:ge},{type:`line`,label:`Line Chart`,Icon:B},{type:`pie`,label:`Pie Chart`,Icon:be},{type:`table`,label:`Table`,Icon:oe},{type:`grid`,label:`Grid`,Icon:ae}],Ot=0;function kt(){return Ot+=1,`widget_${Date.now()}_${Ot}`}function At({widget:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=e.type||`metric`,u=Dt.find(e=>e.type===l)||Dt[0];return(0,J.jsxs)(`div`,{"data-testid":`dashboard-widget-${e.id}`,onClick:a,className:Et(`group cursor-pointer rounded-lg border-2 p-3 transition-colors`,r?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`),children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(p,{className:`h-4 w-4 text-gray-300`}),(0,J.jsx)(u.Icon,{className:`h-4 w-4 text-gray-500`}),(0,J.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.title||`Widget ${t+1}`})]}),!i&&(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,J.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,J.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove widget`,"data-testid":`dashboard-widget-remove-${e.id}`,children:(0,J.jsx)(H,{className:`h-3.5 w-3.5`})})]})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:u.label}),e.object&&(0,J.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:e.object})]})]})}function jt({widget:e,readOnly:t,onChange:n,onClose:r}){let{t:i}=at();return(0,J.jsxs)(`div`,{"data-testid":`widget-property-panel`,className:`shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:i(`appDesigner.widgetProperties`)}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,J.jsx)(Ce,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-title`,className:`text-xs font-medium text-gray-600`,children:`Title`}),(0,J.jsx)(`input`,{id:`widget-title`,"data-testid":`widget-prop-title`,type:`text`,value:e.title??``,onChange:e=>n({title:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-type`,className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,J.jsx)(`select`,{id:`widget-type`,"data-testid":`widget-prop-type`,value:e.type??`metric`,onChange:e=>n({type:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:Dt.map(e=>(0,J.jsx)(`option`,{value:e.type,children:e.label},e.type))})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-object`,className:`text-xs font-medium text-gray-600`,children:`Data Source (Object)`}),(0,J.jsx)(`input`,{id:`widget-object`,"data-testid":`widget-prop-object`,type:`text`,value:e.object??``,onChange:e=>n({object:e.target.value}),disabled:t,placeholder:`e.g. orders`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-value-field`,className:`text-xs font-medium text-gray-600`,children:`Value Field`}),(0,J.jsx)(`input`,{id:`widget-value-field`,"data-testid":`widget-prop-value-field`,type:`text`,value:e.valueField??``,onChange:e=>n({valueField:e.target.value}),disabled:t,placeholder:`e.g. amount`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-aggregate`,className:`text-xs font-medium text-gray-600`,children:`Aggregate`}),(0,J.jsxs)(`select`,{id:`widget-aggregate`,"data-testid":`widget-prop-aggregate`,value:e.aggregate??`count`,onChange:e=>n({aggregate:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,J.jsx)(`option`,{value:`count`,children:`Count`}),(0,J.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,J.jsx)(`option`,{value:`avg`,children:`Average`}),(0,J.jsx)(`option`,{value:`min`,children:`Min`}),(0,J.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-color`,className:`text-xs font-medium text-gray-600`,children:`Color Variant`}),(0,J.jsxs)(`select`,{id:`widget-color`,"data-testid":`widget-prop-color`,value:e.colorVariant??`default`,onChange:e=>n({colorVariant:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,J.jsx)(`option`,{value:`default`,children:`Default`}),(0,J.jsx)(`option`,{value:`blue`,children:`Blue`}),(0,J.jsx)(`option`,{value:`teal`,children:`Teal`}),(0,J.jsx)(`option`,{value:`orange`,children:`Orange`}),(0,J.jsx)(`option`,{value:`purple`,children:`Purple`}),(0,J.jsx)(`option`,{value:`success`,children:`Success`}),(0,J.jsx)(`option`,{value:`warning`,children:`Warning`}),(0,J.jsx)(`option`,{value:`danger`,children:`Danger`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:i(`appDesigner.widgetLayoutSize`)}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-width`,className:`text-[10px] text-gray-400`,children:i(`appDesigner.widgetWidth`)}),(0,J.jsx)(`input`,{id:`widget-width`,"data-testid":`widget-prop-width`,type:`number`,min:1,value:e.layout?.w??1,onChange:t=>n({layout:{...e.layout,w:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`label`,{htmlFor:`widget-height`,className:`text-[10px] text-gray-400`,children:i(`appDesigner.widgetHeight`)}),(0,J.jsx)(`input`,{id:`widget-height`,"data-testid":`widget-prop-height`,type:`number`,min:1,value:e.layout?.h??1,onChange:t=>n({layout:{...e.layout,h:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]})]})]})]})}function Mt({schema:e}){let{t}=at(),n=e.widgets||[];return(0,J.jsxs)(`div`,{"data-testid":`dashboard-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||t(`appDesigner.dashboardPreview`)}),n.length===0?(0,J.jsx)(`div`,{className:`text-xs text-gray-400`,children:t(`appDesigner.noWidgetsPreview`)}):(0,J.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${e.columns??2}, 1fr)`},children:n.map(e=>{let t=Dt.find(t=>t.type===(e.type||`metric`))||Dt[0];return(0,J.jsxs)(`div`,{className:`rounded-md border border-gray-200 bg-white p-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(t.Icon,{className:`h-3 w-3 text-gray-400`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.title||`Untitled`})]}),(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function Nt({schema:e,onChange:t,readOnly:n=!1,className:r,onExport:i,onImport:a,selectedWidgetId:o,onWidgetSelect:s}){let{t:c}=at(),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),p=(0,q.useRef)(null),h=(0,q.useRef)(null),g=o!==void 0,_=g?o:l,v=(0,q.useCallback)(e=>{s&&s(e),g||u(e)},[g,s,u]),{current:b,canUndo:x,canRedo:S,push:C,undo:w,redo:T}=Oe(e),E=(0,q.useCallback)(e=>{C(e),t(e)},[C,t]),D=b.widgets||[],O=D.find(e=>e.id===_),k=(0,q.useCallback)(e=>{let t=kt(),n={id:t,title:``,type:e,layout:{x:0,y:D.length,w:b.columns??2,h:1}};E({...b,widgets:[...D,n]}),v(t)},[b,D,E,v]),j=(0,q.useCallback)(e=>{E({...b,widgets:D.filter(t=>t.id!==e)}),_===e&&v(null)},[b,D,_,E,v]),M=(0,q.useCallback)((e,t)=>{let n=D.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=D.length)return;let i=[...D];[i[n],i[r]]=[i[r],i[n]],E({...b,widgets:i})},[b,D,E]),N=(0,q.useCallback)(e=>{_&&E({...b,widgets:D.map(t=>t.id===_?{...t,...e}:t)})},[b,D,_,E]);(0,q.useEffect)(()=>{let e=p.current;if(!e)return;let t=e=>{if(!n){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),w();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),T();return}if((e.key===`Delete`||e.key===`Backspace`)&&_){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),j(_)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[n,w,T,_,j]);let P=(0,q.useCallback)(()=>{i&&i(b)},[b,i]),F=(0,q.useCallback)(()=>{h.current?.click()},[]),I=(0,q.useCallback)(e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{try{let e=JSON.parse(n.result);e&&e.type===`dashboard`&&(E(e),a?.(e))}catch{}},n.readAsText(t),e.target.value=``},[E,a]);return(0,J.jsxs)(`div`,{ref:p,tabIndex:0,"data-testid":`dashboard-editor`,className:Et(`flex flex-col gap-4 outline-none`,r),children:[(0,J.jsx)(`input`,{ref:h,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`dashboard-import-input`,onChange:I}),O&&!d&&(0,J.jsx)(jt,{widget:O,readOnly:n,onChange:N,onClose:()=>v(null)}),(0,J.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[c(`appDesigner.addWidget`),`:`]}),Dt.map(({type:e,label:t,Icon:r})=>(0,J.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>k(e),disabled:n||d,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(r,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!n&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"data-testid":`dashboard-undo`,onClick:w,disabled:!x,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.undo`),children:(0,J.jsx)(xe,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`dashboard-redo`,onClick:T,disabled:!S,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.redo`),children:(0,J.jsx)(A,{className:`h-4 w-4`})})]}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`dashboard-export`,onClick:P,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navExportSchema`),children:(0,J.jsx)(Ee,{className:`h-4 w-4`})}),!n&&(0,J.jsx)(`button`,{type:`button`,"data-testid":`dashboard-import`,onClick:F,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navImportSchema`),children:(0,J.jsx)(W,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`dashboard-preview-toggle`,onClick:()=>f(e=>!e),className:Et(`rounded p-1.5 transition-colors`,d?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":c(d?`appDesigner.modeEdit`:`appDesigner.preview`),children:d?(0,J.jsx)(y,{className:`h-4 w-4`}):(0,J.jsx)(m,{className:`h-4 w-4`})})]})]}),d?(0,J.jsx)(Mt,{schema:b}):D.length===0?(0,J.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:c(`appDesigner.noWidgets`)}):(0,J.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${b.columns??2}, 1fr)`},children:D.map((e,t)=>(0,J.jsx)(At,{widget:e,index:t,total:D.length,selected:e.id===_,readOnly:n,onSelect:()=>v(e.id??null),onRemove:()=>j(e.id),onMoveUp:()=>M(e.id,`up`),onMoveDown:()=>M(e.id,`down`)},e.id))})]})]})}function Pt(...e){return K(j(e))}var Ft=[{type:`grid`,label:`Data Grid`,Icon:oe},{type:`kanban`,label:`Kanban Board`,Icon:Te},{type:`calendar`,label:`Calendar`,Icon:V},{type:`gallery`,label:`Gallery`,Icon:C},{type:`dashboard`,label:`Dashboard`,Icon:ge},{type:`form`,label:`Form`,Icon:D},{type:`layout-grid`,label:`Grid Layout`,Icon:ae}],It=[{value:`page`,labelKey:`appDesigner.modePage`},{value:`dashboard`,labelKey:`appDesigner.modeDashboard`}],Lt=0;function Rt(){return Lt+=1,`component_${Date.now()}_${Lt}`}function zt({component:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=Ft.find(t=>t.type===e.type)||Ft[0];return(0,J.jsxs)(`div`,{"data-testid":`canvas-component-${e.id}`,onClick:a,className:Pt(`group flex cursor-pointer items-center gap-3 rounded-lg border-2 px-3 py-3 transition-colors`,r?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`),children:[(0,J.jsx)(p,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300`}),(0,J.jsx)(l.Icon,{className:`h-5 w-5 shrink-0 text-gray-500`}),(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,J.jsx)(`span`,{className:`ml-2 text-[10px] text-gray-400`,children:l.label})]}),!i&&(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,J.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,J.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove component`,"data-testid":`canvas-component-remove-${e.id}`,children:(0,J.jsx)(H,{className:`h-3.5 w-3.5`})})]})]})}function Bt({component:e,readOnly:t,onChange:n,onClose:r}){let{t:i}=at();return(0,J.jsxs)(`div`,{"data-testid":`component-property-panel`,className:`w-64 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:i(`appDesigner.componentProperties`)}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,J.jsx)(Ce,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:`component-label`,className:`text-xs font-medium text-gray-600`,children:`Label`}),(0,J.jsx)(`input`,{id:`component-label`,"data-testid":`component-prop-label`,type:`text`,value:e.label,onChange:e=>n({label:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,J.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600`,children:Ft.find(t=>t.type===e.type)?.label??e.type})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`ID`}),(0,J.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-xs font-mono text-gray-500`,children:e.id})]})]})}function Vt({schema:e,components:t}){let{t:n}=at();return(0,J.jsxs)(`div`,{"data-testid":`page-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||n(`appDesigner.pagePreview`)}),t.length===0?(0,J.jsx)(`div`,{className:`text-xs text-gray-400`,children:n(`appDesigner.noComponentsPreview`)}):(0,J.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=Ft.find(t=>t.type===e.type)||Ft[0];return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2`,children:[(0,J.jsx)(t.Icon,{className:`h-4 w-4 text-gray-400`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.label}),(0,J.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function Ht({schema:e,onChange:t,readOnly:n=!1,className:r,onExport:i,onImport:a}){let{t:o}=at(),s=(0,q.useRef)(null),c=(0,q.useRef)(null),[l,u]=(0,q.useState)(()=>(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`existing_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}))),[d,f]=(0,q.useState)(null),[p,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(`page`),v=l.find(e=>e.id===d),{canUndo:b,canRedo:x,push:S,undo:C,redo:w}=Oe(l),T=(0,q.useCallback)(n=>{u(n),S(n),t({...e,children:n.map(e=>({type:e.type,id:e.id,title:e.label,...e.props}))})},[e,t,S]),E=(0,q.useCallback)(e=>{let t=Rt(),n={id:t,type:e,label:Ft.find(t=>t.type===e)?.label||e};T([...l,n]),f(t)},[l,T]),D=(0,q.useCallback)(e=>{T(l.filter(t=>t.id!==e)),d===e&&f(null)},[l,d,T]),O=(0,q.useCallback)((e,t)=>{let n=l.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=l.length)return;let i=[...l];[i[n],i[r]]=[i[r],i[n]],T(i)},[l,T]),k=(0,q.useCallback)(e=>{d&&T(l.map(t=>t.id===d?{...t,...e}:t))},[l,d,T]);(0,q.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>{if(!n){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),C();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),w();return}if((e.key===`Delete`||e.key===`Backspace`)&&d){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),D(d)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[n,C,w,d,D]);let j=(0,q.useCallback)(()=>{i&&i(e)},[e,i]),M=(0,q.useCallback)(()=>{c.current?.click()},[]),N=(0,q.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let e=JSON.parse(r.result);if(e&&e.type===`page`){let n=(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`imported_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}));u(n),S(n),t(e),a?.(e)}}catch{}},r.readAsText(n),e.target.value=``},[t,S,a]);return(0,J.jsxs)(`div`,{ref:s,tabIndex:0,"data-testid":`page-canvas-editor`,className:Pt(`flex flex-col gap-4 outline-none sm:flex-row`,r),children:[(0,J.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`canvas-import-input`,onChange:N}),(0,J.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2 border-b border-gray-200 pb-2`,role:`tablist`,children:It.map(e=>(0,J.jsx)(`button`,{type:`button`,role:`tab`,"data-testid":`canvas-mode-${e.value}`,"aria-selected":g===e.value,onClick:()=>_(e.value),className:Pt(`rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors`,g===e.value?`border-b-2 border-blue-500 text-blue-600`:`text-gray-500 hover:text-gray-700`),children:o(e.labelKey)},e.value))}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[o(`appDesigner.addComponent`),`:`]}),Ft.map(({type:e,label:t,Icon:r})=>(0,J.jsxs)(`button`,{type:`button`,"data-testid":`canvas-add-${e}`,onClick:()=>E(e),disabled:n||p,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,J.jsx)(r,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!n&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"data-testid":`canvas-undo`,onClick:C,disabled:!b,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":o(`appDesigner.undo`),children:(0,J.jsx)(xe,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`canvas-redo`,onClick:w,disabled:!x,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":o(`appDesigner.redo`),children:(0,J.jsx)(A,{className:`h-4 w-4`})})]}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`canvas-export`,onClick:j,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navExportSchema`),children:(0,J.jsx)(Ee,{className:`h-4 w-4`})}),!n&&(0,J.jsx)(`button`,{type:`button`,"data-testid":`canvas-import`,onClick:M,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navImportSchema`),children:(0,J.jsx)(W,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,"data-testid":`canvas-preview-toggle`,onClick:()=>h(e=>!e),className:Pt(`rounded p-1.5 transition-colors`,p?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":o(p?`appDesigner.modeEdit`:`appDesigner.preview`),children:p?(0,J.jsx)(y,{className:`h-4 w-4`}):(0,J.jsx)(m,{className:`h-4 w-4`})})]})]}),p?(0,J.jsx)(Vt,{schema:e,components:l}):l.length===0?(0,J.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:o(`appDesigner.emptyPage`)}):(0,J.jsx)(`div`,{className:`space-y-2`,children:l.map((e,t)=>(0,J.jsx)(zt,{component:e,index:t,total:l.length,selected:e.id===d,readOnly:n,onSelect:()=>f(e.id),onRemove:()=>D(e.id),onMoveUp:()=>O(e.id,`up`),onMoveDown:()=>O(e.id,`down`)},e.id))})]}),v&&!p&&(0,J.jsx)(Bt,{component:v,readOnly:n,onChange:k,onClose:()=>f(null)})]})}function Ut(...e){return K(j(e))}var Wt={grid:{label:`Grid`,Icon:ae},kanban:{label:`Kanban`,Icon:Te},calendar:{label:`Calendar`,Icon:V},gallery:{label:`Gallery`,Icon:C},timeline:{label:`Timeline`,Icon:g},map:{label:`Map`,Icon:he},gantt:{label:`Gantt`,Icon:ce}},Gt=[{value:`compact`,label:`Compact`},{value:`medium`,label:`Medium`},{value:`tall`,label:`Tall`}];function Kt({title:e,icon:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,q.useState)(n);return(0,J.jsxs)(`div`,{className:`border-b border-gray-100 pb-3`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 py-2 text-left`,children:[t,(0,J.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase text-gray-500`,children:e}),i?(0,J.jsx)(O,{className:`h-3.5 w-3.5 text-gray-400`}):(0,J.jsx)(G,{className:`h-3.5 w-3.5 text-gray-400`})]}),i&&(0,J.jsx)(`div`,{className:`space-y-2`,children:r})]})}function qt({config:e,onChange:t,availableViewTypes:n=[`grid`,`kanban`,`calendar`,`gallery`,`timeline`,`map`,`gantt`],readOnly:r=!1,className:i}){let a=(0,q.useCallback)(n=>{t({...e,...n})},[e,t]),o=(0,q.useCallback)(t=>{a({columns:e.columns.map(e=>e.name===t?{...e,visible:!e.visible}:e)})},[e,a]),s=(0,q.useCallback)((t,n)=>{let r=[...e.columns],i=r.findIndex(e=>e.name===t);if(i<0)return;let o=n===`up`?i-1:i+1;o<0||o>=r.length||([r[i],r[o]]=[r[o],r[i]],a({columns:r}))},[e,a]),c=(0,q.useMemo)(()=>e.columns.filter(e=>e.visible).length,[e.columns]);return(0,J.jsxs)(`div`,{"data-testid":`object-view-configurator`,className:Ut(`w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4`,i),children:[(0,J.jsx)(Kt,{title:`View Type`,icon:(0,J.jsx)(ae,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(t=>{let{label:n,Icon:i}=Wt[t];return(0,J.jsxs)(`button`,{type:`button`,"data-testid":`view-type-${t}`,onClick:()=>a({viewType:t}),disabled:r,className:Ut(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors`,e.viewType===t?`bg-blue-100 text-blue-700`:`text-gray-600 hover:bg-gray-100`,r&&`cursor-not-allowed opacity-50`),children:[(0,J.jsx)(i,{className:`h-3 w-3`}),n]},t)})})}),(0,J.jsx)(Kt,{title:`Fields (${c}/${e.columns.length})`,icon:(0,J.jsx)(M,{className:`h-3.5 w-3.5 text-gray-500`}),children:e.columns.length===0?(0,J.jsx)(`p`,{className:`text-xs text-gray-400`,children:`No fields configured.`}):(0,J.jsx)(`ul`,{className:`space-y-0.5`,children:e.columns.map((t,n)=>(0,J.jsxs)(`li`,{"data-testid":`view-column-${t.name}`,className:`flex items-center gap-1.5 rounded px-1.5 py-1 text-xs hover:bg-gray-50`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(t.name),disabled:r,className:Ut(`rounded p-0.5 transition-colors`,t.visible?`text-blue-500`:`text-gray-300`),"aria-label":t.visible?`Hide field`:`Show field`,children:t.visible?(0,J.jsx)(m,{className:`h-3 w-3`}):(0,J.jsx)(y,{className:`h-3 w-3`})}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-gray-700`,children:t.label}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>s(t.name,`up`),disabled:r||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,J.jsx)(O,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>s(t.name,`down`),disabled:r||n===e.columns.length-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,J.jsx)(G,{className:`h-3 w-3`})})]},t.name))})}),(0,J.jsx)(Kt,{title:`Toolbar`,icon:(0,J.jsx)(ue,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.showSearch,onChange:e=>a({showSearch:e.target.checked}),disabled:r,"data-testid":`view-toggle-search`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Search`})]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.showFilters,onChange:e=>a({showFilters:e.target.checked}),disabled:r,"data-testid":`view-toggle-filters`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Filters`})]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.showSort,onChange:e=>a({showSort:e.target.checked}),disabled:r,"data-testid":`view-toggle-sort`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Sort`})]})]})}),(0,J.jsx)(Kt,{title:`Appearance`,icon:(0,J.jsx)(l,{className:`h-3.5 w-3.5 text-gray-500`}),defaultOpen:!1,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-medium text-gray-500`,children:`Row Height`}),(0,J.jsx)(`div`,{className:`flex gap-1`,children:Gt.map(({value:t,label:n})=>(0,J.jsx)(`button`,{type:`button`,"data-testid":`view-row-height-${t}`,onClick:()=>a({rowHeight:t}),disabled:r,className:Ut(`flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors`,e.rowHeight===t?`bg-blue-100 text-blue-700`:`bg-gray-50 text-gray-500 hover:bg-gray-100`),children:n},t))})]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.striped,onChange:e=>a({striped:e.target.checked}),disabled:r,"data-testid":`view-toggle-striped`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Striped Rows`})]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.bordered,onChange:e=>a({bordered:e.target.checked}),disabled:r,"data-testid":`view-toggle-bordered`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,J.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Bordered`})]})]})})]})}function $(...e){return K(j(e))}var Jt=[{hex:`#3b82f6`,name:`Blue`},{hex:`#6366f1`,name:`Indigo`},{hex:`#8b5cf6`,name:`Violet`},{hex:`#a855f7`,name:`Purple`},{hex:`#ec4899`,name:`Pink`},{hex:`#ef4444`,name:`Red`},{hex:`#f97316`,name:`Orange`},{hex:`#f59e0b`,name:`Amber`},{hex:`#eab308`,name:`Yellow`},{hex:`#22c55e`,name:`Green`},{hex:`#14b8a6`,name:`Teal`},{hex:`#06b6d4`,name:`Cyan`},{hex:`#0ea5e9`,name:`Sky`},{hex:`#64748b`,name:`Slate`},{hex:`#1e293b`,name:`Dark`},{hex:`#0f172a`,name:`Navy`}],Yt=[`Inter`,`Roboto`,`Open Sans`,`Lato`,`Montserrat`,`Poppins`,`Source Sans Pro`,`Noto Sans`,`system-ui`];function Xt({branding:e,onChange:t,appTitle:n=`My App`,readOnly:r=!1,className:i,onExport:a,onImport:o}){let{t:s}=at(),[c,l]=(0,q.useState)(`light`),{current:u,push:d,canUndo:p,canRedo:m,undo:h,redo:g}=Oe(e),_=(0,q.useRef)(!0);(0,q.useEffect)(()=>{if(_.current){_.current=!1;return}t(u)},[u]);let v=(0,q.useCallback)(e=>{let n={...u,...e};_.current=!0,d(n),t(n)},[u,d,t]),y=(0,q.useCallback)(()=>{if(a){a(u);return}let e=new Blob([JSON.stringify(u,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`branding.json`,n.click(),URL.revokeObjectURL(t)},[u,a]),b=(0,q.useCallback)(()=>{if(o){o(u);return}let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);if(typeof n==`object`&&n){let e={...u,...n};d(e),t(e)}}catch{}},r.readAsText(n)},e.click()},[u,d,t,o]),x=(0,q.useCallback)(e=>{r||((e.ctrlKey||e.metaKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?g():h()),(e.ctrlKey||e.metaKey)&&e.key===`y`&&(e.preventDefault(),g()))},[r,h,g]),S=u.primaryColor||`#3b82f6`,C=c===`dark`;return(0,J.jsxs)(`div`,{"data-testid":`branding-editor`,className:$(`flex flex-col gap-4 sm:gap-6`,i),onKeyDown:x,tabIndex:0,children:[(0,J.jsxs)(`div`,{"data-testid":`branding-editor-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800 mr-auto`,children:s(`appDesigner.brandingEditor`)}),(0,J.jsxs)(`button`,{"data-testid":`branding-undo`,type:`button`,onClick:h,disabled:!p||r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,p&&!r?`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`:`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`),title:s(`appDesigner.undo`),children:[(0,J.jsx)(xe,{className:`h-3.5 w-3.5`}),s(`appDesigner.undo`)]}),(0,J.jsxs)(`button`,{"data-testid":`branding-redo`,type:`button`,onClick:g,disabled:!m||r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,m&&!r?`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`:`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`),title:s(`appDesigner.redo`),children:[(0,J.jsx)(A,{className:`h-3.5 w-3.5`}),s(`appDesigner.redo`)]}),(0,J.jsxs)(`button`,{"data-testid":`branding-export`,type:`button`,onClick:y,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50`,title:s(`appDesigner.brandingExport`),children:[(0,J.jsx)(Ee,{className:`h-3.5 w-3.5`}),s(`appDesigner.brandingExport`)]}),(0,J.jsxs)(`button`,{"data-testid":`branding-import`,type:`button`,onClick:b,disabled:r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,r?`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`:`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`),title:s(`appDesigner.brandingImport`),children:[(0,J.jsx)(W,{className:`h-3.5 w-3.5`}),s(`appDesigner.brandingImport`)]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:gap-6`,children:[(0,J.jsxs)(`div`,{className:`flex-1 space-y-5`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`be-logo`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.logoUrl`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(f,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`be-logo`,"data-testid":`branding-logo-input`,type:`text`,value:u.logo??``,onChange:e=>v({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`be-color`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.primaryColor`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(L,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`be-color`,"data-testid":`branding-color-input`,type:`text`,value:u.primaryColor??`#3b82f6`,onChange:e=>v({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,J.jsx)(`input`,{"data-testid":`branding-color-picker`,type:`color`,value:S,onChange:e=>v({primaryColor:e.target.value}),disabled:r,className:`h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-gray-500`,children:s(`appDesigner.colorPalette`)}),(0,J.jsx)(`div`,{"data-testid":`branding-color-palette`,className:`flex flex-wrap gap-1.5`,children:Jt.map(e=>(0,J.jsx)(`button`,{"data-testid":`branding-swatch-${e.hex.slice(1)}`,type:`button`,onClick:()=>!r&&v({primaryColor:e.hex}),disabled:r,className:$(`h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed`,S===e.hex?`border-gray-800 ring-2 ring-offset-1 ring-gray-400`:`border-transparent`),style:{backgroundColor:e.hex},title:e.name},e.hex))})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`be-favicon`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.faviconUrl`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(de,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsx)(`input`,{id:`be-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:u.favicon??``,onChange:e=>v({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`be-font`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.fontFamily`)}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(ne,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,J.jsxs)(`select`,{id:`be-font`,"data-testid":`branding-font-select`,value:u.fontFamily??``,onChange:e=>v({fontFamily:e.target.value||void 0}),disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none`,children:[(0,J.jsx)(`option`,{value:``,children:s(`appDesigner.fontDefault`)}),Yt.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,J.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:s(`appDesigner.brandingPreview`)}),(0,J.jsxs)(`div`,{"data-testid":`branding-mode-toggle`,className:`flex rounded-md border border-gray-300 overflow-hidden`,children:[(0,J.jsxs)(`button`,{"data-testid":`branding-mode-light`,type:`button`,onClick:()=>l(`light`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,c===`light`?`bg-blue-50 text-blue-700`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,J.jsx)(z,{className:`h-3.5 w-3.5`}),s(`appDesigner.modeLight`)]}),(0,J.jsxs)(`button`,{"data-testid":`branding-mode-dark`,type:`button`,onClick:()=>l(`dark`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,c===`dark`?`bg-gray-800 text-gray-100`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,J.jsx)(Se,{className:`h-3.5 w-3.5`}),s(`appDesigner.modeDark`)]})]})]}),(0,J.jsxs)(`div`,{"data-testid":`branding-preview`,className:$(`rounded-lg border p-4 transition-colors`,C?`border-gray-700 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-800`),style:{fontFamily:u.fontFamily||`inherit`},children:[(0,J.jsx)(`div`,{className:`rounded-md p-3 mb-3`,style:{backgroundColor:S},children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[u.logo?(0,J.jsx)(`img`,{src:u.logo,alt:`Logo`,className:`h-8 w-8 rounded object-contain bg-white/20`}):(0,J.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white`,children:`Logo`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold text-white`,children:n})]})}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:S}}),(0,J.jsx)(`span`,{className:$(`text-xs`,C?`text-gray-400`:`text-gray-500`),children:S})]}),(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-3 py-1.5 text-xs font-medium text-white transition-colors`,style:{backgroundColor:S},tabIndex:-1,children:s(`appDesigner.brandingSampleButton`)}),(0,J.jsx)(`p`,{className:$(`text-xs`,C?`text-gray-400`:`text-gray-500`),children:s(`appDesigner.brandingSampleText`)}),u.favicon&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`img`,{src:u.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,J.jsx)(`span`,{className:$(`text-xs`,C?`text-gray-400`:`text-gray-500`),children:`Favicon`})]}),u.fontFamily&&(0,J.jsxs)(`div`,{className:$(`text-xs`,C?`text-gray-400`:`text-gray-500`),children:[s(`appDesigner.fontFamily`),`: `,u.fontFamily]})]})]}),(0,J.jsxs)(`div`,{"data-testid":`branding-preview-mobile`,className:$(`mx-auto w-48 rounded-xl border-2 p-2 transition-colors`,C?`border-gray-700 bg-gray-900`:`border-gray-300 bg-white`),style:{fontFamily:u.fontFamily||`inherit`},children:[(0,J.jsx)(`div`,{className:`text-center text-[10px] font-medium text-gray-400 mb-1`,children:s(`appDesigner.mobilePreview`)}),(0,J.jsx)(`div`,{className:`rounded-md p-2 mb-1`,style:{backgroundColor:S},children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[u.logo?(0,J.jsx)(`img`,{src:u.logo,alt:`Logo`,className:`h-4 w-4 rounded object-contain bg-white/20`}):(0,J.jsx)(`div`,{className:`flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white`,children:`L`}),(0,J.jsx)(`span`,{className:`text-[9px] font-semibold text-white truncate`,children:n})]})}),(0,J.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,J.jsx)(`div`,{className:$(`h-2 w-3/4 rounded`,C?`bg-gray-700`:`bg-gray-200`)}),(0,J.jsx)(`div`,{className:$(`h-2 w-1/2 rounded`,C?`bg-gray-700`:`bg-gray-200`)}),(0,J.jsx)(`div`,{className:$(`h-2 w-2/3 rounded`,C?`bg-gray-700`:`bg-gray-200`)})]})]})]})]})]})}t.register(`page-designer`,He,{label:`Page Designer`,category:`Designer`,inputs:[{name:`canvas`,type:`code`,label:`Canvas Configuration`},{name:`components`,type:`code`,label:`Components`},{name:`showComponentTree`,type:`boolean`,label:`Show Component Tree`,defaultValue:!0},{name:`undoRedo`,type:`boolean`,label:`Undo/Redo`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`data-model-designer`,Je,{label:`Data Model Designer`,category:`Designer`,inputs:[{name:`entities`,type:`code`,label:`Entities`},{name:`relationships`,type:`code`,label:`Relationships`},{name:`autoLayout`,type:`boolean`,label:`Auto Layout`,defaultValue:!1},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`process-designer`,$e,{label:`Process Designer (BPMN)`,category:`Designer`,inputs:[{name:`processName`,type:`string`,label:`Process Name`},{name:`nodes`,type:`code`,label:`Nodes`},{name:`edges`,type:`code`,label:`Edges`},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`report-designer`,nt,{label:`Report Designer`,category:`Designer`,inputs:[{name:`reportName`,type:`string`,label:`Report Name`},{name:`objectName`,type:`string`,label:`Data Source Object`},{name:`sections`,type:`code`,label:`Sections`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showPropertyPanel`,type:`boolean`,label:`Show Property Panel`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`app-creation-wizard`,gt,{label:`App Creation Wizard`,category:`Designer`,inputs:[{name:`availableObjects`,type:`code`,label:`Available Objects`},{name:`templates`,type:`code`,label:`Templates`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`navigation-designer`,Tt,{label:`Navigation Designer`,category:`Designer`,inputs:[{name:`items`,type:`code`,label:`Navigation Items`},{name:`showPreview`,type:`boolean`,label:`Show Preview`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`dashboard-editor`,Nt,{label:`Dashboard Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Dashboard Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`page-canvas-editor`,Ht,{label:`Page Canvas Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Page Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`object-view-configurator`,qt,{label:`Object View Configurator`,category:`Designer`,inputs:[{name:`config`,type:`code`,label:`View Config`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.register(`branding-editor`,Xt,{label:`Branding Editor`,category:`Designer`,inputs:[{name:`branding`,type:`code`,label:`Branding Config`},{name:`appTitle`,type:`string`,label:`App Title`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]});export{Ht as PageCanvasEditor,gt as n,Nt as t};
@@ -1 +0,0 @@
1
- var e=[{name:`sys_user`,label:`Users`,icon:`Users`,fields:[{name:`id`,type:`text`,label:`ID`,readonly:!0},{name:`name`,type:`text`,label:`Name`,required:!0},{name:`email`,type:`email`,label:`Email`,required:!0},{name:`role`,type:`select`,label:`Role`,options:[`admin`,`member`,`viewer`]},{name:`status`,type:`select`,label:`Status`,options:[`active`,`inactive`,`suspended`]},{name:`emailVerified`,type:`boolean`,label:`Email Verified`},{name:`image`,type:`url`,label:`Avatar URL`},{name:`lastLoginAt`,type:`datetime`,label:`Last Login`,readonly:!0},{name:`createdAt`,type:`datetime`,label:`Created At`,readonly:!0},{name:`updatedAt`,type:`datetime`,label:`Updated At`,readonly:!0}],titleFormat:`{name}`,views:[{name:`all`,label:`All Users`,type:`grid`,columns:[`name`,`email`,`role`,`status`,`lastLoginAt`]}]},{name:`sys_org`,label:`Organizations`,icon:`Building2`,fields:[{name:`id`,type:`text`,label:`ID`,readonly:!0},{name:`name`,type:`text`,label:`Organization Name`,required:!0},{name:`slug`,type:`text`,label:`Slug`,required:!0},{name:`description`,type:`textarea`,label:`Description`},{name:`plan`,type:`select`,label:`Plan`,options:[`free`,`pro`,`enterprise`]},{name:`status`,type:`select`,label:`Status`,options:[`active`,`inactive`,`suspended`]},{name:`memberCount`,type:`number`,label:`Members`,readonly:!0},{name:`createdAt`,type:`datetime`,label:`Created At`,readonly:!0}],titleFormat:`{name}`,views:[{name:`all`,label:`All Organizations`,type:`grid`,columns:[`name`,`slug`,`plan`,`status`,`memberCount`]}]},{name:`sys_role`,label:`Roles`,icon:`Shield`,fields:[{name:`id`,type:`text`,label:`ID`,readonly:!0},{name:`name`,type:`text`,label:`Role Name`,required:!0},{name:`description`,type:`textarea`,label:`Description`},{name:`permissions`,type:`text`,label:`Permissions`},{name:`isSystem`,type:`boolean`,label:`System Role`,readonly:!0},{name:`userCount`,type:`number`,label:`Users`,readonly:!0},{name:`createdAt`,type:`datetime`,label:`Created At`,readonly:!0}],titleFormat:`{name}`,views:[{name:`all`,label:`All Roles`,type:`grid`,columns:[`name`,`description`,`isSystem`,`userCount`]}]},{name:`sys_permission`,label:`Permissions`,icon:`Key`,fields:[{name:`id`,type:`text`,label:`ID`,readonly:!0},{name:`name`,type:`text`,label:`Permission Name`,required:!0},{name:`description`,type:`textarea`,label:`Description`},{name:`resource`,type:`text`,label:`Resource`},{name:`action`,type:`select`,label:`Action`,options:[`create`,`read`,`update`,`delete`,`manage`]},{name:`createdAt`,type:`datetime`,label:`Created At`,readonly:!0}],titleFormat:`{name}`,views:[{name:`all`,label:`All Permissions`,type:`grid`,columns:[`name`,`resource`,`action`,`description`]}]},{name:`sys_audit_log`,label:`Audit Log`,icon:`ScrollText`,fields:[{name:`id`,type:`text`,label:`ID`,readonly:!0},{name:`action`,type:`text`,label:`Action`,readonly:!0},{name:`resource`,type:`text`,label:`Resource`,readonly:!0},{name:`resourceId`,type:`text`,label:`Resource ID`,readonly:!0},{name:`userId`,type:`text`,label:`User ID`,readonly:!0},{name:`userName`,type:`text`,label:`User Name`,readonly:!0},{name:`ipAddress`,type:`text`,label:`IP Address`,readonly:!0},{name:`details`,type:`textarea`,label:`Details`,readonly:!0},{name:`createdAt`,type:`datetime`,label:`Timestamp`,readonly:!0}],titleFormat:`{action} on {resource}`,views:[{name:`all`,label:`All Logs`,type:`grid`,columns:[`action`,`resource`,`userName`,`ipAddress`,`createdAt`]}]}];export{e as t};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,w as n}from"./framework-DJlDX9E6.js";import{$c as r,An as i,Dc as a,Dt as o,Et as s,Ft as c,Hs as l,It as u,Lt as d,Mt as f,Nt as p,On as m,Ot as h,Pc as g,Po as _,Pt as v,Us as y,Xo as b,Xt as x,_ as S,c as C,f as w,h as T,jt as E,kn as D,l as ee,o as te,p as O,s as ne,u as re,v as k,vs as ie,y as A,yl as ae}from"./plugins-core-PiAAytWV.js";import{S as oe}from"./data-adapter-wZ81OFjZ.js";var j=e(t(),1),se=`popstate`;function ce(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function le(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return fe(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:P(t)}return pe(t,n,null,e)}function M(e,t){if(e===!1||e==null)throw Error(t)}function N(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function ue(){return Math.random().toString(36).substring(2,10)}function de(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function fe(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?F(t):t,state:n,key:t&&t.key||r||ue(),unstable_mask:i}}function P({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function F(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function pe(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=ce(e)?e:fe(h.location,e,t);n&&n(r,e),l=u()+1;let d=de(r,l),f=h.createHref(r.unstable_mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=ce(e)?e:fe(h.location,e,t);n&&n(r,e),l=u();let i=de(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return me(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(se,d),c=e,()=>{i.removeEventListener(se,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function me(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),M(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:P(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function he(e,t,n=`/`){return ge(e,t,n,!1)}function ge(e,t,n,r){let i=L((typeof t==`string`?F(t):t).pathname||`/`,n);if(i==null)return null;let a=ve(e);be(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Me(i);o=Ae(a[e],t,r)}return o}function _e(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function ve(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;M(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=z([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(M(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ve(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Oe(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ye(e.path))a(e,t,!0,n)}),t}function ye(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ye(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function be(e){e.sort((e,t)=>e.score===t.score?ke(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var xe=/^:[\w-]+$/,Se=3,Ce=2,we=1,Te=10,Ee=-2,De=e=>e===`*`;function Oe(e,t){let n=e.split(`/`),r=n.length;return n.some(De)&&(r+=Ee),t&&(r+=Ce),n.filter(e=>!De(e)).reduce((e,t)=>e+(xe.test(t)?Se:t===``?we:Te),r)}function ke(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Ae(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=I({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=I({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:z([a,u.pathname]),pathnameBase:ze(z([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=z([a,u.pathnameBase]))}return o}function I(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=je(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function je(e,t=!1,n=!0){N(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Me(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return N(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function L(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Ne=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Pe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?F(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Fe(n.substring(1),`/`):Fe(n,t)):a=t,{pathname:a,search:Be(r),hash:Ve(i)}}function Fe(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ie(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Le(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Re(e){let t=Le(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function R(e,t,n,r=!1){let i;typeof e==`string`?i=F(e):(i={...e},M(!i.pathname||!i.pathname.includes(`?`),Ie(`?`,`pathname`,`search`,i)),M(!i.pathname||!i.pathname.includes(`#`),Ie(`#`,`pathname`,`hash`,i)),M(!i.search||!i.search.includes(`#`),Ie(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Pe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var z=e=>e.join(`/`).replace(/\/\/+/g,`/`),ze=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Be=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ve=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,He=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ue(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function We(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Ge=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ke(e,t){let n=e;if(typeof n!=`string`||!Ne.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Ge)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=L(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{N(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var qe=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(qe);var Je=[`GET`,...qe];new Set(Je);var B=j.createContext(null);B.displayName=`DataRouter`;var V=j.createContext(null);V.displayName=`DataRouterState`;var Ye=j.createContext(!1),Xe=j.createContext({isTransitioning:!1});Xe.displayName=`ViewTransition`;var Ze=j.createContext(new Map);Ze.displayName=`Fetchers`;var Qe=j.createContext(null);Qe.displayName=`Await`;var H=j.createContext(null);H.displayName=`Navigation`;var U=j.createContext(null);U.displayName=`Location`;var W=j.createContext({outlet:null,matches:[],isDataRoute:!1});W.displayName=`Route`;var $e=j.createContext(null);$e.displayName=`RouteError`;var et=`REACT_ROUTER_ERROR`,tt=`REDIRECT`,nt=`ROUTE_ERROR_RESPONSE`;function rt(e){if(e.startsWith(`${et}:${tt}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function it(e){if(e.startsWith(`${et}:${nt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new He(t.status,t.statusText,t.data)}catch{}}function at(e,{relative:t}={}){M(G(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j.useContext(H),{hash:i,pathname:a,search:o}=J(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:z([n,a])),r.createHref({pathname:s,search:o,hash:i})}function G(){return j.useContext(U)!=null}function K(){return M(G(),`useLocation() may be used only in the context of a <Router> component.`),j.useContext(U).location}var ot=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function st(e){j.useContext(H).static||j.useLayoutEffect(e)}function q(){let{isDataRoute:e}=j.useContext(W);return e?Ot():ct()}function ct(){M(G(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j.useContext(B),{basename:t,navigator:n}=j.useContext(H),{matches:r}=j.useContext(W),{pathname:i}=K(),a=JSON.stringify(Re(r)),o=j.useRef(!1);return st(()=>{o.current=!0}),j.useCallback((r,s={})=>{if(N(o.current,ot),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=R(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:z([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}j.createContext(null);function lt(){let{matches:e}=j.useContext(W),t=e[e.length-1];return t?t.params:{}}function J(e,{relative:t}={}){let{matches:n}=j.useContext(W),{pathname:r}=K(),i=JSON.stringify(Re(n));return j.useMemo(()=>R(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function ut(e,t){return dt(e,t)}function dt(e,t,n){M(G(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=j.useContext(H),{matches:i}=j.useContext(W),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;At(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
-
3
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=K(),d;if(t){let e=typeof t==`string`?F(t):t;M(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=he(e,{pathname:p});N(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),N(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=vt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:z([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:z([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?j.createElement(U.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},h):h}function ft(){let e=Dt(),t=Ue(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=j.createElement(j.Fragment,null,j.createElement(`p`,null,`💿 Hey developer 👋`),j.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,j.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,j.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),j.createElement(j.Fragment,null,j.createElement(`h2`,null,`Unexpected Application Error!`),j.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?j.createElement(`pre`,{style:i},n):null,o)}var pt=j.createElement(ft,null),mt=class extends j.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=it(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:j.createElement(W.Provider,{value:this.props.routeContext},j.createElement($e.Provider,{value:e,children:this.props.component}));return this.context?j.createElement(gt,{error:e},t):t}};mt.contextType=Ye;var ht=new WeakMap;function gt({children:e,error:t}){let{basename:n}=j.useContext(H);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=rt(t.digest);if(e){let r=ht.get(t);if(r)throw r;let i=Ke(e.location,n);if(Ge&&!ht.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw ht.set(t,n),n}return j.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function _t({routeContext:e,match:t,children:n}){let r=j.useContext(B);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),j.createElement(W.Provider,{value:e},n)}function vt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);M(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:We(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||pt,o&&(s<0&&c===0?(At(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?j.createElement(n.route.Component,null):n.route.element?n.route.element:e,j.createElement(_t,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?j.createElement(mt,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function yt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bt(e){let t=j.useContext(B);return M(t,yt(e)),t}function xt(e){let t=j.useContext(V);return M(t,yt(e)),t}function St(e){let t=j.useContext(W);return M(t,yt(e)),t}function Ct(e){let t=St(e),n=t.matches[t.matches.length-1];return M(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function wt(){return Ct(`useRouteId`)}function Tt(){return xt(`useNavigation`).navigation}function Et(){let{matches:e,loaderData:t}=xt(`useMatches`);return j.useMemo(()=>e.map(e=>_e(e,t)),[e,t])}function Dt(){let e=j.useContext($e),t=xt(`useRouteError`),n=Ct(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Ot(){let{router:e}=bt(`useNavigate`),t=Ct(`useNavigate`),n=j.useRef(!1);return st(()=>{n.current=!0}),j.useCallback(async(r,i={})=>{N(n.current,ot),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var kt={};function At(e,t,n){!t&&!kt[e]&&(kt[e]=!0,N(!1,n))}j.useOptimistic,j.memo(jt);function jt({routes:e,future:t,state:n,isStatic:r,onError:i}){return dt(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function Mt({to:e,replace:t,state:n,relative:r}){M(G(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j.useContext(H);N(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=j.useContext(W),{pathname:o}=K(),s=q(),c=R(e,Re(a),o,r===`path`),l=JSON.stringify(c);return j.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Nt(e){M(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Pt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){M(!G(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=j.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=F(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,unstable_mask:m}=n,h=j.useMemo(()=>{let e=L(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,unstable_mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return N(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:j.createElement(H.Provider,{value:c},j.createElement(U.Provider,{children:t,value:h}))}function Ft({children:e,location:t}){return ut(It(e),t)}function It(e,t=[]){let n=[];return j.Children.forEach(e,(e,r)=>{if(!j.isValidElement(e))return;let i=[...t,r];if(e.type===j.Fragment){n.push.apply(n,It(e.props.children,i));return}M(e.type===Nt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),M(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=It(e.props.children,i)),n.push(a)}),n}var Lt=`get`,Rt=`application/x-www-form-urlencoded`;function zt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Bt(e){return zt(e)&&e.tagName.toLowerCase()===`button`}function Vt(e){return zt(e)&&e.tagName.toLowerCase()===`form`}function Ht(e){return zt(e)&&e.tagName.toLowerCase()===`input`}function Ut(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Wt(e,t){return e.button===0&&(!t||t===`_self`)&&!Ut(e)}function Gt(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Kt(e,t){let n=Gt(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var qt=null;function Jt(){if(qt===null)try{new FormData(document.createElement(`form`),0),qt=!1}catch{qt=!0}return qt}var Yt=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Xt(e){return e!=null&&!Yt.has(e)?(N(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Rt}"`),null):e}function Zt(e,t){let n,r,i,a,o;if(Vt(e)){let o=e.getAttribute(`action`);r=o?L(o,t):null,n=e.getAttribute(`method`)||Lt,i=Xt(e.getAttribute(`enctype`))||Rt,a=new FormData(e)}else if(Bt(e)||Ht(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?L(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Lt,i=Xt(e.getAttribute(`formenctype`))||Xt(o.getAttribute(`enctype`))||Rt,a=new FormData(o,e),!Jt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(zt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Lt,r=null,i=Rt,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Qt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},$t=/[&><\u2028\u2029]/g;function en(e){return e.replace($t,e=>Qt[e])}function tn(e,t){if(e===!1||e==null)throw Error(t)}function nn(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&L(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function rn(e,t){if(e.id in t)return t[e.id];try{let n=await oe(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function an(e){return e!=null&&typeof e.page==`string`}function on(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function sn(e,t,n){return fn((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await rn(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(on).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function cn(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function ln(e,t,{includeHydrateFallback:n}={}){return un(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function un(e){return[...new Set(e)]}function dn(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function fn(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!an(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(dn(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function pn(){let e=j.useContext(B);return tn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function mn(){let e=j.useContext(V);return tn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var hn=j.createContext(void 0);hn.displayName=`FrameworkContext`;function gn(){let e=j.useContext(hn);return tn(e,`You must render this element inside a <HydratedRouter> element`),e}function _n(e,t){let n=j.useContext(hn),[r,i]=j.useState(!1),[a,o]=j.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=j.useRef(null);j.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),j.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Y(s,p),onBlur:Y(c,m),onMouseEnter:Y(l,p),onMouseLeave:Y(u,m),onTouchStart:Y(d,p)}]:[a,f,{}]:[!1,f,{}]}function Y(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function vn({page:e,...t}){let{router:n}=pn(),r=j.useMemo(()=>he(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?j.createElement(bn,{page:e,matches:r,...t}):null}function yn(e){let{manifest:t,routeModules:n}=gn(),[r,i]=j.useState([]);return j.useEffect(()=>{let r=!1;return sn(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function bn({page:e,matches:t,...n}){let r=K(),{future:i,manifest:a,routeModules:o}=gn(),{basename:s}=pn(),{loaderData:c,matches:l}=mn(),u=j.useMemo(()=>cn(e,t,l,a,r,`data`),[e,t,l,a,r]),d=j.useMemo(()=>cn(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=j.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=nn(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=j.useMemo(()=>ln(d,a),[d,a]),m=yn(d);return j.createElement(j.Fragment,null,f.map(e=>j.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>j.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>j.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function xn(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Sn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Sn&&(window.__reactRouterVersion=`7.13.1`)}catch{}function Cn({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=j.useRef();i.current??=le({window:r,v5Compat:!0});let a=i.current,[o,s]=j.useState({action:a.action,location:a.location}),c=j.useCallback(e=>{n===!1?s(e):j.startTransition(()=>s(e))},[n]);return j.useLayoutEffect(()=>a.listen(c),[a,c]),j.createElement(Pt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function wn({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=j.useState({action:n.action,location:n.location}),o=j.useCallback(e=>{r===!1?a(e):j.startTransition(()=>a(e))},[r]);return j.useLayoutEffect(()=>n.listen(o),[n,o]),j.createElement(Pt,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}wn.displayName=`unstable_HistoryRouter`;var Tn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,En=j.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,unstable_useTransitions:_}=j.useContext(H),v=typeof l==`string`&&Tn.test(l),y=Ke(l,h);l=y.to;let b=at(l,{relative:r}),x=K(),S=null;if(o){let e=R(o,[],x.unstable_mask?x.unstable_mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:z([h,e.pathname])),S=g.createHref(e)}let[C,w,T]=_n(n,p),E=Nn(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:_});function D(t){e&&e(t),t.defaultPrevented||E(t)}let ee=!(y.isExternal||i),te=j.createElement(`a`,{...p,...T,href:(ee?S:void 0)||y.absoluteURL||b,onClick:ee?D:e,ref:xn(m,w),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return C&&!v?j.createElement(j.Fragment,null,te,j.createElement(vn,{page:b})):te});En.displayName=`Link`;var Dn=j.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=J(a,{relative:c.relative}),d=K(),f=j.useContext(V),{navigator:p,basename:m}=j.useContext(H),h=f!=null&&Un(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=L(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return j.createElement(En,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Dn.displayName=`NavLink`;var On=j.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Lt,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=j.useContext(H),g=Ln(),_=Rn(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Tn.test(s);return j.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?j.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});On.displayName=`Form`;function kn({getKey:e,storageKey:t,...n}){let r=j.useContext(hn),{basename:i}=j.useContext(H),a=K(),o=Et();Vn({getKey:e,storageKey:t});let s=j.useMemo(()=>{if(!r||!e)return null;let t=Bn(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return j.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${en(JSON.stringify(t||zn))}, ${en(JSON.stringify(s))})`}})}kn.displayName=`ScrollRestoration`;function An(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function jn(e){let t=j.useContext(B);return M(t,An(e)),t}function Mn(e){let t=j.useContext(V);return M(t,An(e)),t}function Nn(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=q(),d=K(),f=J(e,{relative:o});return j.useCallback(p=>{if(Wt(p,t)){p.preventDefault();let t=n===void 0?P(d)===P(f):n,m=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?j.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function Pn(e){N(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=j.useRef(Gt(e)),n=j.useRef(!1),r=K(),i=j.useMemo(()=>Kt(r.search,n.current?null:t.current),[r.search]),a=q();return[i,j.useCallback((e,t)=>{let r=Gt(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Fn=0,In=()=>`__${String(++Fn)}__`;function Ln(){let{router:e}=jn(`useSubmit`),{basename:t}=j.useContext(H),n=wt(),r=e.fetch,i=e.navigate;return j.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Zt(e,t);a.navigate===!1?await r(a.fetcherKey||In(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Rn(e,{relative:t}={}){let{basename:n}=j.useContext(H),r=j.useContext(W);M(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...J(e||`.`,{relative:t})},o=K();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:z([n,a.pathname])),P(a)}var zn=`react-router-scroll-positions`,X={};function Bn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:L(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Vn({getKey:e,storageKey:t}={}){let{router:n}=jn(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Mn(`useScrollRestoration`),{basename:a}=j.useContext(H),o=K(),s=Et(),c=Tt();j.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Hn(j.useCallback(()=>{if(c.state===`idle`){let t=Bn(o,s,a,e);X[t]=window.scrollY}try{sessionStorage.setItem(t||zn,JSON.stringify(X))}catch(e){N(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(j.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||zn);e&&(X=JSON.parse(e))}catch{}},[t]),j.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(X,()=>window.scrollY,e?(t,n)=>Bn(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),j.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{N(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Hn(e,t){let{capture:n}=t||{};j.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Un(e,{relative:t}={}){let n=j.useContext(Xe);M(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=jn(`useViewTransitionState`),i=J(e,{relative:t});if(!n.isTransitioning)return!1;let a=L(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=L(n.nextLocation.pathname,r)||n.nextLocation.pathname;return I(i.pathname,o)!=null||I(i.pathname,a)!=null}var Z=n();function Wn(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return`${Math.round(s*360)} ${Math.round(c*100)}% ${Math.round(l*100)}%`}function Gn(e,t){(0,j.useEffect)(()=>{let n=document.documentElement;if(e?.primaryColor){let t=Wn(e.primaryColor);t&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`);if(e?.accentColor){let t=Wn(e.accentColor);t&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`);if(e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function Kn({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return Gn(a,a?.title),(0,Z.jsxs)(u,{defaultOpen:i,children:[e,(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(`header`,{className:`flex h-14 sm:h-16 shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:[(0,Z.jsx)(d,{className:`-ml-1 hidden md:inline-flex`}),(0,Z.jsx)(`div`,{className:`w-px h-4 bg-border mx-1 sm:mx-2 hidden md:block`}),t]}),(0,Z.jsx)(`main`,{className:ae(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6`,r),children:n})]})]})}var qn=new Map;function Jn(e){if(!e)return g;let t=qn.get(e);if(t)return t;if(b[e])return qn.set(e,b[e]),b[e];let n=e.split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return b[n]?(qn.set(e,b[n]),b[n]):g}function Q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function Yn(e,t,n){let r=Q(e.label,n);return t&&e.type===`object`&&e.objectName&&typeof e.label==`string`?t(e.objectName,r):r}var Xn=e=>!(e===!1||e===`false`),Zn=()=>!0;function Qn(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};default:return{href:`#`,external:!1}}}function $n(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=$n(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return Q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var er=5;function tr({item:e,basePath:t,evalVis:n,checkPerm:r,onAction:i,enablePinning:a,onPinToggle:o,enableReorder:s,resolveObjectLabel:c,t:l}){let{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:m,isDragging:h}=C({id:e.id,disabled:!s});return(0,Z.jsx)(`div`,{ref:f,style:{transform:A.Transform.toString(p),transition:m,opacity:h?.5:void 0,zIndex:h?10:void 0},...u,children:(0,Z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,onAction:i,enablePinning:a,onPinToggle:o,dragListeners:s?d:void 0,resolveObjectLabel:c,t:l})})}function $({item:e,basePath:t,evalVis:n,checkPerm:u,onAction:d,enablePinning:g,onPinToggle:b,dragListeners:S,resolveObjectLabel:C,t:w}){let T=K(),[E,ee]=(0,j.useState)(e.defaultOpen!==!1);if(!n(e.visible)||e.requiredPermissions?.length&&!u(e.requiredPermissions))return null;if(e.type===`separator`)return(0,Z.jsx)(x,{className:`my-2`});if(e.type===`group`){let a=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,Z.jsx)(m,{open:E,onOpenChange:ee,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsxs)(i,{className:`flex w-full items-center justify-between`,children:[Q(e.label,w),(0,Z.jsx)(r,{className:`ml-auto h-4 w-4 transition-transform ${E?`rotate-90`:``}`})]})}),(0,Z.jsx)(D,{children:(0,Z.jsx)(o,{children:(0,Z.jsx)(f,{children:a.map(e=>(0,Z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:u,onAction:d,enablePinning:g,onPinToggle:b,resolveObjectLabel:C,t:w},e.id))})})})]})})}if(e.type===`action`){let t=Jn(e.icon);return(0,Z.jsxs)(c,{children:[S&&(0,Z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":`Drag to reorder`,...S,children:(0,Z.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(v,{tooltip:Q(e.label,w),onClick:()=>d?.(e),children:[(0,Z.jsx)(t,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:Q(e.label,w)}),e.badge!=null&&(0,Z.jsx)(_,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),g&&b&&(0,Z.jsx)(p,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned),"aria-label":e.pinned?`Unpin ${Q(e.label,w)}`:`Pin ${Q(e.label,w)}`,children:e.pinned?(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(l,{className:`h-3.5 w-3.5`})})]})}let te=Jn(e.icon),{href:O,external:ne}=Qn(e,t),re=O!==`#`&&T.pathname.startsWith(O),k=Yn(e,C,w),ie=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(te,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k}),e.badge!=null&&(0,Z.jsx)(_,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,Z.jsxs)(c,{children:[S&&(0,Z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":`Drag to reorder`,...S,children:(0,Z.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(v,{asChild:!0,isActive:re,tooltip:k,children:ne?(0,Z.jsx)(`a`,{href:O,target:`_blank`,rel:`noopener noreferrer`,children:ie}):(0,Z.jsx)(En,{to:O,children:ie})}),g&&b&&(0,Z.jsx)(p,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned),"aria-label":e.pinned?`Unpin ${k}`:`Pin ${k}`,children:e.pinned?(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(l,{className:`h-3.5 w-3.5`})})]})}function nr({items:e,basePath:t=``,evaluateVisibility:n=Xn,checkPermission:r=Zn,onAction:i,searchQuery:a,enablePinning:c,onPinToggle:l,enableReorder:u,onReorder:d,resolveObjectLabel:p,t:m}){let g=(0,j.useMemo)(()=>a?$n(e,a):e,[e,a]),_=(0,j.useMemo)(()=>rr(g),[g]),v=g.slice().sort((e,t)=>(e.order??0)-(t.order??0)),y=k(S(O,{activationConstraint:{distance:er}}),S(w)),b=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!d)return;let r=v.findIndex(e=>e.id===t.id),i=v.findIndex(e=>e.id===n.id);r===-1||i===-1||d(ne(v,r,i).map((e,t)=>({...e,order:t})))},x={basePath:t,evalVis:n,checkPerm:r,onAction:i,enablePinning:c,onPinToggle:l,resolveObjectLabel:p,t:m},C=v.some(e=>e.type===`group`),E=_.length>0&&c?(0,Z.jsxs)(s,{children:[(0,Z.jsxs)(h,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ie,{className:`h-3.5 w-3.5`}),`Favorites`]}),(0,Z.jsx)(o,{children:(0,Z.jsx)(f,{children:_.map(e=>(0,Z.jsx)($,{item:e,...x},`fav-${e.id}`))})})]}):null;if(!C){let e=v.filter(e=>e.type!==`group`).map(e=>e.id);return(0,Z.jsxs)(Z.Fragment,{children:[E,(0,Z.jsx)(s,{children:(0,Z.jsx)(o,{children:u?(0,Z.jsx)(re,{sensors:y,collisionDetection:T,onDragEnd:b,children:(0,Z.jsx)(te,{items:e,strategy:ee,children:(0,Z.jsx)(f,{children:v.map(e=>(0,Z.jsx)(tr,{item:e,enableReorder:u,...x},e.id))})})}):(0,Z.jsx)(f,{children:v.map(e=>(0,Z.jsx)($,{item:e,...x},e.id))})})})]})}let D=[],A=[],ae=e=>{if(A.length===0)return;let t=A;A=[],D.push((0,Z.jsx)(s,{children:(0,Z.jsx)(o,{children:(0,Z.jsx)(f,{children:t.map(e=>(0,Z.jsx)($,{item:e,...x},e.id))})})},e))};return v.forEach((e,t)=>{e.type===`group`?(ae(`leaf-${t}`),D.push((0,Z.jsx)($,{item:e,...x},e.id))):A.push(e)}),ae(`leaf-end`),(0,Z.jsxs)(Z.Fragment,{children:[E,D]})}function rr(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...rr(n.children));return t}export{Mt as a,K as c,Pn as d,En as i,q as l,Kn as n,Nt as o,Cn as r,Ft as s,nr as t,lt as u};