@object-ui/console 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdvancedChartImpl-Q6xhwCd2.js → AdvancedChartImpl-D711bBuO.js} +1 -1
- package/dist/assets/{AppManagementPage-Bqi2RIF_.js → AppManagementPage-CaWUYaXX.js} +1 -1
- package/dist/assets/{AuditLogPage-Bhvo34U0.js → AuditLogPage-CB1qkThp.js} +1 -1
- package/dist/assets/AuthPageLayout-9l5xWV_-.js +1 -0
- package/dist/assets/{ChartImpl-SceZDRuZ.js → ChartImpl-B9B4Fnbe.js} +1 -1
- package/dist/assets/CreateAppPage-DLRU3TEg.js +1 -0
- package/dist/assets/DashboardDesignPage-DGz-5xrK.js +1 -0
- package/dist/assets/{DashboardView-DxpkEpzI.js → DashboardView-v834XbaQ.js} +1 -1
- package/dist/assets/{EditAppPage-4REKKtym.js → EditAppPage-DocDqKMS.js} +1 -1
- package/dist/assets/ForgotPasswordPage-8ypvh4-X.js +1 -0
- package/dist/assets/{KanbanEnhanced-Cy_rTBDD.js → KanbanEnhanced-Cw4oddBv.js} +1 -1
- package/dist/assets/{KanbanImpl-BNUeFn31.js → KanbanImpl-D6ggfmB0.js} +1 -1
- package/dist/assets/LoginPage-XakThPoT.js +1 -0
- package/dist/assets/{MarkdownImpl-DQVBgcsA.js → MarkdownImpl-C0wRapHT.js} +1 -1
- package/dist/assets/{OrgManagementPage-9aUMu-3n.js → OrgManagementPage-Df5167oO.js} +1 -1
- package/dist/assets/{PageDesignPage-bfUbiZI-.js → PageDesignPage-BzM4EsXt.js} +1 -1
- package/dist/assets/PageView-CpIQvLmr.js +2 -0
- package/dist/assets/{PermissionManagementPage-CfKXMrSe.js → PermissionManagementPage-CZH3URJU.js} +1 -1
- package/dist/assets/{ProfilePage-aGYrzo6-.js → ProfilePage-BvIbbebc.js} +1 -1
- package/dist/assets/RecordDetailView-BNnPf0DG.js +1 -0
- package/dist/assets/RegisterPage-CIeFN9rY.js +1 -0
- package/dist/assets/{ReportView-DYDYKXxz.js → ReportView-DYhXezmy.js} +1 -1
- package/dist/assets/{RoleManagementPage-DvuObd50.js → RoleManagementPage-D0X7HlqJ.js} +1 -1
- package/dist/assets/{SearchResultsPage-BXv9faGO.js → SearchResultsPage-CoMB32KW.js} +1 -1
- package/dist/assets/{SystemHubPage-DInbGUIC.js → SystemHubPage-Cvl3VKcV.js} +1 -1
- package/dist/assets/{UserManagementPage-DfN7rtzx.js → UserManagementPage-5k8BQxT1.js} +1 -1
- package/dist/assets/data-adapter-Bif-TtZA.js +1 -0
- package/dist/assets/framework-52FGgFF6.js +10 -0
- package/dist/assets/index-D5i0wk-G.js +1 -0
- package/dist/assets/index-fjkakZm9.js +9 -0
- package/dist/assets/index-h9Jznm67.css +1 -0
- package/dist/assets/infrastructure-Dn7jNPwf.js +1 -0
- package/dist/assets/{maplibre-gl-Hx2FX3ON.js → maplibre-gl-DVmJFhI2.js} +1 -1
- package/dist/assets/plugins-core-CP8uPw4p.js +8 -0
- package/dist/assets/plugins-views-DZCu8Ex3.js +62 -0
- package/dist/assets/ui-components-BE4yvyhE.js +36 -0
- package/dist/assets/ui-components-CxztIKgM.css +1 -0
- package/dist/assets/ui-layout-CYnH69Z2.js +1 -0
- package/dist/assets/{vendor-charts-BbkZFaMp.js → vendor-charts-BLNOCZWl.js} +1 -1
- package/dist/assets/{vendor-dndkit-D1_B-HIy.js → vendor-dndkit-CX1oDZqy.js} +1 -1
- package/dist/assets/{vendor-i18n-CikIh7Op.js → vendor-i18n-E3-WitRV.js} +1 -1
- package/dist/assets/{vendor-icons-CsQ20zph.js → vendor-icons-ndICq8DC.js} +2 -2
- package/dist/assets/vendor-objectstack-CatrkstC.js +34 -0
- package/dist/assets/{vendor-radix-CWYRmupg.js → vendor-radix-C6qchjxv.js} +1 -1
- package/dist/assets/{vendor-react-BEJ2LWyF.js → vendor-react-9M-xu2bR.js} +7 -7
- package/dist/assets/{vendor-ui-utils-tMfURc0Z.js → vendor-ui-utils-3tkeUVaX.js} +1 -1
- package/dist/assets/{vendor-zod-DxQVy2_o.js → vendor-zod-C5j6C2CQ.js} +1 -1
- package/dist/index.html +23 -23
- package/package.json +36 -36
- package/plugin.d.ts +1 -2
- package/plugin.js +1 -2
- package/plugin.ts +1 -2
- package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.br +0 -0
- package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.gz +0 -0
- package/dist/assets/AppManagementPage-Bqi2RIF_.js.br +0 -0
- package/dist/assets/AppManagementPage-Bqi2RIF_.js.gz +0 -0
- package/dist/assets/AuditLogPage-Bhvo34U0.js.br +0 -0
- package/dist/assets/AuditLogPage-Bhvo34U0.js.gz +0 -0
- package/dist/assets/ChartImpl-SceZDRuZ.js.br +0 -0
- package/dist/assets/ChartImpl-SceZDRuZ.js.gz +0 -0
- package/dist/assets/CreateAppPage-BBV1-x1E.js +0 -1
- package/dist/assets/CreateAppPage-BBV1-x1E.js.br +0 -0
- package/dist/assets/CreateAppPage-BBV1-x1E.js.gz +0 -0
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js +0 -1
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js.br +0 -0
- package/dist/assets/DashboardDesignPage-Dsve6QAo.js.gz +0 -0
- package/dist/assets/DashboardView-DxpkEpzI.js.br +0 -0
- package/dist/assets/DashboardView-DxpkEpzI.js.gz +0 -0
- package/dist/assets/EditAppPage-4REKKtym.js.br +0 -0
- package/dist/assets/EditAppPage-4REKKtym.js.gz +0 -0
- package/dist/assets/ForgotPasswordPage-_rDOa2Zl.js +0 -1
- package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.br +0 -0
- package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.gz +0 -0
- package/dist/assets/KanbanImpl-BNUeFn31.js.br +0 -0
- package/dist/assets/KanbanImpl-BNUeFn31.js.gz +0 -0
- package/dist/assets/LoginPage-BXP5VJhw.js +0 -1
- package/dist/assets/MarkdownImpl-DQVBgcsA.js.br +0 -0
- package/dist/assets/MarkdownImpl-DQVBgcsA.js.gz +0 -0
- package/dist/assets/OrgManagementPage-9aUMu-3n.js.br +0 -0
- package/dist/assets/OrgManagementPage-9aUMu-3n.js.gz +0 -0
- package/dist/assets/PageDesignPage-bfUbiZI-.js.br +0 -0
- package/dist/assets/PageDesignPage-bfUbiZI-.js.gz +0 -0
- package/dist/assets/PageView-BNyUOHBp.js +0 -2
- package/dist/assets/PageView-BNyUOHBp.js.br +0 -0
- package/dist/assets/PageView-BNyUOHBp.js.gz +0 -0
- package/dist/assets/PermissionManagementPage-CfKXMrSe.js.br +0 -0
- package/dist/assets/PermissionManagementPage-CfKXMrSe.js.gz +0 -0
- package/dist/assets/ProfilePage-aGYrzo6-.js.br +0 -0
- package/dist/assets/ProfilePage-aGYrzo6-.js.gz +0 -0
- package/dist/assets/RecordDetailView-Cbo06TgT.js +0 -1
- package/dist/assets/RecordDetailView-Cbo06TgT.js.br +0 -0
- package/dist/assets/RecordDetailView-Cbo06TgT.js.gz +0 -0
- package/dist/assets/RegisterPage-By5Xlwoy.js +0 -1
- package/dist/assets/ReportView-DYDYKXxz.js.br +0 -0
- package/dist/assets/ReportView-DYDYKXxz.js.gz +0 -0
- package/dist/assets/RoleManagementPage-DvuObd50.js.br +0 -0
- package/dist/assets/RoleManagementPage-DvuObd50.js.gz +0 -0
- package/dist/assets/SearchResultsPage-BXv9faGO.js.br +0 -0
- package/dist/assets/SearchResultsPage-BXv9faGO.js.gz +0 -0
- package/dist/assets/SystemHubPage-DInbGUIC.js.br +0 -0
- package/dist/assets/SystemHubPage-DInbGUIC.js.gz +0 -0
- package/dist/assets/UserManagementPage-DfN7rtzx.js.br +0 -0
- package/dist/assets/UserManagementPage-DfN7rtzx.js.gz +0 -0
- package/dist/assets/data-adapter-Cnk_Mp2r.js +0 -1
- package/dist/assets/data-adapter-Cnk_Mp2r.js.br +0 -0
- package/dist/assets/data-adapter-Cnk_Mp2r.js.gz +0 -0
- package/dist/assets/framework-0M39ZRTM.js +0 -10
- package/dist/assets/framework-0M39ZRTM.js.br +0 -0
- package/dist/assets/framework-0M39ZRTM.js.gz +0 -0
- package/dist/assets/index-B5fEfHjB.css +0 -1
- package/dist/assets/index-B5fEfHjB.css.br +0 -0
- package/dist/assets/index-B5fEfHjB.css.gz +0 -0
- package/dist/assets/index-BlrxLcAr.js +0 -1
- package/dist/assets/index-BlrxLcAr.js.br +0 -0
- package/dist/assets/index-BlrxLcAr.js.gz +0 -0
- package/dist/assets/index-o38_J709.js +0 -9
- package/dist/assets/index-o38_J709.js.br +0 -0
- package/dist/assets/index-o38_J709.js.gz +0 -0
- package/dist/assets/infrastructure-CShH4S9_.js +0 -1
- package/dist/assets/infrastructure-CShH4S9_.js.br +0 -0
- package/dist/assets/infrastructure-CShH4S9_.js.gz +0 -0
- package/dist/assets/maplibre-gl-Hx2FX3ON.js.br +0 -0
- package/dist/assets/maplibre-gl-Hx2FX3ON.js.gz +0 -0
- package/dist/assets/plugins-core-DBl14Uqc.js +0 -8
- package/dist/assets/plugins-core-DBl14Uqc.js.br +0 -0
- package/dist/assets/plugins-core-DBl14Uqc.js.gz +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.br +0 -0
- package/dist/assets/plugins-views-P3eB-els.css.gz +0 -0
- package/dist/assets/plugins-views-g4Cu3W3w.js +0 -62
- package/dist/assets/plugins-views-g4Cu3W3w.js.br +0 -0
- package/dist/assets/plugins-views-g4Cu3W3w.js.gz +0 -0
- package/dist/assets/systemObjects-DSpePIIy.js.br +0 -2
- package/dist/assets/systemObjects-DSpePIIy.js.gz +0 -0
- package/dist/assets/ui-components-BuNW5g1I.js +0 -36
- package/dist/assets/ui-components-BuNW5g1I.js.br +0 -0
- package/dist/assets/ui-components-BuNW5g1I.js.gz +0 -0
- package/dist/assets/ui-components-D5YXsttd.css +0 -1
- package/dist/assets/ui-components-D5YXsttd.css.br +0 -0
- package/dist/assets/ui-components-D5YXsttd.css.gz +0 -0
- package/dist/assets/ui-layout-BSKYz8QD.js +0 -1
- package/dist/assets/ui-layout-BSKYz8QD.js.br +0 -0
- package/dist/assets/ui-layout-BSKYz8QD.js.gz +0 -0
- package/dist/assets/vendor-charts-BbkZFaMp.js.br +0 -0
- package/dist/assets/vendor-charts-BbkZFaMp.js.gz +0 -0
- package/dist/assets/vendor-dndkit-D1_B-HIy.js.br +0 -0
- package/dist/assets/vendor-dndkit-D1_B-HIy.js.gz +0 -0
- package/dist/assets/vendor-i18n-CikIh7Op.js.br +0 -0
- package/dist/assets/vendor-i18n-CikIh7Op.js.gz +0 -0
- package/dist/assets/vendor-icons-CsQ20zph.js.br +0 -0
- package/dist/assets/vendor-icons-CsQ20zph.js.gz +0 -0
- package/dist/assets/vendor-objectstack-aMKO1xRi.js +0 -34
- package/dist/assets/vendor-objectstack-aMKO1xRi.js.br +0 -0
- package/dist/assets/vendor-objectstack-aMKO1xRi.js.gz +0 -0
- package/dist/assets/vendor-radix-CWYRmupg.js.br +0 -0
- package/dist/assets/vendor-radix-CWYRmupg.js.gz +0 -0
- package/dist/assets/vendor-react-BEJ2LWyF.js.br +0 -0
- package/dist/assets/vendor-react-BEJ2LWyF.js.gz +0 -0
- package/dist/assets/vendor-ui-utils-tMfURc0Z.js.br +0 -0
- package/dist/assets/vendor-ui-utils-tMfURc0Z.js.gz +0 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js.br +0 -0
- package/dist/assets/vendor-zod-DxQVy2_o.js.gz +0 -0
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/mockServiceWorker.js.br +0 -0
- package/dist/mockServiceWorker.js.gz +0 -0
- package/dist/stats.html +0 -4950
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as zt,r as fe,C as ge}from"./framework-0M39ZRTM.js";import{r as a,B as $t}from"./vendor-react-BEJ2LWyF.js";import{t as le,c as oe}from"./vendor-ui-utils-tMfURc0Z.js";import"./vendor-objectstack-aMKO1xRi.js";import{X as ct,b as la,d as pt,a as Ae,b7 as ut,be as Ut,bf as Kt,bg as Gt,aY as Ue,ak as mt,ai as Ke,o as we,p as Ce,y as Ge,U as He,J as Ve,K as Pe,u as oa,b5 as ia,b6 as da,N as gt,bh as Ht,as as Vt,a6 as Bt,aS as ca,aT as pa,T as ua,aQ as ot,b2 as _t,b3 as Yt,r as Xt,_ as Be,bi as _e,aj as ma,b4 as ga,m as ve,bj as xa,l as ue,C as me,at as Jt,bk as ba,bl as ha,M as xt,F as Zt,bm as bt,aX as ya,b0 as fa,ag as Wt,aa as qt,f as Te,bn as va,aP as ja,av as Na,bo as wa,bp as Ca,aN as ht,G as Ye,aw as ka,bq as Da,br as Qt,bs as Sa,bt as vt,bu as Ia,aM as Pa,aG as Ta,a8 as Oa,P as Ea,bv as Ra,S as Aa}from"./vendor-icons-CsQ20zph.js";import"./vendor-zod-DxQVy2_o.js";import"./ui-components-BuNW5g1I.js";import"./vendor-radix-CWYRmupg.js";import"./vendor-i18n-CikIh7Op.js";import"./vendor-charts-BbkZFaMp.js";import"./infrastructure-CShH4S9_.js";var jt={exports:{}},Oe={},Nt;function La(){if(Nt)return Oe;Nt=1;var t=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(i,n,r){var p=null;if(r!==void 0&&(p=""+r),n.key!==void 0&&(p=""+n.key),"key"in n){r={};for(var b in n)b!=="key"&&(r[b]=n[b])}else r=n;return n=r.ref,{$$typeof:t,type:i,key:p,ref:n!==void 0?n:null,props:r}}return Oe.Fragment=s,Oe.jsx=l,Oe.jsxs=l,Oe}var wt;function Ma(){return wt||(wt=1,jt.exports=La()),jt.exports}var e=Ma();function ke(t,s={}){const{maxHistory:l=50}=s,[i,n]=a.useState(t),r=a.useRef([]),p=a.useRef([]),b=a.useCallback(d=>{n(m=>(r.current=[...r.current.slice(-(l-1)),m],p.current=[],d))},[l]),g=a.useCallback(()=>{r.current.length!==0&&n(d=>{const m=[...r.current],j=m.pop();return r.current=m,p.current=[d,...p.current],j})},[]),o=a.useCallback(()=>{p.current.length!==0&&n(d=>{const m=[...p.current],j=m.shift();return p.current=m,r.current=[...r.current,d],j})},[]),u=a.useCallback(d=>{r.current=[],p.current=[],n(d)},[]);return{current:i,canUndo:r.current.length>0,canRedo:p.current.length>0,undoCount:r.current.length,redoCount:p.current.length,push:b,undo:g,redo:o,reset:u}}function Le(){const[t,s]=a.useState(!1),[l,i]=a.useState(""),[n,r]=a.useState(""),p=a.useRef(null),b=a.useCallback((u,d)=>(i(u),r(d),s(!0),new Promise(m=>{p.current=m})),[]),g=a.useCallback(()=>{s(!1),p.current?.(!0),p.current=null},[]),o=a.useCallback(()=>{s(!1),p.current?.(!1),p.current=null},[]);return{isOpen:t,title:l,message:n,confirm:b,onConfirm:g,onCancel:o}}function Xe(){const[t,s]=a.useState(new Set),l=a.useCallback((b,g=!1)=>{s(o=>{const u=new Set(g?o:[]);return o.has(b)&&g?u.delete(b):u.add(b),u})},[]),i=a.useCallback(b=>{s(new Set([b]))},[]),n=a.useCallback(b=>{s(new Set(b))},[]),r=a.useCallback(()=>{s(new Set)},[]),p=a.useCallback(b=>t.has(b),[t]);return{selectedIds:t,toggle:l,selectOne:i,selectMany:n,clearSelection:r,isSelected:p,count:t.size}}function Je(){const[t,s]=a.useState(null),l=a.useCallback(n=>{s(structuredClone(n))},[]),i=a.useCallback(()=>t?structuredClone(t):null,[t]);return{clipboard:t,copy:l,paste:i,hasContent:t!==null}}function yt(t={}){const{minZoom:s=.25,maxZoom:l=3,zoomStep:i=.1,initialZoom:n=1}=t,[r,p]=a.useState(n),[b,g]=a.useState({x:0,y:0}),o=a.useRef(!1),u=a.useRef({x:0,y:0}),d=a.useCallback(L=>Math.min(l,Math.max(s,+L.toFixed(2))),[s,l]),m=a.useCallback(()=>p(L=>d(L+i)),[d,i]),j=a.useCallback(()=>p(L=>d(L-i)),[d,i]),x=a.useCallback(()=>{p(1),g({x:0,y:0})},[]),k=a.useCallback(L=>p(d(L)),[d]),T=a.useCallback(L=>{if(L.ctrlKey||L.metaKey){L.preventDefault();const U=L.deltaY>0?-i:i;p(w=>d(w+U))}},[d,i]),P=a.useCallback(L=>{if(L.button===1||L.button===0&&L.altKey){L.preventDefault(),o.current=!0,u.current={x:L.clientX,y:L.clientY};const U=S=>{if(!o.current)return;const y=S.clientX-u.current.x,I=S.clientY-u.current.y;u.current={x:S.clientX,y:S.clientY},g(C=>({x:C.x+y,y:C.y+I}))},w=()=>{o.current=!1,document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",U),document.addEventListener("mouseup",w)}},[]),R={transform:`translate(${b.x}px, ${b.y}px) scale(${r})`,transformOrigin:"0 0"};return{zoom:r,panOffset:b,zoomIn:m,zoomOut:j,resetZoom:x,setZoom:k,handleWheel:T,startPan:P,transformStyle:R}}function Fa(...t){return le(oe(t))}function Ze({isOpen:t,title:s,message:l,confirmLabel:i="Delete",cancelLabel:n="Cancel",destructive:r=!0,onConfirm:p,onCancel:b}){const g=a.useRef(null);return a.useEffect(()=>{const o=g.current;o&&(t&&!o.open?o.showModal():!t&&o.open&&o.close())},[t]),t?e.jsx("dialog",{ref:g,className:"fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50",onClose:b,"aria-labelledby":"confirm-title","aria-describedby":"confirm-message",children:e.jsxs("div",{className:"w-80 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10",children:e.jsx(ua,{className:"h-5 w-5 text-destructive"})}),e.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold",children:s})]}),e.jsx("p",{id:"confirm-message",className:"text-sm text-muted-foreground mb-6",children:l}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:b,className:"px-4 py-2 text-sm rounded-md border hover:bg-accent",children:n}),e.jsx("button",{onClick:p,className:Fa("px-4 py-2 text-sm rounded-md font-medium",r?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"),autoFocus:!0,children:i})]})]})}):null}function za(...t){return le(oe(t))}function We({title:t="Properties",fields:s,onChange:l,className:i}){const[n,r]=a.useState(new Set),p=a.useCallback(g=>{r(o=>{const u=new Set(o);return u.has(g)?u.delete(g):u.add(g),u})},[]),b=s.reduce((g,o)=>{const u=o.group??"General";return g[u]||(g[u]=[]),g[u].push(o),g},{});return e.jsxs("div",{className:za("flex flex-col",i),role:"region","aria-label":t,children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:t}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Object.entries(b).map(([g,o])=>e.jsxs("div",{className:"border-b last:border-b-0",children:[e.jsxs("button",{onClick:()=>p(g),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50",children:[n.has(g)?e.jsx(Ae,{className:"h-3 w-3"}):e.jsx(me,{className:"h-3 w-3"}),g]}),!n.has(g)&&e.jsx("div",{className:"px-3 pb-2 space-y-2",children:o.map(u=>e.jsx($a,{field:u,onChange:l},u.name))})]},g)),s.length===0&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"Select an element to edit its properties"})]})]})}function $a({field:t,onChange:s}){const l=i=>{s(t.name,i)};return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t.label}),t.type==="text"&&e.jsx("input",{type:"text",value:String(t.value??""),onChange:i=>l(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),t.type==="number"&&e.jsx("input",{type:"number",value:Number(t.value??0),onChange:i=>l(Number(i.target.value)),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),t.type==="boolean"&&e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:!!t.value,onChange:i=>l(i.target.checked),className:"rounded"}),e.jsx("span",{className:"text-xs",children:t.value?"Yes":"No"})]}),t.type==="select"&&e.jsx("select",{value:String(t.value??""),onChange:i=>l(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background",children:t.options?.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),t.type==="color"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:String(t.value??"#000000"),onChange:i=>l(i.target.value),className:"h-6 w-6 rounded border cursor-pointer"}),e.jsx("span",{className:"text-xs font-mono",children:String(t.value??"#000000")})]}),t.type==="textarea"&&e.jsx("textarea",{value:String(t.value??""),onChange:i=>l(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background resize-y",rows:3}),t.description&&e.jsx("p",{className:"text-[0.65rem] text-muted-foreground/70",children:t.description})]})}function Ua(...t){return le(oe(t))}function ft({items:t,canvasWidth:s,canvasHeight:l,position:i="bottom-right",size:n=150,className:r}){const p=Math.min(n/s,n/l),b=s*p,g=l*p,o={"top-left":"top-2 left-2","top-right":"top-2 right-2","bottom-left":"bottom-2 left-2","bottom-right":"bottom-2 right-2"};return e.jsx("div",{className:Ua("absolute border rounded bg-background/90 shadow-sm overflow-hidden",o[i],r),role:"img","aria-label":"Canvas minimap",children:e.jsxs("svg",{width:b,height:g,viewBox:`0 0 ${s} ${l}`,children:[e.jsx("rect",{width:s,height:l,fill:"hsl(var(--muted))",opacity:"0.3"}),t.map(u=>e.jsx("rect",{x:u.x,y:u.y,width:u.width,height:u.height,fill:u.selected?"hsl(var(--primary))":u.color??"hsl(var(--foreground) / 0.3)",rx:"2"},u.id))]})})}function Ka(...t){return le(oe(t))}const qe=a.createContext(null);qe.displayName="CollaborationContext";function cn({config:t,user:s,onOperation:l,onPresenceChange:i,children:n}){const r=a.useRef(null),[p,b]=a.useState([]),[g,o]=a.useState("disconnected"),u=a.useRef(0),d=a.useRef(null);a.useEffect(()=>{if(!t.enabled||!s||!t.serverUrl||!(typeof WebSocket<"u"))return;function T(){let P;try{if(P=new URL(t.serverUrl),P.protocol!=="ws:"&&P.protocol!=="wss:")return}catch{return}t.roomId&&P.searchParams.set("room",t.roomId),P.searchParams.set("userId",s.id),o("connecting");const R=new WebSocket(P.toString());R.onopen=()=>{o("connected"),R.send(JSON.stringify({type:"join",userId:s.id,userName:s.name,avatar:s.avatar}))},R.onmessage=L=>{try{const U=JSON.parse(L.data);if(U.type==="presence"){const w=U.users||[];b(w.filter(S=>S.userId!==s.id)),i?.(w)}else U.type==="operation"&&l?.(U.operation)}catch{}},R.onclose=()=>{o("disconnected"),r.current=null,t.enabled&&(d.current=setTimeout(T,t.autoSaveInterval??3e3))},R.onerror=()=>{o("error")},r.current=R}return T(),()=>{d.current&&clearTimeout(d.current),r.current&&(r.current.onclose=null,r.current.close(),r.current=null),o("disconnected")}},[t.enabled,t.serverUrl,t.roomId,t.autoSaveInterval,s,l,i]);const m=a.useMemo(()=>!t.enabled||!s?[]:[{userId:s.id,userName:s.name,avatar:s.avatar,color:Ga(s.id),status:"active",lastActivity:new Date().toISOString()},...p],[t.enabled,s,p]),j=t.enabled&&!!s&&(t.serverUrl?g==="connected":!0),x=a.useCallback(T=>{if(!t.enabled||!s)return;u.current+=1;const P={...T,id:`op-${Date.now()}-${u.current}`,userId:s.id,timestamp:new Date().toISOString(),version:u.current};r.current?.readyState===WebSocket.OPEN&&r.current.send(JSON.stringify({type:"operation",operation:P})),l?.(P)},[t.enabled,s,l]),k=a.useMemo(()=>({users:m,isConnected:j,sendOperation:x,currentUserId:s?.id,connectionState:g,versionCount:u.current}),[m,j,x,s?.id,g]);return e.jsx(qe.Provider,{value:k,children:n})}function Qe(){return a.useContext(qe)}function pn({className:t}){const s=a.useContext(qe);if(!s)return null;const{connectionState:l,users:i}=s,n={connected:{color:"bg-green-500",label:"Connected"},connecting:{color:"bg-yellow-500 animate-pulse",label:"Connecting…"},disconnected:{color:"bg-gray-400",label:"Disconnected"},error:{color:"bg-red-500",label:"Connection error"}},{color:r,label:p}=n[l]??n.disconnected;return e.jsxs("div",{className:Ka("flex items-center gap-2 text-xs",t),role:"status","aria-live":"polite","aria-label":`Collaboration: ${p}`,children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${r}`}),e.jsx("span",{children:p}),l==="connected"&&i.length>1&&e.jsxs("span",{className:"text-muted-foreground",children:["(",i.length," users)"]})]})}function Ga(t){const s=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#f97316","#14b8a6","#f43f5e","#a855f7","#84cc16","#0ea5e9","#e879f9","#fb923c","#facc15"];let l=0;for(let i=0;i<t.length;i++)l=(l<<5)-l+t.charCodeAt(i)|0;return s[Math.abs(l)%s.length]}function ce(...t){return le(oe(t))}function Ha({canvas:t={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:s=[],palette:l=Va,showComponentTree:i=!0,undoRedo:n=!0,propertyEditor:r=!0,readOnly:p=!1,showMinimap:b=!1,onChange:g,className:o}){const u=ke(s),d=u.current,m=a.useCallback(h=>{u.push(h),g?.(h)},[u,g]),j=yt({initialZoom:t.zoom??1}),{zoom:x}=j,k=Xe(),T=a.useMemo(()=>{const h=Array.from(k.selectedIds);return h.length>0?h[0]:null},[k.selectedIds]),P=a.useMemo(()=>d.find(h=>h.id===T),[d,T]),R=Je(),L=Le(),U=Qe(),w=a.useCallback(h=>{U&&U.sendOperation({...h,userId:U.currentUserId??""})},[U]),[S,y]=a.useState(!0),[I,C]=a.useState(!0),[K,Y]=a.useState(b),M=a.useRef(null),Q=a.useRef(null),se=a.useCallback(h=>!t.snapToGrid||!t.gridSize?h:Math.round(h/t.gridSize)*t.gridSize,[t.snapToGrid,t.gridSize]),F=a.useCallback((h,A)=>{if(p)return;const H=l.flatMap(ne=>ne.items).find(ne=>ne.type===h),B=H?.defaultSize,W={id:`comp-${Date.now()}`,type:h,label:A,position:{x:100,y:100,width:B?.width??200,height:B?.height??100},props:H?.defaultProps??{}},ee=[...d,W];m(ee),k.selectOne(W.id),w({type:"insert",elementId:W.id,data:{component:W}})},[d,p,l,m,k,w]),J=a.useCallback(h=>{if(p)return;const A=d.filter(H=>H.id!==h);m(A),k.isSelected(h)&&k.clearSelection(),w({type:"delete",elementId:h,data:{}})},[d,p,m,k,w]),_=a.useCallback(async()=>{if(p||k.count===0||!await L.confirm("Delete components",`Are you sure you want to delete ${k.count} component${k.count>1?"s":""}?`))return;const h=k.selectedIds,A=d.filter(H=>!h.has(H.id));m(A),k.clearSelection(),h.forEach(H=>{w({type:"delete",elementId:H,data:{}})})},[p,k,L,d,m,w]),N=a.useCallback((h,A)=>{if(p||!T)return;const H=d.map(B=>B.id!==T?B:h==="label"?{...B,label:String(A)}:h==="x"?{...B,position:{...B.position,x:Number(A)}}:h==="y"?{...B,position:{...B.position,y:Number(A)}}:h==="width"?{...B,position:{...B.position,width:Number(A)}}:h==="height"?{...B,position:{...B.position,height:Number(A)}}:{...B,props:{...B.props,[h]:A}});m(H),w({type:"update",elementId:T,data:{[h]:A}})},[p,T,d,m,w]),G=a.useCallback(()=>{const h=k.selectedIds;if(h.size===0)return;const A=d.filter(H=>h.has(H.id));R.copy(A)},[k,d,R]),z=a.useCallback(()=>{if(p)return;const h=R.paste();if(!h||h.length===0)return;let A=0;const H=h.map(W=>({...W,id:`comp-${Date.now()}-${++A}-${Math.random().toString(36).slice(2,7)}`,position:{...W.position,x:W.position.x+20,y:W.position.y+20}})),B=[...d,...H];m(B),k.selectMany(H.map(W=>W.id)),H.forEach(W=>{w({type:"insert",elementId:W.id,data:{component:W}})})},[p,R,d,m,k,w]),Z=a.useCallback((h,A)=>{p||(M.current={id:A.id,startX:h.clientX,startY:h.clientY},h.dataTransfer.effectAllowed="move",h.dataTransfer.setData("text/plain",A.id))},[p]),ae=a.useCallback(h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},[]),E=a.useCallback(h=>{h.preventDefault();const A=M.current;if(!A||p)return;const H=(h.clientX-A.startX)/x,B=(h.clientY-A.startY)/x,W=d.map(ee=>ee.id!==A.id?ee:{...ee,position:{...ee.position,x:se(ee.position.x+H),y:se(ee.position.y+B)}});m(W),w({type:"move",elementId:A.id,data:{}}),M.current=null},[p,x,d,m,se,w]),X=a.useMemo(()=>P?[{name:"label",label:"Label",type:"text",value:P.label??"",group:"General"},{name:"x",label:"X",type:"number",value:P.position.x,group:"Position"},{name:"y",label:"Y",type:"number",value:P.position.y,group:"Position"},{name:"width",label:"Width",type:"number",value:P.position.width,group:"Size"},{name:"height",label:"Height",type:"number",value:P.position.height,group:"Size"}]:[],[P]),O=a.useMemo(()=>d.map(h=>({id:h.id,x:h.position.x,y:h.position.y,width:typeof h.position.width=="number"?h.position.width:100,height:typeof h.position.height=="number"?h.position.height:50,selected:k.isSelected(h.id)})),[d,k]);return a.useEffect(()=>{const h=Q.current;if(!h)return;const A=H=>{const B=["INPUT","TEXTAREA","SELECT"].includes(H.target.tagName),W=H.ctrlKey||H.metaKey;if((H.key==="Delete"||H.key==="Backspace")&&k.count>0&&!B){H.preventDefault(),_();return}if(H.key==="Escape"){k.clearSelection();return}if(!B){if(W&&H.key==="z"&&!H.shiftKey&&n&&!p){H.preventDefault(),u.undo();return}if(W&&(H.key==="z"&&H.shiftKey||H.key==="y")&&n&&!p){H.preventDefault(),u.redo();return}if(W&&H.key==="c"){H.preventDefault(),G();return}if(W&&H.key==="v"&&!p){H.preventDefault(),z();return}if(W&&H.key==="a"){H.preventDefault(),k.selectMany(d.map(ee=>ee.id));return}}};return h.addEventListener("keydown",A),()=>h.removeEventListener("keydown",A)},[k,_,n,p,u,G,z,d]),e.jsxs("div",{ref:Q,tabIndex:0,className:ce("flex h-full w-full border rounded-lg overflow-hidden bg-background",o),children:[!p&&e.jsx("div",{className:ce("border-r bg-muted/30 flex flex-col transition-[width] duration-200",S?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component palette",children:S&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:"Components"}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l.map(h=>e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1 uppercase",children:h.label}),h.items.map(A=>e.jsxs("button",{onClick:()=>F(A.type,A.label),className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left",children:[e.jsx(ve,{className:"h-3 w-3"}),A.label]},A.type))]},h.name))})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",role:"toolbar","aria-label":"Designer toolbar",children:[!p&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:S?"Collapse palette":"Expand palette","aria-label":S?"Collapse palette":"Expand palette",onClick:()=>y(h=>!h),children:e.jsx(wa,{className:ce("h-4 w-4",!S&&"rotate-180")})}),n&&!p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:ce("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:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("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:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",k.count===0&&"opacity-40 pointer-events-none"),title:"Copy (Ctrl+C)","aria-label":"Copy",disabled:k.count===0,onClick:G,children:e.jsx(Be,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",!R.hasContent&&"opacity-40 pointer-events-none"),title:"Paste (Ctrl+V)","aria-label":"Paste",disabled:!R.hasContent,onClick:z,children:e.jsx(_e,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!p&&e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",k.count===0&&"opacity-40 pointer-events-none"),title:"Delete selected","aria-label":"Delete selected",disabled:k.count===0,onClick:_,children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Preview","aria-label":"Preview",children:e.jsx(Pe,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",K&&"bg-accent"),title:"Toggle minimap","aria-label":"Toggle minimap",onClick:()=>Y(h=>!h),children:e.jsx(Wt,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Zoom out",onClick:j.zoomOut,children:e.jsx(xt,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10 text-center",children:[Math.round(x*100),"%"]}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Zoom in",onClick:j.zoomIn,children:e.jsx(ve,{className:"h-3 w-3"})}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Reset zoom",onClick:j.resetZoom,children:e.jsx(Ca,{className:"h-3 w-3"})})]}),i&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:I?"Collapse panel":"Expand panel","aria-label":I?"Collapse panel":"Expand panel",onClick:()=>C(h=>!h),children:e.jsx(ht,{className:ce("h-4 w-4",!I&&"rotate-180")})})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4 relative",role:"region","aria-label":"Design canvas",onWheel:j.handleWheel,onMouseDown:j.startPan,onDragOver:ae,onDrop:E,children:e.jsxs("div",{className:"relative bg-background border rounded shadow-sm mx-auto",style:{width:t.width*x,height:t.height*x,transform:`translate(${j.panOffset.x}px, ${j.panOffset.y}px)`,backgroundImage:t.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:t.showGrid&&t.gridSize?`${t.gridSize*x}px ${t.gridSize*x}px`:void 0},children:[d.map(h=>{const A=k.isSelected(h.id);return e.jsxs("div",{draggable:!p,onDragStart:H=>Z(H,h),className:ce("absolute border rounded cursor-move select-none transition-shadow",A?"border-primary ring-2 ring-primary/20 shadow-md":"border-border hover:border-primary/50"),style:{left:h.position.x*x,top:h.position.y*x,width:typeof h.position.width=="number"?h.position.width*x:h.position.width,height:typeof h.position.height=="number"?h.position.height*x:h.position.height},onClick:H=>k.toggle(h.id,H.shiftKey),children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b",children:[e.jsx(Ye,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:h.label??h.type}),!p&&e.jsx("button",{onClick:H=>{H.stopPropagation(),J(h.id)},className:"ml-auto p-0.5 rounded hover:bg-destructive/10","aria-label":`Delete ${h.label??h.type}`,children:e.jsx(ue,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"p-2 text-xs text-muted-foreground",children:h.type})]},h.id)}),K&&e.jsx(ft,{items:O,canvasWidth:t.width,canvasHeight:t.height})]})})]}),i&&e.jsx("div",{className:ce("border-l bg-muted/30 flex flex-col transition-[width] duration-200",I?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component tree",children:I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 border-b font-medium text-sm flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),"Component Tree"]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:d.length===0?e.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."}):d.map(h=>e.jsx("button",{onClick:A=>k.toggle(h.id,A.shiftKey),className:ce("w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left",k.isSelected(h.id)?"bg-accent":"hover:bg-accent/50"),children:e.jsx("span",{className:"truncate",children:h.label??h.type})},h.id))}),r&&P?e.jsx("div",{className:"border-t",children:e.jsx(We,{title:`Properties – ${P.label??P.type}`,fields:X,onChange:N})}):P&&e.jsxs("div",{className:"border-t p-3",children:[e.jsx("div",{className:"text-xs font-medium mb-2",children:"Properties"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{children:["Type: ",P.type]}),e.jsxs("div",{children:["ID: ",P.id]}),e.jsxs("div",{children:["Position: ",P.position.x,","," ",P.position.y]}),e.jsxs("div",{children:["Size: ",P.position.width," ×"," ",P.position.height]})]})]})]})}),e.jsx(Ze,{isOpen:L.isOpen,title:L.title,message:L.message,onConfirm:L.onConfirm,onCancel:L.onCancel})]})}const Va=[{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 Ba(t,s={}){return ke(t,s)}function nt(...t){return le(oe(t))}const _a=["text","number","boolean","date","datetime","uuid","email","url","phone","json","integer","float","decimal","currency","percent","textarea","select","multiselect","lookup","attachment","formula","autonumber"];function Ya(t,s=4,l=280,i=250,n=50,r=50){return t.map((p,b)=>({...p,position:{x:n+b%s*l,y:r+Math.floor(b/s)*i}}))}function Xa({entities:t=[],relationships:s=[],canvas:l={width:1200,height:800,showGrid:!0},showRelationshipLabels:i=!0,readOnly:n=!1,onEntitiesChange:r,onRelationshipsChange:p,className:b}){const g=a.useRef(null),o=Ba({entities:t,relationships:s},{maxHistory:50}),{entities:u,relationships:d}=o.current,m=a.useCallback(f=>{o.push(f),r?.(f.entities),p?.(f.relationships)},[o,r,p]),j=Le(),x=Xe(),k=x.count>0?Array.from(x.selectedIds)[0]:null,T=Je(),P=yt({minZoom:.25,maxZoom:3,zoomStep:.1}),R=Qe(),[L,U]=a.useState(!0),[w,S]=a.useState(!0),[y,I]=a.useState(null),[C,K]=a.useState(""),[Y,M]=a.useState(null),[Q,se]=a.useState(""),F=a.useRef(null),J=a.useCallback(()=>{if(n)return;const f=o.current,c={id:`entity-${Date.now()}`,name:`new_entity_${f.entities.length+1}`,label:`New Entity ${f.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+f.entities.length%4*280,y:50+Math.floor(f.entities.length/4)*250}},D={entities:[...f.entities,c],relationships:f.relationships};m(D),x.selectOne(c.id),R?.sendOperation({type:"insert",userId:R?.currentUserId??"",elementId:c.id,data:{name:c.name,label:c.label}})},[n,o,m,x,R]),_=a.useCallback(async f=>{if(n)return;const c=u.find($=>$.id===f);if(!await j.confirm("Delete Entity",`Are you sure you want to delete "${c?.label??f}"? This action cannot be undone.`))return;const D=o.current,v={entities:D.entities.filter($=>$.id!==f),relationships:D.relationships.filter($=>$.sourceEntity!==f&&$.targetEntity!==f)};m(v),x.isSelected(f)&&x.clearSelection(),R?.sendOperation({type:"delete",userId:R?.currentUserId??"",elementId:f,data:{}})},[n,u,j,o,m,x,R]),N=a.useCallback(async()=>{if(n||x.count===0)return;const f=Array.from(x.selectedIds);if(!await j.confirm("Delete Entities",`Are you sure you want to delete ${f.length} selected entity(s)? This action cannot be undone.`))return;const c=o.current,D=new Set(f),v={entities:c.entities.filter($=>!D.has($.id)),relationships:c.relationships.filter($=>!D.has($.sourceEntity)&&!D.has($.targetEntity))};m(v),x.clearSelection()},[n,x,j,o,m]),G=a.useCallback(()=>{if(n)return;const f=o.current,c={entities:Ya(f.entities),relationships:f.relationships};m(c)},[n,o,m]),z=a.useCallback(()=>{const f=u.filter(c=>x.isSelected(c.id));f.length>0&&T.copy(f)},[u,x,T]),Z=a.useCallback(()=>{if(n)return;const f=T.paste();if(!f||f.length===0)return;const c=o.current,D=f.map(($,q)=>({...$,id:`entity-${Date.now()}-${q}`,name:`${$.name}_copy`,label:`${$.label} (Copy)`,position:{x:$.position.x+30,y:$.position.y+30}})),v={entities:[...c.entities,...D],relationships:c.relationships};m(v),x.selectMany(D.map($=>$.id))},[n,T,o,m,x]),ae=a.useCallback(f=>{if(n)return;const c=o.current,D={entities:c.entities.map(v=>{if(v.id!==f)return v;const $={name:`field_${v.fields.length+1}`,type:"text",required:!1};return{...v,fields:[...v.fields,$]}}),relationships:c.relationships};m(D)},[n,o,m]),E=a.useCallback((f,c,D)=>{n||(I({entityId:f,fieldIndex:c}),K(D))},[n]),X=a.useCallback(()=>{if(!y)return;const f=C.trim();if(f===""){I(null);return}const c=o.current,D={entities:c.entities.map(v=>{if(v.id!==y.entityId)return v;const $=v.fields.map((q,te)=>te===y.fieldIndex?{...q,name:f}:q);return{...v,fields:$}}),relationships:c.relationships};m(D),I(null)},[y,C,o,m]),O=a.useCallback(()=>{I(null)},[]),h=a.useCallback((f,c)=>{n||(M(f),se(c))},[n]),A=a.useCallback(()=>{if(!Y)return;const f=Q.trim();if(f===""){M(null);return}const c=o.current,D={entities:c.entities.map(v=>v.id===Y?{...v,label:f}:v),relationships:c.relationships};m(D),M(null)},[Y,Q,o,m]),H=a.useCallback(()=>{M(null)},[]),B=a.useCallback((f,c,D)=>{if(n)return;const v=o.current,$={entities:v.entities.map(q=>{if(q.id!==f)return q;const te=q.fields.map((de,he)=>he===c?{...de,type:D}:de);return{...q,fields:te}}),relationships:v.relationships};m($)},[n,o,m]),W=a.useCallback((f,c)=>{if(n||!u.find(v=>v.id===c))return;const D=f.target.getBoundingClientRect();F.current={entityId:c,offsetX:f.clientX-D.left,offsetY:f.clientY-D.top},f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",c)},[n,u]),ee=a.useCallback(f=>{f.preventDefault(),f.dataTransfer.dropEffect="move"},[]),ne=a.useCallback(f=>{if(f.preventDefault(),!F.current)return;const c=f.currentTarget.getBoundingClientRect(),D=P.zoom,v=(f.clientX-c.left-P.panOffset.x)/D-F.current.offsetX,$=(f.clientY-c.top-P.panOffset.y)/D-F.current.offsetY,q=o.current,te={entities:q.entities.map(de=>de.id===F.current.entityId?{...de,position:{x:Math.max(0,Math.round(v)),y:Math.max(0,Math.round($))}}:de),relationships:q.relationships};m(te),F.current=null},[P.zoom,P.panOffset,o,m]),ie=k?u.find(f=>f.id===k):null,et=ie?[{name:"name",label:"Name",type:"text",value:ie.name,group:"General"},{name:"label",label:"Label",type:"text",value:ie.label,group:"General"},{name:"description",label:"Description",type:"textarea",value:ie.description??"",group:"General"},{name:"color",label:"Color",type:"color",value:ie.color??"#3b82f6",group:"Appearance"},{name:"position.x",label:"X Position",type:"number",value:ie.position.x,group:"Position"},{name:"position.y",label:"Y Position",type:"number",value:ie.position.y,group:"Position"}]:[],tt=a.useCallback((f,c)=>{if(!k)return;const D=o.current,v={entities:D.entities.map($=>$.id!==k?$:f==="position.x"?{...$,position:{...$.position,x:Number(c)}}:f==="position.y"?{...$,position:{...$.position,y:Number(c)}}:{...$,[f]:c}),relationships:D.relationships};m(v)},[k,o,m]);a.useEffect(()=>{const f=g.current;if(!f)return;const c=D=>{const v=D.target.tagName;if(v==="INPUT"||v==="TEXTAREA"||v==="SELECT")return;const $=D.ctrlKey||D.metaKey;$&&D.key==="z"?(D.preventDefault(),o.undo()):$&&(D.key==="y"||D.shiftKey&&D.key==="Z")?(D.preventDefault(),o.redo()):$&&D.key==="c"?(D.preventDefault(),z()):$&&D.key==="v"?(D.preventDefault(),Z()):(D.key==="Delete"||D.key==="Backspace")&&x.count>0?(D.preventDefault(),N()):D.key==="Escape"&&(x.clearSelection(),I(null),M(null))};return f.addEventListener("keydown",c),()=>f.removeEventListener("keydown",c)},[o,z,Z,N,x]);const at=u.map(f=>({id:f.id,x:f.position.x,y:f.position.y,width:240,height:40+f.fields.length*24,color:f.color,selected:x.isSelected(f.id)}));return e.jsxs("div",{ref:g,tabIndex:0,className:nt("flex h-full w-full border rounded-lg overflow-hidden bg-background",b),children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsxs("div",{role:"toolbar","aria-label":"Designer toolbar",className:"flex items-center gap-2 p-2 border-b bg-muted/20 flex-wrap",children:[e.jsx(ot,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:"Data Model Designer"}),e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsx("button",{onClick:()=>o.undo(),disabled:!o.canUndo,"aria-label":"Undo",title:"Undo (Ctrl+Z)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(we,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>o.redo(),disabled:!o.canRedo,"aria-label":"Redo",title:"Redo (Ctrl+Y)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-1 border-l pl-2",children:[e.jsx("button",{onClick:P.zoomOut,"aria-label":"Zoom Out",title:"Zoom Out",className:"p-1 rounded hover:bg-accent",children:e.jsx(_t,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"text-xs tabular-nums w-10 text-center",children:[Math.round(P.zoom*100),"%"]}),e.jsx("button",{onClick:P.zoomIn,"aria-label":"Zoom In",title:"Zoom In",className:"p-1 rounded hover:bg-accent",children:e.jsx(Yt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:P.resetZoom,"aria-label":"Reset Zoom",title:"Reset Zoom",className:"p-1 rounded hover:bg-accent",children:e.jsx(Xt,{className:"h-3 w-3"})})]}),!n&&e.jsxs("div",{className:"flex items-center gap-1 border-l pl-2",children:[e.jsx("button",{onClick:z,disabled:x.count===0,"aria-label":"Copy",title:"Copy (Ctrl+C)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(Be,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Z,disabled:!T.hasContent,"aria-label":"Paste",title:"Paste (Ctrl+V)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(_e,{className:"h-3.5 w-3.5"})})]}),!n&&e.jsxs("button",{onClick:G,"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:[e.jsx(ma,{className:"h-3 w-3"})," Auto Layout"]}),e.jsx("div",{className:"flex-1"}),R?.isConnected&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",role:"status","aria-label":"Collaboration active",children:[e.jsx(ga,{className:"h-3 w-3"}),e.jsxs("span",{children:[R.users.length," user",R.users.length!==1?"s":""]})]}),x.count>1&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[x.count," selected"]}),!n&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:J,"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:[e.jsx(ve,{className:"h-3 w-3"})," Add Entity"]}),e.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:[e.jsx(xa,{className:"h-3 w-3"})," Add Relationship"]})]})]}),e.jsxs("div",{role:"region","aria-label":"Canvas",className:"flex-1 overflow-auto bg-muted/10 p-4 relative",onWheel:P.handleWheel,onMouseDown:P.startPan,onDragOver:ee,onDrop:ne,children:[e.jsxs("div",{className:"relative",style:{width:l.width,minHeight:l.height,...P.transformStyle,backgroundImage:l.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:l.showGrid?"20px 20px":void 0},children:[e.jsx("svg",{className:"absolute inset-0 pointer-events-none",width:l.width,height:l.height,children:d.map(f=>{const c=u.find(v=>v.id===f.sourceEntity),D=u.find(v=>v.id===f.targetEntity);return!c||!D?null:e.jsxs("g",{children:[e.jsx("line",{x1:c.position.x+120,y1:c.position.y+50,x2:D.position.x+120,y2:D.position.y+50,stroke:"hsl(var(--primary))",strokeWidth:"2",strokeDasharray:f.type==="many-to-many"?"5,5":void 0}),i&&f.label&&e.jsx("text",{x:(c.position.x+D.position.x)/2+120,y:(c.position.y+D.position.y)/2+50-8,textAnchor:"middle",className:"text-xs fill-muted-foreground",children:f.label})]},f.id)})}),u.length===0&&e.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."}),u.map(f=>e.jsxs("div",{role:"group","aria-label":f.label,draggable:!n,onDragStart:c=>W(c,f.id),className:nt("absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing",x.isSelected(f.id)?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/50"),style:{left:f.position.x,top:f.position.y},onClick:c=>x.toggle(f.id,c.shiftKey),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm",style:{backgroundColor:f.color??"hsl(var(--primary) / 0.1)"},children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),Y===f.id?e.jsx("input",{type:"text",value:Q,onChange:c=>se(c.target.value),onBlur:A,onKeyDown:c=>{c.key==="Enter"&&A(),c.key==="Escape"&&H()},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:c=>c.stopPropagation(),"data-testid":`entity-label-input-${f.id}`}):e.jsx("span",{className:"truncate cursor-text",onDoubleClick:c=>{c.stopPropagation(),h(f.id,f.label)},title:"Double-click to edit label","data-testid":`entity-label-${f.id}`,children:f.label}),!n&&e.jsx("button",{onClick:c=>{c.stopPropagation(),_(f.id)},"aria-label":`Delete ${f.label}`,className:"ml-auto p-0.5 rounded hover:bg-destructive/20",children:e.jsx(ue,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"px-3 py-1 divide-y",children:f.fields.map((c,D)=>e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs",children:[y&&y.entityId===f.id&&y.fieldIndex===D?e.jsx("input",{type:"text",value:C,onChange:v=>K(v.target.value),onBlur:X,onKeyDown:v=>{v.key==="Enter"&&X(),v.key==="Escape"&&O()},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:v=>v.stopPropagation()}):e.jsxs("span",{className:nt("font-mono cursor-text",c.primaryKey&&"font-bold text-primary"),onClick:v=>{v.stopPropagation(),E(f.id,D,c.name)},title:"Click to edit field name",children:[c.primaryKey&&e.jsx("span",{className:"text-[0.65rem] font-semibold text-primary mr-0.5",children:"PK"}),c.name]}),n?e.jsx("span",{className:"text-muted-foreground ml-auto",children:c.type}):e.jsx("select",{value:c.type,onChange:v=>{v.stopPropagation(),B(f.id,D,v.target.value)},onClick:v=>v.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-${f.id}-${D}`,children:_a.map(v=>e.jsx("option",{value:v,children:v},v))}),c.required&&e.jsx("span",{className:"text-destructive",children:"*"})]},`${c.name}-${D}`))}),!n&&e.jsx("div",{className:"px-3 py-1 border-t",children:e.jsxs("button",{onClick:c=>{c.stopPropagation(),ae(f.id)},"aria-label":`Add field to ${f.label}`,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5",children:[e.jsx(ve,{className:"h-3 w-3"})," Add Field"]})})]},f.id))]}),w&&u.length>0&&e.jsx(ft,{items:at,canvasWidth:l.width,canvasHeight:l.height,position:"bottom-right",size:150})]})]}),e.jsxs("div",{className:"w-64 border-l flex flex-col bg-background shrink-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("button",{onClick:()=>U(f=>!f),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":L,"aria-controls":"property-editor-panel",children:[L?e.jsx(me,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"}),"Properties"]}),L&&e.jsx("div",{id:"property-editor-panel",className:"flex-1 overflow-y-auto",children:e.jsx(We,{title:ie?ie.label:"Properties",fields:et,onChange:tt})})]}),e.jsx("div",{className:"border-t",children:e.jsxs("button",{onClick:()=>S(f=>!f),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":w,children:[w?e.jsx(me,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"}),"Minimap"]})})]}),e.jsx(Ze,{isOpen:j.isOpen,title:j.title,message:j.message,onConfirm:j.onConfirm,onCancel:j.onCancel,destructive:!0})]})}function Me(...t){return le(oe(t))}const De=120,Ee=50;function Ja(t,s){if(t.length===0)return t;const l=200,i=100,n=new Map,r=new Map;for(const d of t)n.set(d.id,0),r.set(d.id,[]);for(const d of s)n.set(d.target,(n.get(d.target)??0)+1),r.get(d.source)?.push(d.target);const p=[],b=new Set;let g=t.filter(d=>(n.get(d.id)??0)===0).map(d=>d.id);for(g.length===0&&(g=[t[0].id]);g.length>0;){p.push(g);for(const m of g)b.add(m);const d=new Set;for(const m of g)for(const j of r.get(m)??[])b.has(j)||d.add(j);g=Array.from(d)}const o=t.filter(d=>!b.has(d.id)).map(d=>d.id);o.length>0&&p.push(o);const u=new Map;for(let d=0;d<p.length;d++){const m=p[d];for(let j=0;j<m.length;j++)u.set(m[j],{x:80+d*l,y:80+j*i})}return t.map(d=>({...d,position:u.get(d.id)??d.position}))}function Za({processName:t="New Process",nodes:s=[],edges:l=[],lanes:i,canvas:n={width:1400,height:800,showGrid:!0},showMinimap:r=!0,showToolbar:p=!0,readOnly:b=!1,onNodesChange:g,onEdgesChange:o,className:u}){const d=ke({nodes:s,edges:l},{maxHistory:50}),m=d.current.nodes,j=d.current.edges,x=a.useCallback((c,D)=>{d.push({nodes:c,edges:D}),g?.(c),o?.(D)},[d,g,o]),k=Le(),T=Xe(),P=Je(),R=yt({initialZoom:1}),L=Qe(),[U,w]=a.useState(null),[S,y]=a.useState(!1),[I,C]=a.useState(null),[K,Y]=a.useState(null),[M,Q]=a.useState(!0),[se,F]=a.useState(null),[J,_]=a.useState({x:0,y:0}),N=a.useRef(null),G=a.useRef(g),z=a.useRef(o);G.current=g,z.current=o,a.useEffect(()=>{G.current?.(m),z.current?.(j)},[d.current]);const Z=a.useCallback((c,D)=>{if(b)return;const v={id:`node-${Date.now()}`,type:c,label:D,position:{x:200+m.length*160,y:200}},$=[...m,v];x($,j),w(v.id),T.selectOne(v.id),L?.sendOperation({type:"insert",elementId:v.id,data:{label:D},userId:L.currentUserId??""})},[m,j,b,x,T,L]),ae=a.useCallback(async c=>{if(b)return;const D=m.find(q=>q.id===c);if(!await k.confirm("Delete Node",`Are you sure you want to delete "${D?.label??c}"? This will also remove all connected edges.`))return;const v=m.filter(q=>q.id!==c),$=j.filter(q=>q.source!==c&&q.target!==c);x(v,$),U===c&&w(null),T.clearSelection(),L?.sendOperation({type:"delete",elementId:c,data:{},userId:L.currentUserId??""})},[m,j,U,b,x,k,T,L]),E=a.useCallback(async()=>{if(b||T.count===0||!await k.confirm("Delete Selected Nodes",`Are you sure you want to delete ${T.count} selected node(s) and their connected edges?`))return;const c=T.selectedIds,D=m.filter($=>!c.has($.id)),v=j.filter($=>!c.has($.source)&&!c.has($.target));x(D,v),w(null),T.clearSelection()},[m,j,b,x,k,T]),X=a.useCallback(()=>{const c=T.count>0?T.selectedIds:U?new Set([U]):new Set;if(c.size===0)return;const D=m.filter(v=>c.has(v.id));P.copy(D)},[m,U,T,P]),O=a.useCallback(()=>{if(b)return;const c=P.paste();if(!c||c.length===0)return;const D=40,v=c.map(q=>({...q,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:q.position.x+D,y:q.position.y+D}})),$=[...m,...v];x($,j),T.selectMany(v.map(q=>q.id)),w(v[0].id)},[b,m,j,P,x,T]),h=a.useCallback(()=>{y(c=>c?(C(null),!1):!0)},[]),A=a.useCallback(c=>{if(!S)return!1;if(!I)return C(c),!0;if(I===c)return!0;const D={id:`edge-${Date.now()}`,source:I,target:c},v=[...j,D];return x(m,v),C(null),y(!1),L?.sendOperation({type:"insert",elementId:D.id,data:{source:I,target:c},userId:L.currentUserId??""}),!0},[S,I,m,j,x,L]),H=a.useCallback(()=>{if(b||m.length===0)return;const c=Ja(m,j);x(c,j)},[m,j,b,x]),B=a.useCallback((c,D)=>{if(b||!m.find($=>$.id===D))return;F(D);const v=c.target.getBoundingClientRect();_({x:c.clientX-v.left,y:c.clientY-v.top}),c.dataTransfer.effectAllowed="move",c.dataTransfer.setData("text/plain",D)},[b,m]),W=a.useCallback(c=>{if(c.preventDefault(),b||!se)return;const D=c.currentTarget.getBoundingClientRect(),v=R.zoom,$=(c.clientX-D.left-R.panOffset.x)/v-J.x,q=(c.clientY-D.top-R.panOffset.y)/v-J.y,te=Math.max(0,Math.round($/20)*20),de=Math.max(0,Math.round(q/20)*20),he=m.map(ye=>ye.id===se?{...ye,position:{x:te,y:de}}:ye);x(he,j),F(null)},[b,se,J,m,j,R.zoom,R.panOffset,x]),ee=a.useCallback(c=>{c.preventDefault(),c.dataTransfer.dropEffect="move"},[]),ne=a.useMemo(()=>m.find(c=>c.id===U)??null,[m,U]),ie=a.useMemo(()=>ne?[{name:"label",label:"Name",type:"text",value:ne.label,group:"General"},{name:"type",label:"Type",type:"select",value:ne.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:ne.description??"",group:"General"}]:[],[ne]),et=a.useCallback((c,D)=>{if(b||!U)return;const v=m.map($=>$.id===U?{...$,[c]:D}:$);x(v,j)},[b,U,m,j,x]),tt=c=>{switch(c){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"}},at=a.useMemo(()=>m.map(c=>({id:c.id,x:c.position.x,y:c.position.y,width:De,height:Ee,selected:T.isSelected(c.id)||c.id===U})),[m,T,U]);a.useEffect(()=>{const c=N.current;if(!c)return;const D=v=>{const $=v.target?.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return;const q=v.ctrlKey||v.metaKey;if(q&&v.key==="z"&&!v.shiftKey){v.preventDefault(),d.undo();return}if(q&&v.key==="y"||q&&v.key==="z"&&v.shiftKey){v.preventDefault(),d.redo();return}if(q&&v.key==="c"){v.preventDefault(),X();return}if(q&&v.key==="v"){v.preventDefault(),O();return}if(v.key==="Delete"||v.key==="Backspace"){T.count>0?(v.preventDefault(),E()):U&&(v.preventDefault(),ae(U));return}if(v.key==="Escape"){S?(y(!1),C(null)):(w(null),T.clearSelection());return}};return c.addEventListener("keydown",D),()=>c.removeEventListener("keydown",D)},[U,S,T,d,X,O,ae,E]);const f=a.useCallback(c=>{c.target===c.currentTarget&&(w(null),T.clearSelection(),S&&(y(!1),C(null)))},[S,T]);return e.jsxs("div",{ref:N,tabIndex:0,className:Me("flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background",u),children:[e.jsx(Ze,{isOpen:k.isOpen,title:k.title,message:k.message,onConfirm:k.onConfirm,onCancel:k.onCancel,destructive:!0}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",role:"toolbar","aria-label":"Process toolbar",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm","aria-label":"Process name",children:t}),L?.isConnected&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",role:"status","aria-label":"Collaboration active",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-green-500"}),L.users.length," user",L.users.length!==1?"s":""]}),e.jsx("div",{className:"flex-1"}),!b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>d.undo(),disabled:!d.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:e.jsx(we,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>d.redo(),disabled:!d.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:e.jsx(Ce,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:X,disabled:T.count===0&&!U,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:e.jsx(Be,{className:"h-3 w-3"})}),e.jsx("button",{onClick:O,disabled:!P.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:e.jsx(_e,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:h,className:Me("flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",S&&"bg-primary text-primary-foreground"),title:"Connect nodes","aria-label":"Connect nodes","aria-pressed":S,children:[e.jsx(bt,{className:"h-3 w-3"})," Connect"]}),e.jsxs("button",{onClick:H,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Auto layout","aria-label":"Auto layout",children:[e.jsx(Qt,{className:"h-3 w-3"})," Layout"]}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:R.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:e.jsx(Yt,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-xs tabular-nums min-w-[3ch] text-center","aria-label":"Zoom level",children:[Math.round(R.zoom*100),"%"]}),e.jsx("button",{onClick:R.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:e.jsx(_t,{className:"h-3 w-3"})}),e.jsx("button",{onClick:R.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:e.jsx(Xt,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:()=>Z("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:[e.jsx(Sa,{className:"h-3 w-3 text-green-600"})," Start"]}),e.jsxs("button",{onClick:()=>Z("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:[e.jsx(vt,{className:"h-3 w-3 text-blue-600"})," Task"]}),e.jsxs("button",{onClick:()=>Z("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:[e.jsx(Ia,{className:"h-3 w-3 text-yellow-600"})," Gateway"]}),e.jsxs("button",{onClick:()=>Z("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:[e.jsx(vt,{className:"h-3 w-3 text-red-600"})," End"]}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:()=>Q(c=>!c),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:M?"Hide properties":"Show properties","aria-label":M?"Hide property panel":"Show property panel","aria-expanded":M,children:M?e.jsx(ht,{className:"h-3 w-3"}):e.jsx(Pa,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4",role:"region","aria-label":"Process canvas",onWheel:R.handleWheel,onMouseDown:R.startPan,children:e.jsxs("div",{className:"relative",style:{...R.transformStyle,width:n.width,minHeight:n.height,backgroundImage:n.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:n.showGrid?"20px 20px":void 0},onClick:f,onDrop:W,onDragOver:ee,children:[e.jsxs("svg",{className:"absolute inset-0 pointer-events-none",width:n.width,height:n.height,children:[e.jsx("defs",{children:e.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"hsl(var(--foreground))"})})}),j.map(c=>{const D=m.find(st=>st.id===c.source),v=m.find(st=>st.id===c.target);if(!D||!v)return null;D.position.x+De/2;const $=D.position.y+Ee/2;v.position.x+De/2;const q=v.position.y+Ee/2,te=D.position.x+De,de=$,he=v.position.x,ye=q,na=(te+he)/2,ra=`M ${te} ${de} Q ${na} ${de}, ${(te+he)/2} ${(de+ye)/2} T ${he} ${ye}`;return e.jsxs("g",{children:[e.jsx("path",{d:ra,fill:"none",stroke:"hsl(var(--foreground) / 0.5)",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),c.label&&e.jsx("text",{x:(te+he)/2,y:(de+ye)/2-8,textAnchor:"middle",className:"text-[10px] fill-muted-foreground",children:c.label})]},c.id)})]}),m.length===0&&e.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."}),m.map(c=>{const D=T.isSelected(c.id)||U===c.id,v=I===c.id,$=K===c.id,q=S||$;return e.jsxs("div",{className:"absolute select-none",style:{left:c.position.x,top:c.position.y},role:"group","aria-label":c.label,draggable:!b&&!S,onDragStart:te=>B(te,c.id),onMouseEnter:()=>Y(c.id),onMouseLeave:()=>Y(null),onClick:te=>{A(c.id)||(te.shiftKey?T.toggle(c.id,!0):(w(c.id),T.selectOne(c.id)))},children:[e.jsx("div",{className:Me("flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow",tt(c.type),D&&"ring-2 ring-primary shadow-md",v&&"ring-2 ring-blue-400 shadow-lg",S&&!v&&"cursor-crosshair"),children:e.jsx("span",{className:Me("text-xs font-medium",(c.type==="exclusive-gateway"||c.type==="parallel-gateway"||c.type==="inclusive-gateway"||c.type==="event-based-gateway")&&"-rotate-45"),children:c.label})}),q&&!b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair",style:{left:-6,top:Ee/2-6},title:"Input port",onClick:te=>{te.stopPropagation(),A(c.id)}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair",style:{right:-6,top:Ee/2-6},title:"Output port",onClick:te=>{te.stopPropagation(),S?A(c.id):(y(!0),C(c.id))}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:De/2-6,top:-6},title:"Port",onClick:te=>{te.stopPropagation(),A(c.id)}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:De/2-6,bottom:-6},title:"Port",onClick:te=>{te.stopPropagation(),A(c.id)}})]}),!b&&D&&!S&&e.jsx("button",{onClick:te=>{te.stopPropagation(),ae(c.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow","aria-label":"Delete node",children:e.jsx(ue,{className:"h-3 w-3"})})]},c.id)}),r&&m.length>0&&e.jsx(ft,{items:at,canvasWidth:n.width??1400,canvasHeight:n.height??800,position:"bottom-right"})]})}),M&&!b&&e.jsx("div",{className:"w-64 border-l bg-background overflow-y-auto flex-shrink-0",role:"complementary","aria-label":"Property panel",children:e.jsx(We,{title:ne?`Properties: ${ne.label}`:"Properties",fields:ie,onChange:et})})]})]})}function xe(...t){return le(oe(t))}const V={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:t=>`Are you sure you want to delete ${t} element${t>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"},Wa={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}},qa=[{type:"header",height:80,elements:[]},{type:"detail",height:400,elements:[],repeat:!0},{type:"footer",height:60,elements:[]}];function Qa({reportName:t=V.untitledReport,objectName:s,pageSize:l="A4",orientation:i="portrait",margins:n={top:40,right:40,bottom:40,left:40},sections:r=[],showToolbar:p=!0,showPropertyPanel:b=!0,readOnly:g=!1,onSectionsChange:o,className:u}){const d=ke(r.length>0?r:qa),m=d.current,j=a.useCallback(E=>{d.push(E),o?.(E)},[d,o]),x=Xe(),k=a.useMemo(()=>{const E=Array.from(x.selectedIds);return E.length>0?E[0]:null},[x.selectedIds]),T=Je(),P=Le(),R=Qe(),L=a.useCallback(E=>{R&&R.sendOperation({...E,userId:R.currentUserId??""})},[R]),[U,w]=a.useState(!0),S=a.useRef(null),y=a.useRef(null),I=Wa[l],C=i==="landscape"?I.height:I.width,K=i==="landscape"?I.width:I.height,Y=E=>{switch(E){case"header":return V.sectionHeader;case"page-header":return V.sectionPageHeader;case"group-header":return V.sectionGroupHeader;case"detail":return V.sectionDetail;case"group-footer":return V.sectionGroupFooter;case"page-footer":return V.sectionPageFooter;case"footer":return V.sectionFooter;default:return E}},M=a.useMemo(()=>k?m.flatMap(E=>E.elements).find(E=>E.id===k):null,[k,m]),Q=a.useCallback((E,X)=>{if(g)return;const O={id:`elem-${Date.now()}`,type:X,position:{x:n.left,y:10,width:200,height:30},properties:{text:X==="text"?"New Text":void 0,field:X==="field"?"field_name":void 0}},h=m.map((A,H)=>H===E?{...A,elements:[...A.elements,O]}:A);j(h),x.selectOne(O.id),L({type:"insert",elementId:O.id,data:{element:O}})},[m,n.left,g,j,x,L]),se=a.useCallback(E=>{if(g)return;const X=m.map(O=>({...O,elements:O.elements.filter(h=>h.id!==E)}));j(X),x.isSelected(E)&&x.clearSelection(),L({type:"delete",elementId:E,data:{}})},[m,g,j,x,L]),F=a.useCallback(async()=>{if(g||x.count===0||!await P.confirm(V.deleteElementsTitle,V.deleteElementMessage(x.count)))return;const E=x.selectedIds,X=m.map(O=>({...O,elements:O.elements.filter(h=>!E.has(h.id))}));j(X),x.clearSelection(),E.forEach(O=>{L({type:"delete",elementId:O,data:{}})})},[g,x,P,m,j,L]),J=a.useCallback((E,X)=>{if(g||!k)return;const O=m.map(h=>({...h,elements:h.elements.map(A=>A.id!==k?A:E==="x"?{...A,position:{...A.position,x:Number(X)}}:E==="y"?{...A,position:{...A.position,y:Number(X)}}:E==="width"?{...A,position:{...A.position,width:Number(X)}}:E==="height"?{...A,position:{...A.position,height:Number(X)}}:{...A,properties:{...A.properties,[E]:X}})}));j(O),L({type:"update",elementId:k,data:{[E]:X}})},[g,k,m,j,L]),_=a.useCallback(()=>{const E=x.selectedIds;if(E.size===0)return;const X=m.flatMap(O=>O.elements).filter(O=>E.has(O.id));T.copy(X)},[x,m,T]),N=a.useCallback(()=>{if(g)return;const E=T.paste();if(!E||E.length===0)return;let X=0;const O=E.map(B=>({...B,id:`elem-${Date.now()}-${++X}-${Math.random().toString(36).slice(2,7)}`,position:{...B.position,x:B.position.x+20,y:B.position.y+20}})),h=m.findIndex(B=>B.type==="detail"),A=h>=0?h:0,H=m.map((B,W)=>W===A?{...B,elements:[...B.elements,...O]}:B);j(H),x.selectMany(O.map(B=>B.id)),O.forEach(B=>{L({type:"insert",elementId:B.id,data:{element:B}})})},[g,T,m,j,x,L]),G=a.useCallback((E,X,O)=>{g||(S.current={id:X.id,sectionIndex:O,startX:E.clientX,startY:E.clientY},E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/plain",X.id))},[g]),z=a.useCallback(E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},[]),Z=a.useCallback((E,X)=>{E.preventDefault();const O=S.current;if(!O||g)return;const h=E.clientX-O.startX,A=E.clientY-O.startY;if(O.sectionIndex===X){const H=m.map((B,W)=>W!==X?B:{...B,elements:B.elements.map(ee=>ee.id!==O.id?ee:{...ee,position:{...ee.position,x:Math.max(0,ee.position.x+h),y:Math.max(0,(typeof ee.position.y=="number"?ee.position.y:0)+A)}})});j(H)}else{let H=null;const B=m.map((W,ee)=>{if(ee!==O.sectionIndex)return W;const ne=W.elements.find(ie=>ie.id===O.id);return ne&&(H={...ne,position:{...ne.position,x:Math.max(0,ne.position.x+h),y:Math.max(0,10)}}),{...W,elements:W.elements.filter(ie=>ie.id!==O.id)}});if(H){const W=B.map((ee,ne)=>ne!==X?ee:{...ee,elements:[...ee.elements,H]});j(W)}}L({type:"move",elementId:O.id,data:{}}),S.current=null},[g,m,j,L]),ae=a.useMemo(()=>{if(!M)return[];const E=[{name:"x",label:V.propX,type:"number",value:M.position.x,group:V.groupPosition},{name:"y",label:V.propY,type:"number",value:M.position.y,group:V.groupPosition},{name:"width",label:V.propWidth,type:"number",value:M.position.width,group:V.groupSize},{name:"height",label:V.propHeight,type:"number",value:M.position.height,group:V.groupSize}];return M.type==="text"&&E.push({name:"text",label:V.propText,type:"text",value:M.properties.text??"",group:V.groupContent}),M.type==="field"&&E.push({name:"field",label:V.propField,type:"text",value:M.properties.field??"",group:V.groupContent}),E},[M]);return a.useEffect(()=>{const E=y.current;if(!E)return;const X=O=>{const h=["INPUT","TEXTAREA","SELECT"].includes(O.target.tagName),A=O.ctrlKey||O.metaKey;if((O.key==="Delete"||O.key==="Backspace")&&x.count>0&&!h){O.preventDefault(),F();return}if(O.key==="Escape"){x.clearSelection();return}if(!h){if(A&&O.key==="z"&&!O.shiftKey&&!g){O.preventDefault(),d.undo();return}if(A&&(O.key==="z"&&O.shiftKey||O.key==="y")&&!g){O.preventDefault(),d.redo();return}if(A&&O.key==="c"){O.preventDefault(),_();return}if(A&&O.key==="v"&&!g){O.preventDefault(),N();return}if(A&&O.key==="a"){O.preventDefault();const H=m.flatMap(B=>B.elements).map(B=>B.id);x.selectMany(H);return}}};return E.addEventListener("keydown",X),()=>E.removeEventListener("keydown",X)},[x,F,g,d,_,N,m]),e.jsxs("div",{ref:y,tabIndex:0,className:xe("flex h-full w-full border rounded-lg overflow-hidden bg-background",u),children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[p&&e.jsxs("div",{role:"toolbar","aria-label":V.designerToolbar,className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(mt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:t}),s&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s,")"]}),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:xe("p-1.5 rounded hover:bg-accent",!d.canUndo&&"opacity-40 pointer-events-none"),title:V.undoShortcut,"aria-label":V.undo,disabled:!d.canUndo,onClick:()=>d.undo(),children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("button",{className:xe("p-1.5 rounded hover:bg-accent",!d.canRedo&&"opacity-40 pointer-events-none"),title:V.redoShortcut,"aria-label":V.redo,disabled:!d.canRedo,onClick:()=>d.redo(),children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!g&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:xe("p-1.5 rounded hover:bg-accent",x.count===0&&"opacity-40 pointer-events-none"),title:V.copyShortcut,"aria-label":V.copy,disabled:x.count===0,onClick:_,children:e.jsx(Be,{className:"h-4 w-4"})}),e.jsx("button",{className:xe("p-1.5 rounded hover:bg-accent",!T.hasContent&&"opacity-40 pointer-events-none"),title:V.pasteShortcut,"aria-label":V.paste,disabled:!T.hasContent,onClick:N,children:e.jsx(_e,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!g&&e.jsx("button",{className:xe("p-1.5 rounded hover:bg-accent",x.count===0&&"opacity-40 pointer-events-none"),title:V.deleteSelected,"aria-label":V.deleteSelected,disabled:x.count===0,onClick:F,children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),R?.isConnected&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-green-500"}),V.collaborationConnected,R.users.length>1&&` (${R.users.length})`]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[l," ",i]}),b&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:U?V.collapsePanel:V.expandPanel,"aria-label":U?V.collapsePanel:V.expandPanel,onClick:()=>w(E=>!E),children:e.jsx(ht,{className:xe("h-4 w-4",!U&&"rotate-180")})})]}),e.jsx("div",{role:"region","aria-label":V.reportCanvas,className:"flex-1 overflow-auto bg-muted/10 p-4 flex justify-center",children:e.jsx("div",{className:"bg-white shadow-lg border",style:{width:C,minHeight:K},children:m.map((E,X)=>e.jsxs("div",{className:"relative border-b border-dashed border-gray-300",style:{minHeight:E.height},onDragOver:z,onDrop:O=>Z(O,X),children:[e.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:[Y(E.type),E.repeat&&" ↻"]}),!g&&e.jsxs("div",{className:"absolute right-1 top-0 flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>Q(X,"text"),className:"p-0.5 rounded hover:bg-accent",title:V.addText,"aria-label":V.addText,children:e.jsx(Bt,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>Q(X,"field"),className:"p-0.5 rounded hover:bg-accent",title:V.addField,"aria-label":V.addField,children:e.jsx(ve,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>Q(X,"image"),className:"p-0.5 rounded hover:bg-accent",title:V.addImage,"aria-label":V.addImage,children:e.jsx(gt,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>Q(X,"chart"),className:"p-0.5 rounded hover:bg-accent",title:V.addChart,"aria-label":V.addChart,children:e.jsx(Ue,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>Q(X,"table"),className:"p-0.5 rounded hover:bg-accent",title:V.addTable,"aria-label":V.addTable,children:e.jsx(ut,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"relative",style:{minHeight:E.height,paddingTop:24},children:[E.elements.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground text-center pt-4",children:V.addElementsPrompt}),E.elements.map(O=>{const h=x.isSelected(O.id);return e.jsxs("div",{draggable:!g,onDragStart:A=>G(A,O,X),className:xe("absolute border rounded px-2 py-1 text-xs cursor-pointer",h?"border-primary ring-1 ring-primary/30 bg-primary/5":"border-dashed border-gray-400 hover:border-primary/50"),style:{left:O.position.x,top:(typeof O.position.y=="number"?O.position.y:0)+24,width:O.position.width,height:O.position.height},onClick:A=>x.toggle(O.id,A.shiftKey),children:[e.jsxs("span",{className:"text-muted-foreground",children:[O.type==="text"&&(O.properties.text??V.elementText),O.type==="field"&&`{${O.properties.field??"field"}}`,O.type==="image"&&V.elementImage,O.type==="chart"&&V.elementChart,O.type==="table"&&V.elementTable]}),!g&&h&&e.jsx("button",{onClick:A=>{A.stopPropagation(),se(O.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow","aria-label":V.deleteElement,children:e.jsx(ue,{className:"h-2.5 w-2.5"})})]},O.id)})]})]},`${E.type}-${X}`))})})]}),b&&e.jsx("div",{role:"region","aria-label":V.propertiesPanel,className:xe("border-l bg-muted/30 flex flex-col transition-[width] duration-200",U?"w-56":"w-0 overflow-hidden"),children:U&&(k&&M?e.jsx(We,{title:`${V.properties} – ${M.type}`,fields:ae,onChange:J}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:V.properties}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:V.selectElementPrompt})})]}))}),e.jsx(Ze,{isOpen:P.isOpen,title:P.title,message:P.message,onConfirm:P.onConfirm,onCancel:P.onCancel})]})}const es=(t,s,l,i)=>{const n=[l,{code:s,...i||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(n,"warn","react-i18next::",!0);je(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...n):console?.warn&&console.warn(...n)},Ct={},ea=(t,s,l,i)=>{je(l)&&Ct[l]||(je(l)&&(Ct[l]=new Date),es(t,s,l,i))},ta=(t,s)=>()=>{if(t.isInitialized)s();else{const l=()=>{setTimeout(()=>{t.off("initialized",l)},0),s()};t.on("initialized",l)}},it=(t,s,l)=>{t.loadNamespaces(s,ta(t,l))},kt=(t,s,l,i)=>{if(je(l)&&(l=[l]),t.options.preload&&t.options.preload.indexOf(s)>-1)return it(t,l,i);l.forEach(n=>{t.options.ns.indexOf(n)<0&&t.options.ns.push(n)}),t.loadLanguages(s,ta(t,i))},ts=(t,s,l={})=>!s.languages||!s.languages.length?(ea(s,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:s.languages}),!0):s.hasLoadedNamespace(t,{lng:l.lng,precheck:(i,n)=>{if(l.bindI18n&&l.bindI18n.indexOf("languageChanging")>-1&&i.services.backendConnector.backend&&i.isLanguageChangingTo&&!n(i.isLanguageChangingTo,t))return!1}}),je=t=>typeof t=="string",as=t=>typeof t=="object"&&t!==null,ss=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ns={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},rs=t=>ns[t],ls=t=>t.replace(ss,rs);let os={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ls,transDefaultProps:void 0};const is=()=>os;let ds;const cs=()=>ds,ps=a.createContext();class us{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(l=>{this.usedNamespaces[l]||(this.usedNamespaces[l]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Dt={exports:{}},rt={},St;function ms(){if(St)return rt;St=1;var t=$t;function s(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var l=typeof Object.is=="function"?Object.is:s,i=t.useState,n=t.useEffect,r=t.useLayoutEffect,p=t.useDebugValue;function b(d,m){var j=m(),x=i({inst:{value:j,getSnapshot:m}}),k=x[0].inst,T=x[1];return r(function(){k.value=j,k.getSnapshot=m,g(k)&&T({inst:k})},[d,j,m]),n(function(){return g(k)&&T({inst:k}),d(function(){g(k)&&T({inst:k})})},[d]),p(j),j}function g(d){var m=d.getSnapshot;d=d.value;try{var j=m();return!l(d,j)}catch{return!0}}function o(d,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:b;return rt.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,rt}var It;function gs(){return It||(It=1,Dt.exports=ms()),Dt.exports}var xs=gs();const bs=(t,s)=>je(s)?s:as(s)&&je(s.defaultValue)?s.defaultValue:Array.isArray(t)?t[t.length-1]:t,hs={t:bs,ready:!1},ys=()=>()=>{},fs=(t,s={})=>{const{i18n:l}=s,{i18n:i,defaultNS:n}=a.useContext(ps)||{},r=l||i||cs();r&&!r.reportNamespaces&&(r.reportNamespaces=new us),r||ea(r,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const p=a.useMemo(()=>({...is(),...r?.options?.react,...s}),[r,s]),{useSuspense:b,keyPrefix:g}=p,o=n||r?.options?.defaultNS,u=je(o)?[o]:o||["translation"],d=a.useMemo(()=>u,u);r?.reportNamespaces?.addUsedNamespaces?.(d);const m=a.useRef(0),j=a.useCallback(C=>{if(!r)return ys;const{bindI18n:K,bindI18nStore:Y}=p,M=()=>{m.current+=1,C()};return K&&r.on(K,M),Y&&r.store.on(Y,M),()=>{K&&K.split(" ").forEach(Q=>r.off(Q,M)),Y&&Y.split(" ").forEach(Q=>r.store.off(Q,M))}},[r,p]),x=a.useRef(),k=a.useCallback(()=>{if(!r)return hs;const C=!!(r.isInitialized||r.initializedStoreOnce)&&d.every(se=>ts(se,r,p)),K=s.lng||r.language,Y=m.current,M=x.current;if(M&&M.ready===C&&M.lng===K&&M.keyPrefix===g&&M.revision===Y)return M;const Q={t:r.getFixedT(K,p.nsMode==="fallback"?d:d[0],g),ready:C,lng:K,keyPrefix:g,revision:Y};return x.current=Q,Q},[r,d,g,p,s.lng]),[T,P]=a.useState(0),{t:R,ready:L}=xs.useSyncExternalStore(j,k,k);a.useEffect(()=>{if(r&&!L&&!b){const C=()=>P(K=>K+1);s.lng?kt(r,s.lng,d,C):it(r,d,C)}},[r,s.lng,d,L,b,T]);const U=r||{},w=a.useRef(null),S=a.useRef(),y=C=>{const K=Object.getOwnPropertyDescriptors(C);K.__original&&delete K.__original;const Y=Object.create(Object.getPrototypeOf(C),K);if(!Object.prototype.hasOwnProperty.call(Y,"__original"))try{Object.defineProperty(Y,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return Y},I=a.useMemo(()=>{const C=U,K=C?.language;let Y=C;C&&(w.current&&w.current.__original===C?S.current!==K?(Y=y(C),w.current=Y,S.current=K):Y=w.current:(Y=y(C),w.current=Y,S.current=K));const M=[R,Y,L];return M.t=R,M.i18n=Y,M.ready=L,M},[R,U,L,U.resolvedLanguage,U.language,U.languages]);if(r&&b&&!L)throw new Promise(C=>{const K=()=>C();s.lng?kt(r,s.lng,d,K):it(r,d,K)});return I},vs=a.createContext(null);function js(t){const s=a.useContext(vs),{t:l,i18n:i}=fs();return{t:l,language:s?.language||i.language||"en",changeLanguage:s?.changeLanguage||(async n=>{await i.changeLanguage(n)}),direction:s?.direction||"ltr",i18n:i}}const Pt={"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 Tt(t){return(s,l)=>{let i=t[s]||s;if(l)for(const[n,r]of Object.entries(l))i=i.replace(`{{${n}}}`,String(r));return i}}function be(){try{const t=js();return t.t("appDesigner.basicInfo")==="appDesigner.basicInfo"?{t:Tt(Pt)}:{t:t.t}}catch{return{t:Tt(Pt)}}}function pe(...t){return le(oe(t))}const Ns={name:"",title:"",description:"",icon:"",template:"",layout:"sidebar",objects:[],navigation:[],branding:{logo:"",primaryColor:"#3b82f6",favicon:""}};function Ot(t){return t.filter(s=>s.selected).map(s=>({id:s.name,type:"object",label:s.label,icon:s.icon,objectName:s.name}))}let Et=0;function ws(t){return Et+=1,`${t}_${Date.now()}_${Et}`}function Cs({steps:t,currentIndex:s,onStepClick:l}){return e.jsx("nav",{className:"flex items-center justify-center gap-0 px-4 py-6",children:t.map((i,n)=>{const r=n<s,p=n===s;return e.jsxs($t.Fragment,{children:[n>0&&e.jsx("div",{className:pe("h-0.5 w-12 sm:w-20",r?"bg-blue-500":"bg-gray-200")}),e.jsxs("button",{type:"button","data-testid":`wizard-step-${i.id}`,onClick:()=>l(n),className:pe("flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1",p&&"cursor-default",!p&&"cursor-pointer"),children:[e.jsx("div",{className:pe("flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors",r&&"bg-blue-500 text-white",p&&"bg-blue-600 text-white ring-2 ring-blue-300",!r&&!p&&"bg-gray-200 text-gray-500"),children:r?e.jsx(pt,{className:"h-4 w-4"}):n+1}),e.jsx("span",{className:pe("text-xs font-medium",p?"text-blue-600":"text-gray-500"),children:i.label})]})]},i.id)})})}function ks({draft:t,templates:s,readOnly:l,onChange:i,t:n}){const r=t.name.length>0&&!zt(t.name);return e.jsxs("div",{"data-testid":"wizard-step-basic-content",className:"mx-auto max-w-lg space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:"app-name",className:"block text-sm font-medium text-gray-700",children:[n("appDesigner.appName")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"app-name","data-testid":"app-name-input",type:"text",value:t.name,onChange:p=>i({name:p.target.value}),placeholder:"my_app",disabled:l,className:pe("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",r?"border-red-400":"border-gray-300")}),r&&e.jsx("p",{className:"text-xs text-red-500",children:n("appDesigner.snakeCaseHint")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:"app-title",className:"block text-sm font-medium text-gray-700",children:[n("appDesigner.appTitle")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"app-title","data-testid":"app-title-input",type:"text",value:t.title,onChange:p=>i({title:p.target.value}),placeholder:"My Application",disabled:l,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"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-description",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.appDescription")}),e.jsx("textarea",{id:"app-description","data-testid":"app-description-input",value:t.description??"",onChange:p=>i({description:p.target.value}),rows:3,disabled:l,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"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-icon",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.appIcon")}),e.jsx("input",{id:"app-icon",type:"text",value:t.icon??"",onChange:p=>i({icon:p.target.value}),placeholder:"LayoutDashboard",disabled:l,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"})]}),s.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-template",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.template")}),e.jsxs("select",{id:"app-template",value:t.template??"",onChange:p=>i({template:p.target.value}),disabled:l,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:[e.jsx("option",{value:"",children:"None"}),s.map(p=>e.jsx("option",{value:p.id,children:p.label},p.id))]})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium text-gray-700",children:n("appDesigner.layout")}),e.jsx("div",{className:"flex gap-3",children:[{value:"sidebar",labelKey:"appDesigner.layoutSidebar",Icon:Ea},{value:"header",labelKey:"appDesigner.layoutHeader",Icon:Qt},{value:"empty",labelKey:"appDesigner.layoutEmpty",Icon:Ra}].map(({value:p,labelKey:b,Icon:g})=>e.jsxs("label",{"data-testid":`app-layout-${p}`,className:pe("flex flex-1 cursor-pointer flex-col items-center gap-1.5 rounded-lg border-2 p-3 transition-colors",t.layout===p?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300",l&&"pointer-events-none opacity-60"),children:[e.jsx(g,{className:"h-5 w-5 text-gray-600"}),e.jsx("span",{className:"text-xs font-medium text-gray-700",children:n(b)}),e.jsx("input",{type:"radio",name:"layout",value:p,checked:t.layout===p,onChange:()=>i({layout:p}),disabled:l,className:"sr-only"})]},p))})]})]})}function Ds({objects:t,readOnly:s,onToggle:l,onToggleAll:i,search:n,onSearchChange:r,t:p}){const b=a.useMemo(()=>{if(!n)return t;const o=n.toLowerCase();return t.filter(u=>u.name.toLowerCase().includes(o)||u.label.toLowerCase().includes(o))},[t,n]),g=t.length>0&&t.every(o=>o.selected);return t.every(o=>!o.selected),e.jsxs("div",{"data-testid":"wizard-step-objects-content",className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Aa,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{"data-testid":"object-search",type:"text",value:n,onChange:o=>r(o.target.value),placeholder:p("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"})]}),e.jsx("button",{type:"button",onClick:()=>i(!g),disabled:s,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:p(g?"appDesigner.deselectAll":"appDesigner.selectAll")})]}),b.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-gray-400",children:p("appDesigner.noObjectsFound")}):e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:b.map(o=>e.jsxs("button",{type:"button","data-testid":`object-card-${o.name}`,disabled:s,onClick:()=>l(o.name),className:pe("flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors",o.selected?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300",s&&"pointer-events-none opacity-60"),children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800",children:o.label}),e.jsx("div",{className:pe("flex h-5 w-5 items-center justify-center rounded border transition-colors",o.selected?"border-blue-500 bg-blue-500 text-white":"border-gray-300"),children:o.selected&&e.jsx(pt,{className:"h-3 w-3"})})]}),e.jsx("span",{className:"text-xs text-gray-500",children:o.name}),o.icon&&e.jsx("span",{className:"text-xs text-gray-400",children:o.icon})]},o.name))})]})}const Ss={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 Is({items:t,readOnly:s,onAdd:l,onRemove:i,onReorder:n,t:r}){return e.jsxs("div",{"data-testid":"wizard-step-navigation-content",className:"mx-auto max-w-lg space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button","data-testid":"add-group-btn",onClick:()=>l("group"),disabled:s,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:[e.jsx(Zt,{className:"h-3.5 w-3.5"}),r("appDesigner.addGroup")]}),e.jsxs("button",{type:"button","data-testid":"add-url-btn",onClick:()=>l("url"),disabled:s,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:[e.jsx(bt,{className:"h-3.5 w-3.5"}),r("appDesigner.addUrl")]}),e.jsxs("button",{type:"button","data-testid":"add-separator-btn",onClick:()=>l("separator"),disabled:s,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:[e.jsx(xt,{className:"h-3.5 w-3.5"}),r("appDesigner.addSeparator")]})]}),t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-gray-400",children:r("appDesigner.noNavItemsHint")}):e.jsx("ul",{className:"space-y-1.5",children:t.map((p,b)=>e.jsxs("li",{"data-testid":`nav-item-${p.id}`,className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2",children:[p.icon&&e.jsx("span",{className:"text-xs text-gray-400",children:p.icon}),e.jsx("span",{className:"flex-1 truncate text-sm text-gray-800",children:p.type==="separator"?r("appDesigner.separatorLabel"):fe(p.label)}),e.jsx("span",{className:pe("rounded-full px-2 py-0.5 text-[10px] font-medium",Ss[p.type]??"bg-gray-100 text-gray-600"),children:p.type}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>n(p.id,"up"),disabled:s||b===0,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(p.id,"down"),disabled:s||b===t.length-1,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(me,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>i(p.id),disabled:s,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30","aria-label":"Remove",children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]},p.id))})]})}function Ps({branding:t,title:s,readOnly:l,onChange:i,t:n}){return e.jsxs("div",{"data-testid":"wizard-step-branding-content",className:"mx-auto max-w-lg space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-logo",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.logoUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(gt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-logo","data-testid":"branding-logo-input",type:"text",value:t.logo??"",onChange:r=>i({logo:r.target.value}),placeholder:"https://example.com/logo.svg",disabled:l,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"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-color",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.primaryColor")}),e.jsxs("div",{className:"relative",children:[e.jsx(Ht,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-color","data-testid":"branding-color-input",type:"text",value:t.primaryColor??"#3b82f6",onChange:r=>i({primaryColor:r.target.value}),placeholder:"#3b82f6",disabled:l,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"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-favicon",className:"block text-sm font-medium text-gray-700",children:n("appDesigner.faviconUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-favicon","data-testid":"branding-favicon-input",type:"text",value:t.favicon??"",onChange:r=>i({favicon:r.target.value}),placeholder:"https://example.com/favicon.ico",disabled:l,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"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"block text-sm font-medium text-gray-700",children:n("appDesigner.preview")}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.logo?e.jsx("img",{src:t.logo,alt:"App logo",className:"h-8 w-8 rounded object-contain"}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400",children:"Logo"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800",children:s||n("appDesigner.appTitle")})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border border-gray-200",style:{backgroundColor:t.primaryColor||"#3b82f6"}}),e.jsx("span",{className:"text-xs text-gray-500",children:t.primaryColor||"#3b82f6"})]}),t.favicon&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("img",{src:t.favicon,alt:"Favicon",className:"h-4 w-4 rounded object-contain"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Favicon"})]})]})]})]})}function Ts({availableObjects:t=[],templates:s=[],initialDraft:l,onComplete:i,onCancel:n,onSaveDraft:r,readOnly:p=!1,className:b}){const{t:g}=be(),o=Le(),[u,d]=a.useState(0),[m,j]=a.useState(""),[x,k]=a.useState(()=>({...Ns,objects:t.map(N=>({...N})),...l})),T=a.useMemo(()=>[{id:"basic",label:g("appDesigner.basicInfo"),description:g("appDesigner.stepBasicDesc"),icon:"Settings"},{id:"objects",label:g("appDesigner.objects"),description:g("appDesigner.stepObjectsDesc"),icon:"Database"},{id:"navigation",label:g("appDesigner.navigation"),description:g("appDesigner.stepNavigationDesc"),icon:"Menu"},{id:"branding",label:g("appDesigner.branding"),description:g("appDesigner.stepBrandingDesc"),icon:"Palette"}],[g]),P=u===0,R=u===T.length-1,L=a.useMemo(()=>x.name.length>0&&zt(x.name)&&x.title.trim().length>0,[x.name,x.title]),U=a.useMemo(()=>u===0?L:!0,[u,L]),w=a.useCallback(N=>{k(G=>({...G,...N}))},[]),S=a.useCallback(N=>{k(G=>({...G,branding:{...G.branding,...N}}))},[]),y=a.useCallback(N=>{k(G=>({...G,objects:G.objects.map(z=>z.name===N?{...z,selected:!z.selected}:z)}))},[]),I=a.useCallback(N=>{k(G=>({...G,objects:G.objects.map(z=>({...z,selected:N}))}))},[]),C=a.useCallback(N=>{const G={id:ws(N),type:N,label:N==="separator"?"":N==="group"?"New Group":"New Link",...N==="group"?{children:[]}:{},...N==="url"?{url:""}:{}};k(z=>({...z,navigation:[...z.navigation,G]}))},[]),K=a.useCallback(N=>{k(G=>({...G,navigation:G.navigation.filter(z=>z.id!==N)}))},[]),Y=a.useCallback((N,G)=>{k(z=>{const Z=[...z.navigation],ae=Z.findIndex(X=>X.id===N);if(ae<0)return z;const E=G==="up"?ae-1:ae+1;return E<0||E>=Z.length?z:([Z[ae],Z[E]]=[Z[E],Z[ae]],{...z,navigation:Z})})},[]),M=a.useCallback(()=>{R||(u===1&&k(N=>({...N,navigation:Ot(N.objects)})),d(N=>N+1))},[u,R]),Q=a.useCallback(()=>{P||d(N=>N-1)},[P]),se=a.useCallback(()=>{i?.(x)},[x,i]),F=a.useCallback(async()=>{(x.name.length>0||x.title.length>0)&&n?await o.confirm(g("appDesigner.cancelConfirmTitle"),g("appDesigner.cancelConfirmMessage"))&&n():n?.()},[x.name,x.title,n,o,g]),J=a.useCallback(()=>{r?.(x)},[x,r]),_=a.useCallback(N=>{N<=u?d(N):N===u+1&&U&&(u===1&&N===2&&k(G=>({...G,navigation:Ot(G.objects)})),d(N))},[u,U]);return e.jsxs("div",{className:pe("flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm",b),children:[o.isOpen&&e.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:e.jsxs("div",{className:"mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:o.title}),e.jsx("button",{type:"button",onClick:o.onCancel,className:"rounded p-1 text-gray-400 hover:text-gray-600","aria-label":g("common.close"),children:e.jsx(ct,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:o.message}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button","data-testid":"cancel-confirm-keep",onClick:o.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:g("appDesigner.keepEditing")}),e.jsx("button",{type:"button","data-testid":"cancel-confirm-discard",onClick:o.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:g("appDesigner.confirmDiscard")})]})]})}),e.jsx("div",{className:"border-b border-gray-100",children:e.jsx(Cs,{steps:T,currentIndex:u,onStepClick:_})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[u===0&&e.jsx(ks,{draft:x,templates:s,readOnly:p,onChange:w,t:g}),u===1&&e.jsx(Ds,{objects:x.objects,readOnly:p,onToggle:y,onToggleAll:I,search:m,onSearchChange:j,t:g}),u===2&&e.jsx(Is,{items:x.navigation,readOnly:p,onAdd:C,onRemove:K,onReorder:Y,t:g}),u===3&&e.jsx(Ps,{branding:x.branding,title:x.title,readOnly:p,onChange:S,t:g})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","data-testid":"wizard-cancel",onClick:F,disabled:p,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:g("common.cancel")}),r&&e.jsx("button",{type:"button","data-testid":"wizard-save-draft",onClick:J,disabled:p,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:g("appDesigner.saveDraft")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!P&&e.jsxs("button",{type:"button","data-testid":"wizard-back",onClick:Q,disabled:p,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:[e.jsx(la,{className:"h-4 w-4"}),g("common.back")]}),R?e.jsxs("button",{type:"button","data-testid":"wizard-complete",onClick:se,disabled:p||!U,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:[e.jsx(pt,{className:"h-4 w-4"}),g("appDesigner.complete")]}):e.jsxs("button",{type:"button","data-testid":"wizard-next",onClick:M,disabled:p||!U,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:[g("common.next"),e.jsx(Ae,{className:"h-4 w-4"})]})]})]})]})}function Se(...t){return le(oe(t))}let Rt=0;function At(t){return Rt+=1,`${t}_${Date.now()}_${Rt}`}const Re={object:{labelKey:"appDesigner.navTypeObject",color:"bg-green-100 text-green-700",Icon:ot},dashboard:{labelKey:"appDesigner.navTypeDashboard",color:"bg-amber-100 text-amber-700",Icon:ya},page:{labelKey:"appDesigner.navTypePage",color:"bg-teal-100 text-teal-700",Icon:mt},report:{labelKey:"appDesigner.navTypeReport",color:"bg-rose-100 text-rose-700",Icon:Ue},url:{labelKey:"appDesigner.navTypeUrl",color:"bg-sky-100 text-sky-700",Icon:bt},group:{labelKey:"appDesigner.navTypeGroup",color:"bg-purple-100 text-purple-700",Icon:Zt},separator:{labelKey:"appDesigner.navTypeSeparator",color:"bg-gray-100 text-gray-600",Icon:xt},action:{labelKey:"appDesigner.navTypeAction",color:"bg-orange-100 text-orange-700",Icon:ha}},Os=[{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 aa({item:t,depth:s,index:l,total:i,readOnly:n,onRemove:r,onMoveUp:p,onMoveDown:b,onToggleExpand:g,onUpdateLabel:o,onUpdateIcon:u,onToggleVisible:d,onAddChild:m,expandedIds:j,t:x}){const[k,T]=a.useState(!1),[P,R]=a.useState(fe(t.label)??""),[L,U]=a.useState(!1),[w,S]=a.useState(t.icon||""),y=Re[t.type];t.type==="group"&&t.children&&t.children.length>0;const I=j.has(t.id),C=t.visible===!1,K=()=>{P.trim()?o(t.id,P.trim()):R(fe(t.label)??""),T(!1)},Y=()=>{u(t.id,w.trim()),U(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("li",{"data-testid":`nav-designer-item-${t.id}`,className:Se("flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50",C&&"opacity-50"),style:{marginLeft:s*20},children:[e.jsx(Ye,{className:"h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300"}),t.type==="group"?e.jsx("button",{type:"button",onClick:()=>g(t.id),className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":x(I?"appDesigner.navCollapseGroup":"appDesigner.navExpandGroup"),children:I?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})}):e.jsx("span",{className:"w-5"}),L&&!n?e.jsx("input",{type:"text",value:w,onChange:M=>S(M.target.value),onBlur:Y,onKeyDown:M=>{M.key==="Enter"&&Y(),M.key==="Escape"&&(S(t.icon||""),U(!1))},autoFocus:!0,placeholder:x("appDesigner.navIconPlaceholder"),"data-testid":`nav-designer-icon-input-${t.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"}):e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(y.Icon,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}),!n&&t.type!=="separator"&&e.jsx("button",{type:"button",onClick:()=>{S(t.icon||""),U(!0)},className:"rounded p-0.5 text-gray-300 hover:text-blue-500","aria-label":x("appDesigner.navEditIcon"),"data-testid":`nav-designer-edit-icon-${t.id}`,children:e.jsx(Jt,{className:"h-2.5 w-2.5"})})]}),t.type==="separator"?e.jsx("span",{className:"flex-1 text-xs italic text-gray-400",children:x("appDesigner.separatorLabel")}):k&&!n?e.jsx("input",{type:"text",value:P,onChange:M=>R(M.target.value),onBlur:K,onKeyDown:M=>{M.key==="Enter"&&K(),M.key==="Escape"&&(R(fe(t.label)??""),T(!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"}):e.jsx("span",{className:Se("flex-1 truncate text-sm text-gray-800",!n&&"cursor-text"),onDoubleClick:()=>{!n&&t.type!=="separator"&&(R(fe(t.label)??""),T(!0))},children:fe(t.label)}),e.jsx("span",{className:Se("rounded-full px-2 py-0.5 text-[10px] font-medium",y.color),children:x(y.labelKey)}),C&&e.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-${t.id}`,children:x("appDesigner.navHidden")}),!n&&t.type!=="separator"&&e.jsx("button",{type:"button",onClick:()=>d(t.id),className:"rounded p-0.5 text-gray-400 hover:text-gray-700","aria-label":x("appDesigner.navToggleVisible"),"data-testid":`nav-designer-toggle-visible-${t.id}`,children:C?e.jsx(Ve,{className:"h-3.5 w-3.5"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})}),t.type==="group"&&!n&&e.jsx("button",{type:"button",onClick:()=>m(t.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-${t.id}`,children:e.jsx(ve,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>p(t.id),disabled:n||l===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":x("appDesigner.navMoveUp"),children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>b(t.id),disabled:n||l===i-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":x("appDesigner.navMoveDown"),children:e.jsx(me,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>r(t.id),disabled:n,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-${t.id}`,children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]}),t.type==="group"&&I&&t.children&&e.jsx(e.Fragment,{children:t.children.map((M,Q)=>e.jsx(aa,{item:M,depth:s+1,index:Q,total:t.children.length,readOnly:n,onRemove:r,onMoveUp:p,onMoveDown:b,onToggleExpand:g,onUpdateLabel:o,onUpdateIcon:u,onToggleVisible:d,onAddChild:m,expandedIds:j,t:x},M.id))})]})}function Es({items:t,t:s}){return e.jsxs("div",{"data-testid":"nav-designer-preview",className:"w-56 shrink-0 rounded-lg border border-gray-200 bg-gray-50 p-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase text-gray-500",children:s("appDesigner.navLivePreview")}),t.length===0?e.jsx("p",{className:"text-xs text-gray-400",children:s("appDesigner.navNoPreviewItems")}):e.jsx("ul",{className:"space-y-0.5",children:t.map(l=>e.jsx(sa,{item:l,depth:0},l.id))})]})}function sa({item:t,depth:s}){const l=Re[t.type];return t.type==="separator"?e.jsx("li",{className:"my-1 border-t border-gray-200",style:{marginLeft:s*12}}):e.jsxs(e.Fragment,{children:[e.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:s*12},children:[e.jsx(l.Icon,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"truncate",children:fe(t.label)})]}),t.type==="group"&&t.children?.map(i=>e.jsx(sa,{item:i,depth:s+1},i.id))]})}function Rs({items:t,onChange:s,readOnly:l=!1,showPreview:i=!0,className:n,onExport:r,onImport:p}){const{t:b}=be(),g=a.useRef(null),[o,u]=a.useState(()=>new Set(t.filter(w=>w.type==="group").map(w=>w.id))),d=a.useCallback(w=>{function S(y){return y.filter(I=>I.id!==w).map(I=>I.children?{...I,children:S(I.children)}:I)}s(S(t))},[t,s]),m=a.useCallback((w,S)=>{function y(I){const C=I.findIndex(K=>K.id===w);if(C>=0){const K=S==="up"?C-1:C+1;if(K>=0&&K<I.length){const Y=[...I];return[Y[C],Y[K]]=[Y[K],Y[C]],Y}return I}return I.map(K=>K.children?{...K,children:y(K.children)}:K)}s(y(t))},[t,s]),j=a.useCallback((w,S)=>{function y(I){return I.map(C=>C.id===w?{...C,label:S}:C.children?{...C,children:y(C.children)}:C)}s(y(t))},[t,s]),x=a.useCallback((w,S)=>{function y(I){return I.map(C=>C.id===w?{...C,icon:S||void 0}:C.children?{...C,children:y(C.children)}:C)}s(y(t))},[t,s]),k=a.useCallback(w=>{function S(y){return y.map(I=>I.id===w?{...I,visible:I.visible===!1}:I.children?{...I,children:S(I.children)}:I)}s(S(t))},[t,s]),T=a.useCallback((w,S)=>{const y={id:At(S),type:S,label:S==="separator"?"":`New ${b(Re[S].labelKey)}`,...S==="group"?{children:[]}:{},...S==="url"?{url:""}:{}};function I(C){return C.map(K=>K.id===w&&K.type==="group"?{...K,children:[...K.children||[],y]}:K.children?{...K,children:I(K.children)}:K)}s(I(t)),u(C=>new Set(C).add(w))},[t,s]),P=a.useCallback(w=>{const S={id:At(w),type:w,label:w==="separator"?"":`New ${b(Re[w].labelKey)}`,...w==="group"?{children:[]}:{},...w==="url"?{url:""}:{}};s([...t,S])},[t,s,b]),R=a.useCallback(w=>{u(S=>{const y=new Set(S);return y.has(w)?y.delete(w):y.add(w),y})},[]),L=a.useCallback(()=>{if(r)r(t);else{const w=JSON.stringify(t,null,2),S=new Blob([w],{type:"application/json"}),y=URL.createObjectURL(S),I=document.createElement("a");I.href=y,I.download="navigation-schema.json",I.click(),URL.revokeObjectURL(y)}},[t,r]),U=a.useCallback(w=>{const S=w.target.files?.[0];if(!S)return;const y=new FileReader;y.onload=I=>{try{const C=JSON.parse(I.target?.result);Array.isArray(C)&&(p?p(C):s(C))}catch{}},y.readAsText(S),g.current&&(g.current.value="")},[s,p]);return e.jsxs("div",{"data-testid":"navigation-designer",className:Se("flex flex-col gap-4 sm:flex-row",n),children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Os.map(({type:w,labelKey:S})=>{const{Icon:y,color:I}=Re[w];return e.jsxs("button",{type:"button","data-testid":`nav-designer-add-${w}`,onClick:()=>P(w),disabled:l,className:Se("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:[e.jsx(ve,{className:"h-3 w-3"}),b(S)]},w)}),e.jsx("span",{className:"mx-1 hidden h-4 w-px bg-gray-200 sm:block"}),e.jsxs("button",{type:"button","data-testid":"nav-designer-export",onClick:L,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:[e.jsx(Ge,{className:"h-3 w-3"}),b("appDesigner.navExportSchema")]}),e.jsxs("label",{"data-testid":"nav-designer-import",className:Se("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",l&&"cursor-not-allowed opacity-50"),children:[e.jsx(He,{className:"h-3 w-3"}),b("appDesigner.navImportSchema"),e.jsx("input",{ref:g,type:"file",accept:".json",className:"hidden",onChange:U,disabled:l,"data-testid":"nav-designer-import-input"})]})]}),t.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-gray-400",children:b("appDesigner.navNoItems")}):e.jsx("ul",{className:"space-y-1","data-testid":"nav-designer-tree",children:t.map((w,S)=>e.jsx(aa,{item:w,depth:0,index:S,total:t.length,readOnly:l,onRemove:d,onMoveUp:y=>m(y,"up"),onMoveDown:y=>m(y,"down"),onToggleExpand:R,onUpdateLabel:j,onUpdateIcon:x,onToggleVisible:k,onAddChild:T,expandedIds:o,t:b},w.id))})]}),i&&e.jsx(Es,{items:t,t:b})]})}function Lt(...t){return le(oe(t))}const As=[{value:"edit",label:"Edit",Icon:Jt},{value:"preview",label:"Preview",Icon:Pe},{value:"code",label:"Code",Icon:ba}];function un({mode:t,onChange:s,disabled:l=!1,className:i}){return e.jsx("div",{"data-testid":"editor-mode-toggle",className:Lt("inline-flex items-center rounded-lg border border-gray-200 bg-gray-50 p-0.5",i),role:"radiogroup","aria-label":"Editor mode",children:As.map(({value:n,label:r,Icon:p})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":t===n,"data-testid":`editor-mode-${n}`,onClick:()=>s(n),disabled:l,className:Lt("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===n?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700",l&&"cursor-not-allowed opacity-50"),children:[e.jsx(p,{className:"h-3.5 w-3.5"}),r]},n))})}function dt(...t){return le(oe(t))}const Ie=[{type:"metric",label:"KPI Metric",Icon:oa},{type:"bar",label:"Bar Chart",Icon:Ue},{type:"line",label:"Line Chart",Icon:ia},{type:"pie",label:"Pie Chart",Icon:da},{type:"table",label:"Table",Icon:ut},{type:"grid",label:"Grid",Icon:Ke}];let Mt=0;function Ls(){return Mt+=1,`widget_${Date.now()}_${Mt}`}function Ms({widget:t,index:s,total:l,selected:i,readOnly:n,onSelect:r,onRemove:p,onMoveUp:b,onMoveDown:g}){const o=t.type||"metric",u=Ie.find(d=>d.type===o)||Ie[0];return e.jsxs("div",{"data-testid":`dashboard-widget-${t.id}`,onClick:r,className:dt("group cursor-pointer rounded-lg border-2 p-3 transition-colors",i?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{className:"h-4 w-4 text-gray-300"}),e.jsx(u.Icon,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-800",children:t.title||`Widget ${s+1}`})]}),!n&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),b()},disabled:s===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),g()},disabled:s===l-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(me,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),p()},className:"rounded p-0.5 text-gray-400 hover:text-red-500","aria-label":"Remove widget","data-testid":`dashboard-widget-remove-${t.id}`,children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600",children:u.label}),t.object&&e.jsx("span",{className:"text-[10px] text-gray-400",children:t.object})]})]})}function Fs({widget:t,readOnly:s,onChange:l,onClose:i}){const{t:n}=be();return e.jsxs("div",{"data-testid":"widget-property-panel",className:"shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:n("appDesigner.widgetProperties")}),e.jsx("button",{type:"button",onClick:i,className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":"Close",children:e.jsx(ct,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-title",className:"text-xs font-medium text-gray-600",children:"Title"}),e.jsx("input",{id:"widget-title","data-testid":"widget-prop-title",type:"text",value:t.title??"",onChange:r=>l({title:r.target.value}),disabled:s,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"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-type",className:"text-xs font-medium text-gray-600",children:"Type"}),e.jsx("select",{id:"widget-type","data-testid":"widget-prop-type",value:t.type??"metric",onChange:r=>l({type:r.target.value}),disabled:s,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:Ie.map(r=>e.jsx("option",{value:r.type,children:r.label},r.type))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-object",className:"text-xs font-medium text-gray-600",children:"Data Source (Object)"}),e.jsx("input",{id:"widget-object","data-testid":"widget-prop-object",type:"text",value:t.object??"",onChange:r=>l({object:r.target.value}),disabled:s,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"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-value-field",className:"text-xs font-medium text-gray-600",children:"Value Field"}),e.jsx("input",{id:"widget-value-field","data-testid":"widget-prop-value-field",type:"text",value:t.valueField??"",onChange:r=>l({valueField:r.target.value}),disabled:s,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"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-aggregate",className:"text-xs font-medium text-gray-600",children:"Aggregate"}),e.jsxs("select",{id:"widget-aggregate","data-testid":"widget-prop-aggregate",value:t.aggregate??"count",onChange:r=>l({aggregate:r.target.value}),disabled:s,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:[e.jsx("option",{value:"count",children:"Count"}),e.jsx("option",{value:"sum",children:"Sum"}),e.jsx("option",{value:"avg",children:"Average"}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-color",className:"text-xs font-medium text-gray-600",children:"Color Variant"}),e.jsxs("select",{id:"widget-color","data-testid":"widget-prop-color",value:t.colorVariant??"default",onChange:r=>l({colorVariant:r.target.value}),disabled:s,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:[e.jsx("option",{value:"default",children:"Default"}),e.jsx("option",{value:"blue",children:"Blue"}),e.jsx("option",{value:"teal",children:"Teal"}),e.jsx("option",{value:"orange",children:"Orange"}),e.jsx("option",{value:"purple",children:"Purple"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"danger",children:"Danger"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:n("appDesigner.widgetLayoutSize")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"widget-width",className:"text-[10px] text-gray-400",children:n("appDesigner.widgetWidth")}),e.jsx("input",{id:"widget-width","data-testid":"widget-prop-width",type:"number",min:1,value:t.layout?.w??1,onChange:r=>l({layout:{...t.layout,w:Number(r.target.value)||1}}),disabled:s,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"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"widget-height",className:"text-[10px] text-gray-400",children:n("appDesigner.widgetHeight")}),e.jsx("input",{id:"widget-height","data-testid":"widget-prop-height",type:"number",min:1,value:t.layout?.h??1,onChange:r=>l({layout:{...t.layout,h:Number(r.target.value)||1}}),disabled:s,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 zs({schema:t}){const{t:s}=be(),l=t.widgets||[];return e.jsxs("div",{"data-testid":"dashboard-preview",className:"rounded-lg border border-gray-200 bg-gray-50 p-4",children:[e.jsx("h4",{className:"mb-3 text-sm font-semibold text-gray-700",children:t.title||s("appDesigner.dashboardPreview")}),l.length===0?e.jsx("div",{className:"text-xs text-gray-400",children:s("appDesigner.noWidgetsPreview")}):e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${t.columns??2}, 1fr)`},children:l.map(i=>{const n=Ie.find(r=>r.type===(i.type||"metric"))||Ie[0];return e.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(n.Icon,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-600",children:i.title||"Untitled"})]}),e.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:n.label})]},i.id)})})]})}function $s({schema:t,onChange:s,readOnly:l=!1,className:i,onExport:n,onImport:r,selectedWidgetId:p,onWidgetSelect:b}){const{t:g}=be(),[o,u]=a.useState(null),[d,m]=a.useState(!1),j=a.useRef(null),x=a.useRef(null),k=p!==void 0,T=k?p:o,P=a.useCallback(N=>{b&&b(N),k||u(N)},[k,b,u]),{current:R,canUndo:L,canRedo:U,push:w,undo:S,redo:y}=ke(t),I=a.useCallback(N=>{w(N),s(N)},[w,s]),C=R.widgets||[],K=C.find(N=>N.id===T),Y=a.useCallback(N=>{const G=Ls(),z={id:G,title:"",type:N,layout:{x:0,y:C.length,w:R.columns??2,h:1}};I({...R,widgets:[...C,z]}),P(G)},[R,C,I,P]),M=a.useCallback(N=>{I({...R,widgets:C.filter(G=>G.id!==N)}),T===N&&P(null)},[R,C,T,I,P]),Q=a.useCallback((N,G)=>{const z=C.findIndex(E=>E.id===N);if(z<0)return;const Z=G==="up"?z-1:z+1;if(Z<0||Z>=C.length)return;const ae=[...C];[ae[z],ae[Z]]=[ae[Z],ae[z]],I({...R,widgets:ae})},[R,C,I]),se=a.useCallback(N=>{T&&I({...R,widgets:C.map(G=>G.id===T?{...G,...N}:G)})},[R,C,T,I]);a.useEffect(()=>{const N=j.current;if(!N)return;const G=z=>{if(!l){if((z.ctrlKey||z.metaKey)&&z.key==="z"&&!z.shiftKey){z.preventDefault(),S();return}if((z.ctrlKey||z.metaKey)&&(z.key==="y"||z.key==="z"&&z.shiftKey)){z.preventDefault(),y();return}if((z.key==="Delete"||z.key==="Backspace")&&T){const Z=z.target;if(Z.tagName==="INPUT"||Z.tagName==="SELECT"||Z.tagName==="TEXTAREA")return;z.preventDefault(),M(T)}}};return N.addEventListener("keydown",G),()=>N.removeEventListener("keydown",G)},[l,S,y,T,M]);const F=a.useCallback(()=>{n&&n(R)},[R,n]),J=a.useCallback(()=>{x.current?.click()},[]),_=a.useCallback(N=>{const G=N.target.files?.[0];if(!G)return;const z=new FileReader;z.onload=()=>{try{const Z=JSON.parse(z.result);Z&&Z.type==="dashboard"&&(I(Z),r?.(Z))}catch{}},z.readAsText(G),N.target.value=""},[I,r]);return e.jsxs("div",{ref:j,tabIndex:0,"data-testid":"dashboard-editor",className:dt("flex flex-col gap-4 outline-none",i),children:[e.jsx("input",{ref:x,type:"file",accept:".json",className:"hidden","data-testid":"dashboard-import-input",onChange:_}),K&&!d&&e.jsx(Fs,{widget:K,readOnly:l,onChange:se,onClose:()=>P(null)}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[g("appDesigner.addWidget"),":"]}),Ie.map(({type:N,label:G,Icon:z})=>e.jsxs("button",{type:"button","data-testid":`dashboard-add-${N}`,onClick:()=>Y(N),disabled:l||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:[e.jsx(z,{className:"h-3.5 w-3.5"}),G]},N))]}),e.jsxs("div",{className:"flex items-center gap-1",children:[!l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","data-testid":"dashboard-undo",onClick:S,disabled:!L,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":g("appDesigner.undo"),children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"dashboard-redo",onClick:y,disabled:!U,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":g("appDesigner.redo"),children:e.jsx(Ce,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"button","data-testid":"dashboard-export",onClick:F,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":g("appDesigner.navExportSchema"),children:e.jsx(Ge,{className:"h-4 w-4"})}),!l&&e.jsx("button",{type:"button","data-testid":"dashboard-import",onClick:J,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":g("appDesigner.navImportSchema"),children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"dashboard-preview-toggle",onClick:()=>m(N=>!N),className:dt("rounded p-1.5 transition-colors",d?"bg-blue-100 text-blue-600":"text-gray-400 hover:text-gray-700"),"aria-label":g(d?"appDesigner.modeEdit":"appDesigner.preview"),children:d?e.jsx(Ve,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})]})]}),d?e.jsx(zs,{schema:R}):C.length===0?e.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:g("appDesigner.noWidgets")}):e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${R.columns??2}, 1fr)`},children:C.map((N,G)=>e.jsx(Ms,{widget:N,index:G,total:C.length,selected:N.id===T,readOnly:l,onSelect:()=>P(N.id??null),onRemove:()=>M(N.id),onMoveUp:()=>Q(N.id,"up"),onMoveDown:()=>Q(N.id,"down")},N.id))})]})]})}function $e(...t){return le(oe(t))}const Ne=[{type:"grid",label:"Data Grid",Icon:ut},{type:"kanban",label:"Kanban Board",Icon:Ut},{type:"calendar",label:"Calendar",Icon:Kt},{type:"gallery",label:"Gallery",Icon:Gt},{type:"dashboard",label:"Dashboard",Icon:Ue},{type:"form",label:"Form",Icon:mt},{type:"layout-grid",label:"Grid Layout",Icon:Ke}],Us=[{value:"page",labelKey:"appDesigner.modePage"},{value:"dashboard",labelKey:"appDesigner.modeDashboard"}];let Ft=0;function Ks(){return Ft+=1,`component_${Date.now()}_${Ft}`}function Gs({component:t,index:s,total:l,selected:i,readOnly:n,onSelect:r,onRemove:p,onMoveUp:b,onMoveDown:g}){const o=Ne.find(u=>u.type===t.type)||Ne[0];return e.jsxs("div",{"data-testid":`canvas-component-${t.id}`,onClick:r,className:$e("group flex cursor-pointer items-center gap-3 rounded-lg border-2 px-3 py-3 transition-colors",i?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),children:[e.jsx(Ye,{className:"h-4 w-4 shrink-0 cursor-grab text-gray-300"}),e.jsx(o.Icon,{className:"h-5 w-5 shrink-0 text-gray-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800",children:t.label}),e.jsx("span",{className:"ml-2 text-[10px] text-gray-400",children:o.label})]}),!n&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),b()},disabled:s===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),g()},disabled:s===l-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(me,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),p()},className:"rounded p-0.5 text-gray-400 hover:text-red-500","aria-label":"Remove component","data-testid":`canvas-component-remove-${t.id}`,children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]})}function Hs({component:t,readOnly:s,onChange:l,onClose:i}){const{t:n}=be();return e.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:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:n("appDesigner.componentProperties")}),e.jsx("button",{type:"button",onClick:i,className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":"Close",children:e.jsx(ct,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"component-label",className:"text-xs font-medium text-gray-600",children:"Label"}),e.jsx("input",{id:"component-label","data-testid":"component-prop-label",type:"text",value:t.label,onChange:r=>l({label:r.target.value}),disabled:s,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"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:"Type"}),e.jsx("div",{className:"rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600",children:Ne.find(r=>r.type===t.type)?.label??t.type})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:"ID"}),e.jsx("div",{className:"rounded-md bg-gray-50 px-2.5 py-1.5 text-xs font-mono text-gray-500",children:t.id})]})]})}function Vs({schema:t,components:s}){const{t:l}=be();return e.jsxs("div",{"data-testid":"page-preview",className:"rounded-lg border border-gray-200 bg-gray-50 p-4",children:[e.jsx("h4",{className:"mb-3 text-sm font-semibold text-gray-700",children:t.title||l("appDesigner.pagePreview")}),s.length===0?e.jsx("div",{className:"text-xs text-gray-400",children:l("appDesigner.noComponentsPreview")}):e.jsx("div",{className:"space-y-2",children:s.map(i=>{const n=Ne.find(r=>r.type===i.type)||Ne[0];return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2",children:[e.jsx(n.Icon,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-600",children:i.label}),e.jsx("span",{className:"text-[10px] text-gray-400",children:n.label})]},i.id)})})]})}function Bs({schema:t,onChange:s,readOnly:l=!1,className:i,onExport:n,onImport:r}){const{t:p}=be(),b=a.useRef(null),g=a.useRef(null),[o,u]=a.useState(()=>(t.children?Array.isArray(t.children)?t.children:[t.children]:[]).map((F,J)=>({id:F.id||`existing_${J}`,type:F.type||"grid",label:F.title||F.label||`Component ${J+1}`,props:F}))),[d,m]=a.useState(null),[j,x]=a.useState(!1),[k,T]=a.useState("page"),P=o.find(F=>F.id===d),{canUndo:R,canRedo:L,push:U,undo:w,redo:S}=ke(o),y=a.useCallback(F=>{u(F),U(F),s({...t,children:F.map(J=>({type:J.type,id:J.id,title:J.label,...J.props}))})},[t,s,U]),I=a.useCallback(F=>{const J=Ks(),_=Ne.find(z=>z.type===F),N={id:J,type:F,label:_?.label||F},G=[...o,N];y(G),m(J)},[o,y]),C=a.useCallback(F=>{const J=o.filter(_=>_.id!==F);y(J),d===F&&m(null)},[o,d,y]),K=a.useCallback((F,J)=>{const _=o.findIndex(z=>z.id===F);if(_<0)return;const N=J==="up"?_-1:_+1;if(N<0||N>=o.length)return;const G=[...o];[G[_],G[N]]=[G[N],G[_]],y(G)},[o,y]),Y=a.useCallback(F=>{if(!d)return;const J=o.map(_=>_.id===d?{..._,...F}:_);y(J)},[o,d,y]);a.useEffect(()=>{const F=b.current;if(!F)return;const J=_=>{if(!l){if((_.ctrlKey||_.metaKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),w();return}if((_.ctrlKey||_.metaKey)&&(_.key==="y"||_.key==="z"&&_.shiftKey)){_.preventDefault(),S();return}if((_.key==="Delete"||_.key==="Backspace")&&d){const N=_.target;if(N.tagName==="INPUT"||N.tagName==="SELECT"||N.tagName==="TEXTAREA")return;_.preventDefault(),C(d)}}};return F.addEventListener("keydown",J),()=>F.removeEventListener("keydown",J)},[l,w,S,d,C]);const M=a.useCallback(()=>{n&&n(t)},[t,n]),Q=a.useCallback(()=>{g.current?.click()},[]),se=a.useCallback(F=>{const J=F.target.files?.[0];if(!J)return;const _=new FileReader;_.onload=()=>{try{const N=JSON.parse(_.result);if(N&&N.type==="page"){const G=(N.children?Array.isArray(N.children)?N.children:[N.children]:[]).map((z,Z)=>({id:z.id||`imported_${Z}`,type:z.type||"grid",label:z.title||z.label||`Component ${Z+1}`,props:z}));u(G),U(G),s(N),r?.(N)}}catch{}},_.readAsText(J),F.target.value=""},[s,U,r]);return e.jsxs("div",{ref:b,tabIndex:0,"data-testid":"page-canvas-editor",className:$e("flex flex-col gap-4 outline-none sm:flex-row",i),children:[e.jsx("input",{ref:g,type:"file",accept:".json",className:"hidden","data-testid":"canvas-import-input",onChange:se}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 border-b border-gray-200 pb-2",role:"tablist",children:Us.map(F=>e.jsx("button",{type:"button",role:"tab","data-testid":`canvas-mode-${F.value}`,"aria-selected":k===F.value,onClick:()=>T(F.value),className:$e("rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors",k===F.value?"border-b-2 border-blue-500 text-blue-600":"text-gray-500 hover:text-gray-700"),children:p(F.labelKey)},F.value))}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[p("appDesigner.addComponent"),":"]}),Ne.map(({type:F,label:J,Icon:_})=>e.jsxs("button",{type:"button","data-testid":`canvas-add-${F}`,onClick:()=>I(F),disabled:l||j,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:[e.jsx(_,{className:"h-3.5 w-3.5"}),J]},F))]}),e.jsxs("div",{className:"flex items-center gap-1",children:[!l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","data-testid":"canvas-undo",onClick:w,disabled:!R,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":p("appDesigner.undo"),children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"canvas-redo",onClick:S,disabled:!L,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":p("appDesigner.redo"),children:e.jsx(Ce,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"button","data-testid":"canvas-export",onClick:M,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":p("appDesigner.navExportSchema"),children:e.jsx(Ge,{className:"h-4 w-4"})}),!l&&e.jsx("button",{type:"button","data-testid":"canvas-import",onClick:Q,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":p("appDesigner.navImportSchema"),children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"canvas-preview-toggle",onClick:()=>x(F=>!F),className:$e("rounded p-1.5 transition-colors",j?"bg-blue-100 text-blue-600":"text-gray-400 hover:text-gray-700"),"aria-label":p(j?"appDesigner.modeEdit":"appDesigner.preview"),children:j?e.jsx(Ve,{className:"h-4 w-4"}):e.jsx(Pe,{className:"h-4 w-4"})})]})]}),j?e.jsx(Vs,{schema:t,components:o}):o.length===0?e.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:p("appDesigner.emptyPage")}):e.jsx("div",{className:"space-y-2",children:o.map((F,J)=>e.jsx(Gs,{component:F,index:J,total:o.length,selected:F.id===d,readOnly:l,onSelect:()=>m(F.id),onRemove:()=>C(F.id),onMoveUp:()=>K(F.id,"up"),onMoveDown:()=>K(F.id,"down")},F.id))})]}),P&&!j&&e.jsx(Hs,{component:P,readOnly:l,onChange:Y,onClose:()=>m(null)})]})}function Fe(...t){return le(oe(t))}const _s={grid:{label:"Grid",Icon:Ke},kanban:{label:"Kanban",Icon:Ut},calendar:{label:"Calendar",Icon:Kt},gallery:{label:"Gallery",Icon:Gt},timeline:{label:"Timeline",Icon:qt},map:{label:"Map",Icon:Wt},gantt:{label:"Gantt",Icon:fa}},Ys=[{value:"compact",label:"Compact"},{value:"medium",label:"Medium"},{value:"tall",label:"Tall"}];function ze({title:t,icon:s,defaultOpen:l=!0,children:i}){const[n,r]=a.useState(l);return e.jsxs("div",{className:"border-b border-gray-100 pb-3",children:[e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex w-full items-center gap-2 py-2 text-left",children:[s,e.jsx("span",{className:"flex-1 text-xs font-semibold uppercase text-gray-500",children:t}),n?e.jsx(Te,{className:"h-3.5 w-3.5 text-gray-400"}):e.jsx(me,{className:"h-3.5 w-3.5 text-gray-400"})]}),n&&e.jsx("div",{className:"space-y-2",children:i})]})}function Xs({config:t,onChange:s,availableViewTypes:l=["grid","kanban","calendar","gallery","timeline","map","gantt"],readOnly:i=!1,className:n}){const r=a.useCallback(o=>{s({...t,...o})},[t,s]),p=a.useCallback(o=>{r({columns:t.columns.map(u=>u.name===o?{...u,visible:!u.visible}:u)})},[t,r]),b=a.useCallback((o,u)=>{const d=[...t.columns],m=d.findIndex(x=>x.name===o);if(m<0)return;const j=u==="up"?m-1:m+1;j<0||j>=d.length||([d[m],d[j]]=[d[j],d[m]],r({columns:d}))},[t,r]),g=a.useMemo(()=>t.columns.filter(o=>o.visible).length,[t.columns]);return e.jsxs("div",{"data-testid":"object-view-configurator",className:Fe("w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4",n),children:[e.jsx(ze,{title:"View Type",icon:e.jsx(Ke,{className:"h-3.5 w-3.5 text-gray-500"}),children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(o=>{const{label:u,Icon:d}=_s[o];return e.jsxs("button",{type:"button","data-testid":`view-type-${o}`,onClick:()=>r({viewType:o}),disabled:i,className:Fe("inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",t.viewType===o?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100",i&&"cursor-not-allowed opacity-50"),children:[e.jsx(d,{className:"h-3 w-3"}),u]},o)})})}),e.jsx(ze,{title:`Fields (${g}/${t.columns.length})`,icon:e.jsx(va,{className:"h-3.5 w-3.5 text-gray-500"}),children:t.columns.length===0?e.jsx("p",{className:"text-xs text-gray-400",children:"No fields configured."}):e.jsx("ul",{className:"space-y-0.5",children:t.columns.map((o,u)=>e.jsxs("li",{"data-testid":`view-column-${o.name}`,className:"flex items-center gap-1.5 rounded px-1.5 py-1 text-xs hover:bg-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>p(o.name),disabled:i,className:Fe("rounded p-0.5 transition-colors",o.visible?"text-blue-500":"text-gray-300"),"aria-label":o.visible?"Hide field":"Show field",children:o.visible?e.jsx(Pe,{className:"h-3 w-3"}):e.jsx(Ve,{className:"h-3 w-3"})}),e.jsx("span",{className:"flex-1 truncate text-gray-700",children:o.label}),e.jsx("button",{type:"button",onClick:()=>b(o.name,"up"),disabled:i||u===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Te,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>b(o.name,"down"),disabled:i||u===t.columns.length-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(me,{className:"h-3 w-3"})})]},o.name))})}),e.jsx(ze,{title:"Toolbar",icon:e.jsx(ja,{className:"h-3.5 w-3.5 text-gray-500"}),children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showSearch,onChange:o=>r({showSearch:o.target.checked}),disabled:i,"data-testid":"view-toggle-search",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Search"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showFilters,onChange:o=>r({showFilters:o.target.checked}),disabled:i,"data-testid":"view-toggle-filters",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Filters"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showSort,onChange:o=>r({showSort:o.target.checked}),disabled:i,"data-testid":"view-toggle-sort",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Sort"})]})]})}),e.jsx(ze,{title:"Appearance",icon:e.jsx(Na,{className:"h-3.5 w-3.5 text-gray-500"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-medium text-gray-500",children:"Row Height"}),e.jsx("div",{className:"flex gap-1",children:Ys.map(({value:o,label:u})=>e.jsx("button",{type:"button","data-testid":`view-row-height-${o}`,onClick:()=>r({rowHeight:o}),disabled:i,className:Fe("flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors",t.rowHeight===o?"bg-blue-100 text-blue-700":"bg-gray-50 text-gray-500 hover:bg-gray-100"),children:u},o))})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.striped,onChange:o=>r({striped:o.target.checked}),disabled:i,"data-testid":"view-toggle-striped",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Striped Rows"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.bordered,onChange:o=>r({bordered:o.target.checked}),disabled:i,"data-testid":"view-toggle-bordered",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Bordered"})]})]})})]})}function re(...t){return le(oe(t))}const Js=[{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"}],Zs=["Inter","Roboto","Open Sans","Lato","Montserrat","Poppins","Source Sans Pro","Noto Sans","system-ui"];function Ws({branding:t,onChange:s,appTitle:l="My App",readOnly:i=!1,className:n,onExport:r,onImport:p}){const{t:b}=be(),[g,o]=a.useState("light"),{current:u,push:d,canUndo:m,canRedo:j,undo:x,redo:k}=ke(t),T=a.useRef(!0);a.useEffect(()=>{if(T.current){T.current=!1;return}s(u)},[u]);const P=a.useCallback(y=>{const I={...u,...y};T.current=!0,d(I),s(I)},[u,d,s]),R=a.useCallback(()=>{if(r){r(u);return}const y=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),I=URL.createObjectURL(y),C=document.createElement("a");C.href=I,C.download="branding.json",C.click(),URL.revokeObjectURL(I)},[u,r]),L=a.useCallback(()=>{if(p){p(u);return}const y=document.createElement("input");y.type="file",y.accept=".json",y.onchange=I=>{const C=I.target.files?.[0];if(!C)return;const K=new FileReader;K.onload=Y=>{try{const M=JSON.parse(Y.target?.result);if(typeof M=="object"&&M!==null){const Q={...u,...M};d(Q),s(Q)}}catch{}},K.readAsText(C)},y.click()},[u,d,s,p]),U=a.useCallback(y=>{i||((y.ctrlKey||y.metaKey)&&y.key==="z"&&(y.preventDefault(),y.shiftKey?k():x()),(y.ctrlKey||y.metaKey)&&y.key==="y"&&(y.preventDefault(),k()))},[i,x,k]),w=u.primaryColor||"#3b82f6",S=g==="dark";return e.jsxs("div",{"data-testid":"branding-editor",className:re("flex flex-col gap-4 sm:gap-6",n),onKeyDown:U,tabIndex:0,children:[e.jsxs("div",{"data-testid":"branding-editor-toolbar",className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 mr-auto",children:b("appDesigner.brandingEditor")}),e.jsxs("button",{"data-testid":"branding-undo",type:"button",onClick:x,disabled:!m||i,className:re("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",m&&!i?"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:b("appDesigner.undo"),children:[e.jsx(we,{className:"h-3.5 w-3.5"}),b("appDesigner.undo")]}),e.jsxs("button",{"data-testid":"branding-redo",type:"button",onClick:k,disabled:!j||i,className:re("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",j&&!i?"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:b("appDesigner.redo"),children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),b("appDesigner.redo")]}),e.jsxs("button",{"data-testid":"branding-export",type:"button",onClick:R,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:b("appDesigner.brandingExport"),children:[e.jsx(Ge,{className:"h-3.5 w-3.5"}),b("appDesigner.brandingExport")]}),e.jsxs("button",{"data-testid":"branding-import",type:"button",onClick:L,disabled:i,className:re("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",i?"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:b("appDesigner.brandingImport"),children:[e.jsx(He,{className:"h-3.5 w-3.5"}),b("appDesigner.brandingImport")]})]}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-logo",className:"block text-sm font-medium text-gray-700",children:b("appDesigner.logoUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(gt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-logo","data-testid":"branding-logo-input",type:"text",value:u.logo??"",onChange:y=>P({logo:y.target.value}),placeholder:"https://example.com/logo.svg",disabled:i,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"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-color",className:"block text-sm font-medium text-gray-700",children:b("appDesigner.primaryColor")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ht,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-color","data-testid":"branding-color-input",type:"text",value:u.primaryColor??"#3b82f6",onChange:y=>P({primaryColor:y.target.value}),placeholder:"#3b82f6",disabled:i,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"})]}),e.jsx("input",{"data-testid":"branding-color-picker",type:"color",value:w,onChange:y=>P({primaryColor:y.target.value}),disabled:i,className:"h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:b("appDesigner.colorPalette")}),e.jsx("div",{"data-testid":"branding-color-palette",className:"flex flex-wrap gap-1.5",children:Js.map(y=>e.jsx("button",{"data-testid":`branding-swatch-${y.hex.slice(1)}`,type:"button",onClick:()=>!i&&P({primaryColor:y.hex}),disabled:i,className:re("h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed",w===y.hex?"border-gray-800 ring-2 ring-offset-1 ring-gray-400":"border-transparent"),style:{backgroundColor:y.hex},title:y.name},y.hex))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-favicon",className:"block text-sm font-medium text-gray-700",children:b("appDesigner.faviconUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-favicon","data-testid":"branding-favicon-input",type:"text",value:u.favicon??"",onChange:y=>P({favicon:y.target.value}),placeholder:"https://example.com/favicon.ico",disabled:i,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"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-font",className:"block text-sm font-medium text-gray-700",children:b("appDesigner.fontFamily")}),e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsxs("select",{id:"be-font","data-testid":"branding-font-select",value:u.fontFamily??"",onChange:y=>P({fontFamily:y.target.value||void 0}),disabled:i,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:[e.jsx("option",{value:"",children:b("appDesigner.fontDefault")}),Zs.map(y=>e.jsx("option",{value:y,children:y},y))]})]})]})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:b("appDesigner.brandingPreview")}),e.jsxs("div",{"data-testid":"branding-mode-toggle",className:"flex rounded-md border border-gray-300 overflow-hidden",children:[e.jsxs("button",{"data-testid":"branding-mode-light",type:"button",onClick:()=>o("light"),className:re("inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors",g==="light"?"bg-blue-50 text-blue-700":"bg-white text-gray-600 hover:bg-gray-50"),children:[e.jsx(ca,{className:"h-3.5 w-3.5"}),b("appDesigner.modeLight")]}),e.jsxs("button",{"data-testid":"branding-mode-dark",type:"button",onClick:()=>o("dark"),className:re("inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors",g==="dark"?"bg-gray-800 text-gray-100":"bg-white text-gray-600 hover:bg-gray-50"),children:[e.jsx(pa,{className:"h-3.5 w-3.5"}),b("appDesigner.modeDark")]})]})]}),e.jsxs("div",{"data-testid":"branding-preview",className:re("rounded-lg border p-4 transition-colors",S?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-800"),style:{fontFamily:u.fontFamily||"inherit"},children:[e.jsx("div",{className:"rounded-md p-3 mb-3",style:{backgroundColor:w},children:e.jsxs("div",{className:"flex items-center gap-3",children:[u.logo?e.jsx("img",{src:u.logo,alt:"Logo",className:"h-8 w-8 rounded object-contain bg-white/20"}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white",children:"Logo"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:l})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border border-gray-200",style:{backgroundColor:w}}),e.jsx("span",{className:re("text-xs",S?"text-gray-400":"text-gray-500"),children:w})]}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-1.5 text-xs font-medium text-white transition-colors",style:{backgroundColor:w},tabIndex:-1,children:b("appDesigner.brandingSampleButton")}),e.jsx("p",{className:re("text-xs",S?"text-gray-400":"text-gray-500"),children:b("appDesigner.brandingSampleText")}),u.favicon&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:u.favicon,alt:"Favicon",className:"h-4 w-4 rounded object-contain"}),e.jsx("span",{className:re("text-xs",S?"text-gray-400":"text-gray-500"),children:"Favicon"})]}),u.fontFamily&&e.jsxs("div",{className:re("text-xs",S?"text-gray-400":"text-gray-500"),children:[b("appDesigner.fontFamily"),": ",u.fontFamily]})]})]}),e.jsxs("div",{"data-testid":"branding-preview-mobile",className:re("mx-auto w-48 rounded-xl border-2 p-2 transition-colors",S?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"),style:{fontFamily:u.fontFamily||"inherit"},children:[e.jsx("div",{className:"text-center text-[10px] font-medium text-gray-400 mb-1",children:b("appDesigner.mobilePreview")}),e.jsx("div",{className:"rounded-md p-2 mb-1",style:{backgroundColor:w},children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.logo?e.jsx("img",{src:u.logo,alt:"Logo",className:"h-4 w-4 rounded object-contain bg-white/20"}):e.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white",children:"L"}),e.jsx("span",{className:"text-[9px] font-semibold text-white truncate",children:l})]})}),e.jsxs("div",{className:"space-y-1 px-1",children:[e.jsx("div",{className:re("h-2 w-3/4 rounded",S?"bg-gray-700":"bg-gray-200")}),e.jsx("div",{className:re("h-2 w-1/2 rounded",S?"bg-gray-700":"bg-gray-200")}),e.jsx("div",{className:re("h-2 w-2/3 rounded",S?"bg-gray-700":"bg-gray-200")})]})]})]})]})]})}function lt(...t){return le(oe(t))}function mn({versions:t,onRestore:s,className:l}){return e.jsxs("div",{className:lt("flex flex-col",l),role:"region","aria-label":"Version history",children:[e.jsxs("div",{className:"p-3 border-b font-medium text-sm flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4"}),"Version History"]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:t.length===0?e.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"No version history available"}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-5 top-0 bottom-0 w-px bg-border"}),t.map(i=>e.jsxs("div",{className:lt("relative flex items-start gap-3 px-3 py-2 hover:bg-accent/50",i.isCurrent&&"bg-accent/30"),children:[e.jsx("div",{className:lt("relative z-10 mt-1 h-2.5 w-2.5 rounded-full border-2 bg-background",i.isCurrent?"border-primary":"border-muted-foreground")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"font-medium",children:["v",i.version]}),i.isCurrent&&e.jsx("span",{className:"px-1 py-0.5 rounded bg-primary/10 text-primary text-[0.6rem]",children:"Current"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:i.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[0.65rem] text-muted-foreground/70",children:[e.jsx(Oa,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:i.userName}),e.jsx(qt,{className:"h-2.5 w-2.5 ml-1"}),e.jsx("span",{children:new Date(i.timestamp).toLocaleString()})]}),!i.isCurrent&&s&&e.jsx("button",{onClick:()=>s(i.version),className:"mt-1 text-[0.65rem] text-primary hover:underline",children:"Restore this version"})]})]},i.version))]})})]})}ge.register("page-designer",Ha,{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}]});ge.register("data-model-designer",Xa,{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}]});ge.register("process-designer",Za,{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}]});ge.register("report-designer",Qa,{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}]});ge.register("app-creation-wizard",Ts,{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}]});ge.register("navigation-designer",Rs,{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}]});ge.register("dashboard-editor",$s,{label:"Dashboard Editor",category:"Designer",inputs:[{name:"schema",type:"code",label:"Dashboard Schema"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});ge.register("page-canvas-editor",Bs,{label:"Page Canvas Editor",category:"Designer",inputs:[{name:"schema",type:"code",label:"Page Schema"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});ge.register("object-view-configurator",Xs,{label:"Object View Configurator",category:"Designer",inputs:[{name:"config",type:"code",label:"View Config"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});ge.register("branding-editor",Ws,{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{Ts as AppCreationWizard,Ws as BrandingEditor,cn as CollaborationProvider,Ze as ConfirmDialog,pn as ConnectionStatusIndicator,$s as DashboardEditor,Xa as DataModelDesigner,un as EditorModeToggle,ft as Minimap,Rs as NavigationDesigner,Xs as ObjectViewConfigurator,Bs as PageCanvasEditor,Ha as PageDesigner,Za as ProcessDesigner,We as PropertyEditor,Qa as ReportDesigner,mn as VersionHistory,yt as useCanvasPanZoom,Je as useClipboard,Le as useConfirmDialog,Ba as useDesignerHistory,Xe as useMultiSelect,ke as useUndoRedo};
|
|
Binary file
|
|
Binary file
|