@object-ui/plugin-designer 4.0.1 → 4.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @object-ui/plugin-designer
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4be43e2: **Page-mode record forms (`editMode: 'page'`).** New per-object metadata flag that opts a record's create/edit form into a dedicated full-screen route (`/apps/:appName/:objectName/new`, `/apps/:appName/:objectName/record/:recordId/edit`). Two new declarative actions `navigate_create` and `navigate_edit` open these routes from JSON action buttons. Default modal behavior is preserved for objects that do not set `editMode`.
8
+
9
+ **`@object-ui/plugin-list` & `@object-ui/plugin-detail`: `ComponentRegistry` singleton fix.** Both plugins' Vite configs now mark all `@object-ui/*` packages as external so each plugin no longer bundles its own private copy of `@object-ui/core`. Cross-plugin component lookups now resolve correctly from the same singleton registry. `plugin-list` dist shrank from multi-MB to 67 kB (gzip 16 kB); `plugin-detail` to 124 kB (gzip 28 kB).
10
+
11
+ **`@object-ui/app-shell` `CreateViewDialog` churn fix.** `existingSet` is now memoised on the joined string key of `existingLabels` rather than the raw array reference, preventing the name-suggest `useEffect` from re-firing on every parent render.
12
+
13
+ **CI fixes.** `ReportViewer` conditional-formatting test now accepts both `rgb(...)` and hex color representations. `ObjectView` i18n mocks rewritten to mirror the real hook shapes (`useObjectTranslation`, `useObjectLabel`).
14
+
15
+ - Updated dependencies [4be43e2]
16
+ - @object-ui/types@4.0.3
17
+ - @object-ui/core@4.0.3
18
+ - @object-ui/i18n@4.0.3
19
+ - @object-ui/react@4.0.3
20
+ - @object-ui/components@4.0.3
21
+ - @object-ui/fields@4.0.3
22
+ - @object-ui/plugin-form@4.0.3
23
+ - @object-ui/plugin-grid@4.0.3
24
+
3
25
  ## 4.0.1
4
26
 
5
27
  ### Patch Changes
package/dist/index.js CHANGED
@@ -7980,6 +7980,7 @@ function Tr() {
7980
7980
  });
7981
7981
  }
7982
7982
  e.register("page-designer", wt, {
7983
+ namespace: "plugin-designer",
7983
7984
  label: "Page Designer",
7984
7985
  category: "Designer",
7985
7986
  inputs: [
@@ -8013,6 +8014,7 @@ e.register("page-designer", wt, {
8013
8014
  }
8014
8015
  ]
8015
8016
  }), e.register("data-model-designer", At, {
8017
+ namespace: "plugin-designer",
8016
8018
  label: "Data Model Designer",
8017
8019
  category: "Designer",
8018
8020
  inputs: [
@@ -8040,6 +8042,7 @@ e.register("page-designer", wt, {
8040
8042
  }
8041
8043
  ]
8042
8044
  }), e.register("process-designer", Ft, {
8045
+ namespace: "plugin-designer",
8043
8046
  label: "Process Designer (BPMN)",
8044
8047
  category: "Designer",
8045
8048
  inputs: [
@@ -8078,6 +8081,7 @@ e.register("page-designer", wt, {
8078
8081
  }
8079
8082
  ]
8080
8083
  }), e.register("report-designer", zt, {
8084
+ namespace: "plugin-designer",
8081
8085
  label: "Report Designer",
8082
8086
  category: "Designer",
8083
8087
  inputs: [
@@ -8116,6 +8120,7 @@ e.register("page-designer", wt, {
8116
8120
  }
8117
8121
  ]
8118
8122
  }), e.register("app-creation-wizard", En, {
8123
+ namespace: "plugin-designer",
8119
8124
  label: "App Creation Wizard",
8120
8125
  category: "Designer",
8121
8126
  inputs: [
@@ -8137,6 +8142,7 @@ e.register("page-designer", wt, {
8137
8142
  }
8138
8143
  ]
8139
8144
  }), e.register("navigation-designer", Fn, {
8145
+ namespace: "plugin-designer",
8140
8146
  label: "Navigation Designer",
8141
8147
  category: "Designer",
8142
8148
  inputs: [
@@ -8159,6 +8165,7 @@ e.register("page-designer", wt, {
8159
8165
  }
8160
8166
  ]
8161
8167
  }), e.register("dashboard-editor", Kn, {
8168
+ namespace: "plugin-designer",
8162
8169
  label: "Dashboard Editor",
8163
8170
  category: "Designer",
8164
8171
  inputs: [{
@@ -8172,6 +8179,7 @@ e.register("page-designer", wt, {
8172
8179
  defaultValue: !1
8173
8180
  }]
8174
8181
  }), e.register("page-canvas-editor", tr, {
8182
+ namespace: "plugin-designer",
8175
8183
  label: "Page Canvas Editor",
8176
8184
  category: "Designer",
8177
8185
  inputs: [{
@@ -8185,6 +8193,7 @@ e.register("page-designer", wt, {
8185
8193
  defaultValue: !1
8186
8194
  }]
8187
8195
  }), e.register("object-view-configurator", or, {
8196
+ namespace: "plugin-designer",
8188
8197
  label: "Object View Configurator",
8189
8198
  category: "Designer",
8190
8199
  inputs: [{
@@ -8198,6 +8207,7 @@ e.register("page-designer", wt, {
8198
8207
  defaultValue: !1
8199
8208
  }]
8200
8209
  }), e.register("branding-editor", lr, {
8210
+ namespace: "plugin-designer",
8201
8211
  label: "Branding Editor",
8202
8212
  category: "Designer",
8203
8213
  inputs: [
@@ -8219,6 +8229,7 @@ e.register("page-designer", wt, {
8219
8229
  }
8220
8230
  ]
8221
8231
  }), e.register("object-manager", pr, {
8232
+ namespace: "plugin-designer",
8222
8233
  label: "Object Manager",
8223
8234
  category: "Designer",
8224
8235
  inputs: [
@@ -8241,6 +8252,7 @@ e.register("page-designer", wt, {
8241
8252
  }
8242
8253
  ]
8243
8254
  }), e.register("field-designer", vr, {
8255
+ namespace: "plugin-designer",
8244
8256
  label: "Field Designer",
8245
8257
  category: "Designer",
8246
8258
  inputs: [
@@ -3,4 +3,4 @@
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),O=v(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=E():t.exports=D()}))();function k(...e){return(0,a.twMerge)((0,i.clsx)(e))}function A({isOpen:e,title:t,message:i,confirmLabel:a=`Delete`,cancelLabel:o=`Cancel`,destructive:s=!0,onConfirm:c,onCancel:l}){let u=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),e?(0,O.jsx)(`dialog`,{ref:u,className:`fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50`,onClose:l,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-message`,children:(0,O.jsxs)(`div`,{className:`w-80 p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[s&&(0,O.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10`,children:(0,O.jsx)(r.AlertTriangle,{className:`h-5 w-5 text-destructive`})}),(0,O.jsx)(`h2`,{id:`confirm-title`,className:`text-lg font-semibold`,children:t})]}),(0,O.jsx)(`p`,{id:`confirm-message`,className:`text-sm text-muted-foreground mb-6`,children:i}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{onClick:l,className:`px-4 py-2 text-sm rounded-md border hover:bg-accent`,children:o}),(0,O.jsx)(`button`,{onClick:c,className:k(`px-4 py-2 text-sm rounded-md font-medium`,s?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`),autoFocus:!0,children:a})]})]})}):null}function j(...e){return(0,a.twMerge)((0,i.clsx)(e))}function M({title:e=`Properties`,fields:t,onChange:i,className:a}){let[o,s]=(0,n.useState)(new Set),c=(0,n.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=t.reduce((e,t)=>{let n=t.group??`General`;return e[n]||(e[n]=[]),e[n].push(t),e},{});return(0,O.jsxs)(`div`,{className:j(`flex flex-col`,a),role:`region`,"aria-label":e,children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:e}),(0,O.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[Object.entries(l).map(([e,t])=>(0,O.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,O.jsxs)(`button`,{onClick:()=>c(e),className:`w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50`,children:[o.has(e)?(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}),e]}),!o.has(e)&&(0,O.jsx)(`div`,{className:`px-3 pb-2 space-y-2`,children:t.map(e=>(0,O.jsx)(N,{field:e,onChange:i},e.name))})]},e)),t.length===0&&(0,O.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`Select an element to edit its properties`})]})]})}function N({field:e,onChange:t}){let n=n=>{t(e.name,n)};return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:e.label}),e.type===`text`&&(0,O.jsx)(`input`,{type:`text`,value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`number`&&(0,O.jsx)(`input`,{type:`number`,value:Number(e.value??0),onChange:e=>n(Number(e.target.value)),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`boolean`&&(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:!!e.value,onChange:e=>n(e.target.checked),className:`rounded`}),(0,O.jsx)(`span`,{className:`text-xs`,children:e.value?`Yes`:`No`})]}),e.type===`select`&&(0,O.jsx)(`select`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`,children:e.options?.map(e=>(0,O.jsx)(`option`,{value:e.value,children:e.label},e.value))}),e.type===`color`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`color`,value:String(e.value??`#000000`),onChange:e=>n(e.target.value),className:`h-6 w-6 rounded border cursor-pointer`}),(0,O.jsx)(`span`,{className:`text-xs font-mono`,children:String(e.value??`#000000`)})]}),e.type===`textarea`&&(0,O.jsx)(`textarea`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background resize-y`,rows:3}),e.description&&(0,O.jsx)(`p`,{className:`text-[0.65rem] text-muted-foreground/70`,children:e.description})]})}function P(...e){return(0,a.twMerge)((0,i.clsx)(e))}function F({items:e,canvasWidth:t,canvasHeight:n,position:r=`bottom-right`,size:i=150,className:a}){let o=Math.min(i/t,i/n),s=t*o,c=n*o;return(0,O.jsx)(`div`,{className:P(`absolute border rounded bg-background/90 shadow-sm overflow-hidden`,{"top-left":`top-2 left-2`,"top-right":`top-2 right-2`,"bottom-left":`bottom-2 left-2`,"bottom-right":`bottom-2 right-2`}[r],a),role:`img`,"aria-label":`Canvas minimap`,children:(0,O.jsxs)(`svg`,{width:s,height:c,viewBox:`0 0 ${t} ${n}`,children:[(0,O.jsx)(`rect`,{width:t,height:n,fill:`hsl(var(--muted))`,opacity:`0.3`}),e.map(e=>(0,O.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:e.selected?`hsl(var(--primary))`:e.color??`hsl(var(--foreground) / 0.3)`,rx:`2`},e.id))]})})}function I(...e){return(0,a.twMerge)((0,i.clsx)(e))}var L=(0,n.createContext)(null);L.displayName=`CollaborationContext`;function R({config:e,user:t,onOperation:r,onPresenceChange:i,children:a}){let o=(0,n.useRef)(null),[s,c]=(0,n.useState)([]),[l,u]=(0,n.useState)(`disconnected`),d=(0,n.useRef)(0),f=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e.enabled||!t||!e.serverUrl||!(typeof WebSocket<`u`))return;function n(){let a;try{if(a=new URL(e.serverUrl),a.protocol!==`ws:`&&a.protocol!==`wss:`)return}catch{return}e.roomId&&a.searchParams.set(`room`,e.roomId),a.searchParams.set(`userId`,t.id),u(`connecting`);let s=new WebSocket(a.toString());s.onopen=()=>{u(`connected`),s.send(JSON.stringify({type:`join`,userId:t.id,userName:t.name,avatar:t.avatar}))},s.onmessage=e=>{try{let n=JSON.parse(e.data);if(n.type===`presence`){let e=n.users||[];c(e.filter(e=>e.userId!==t.id)),i?.(e)}else n.type===`operation`&&r?.(n.operation)}catch{}},s.onclose=()=>{u(`disconnected`),o.current=null,e.enabled&&(f.current=setTimeout(n,e.autoSaveInterval??3e3))},s.onerror=()=>{u(`error`)},o.current=s}return n(),()=>{f.current&&clearTimeout(f.current),o.current&&=(o.current.onclose=null,o.current.close(),null),u(`disconnected`)}},[e.enabled,e.serverUrl,e.roomId,e.autoSaveInterval,t,r,i]);let p=(0,n.useMemo)(()=>!e.enabled||!t?[]:[{userId:t.id,userName:t.name,avatar:t.avatar,color:B(t.id),status:`active`,lastActivity:new Date().toISOString()},...s],[e.enabled,t,s]),m=e.enabled&&!!t&&(e.serverUrl?l===`connected`:!0),h=(0,n.useCallback)(n=>{if(!e.enabled||!t)return;d.current+=1;let i={...n,id:`op-${Date.now()}-${d.current}`,userId:t.id,timestamp:new Date().toISOString(),version:d.current};o.current?.readyState===WebSocket.OPEN&&o.current.send(JSON.stringify({type:`operation`,operation:i})),r?.(i)},[e.enabled,t,r]),g=(0,n.useMemo)(()=>({users:p,isConnected:m,sendOperation:h,currentUserId:t?.id,connectionState:l,versionCount:d.current}),[p,m,h,t?.id,l]);return(0,O.jsx)(L.Provider,{value:g,children:a})}function ee(){return(0,n.useContext)(L)}function z({className:e}){let t=(0,n.useContext)(L);if(!t)return null;let{connectionState:r,users:i}=t,a={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:o,label:s}=a[r]??a.disconnected;return(0,O.jsxs)(`div`,{className:I(`flex items-center gap-2 text-xs`,e),role:`status`,"aria-live":`polite`,"aria-label":`Collaboration: ${s}`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${o}`}),(0,O.jsx)(`span`,{children:s}),r===`connected`&&i.length>1&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,i.length,` users)`]})]})}function B(e){let t=[`#3b82f6`,`#ef4444`,`#22c55e`,`#f59e0b`,`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f97316`,`#14b8a6`,`#f43f5e`,`#a855f7`,`#84cc16`,`#0ea5e9`,`#e879f9`,`#fb923c`,`#facc15`],n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t)|0;return t[Math.abs(n)%t.length]}function V(...e){return(0,a.twMerge)((0,i.clsx)(e))}function H({canvas:e={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:t=[],palette:i=U,showComponentTree:a=!0,undoRedo:o=!0,propertyEditor:s=!0,readOnly:c=!1,showMinimap:l=!1,onChange:u,className:d}){let f=x(t),p=f.current,m=(0,n.useCallback)(e=>{f.push(e),u?.(e)},[f,u]),h=T({initialZoom:e.zoom??1}),{zoom:g}=h,_=C(),v=(0,n.useMemo)(()=>{let e=Array.from(_.selectedIds);return e.length>0?e[0]:null},[_.selectedIds]),y=(0,n.useMemo)(()=>p.find(e=>e.id===v),[p,v]),b=w(),E=S(),D=ee(),k=(0,n.useCallback)(e=>{D&&D.sendOperation({...e,userId:D.currentUserId??``})},[D]),[j,N]=(0,n.useState)(!0),[P,I]=(0,n.useState)(!0),[L,R]=(0,n.useState)(l),z=(0,n.useRef)(null),B=(0,n.useRef)(null),H=(0,n.useCallback)(t=>!e.snapToGrid||!e.gridSize?t:Math.round(t/e.gridSize)*e.gridSize,[e.snapToGrid,e.gridSize]),te=(0,n.useCallback)((e,t)=>{if(c)return;let n=i.flatMap(e=>e.items).find(t=>t.type===e),r=n?.defaultSize,a={id:`comp-${Date.now()}`,type:e,label:t,position:{x:100,y:100,width:r?.width??200,height:r?.height??100},props:n?.defaultProps??{}};m([...p,a]),_.selectOne(a.id),k({type:`insert`,elementId:a.id,data:{component:a}})},[p,c,i,m,_,k]),ne=(0,n.useCallback)(e=>{c||(m(p.filter(t=>t.id!==e)),_.isSelected(e)&&_.clearSelection(),k({type:`delete`,elementId:e,data:{}}))},[p,c,m,_,k]),re=(0,n.useCallback)(async()=>{if(c||_.count===0||!await E.confirm(`Delete components`,`Are you sure you want to delete ${_.count} component${_.count>1?`s`:``}?`))return;let e=_.selectedIds;m(p.filter(t=>!e.has(t.id))),_.clearSelection(),e.forEach(e=>{k({type:`delete`,elementId:e,data:{}})})},[c,_,E,p,m,k]),ie=(0,n.useCallback)((e,t)=>{c||!v||(m(p.map(n=>n.id===v?e===`label`?{...n,label:String(t)}:e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,props:{...n.props,[e]:t}}:n)),k({type:`update`,elementId:v,data:{[e]:t}}))},[c,v,p,m,k]),W=(0,n.useCallback)(()=>{let e=_.selectedIds;if(e.size===0)return;let t=p.filter(t=>e.has(t.id));b.copy(t)},[_,p,b]),ae=(0,n.useCallback)(()=>{if(c)return;let e=b.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`comp-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}}));m([...p,...n]),_.selectMany(n.map(e=>e.id)),n.forEach(e=>{k({type:`insert`,elementId:e.id,data:{component:e}})})},[c,b,p,m,_,k]),G=(0,n.useCallback)((e,t)=>{c||(z.current={id:t.id,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[c]),K=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),oe=(0,n.useCallback)(e=>{e.preventDefault();let t=z.current;if(!t||c)return;let n=(e.clientX-t.startX)/g,r=(e.clientY-t.startY)/g;m(p.map(e=>e.id===t.id?{...e,position:{...e.position,x:H(e.position.x+n),y:H(e.position.y+r)}}:e)),k({type:`move`,elementId:t.id,data:{}}),z.current=null},[c,g,p,m,H,k]),se=(0,n.useMemo)(()=>y?[{name:`label`,label:`Label`,type:`text`,value:y.label??``,group:`General`},{name:`x`,label:`X`,type:`number`,value:y.position.x,group:`Position`},{name:`y`,label:`Y`,type:`number`,value:y.position.y,group:`Position`},{name:`width`,label:`Width`,type:`number`,value:y.position.width,group:`Size`},{name:`height`,label:`Height`,type:`number`,value:y.position.height,group:`Size`}]:[],[y]),q=(0,n.useMemo)(()=>p.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:typeof e.position.width==`number`?e.position.width:100,height:typeof e.position.height==`number`?e.position.height:50,selected:_.isSelected(e.id)})),[p,_]);return(0,n.useEffect)(()=>{let e=B.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&_.count>0&&!t){e.preventDefault(),re();return}if(e.key===`Escape`){_.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&o&&!c){e.preventDefault(),f.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&o&&!c){e.preventDefault(),f.redo();return}if(n&&e.key===`c`){e.preventDefault(),W();return}if(n&&e.key===`v`&&!c){e.preventDefault(),ae();return}if(n&&e.key===`a`){e.preventDefault(),_.selectMany(p.map(e=>e.id));return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[_,re,o,c,f,W,ae,p]),(0,O.jsxs)(`div`,{ref:B,tabIndex:0,className:V(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,d),children:[!c&&(0,O.jsx)(`div`,{className:V(`border-r bg-muted/30 flex flex-col transition-[width] duration-200`,j?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component palette`,children:j&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:`Components`}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:i.map(e=>(0,O.jsxs)(`div`,{className:`mb-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-2 py-1 uppercase`,children:e.label}),e.items.map(e=>(0,O.jsxs)(`button`,{onClick:()=>te(e.type,e.label),className:`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),e.label]},e.type))]},e.name))})]})}),(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Designer toolbar`,children:[!c&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:j?`Collapse palette`:`Expand palette`,"aria-label":j?`Collapse palette`:`Expand palette`,onClick:()=>N(e=>!e),children:(0,O.jsx)(r.PanelLeftClose,{className:V(`h-4 w-4`,!j&&`rotate-180`)})}),o&&!c&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!f.canUndo&&`opacity-40 pointer-events-none`),title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,disabled:!f.canUndo,onClick:()=>f.undo(),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!f.canRedo&&`opacity-40 pointer-events-none`),title:`Redo (Ctrl+Shift+Z)`,"aria-label":`Redo`,disabled:!f.canRedo,onClick:()=>f.redo(),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,_.count===0&&`opacity-40 pointer-events-none`),title:`Copy (Ctrl+C)`,"aria-label":`Copy`,disabled:_.count===0,onClick:W,children:(0,O.jsx)(r.Copy,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!b.hasContent&&`opacity-40 pointer-events-none`),title:`Paste (Ctrl+V)`,"aria-label":`Paste`,disabled:!b.hasContent,onClick:ae,children:(0,O.jsx)(r.Clipboard,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,_.count===0&&`opacity-40 pointer-events-none`),title:`Delete selected`,"aria-label":`Delete selected`,disabled:_.count===0,onClick:re,children:(0,O.jsx)(r.Trash2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:`Preview`,"aria-label":`Preview`,children:(0,O.jsx)(r.Eye,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,L&&`bg-accent`),title:`Toggle minimap`,"aria-label":`Toggle minimap`,onClick:()=>R(e=>!e),children:(0,O.jsx)(r.Map,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`flex-1`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom out`,onClick:h.zoomOut,children:(0,O.jsx)(r.Minus,{className:`h-3 w-3`})}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground w-10 text-center`,children:[Math.round(g*100),`%`]}),(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom in`,onClick:h.zoomIn,children:(0,O.jsx)(r.Plus,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Reset zoom`,onClick:h.resetZoom,children:(0,O.jsx)(r.Maximize2,{className:`h-3 w-3`})})]}),a&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:P?`Collapse panel`:`Expand panel`,"aria-label":P?`Collapse panel`:`Expand panel`,onClick:()=>I(e=>!e),children:(0,O.jsx)(r.PanelRightClose,{className:V(`h-4 w-4`,!P&&`rotate-180`)})})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,role:`region`,"aria-label":`Design canvas`,onWheel:h.handleWheel,onMouseDown:h.startPan,onDragOver:K,onDrop:oe,children:(0,O.jsxs)(`div`,{className:`relative bg-background border rounded shadow-sm mx-auto`,style:{width:e.width*g,height:e.height*g,transform:`translate(${h.panOffset.x}px, ${h.panOffset.y}px)`,backgroundImage:e.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:e.showGrid&&e.gridSize?`${e.gridSize*g}px ${e.gridSize*g}px`:void 0},children:[p.map(e=>{let t=_.isSelected(e.id);return(0,O.jsxs)(`div`,{draggable:!c,onDragStart:t=>G(t,e),className:V(`absolute border rounded cursor-move select-none transition-shadow`,t?`border-primary ring-2 ring-primary/20 shadow-md`:`border-border hover:border-primary/50`),style:{left:e.position.x*g,top:e.position.y*g,width:typeof e.position.width==`number`?e.position.width*g:e.position.width,height:typeof e.position.height==`number`?e.position.height*g:e.position.height},onClick:t=>_.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b`,children:[(0,O.jsx)(r.GripVertical,{className:`h-3 w-3 text-muted-foreground`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.label??e.type}),!c&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ne(e.id)},className:`ml-auto p-0.5 rounded hover:bg-destructive/10`,"aria-label":`Delete ${e.label??e.type}`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3 text-destructive`})})]}),(0,O.jsx)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:e.type})]},e.id)}),L&&(0,O.jsx)(F,{items:q,canvasWidth:e.width,canvasHeight:e.height})]})})]}),a&&(0,O.jsx)(`div`,{className:V(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,P?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component tree`,children:P&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,O.jsx)(r.Layers,{className:`h-4 w-4`}),`Component Tree`]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:p.length===0?(0,O.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.`}):p.map(e=>(0,O.jsx)(`button`,{onClick:t=>_.toggle(e.id,t.shiftKey),className:V(`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left`,_.isSelected(e.id)?`bg-accent`:`hover:bg-accent/50`),children:(0,O.jsx)(`span`,{className:`truncate`,children:e.label??e.type})},e.id))}),s&&y?(0,O.jsx)(`div`,{className:`border-t`,children:(0,O.jsx)(M,{title:`Properties – ${y.label??y.type}`,fields:se,onChange:ie})}):y&&(0,O.jsxs)(`div`,{className:`border-t p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium mb-2`,children:`Properties`}),(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,O.jsxs)(`div`,{children:[`Type: `,y.type]}),(0,O.jsxs)(`div`,{children:[`ID: `,y.id]}),(0,O.jsxs)(`div`,{children:[`Position: `,y.position.x,`,`,` `,y.position.y]}),(0,O.jsxs)(`div`,{children:[`Size: `,y.position.width,` ×`,` `,y.position.height]})]})]})]})}),(0,O.jsx)(A,{isOpen:E.isOpen,title:E.title,message:E.message,onConfirm:E.onConfirm,onCancel:E.onCancel})]})}var U=[{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 te(e,t={}){return x(e,t)}function ne(...e){return(0,a.twMerge)((0,i.clsx)(e))}var re=[`text`,`number`,`boolean`,`date`,`datetime`,`uuid`,`email`,`url`,`phone`,`json`,`integer`,`float`,`decimal`,`currency`,`percent`,`textarea`,`select`,`multiselect`,`lookup`,`attachment`,`formula`,`autonumber`];function ie(e,t=4,n=280,r=250,i=50,a=50){return e.map((e,o)=>({...e,position:{x:i+o%t*n,y:a+Math.floor(o/t)*r}}))}function W({entities:e=[],relationships:t=[],canvas:i={width:1200,height:800,showGrid:!0},showRelationshipLabels:a=!0,readOnly:o=!1,onEntitiesChange:s,onRelationshipsChange:c,className:l}){let u=(0,n.useRef)(null),d=te({entities:e,relationships:t},{maxHistory:50}),{entities:f,relationships:p}=d.current,m=(0,n.useCallback)(e=>{d.push(e),s?.(e.entities),c?.(e.relationships)},[d,s,c]),h=S(),g=C(),_=g.count>0?Array.from(g.selectedIds)[0]:null,v=w(),y=T({minZoom:.25,maxZoom:3,zoomStep:.1}),b=ee(),[x,E]=(0,n.useState)(!0),[D,k]=(0,n.useState)(!0),[j,N]=(0,n.useState)(null),[P,I]=(0,n.useState)(``),[L,R]=(0,n.useState)(null),[z,B]=(0,n.useState)(``),V=(0,n.useRef)(null),H=(0,n.useCallback)(()=>{if(o)return;let e=d.current,t={id:`entity-${Date.now()}`,name:`new_entity_${e.entities.length+1}`,label:`New Entity ${e.entities.length+1}`,fields:[{name:`id`,type:`uuid`,primaryKey:!0,required:!0},{name:`created_at`,type:`datetime`,required:!0},{name:`updated_at`,type:`datetime`,required:!0}],position:{x:50+e.entities.length%4*280,y:50+Math.floor(e.entities.length/4)*250}};m({entities:[...e.entities,t],relationships:e.relationships}),g.selectOne(t.id),b?.sendOperation({type:`insert`,userId:b?.currentUserId??``,elementId:t.id,data:{name:t.name,label:t.label}})},[o,d,m,g,b]),U=(0,n.useCallback)(async e=>{if(o)return;let t=f.find(t=>t.id===e);if(!await h.confirm(`Delete Entity`,`Are you sure you want to delete "${t?.label??e}"? This action cannot be undone.`))return;let n=d.current;m({entities:n.entities.filter(t=>t.id!==e),relationships:n.relationships.filter(t=>t.sourceEntity!==e&&t.targetEntity!==e)}),g.isSelected(e)&&g.clearSelection(),b?.sendOperation({type:`delete`,userId:b?.currentUserId??``,elementId:e,data:{}})},[o,f,h,d,m,g,b]),W=(0,n.useCallback)(async()=>{if(o||g.count===0)return;let e=Array.from(g.selectedIds);if(!await h.confirm(`Delete Entities`,`Are you sure you want to delete ${e.length} selected entity(s)? This action cannot be undone.`))return;let t=d.current,n=new Set(e);m({entities:t.entities.filter(e=>!n.has(e.id)),relationships:t.relationships.filter(e=>!n.has(e.sourceEntity)&&!n.has(e.targetEntity))}),g.clearSelection()},[o,g,h,d,m]),ae=(0,n.useCallback)(()=>{if(o)return;let e=d.current;m({entities:ie(e.entities),relationships:e.relationships})},[o,d,m]),G=(0,n.useCallback)(()=>{let e=f.filter(e=>g.isSelected(e.id));e.length>0&&v.copy(e)},[f,g,v]),K=(0,n.useCallback)(()=>{if(o)return;let e=v.paste();if(!e||e.length===0)return;let t=d.current,n=e.map((e,t)=>({...e,id:`entity-${Date.now()}-${t}`,name:`${e.name}_copy`,label:`${e.label} (Copy)`,position:{x:e.position.x+30,y:e.position.y+30}}));m({entities:[...t.entities,...n],relationships:t.relationships}),g.selectMany(n.map(e=>e.id))},[o,v,d,m,g]),oe=(0,n.useCallback)(e=>{if(o)return;let t=d.current;m({entities:t.entities.map(t=>{if(t.id!==e)return t;let n={name:`field_${t.fields.length+1}`,type:`text`,required:!1};return{...t,fields:[...t.fields,n]}}),relationships:t.relationships})},[o,d,m]),se=(0,n.useCallback)((e,t,n)=>{o||(N({entityId:e,fieldIndex:t}),I(n))},[o]),q=(0,n.useCallback)(()=>{if(!j)return;let e=P.trim();if(e===``){N(null);return}let t=d.current;m({entities:t.entities.map(t=>{if(t.id!==j.entityId)return t;let n=t.fields.map((t,n)=>n===j.fieldIndex?{...t,name:e}:t);return{...t,fields:n}}),relationships:t.relationships}),N(null)},[j,P,d,m]),J=(0,n.useCallback)(()=>{N(null)},[]),ce=(0,n.useCallback)((e,t)=>{o||(R(e),B(t))},[o]),le=(0,n.useCallback)(()=>{if(!L)return;let e=z.trim();if(e===``){R(null);return}let t=d.current;m({entities:t.entities.map(t=>t.id===L?{...t,label:e}:t),relationships:t.relationships}),R(null)},[L,z,d,m]),ue=(0,n.useCallback)(()=>{R(null)},[]),de=(0,n.useCallback)((e,t,n)=>{if(o)return;let r=d.current;m({entities:r.entities.map(r=>{if(r.id!==e)return r;let i=r.fields.map((e,r)=>r===t?{...e,type:n}:e);return{...r,fields:i}}),relationships:r.relationships})},[o,d,m]),fe=(0,n.useCallback)((e,t)=>{if(o||!f.find(e=>e.id===t))return;let n=e.target.getBoundingClientRect();V.current={entityId:t,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[o,f]),pe=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),me=(0,n.useCallback)(e=>{if(e.preventDefault(),!V.current)return;let t=e.currentTarget.getBoundingClientRect(),n=y.zoom,r=(e.clientX-t.left-y.panOffset.x)/n-V.current.offsetX,i=(e.clientY-t.top-y.panOffset.y)/n-V.current.offsetY,a=d.current;m({entities:a.entities.map(e=>e.id===V.current.entityId?{...e,position:{x:Math.max(0,Math.round(r)),y:Math.max(0,Math.round(i))}}:e),relationships:a.relationships}),V.current=null},[y.zoom,y.panOffset,d,m]),Y=_?f.find(e=>e.id===_):null,he=Y?[{name:`name`,label:`Name`,type:`text`,value:Y.name,group:`General`},{name:`label`,label:`Label`,type:`text`,value:Y.label,group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:Y.description??``,group:`General`},{name:`color`,label:`Color`,type:`color`,value:Y.color??`#3b82f6`,group:`Appearance`},{name:`position.x`,label:`X Position`,type:`number`,value:Y.position.x,group:`Position`},{name:`position.y`,label:`Y Position`,type:`number`,value:Y.position.y,group:`Position`}]:[],ge=(0,n.useCallback)((e,t)=>{if(!_)return;let n=d.current;m({entities:n.entities.map(n=>n.id===_?e===`position.x`?{...n,position:{...n.position,x:Number(t)}}:e===`position.y`?{...n,position:{...n.position,y:Number(t)}}:{...n,[e]:t}:n),relationships:n.relationships})},[_,d,m]);(0,n.useEffect)(()=>{let e=u.current;if(!e)return;let t=e=>{let t=e.target.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;n&&e.key===`z`?(e.preventDefault(),d.undo()):n&&(e.key===`y`||e.shiftKey&&e.key===`Z`)?(e.preventDefault(),d.redo()):n&&e.key===`c`?(e.preventDefault(),G()):n&&e.key===`v`?(e.preventDefault(),K()):(e.key===`Delete`||e.key===`Backspace`)&&g.count>0?(e.preventDefault(),W()):e.key===`Escape`&&(g.clearSelection(),N(null),R(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[d,G,K,W,g]);let X=f.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:240,height:40+e.fields.length*24,color:e.color,selected:g.isSelected(e.id)}));return(0,O.jsxs)(`div`,{ref:u,tabIndex:0,className:ne(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,l),children:[(0,O.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{role:`toolbar`,"aria-label":`Designer toolbar`,className:`flex items-center gap-2 p-2 border-b bg-muted/20 flex-wrap`,children:[(0,O.jsx)(r.Database,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:`Data Model Designer`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ml-2 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:()=>d.undo(),disabled:!d.canUndo,"aria-label":`Undo`,title:`Undo (Ctrl+Z)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Undo2,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:()=>d.redo(),disabled:!d.canRedo,"aria-label":`Redo`,title:`Redo (Ctrl+Y)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Redo2,{className:`h-3.5 w-3.5`})})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:y.zoomOut,"aria-label":`Zoom Out`,title:`Zoom Out`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.ZoomOut,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-center`,children:[Math.round(y.zoom*100),`%`]}),(0,O.jsx)(`button`,{onClick:y.zoomIn,"aria-label":`Zoom In`,title:`Zoom In`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.ZoomIn,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:y.resetZoom,"aria-label":`Reset Zoom`,title:`Reset Zoom`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.RotateCcw,{className:`h-3 w-3`})})]}),!o&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:G,disabled:g.count===0,"aria-label":`Copy`,title:`Copy (Ctrl+C)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Copy,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:K,disabled:!v.hasContent,"aria-label":`Paste`,title:`Paste (Ctrl+V)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Clipboard,{className:`h-3.5 w-3.5`})})]}),!o&&(0,O.jsxs)(`button`,{onClick:ae,"aria-label":`Auto Layout`,title:`Auto Layout`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded border hover:bg-accent`,children:[(0,O.jsx)(r.Grid3X3,{className:`h-3 w-3`}),` Auto Layout`]}),(0,O.jsx)(`div`,{className:`flex-1`}),b?.isConnected&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,O.jsx)(r.Users,{className:`h-3 w-3`}),(0,O.jsxs)(`span`,{children:[b.users.length,` user`,b.users.length===1?``:`s`]})]}),g.count>1&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[g.count,` selected`]}),!o&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`button`,{onClick:H,"aria-label":`Add Entity`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),` Add Entity`]}),(0,O.jsxs)(`button`,{"aria-label":`Add Relationship`,title:`Add Relationship (coming soon)`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-secondary text-secondary-foreground hover:bg-secondary/80`,children:[(0,O.jsx)(r.Link2,{className:`h-3 w-3`}),` Add Relationship`]})]})]}),(0,O.jsxs)(`div`,{role:`region`,"aria-label":`Canvas`,className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,onWheel:y.handleWheel,onMouseDown:y.startPan,onDragOver:pe,onDrop:me,children:[(0,O.jsxs)(`div`,{className:`relative`,style:{width:i.width,minHeight:i.height,...y.transformStyle,backgroundImage:i.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:i.showGrid?`20px 20px`:void 0},children:[(0,O.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:i.width,height:i.height,children:p.map(e=>{let t=f.find(t=>t.id===e.sourceEntity),n=f.find(t=>t.id===e.targetEntity);return!t||!n?null:(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:t.position.x+120,y1:t.position.y+50,x2:n.position.x+120,y2:n.position.y+50,stroke:`hsl(var(--primary))`,strokeWidth:`2`,strokeDasharray:e.type===`many-to-many`?`5,5`:void 0}),a&&e.label&&(0,O.jsx)(`text`,{x:(t.position.x+n.position.x)/2+120,y:(t.position.y+n.position.y)/2+50-8,textAnchor:`middle`,className:`text-xs fill-muted-foreground`,children:e.label})]},e.id)})}),f.length===0&&(0,O.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.`}),f.map(e=>(0,O.jsxs)(`div`,{role:`group`,"aria-label":e.label,draggable:!o,onDragStart:t=>fe(t,e.id),className:ne(`absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing`,g.isSelected(e.id)?`border-primary ring-2 ring-primary/20`:`border-border hover:border-primary/50`),style:{left:e.position.x,top:e.position.y},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm`,style:{backgroundColor:e.color??`hsl(var(--primary) / 0.1)`},children:[(0,O.jsx)(r.Database,{className:`h-3.5 w-3.5`}),L===e.id?(0,O.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),onBlur:le,onKeyDown:e=>{e.key===`Enter`&&le(),e.key===`Escape`&&ue()},className:`text-sm font-medium px-1 py-0 border rounded bg-background w-32 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation(),"data-testid":`entity-label-input-${e.id}`}):(0,O.jsx)(`span`,{className:`truncate cursor-text`,onDoubleClick:t=>{t.stopPropagation(),ce(e.id,e.label)},title:`Double-click to edit label`,"data-testid":`entity-label-${e.id}`,children:e.label}),!o&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),U(e.id)},"aria-label":`Delete ${e.label}`,className:`ml-auto p-0.5 rounded hover:bg-destructive/20`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3 text-destructive`})})]}),(0,O.jsx)(`div`,{className:`px-3 py-1 divide-y`,children:e.fields.map((t,n)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs`,children:[j&&j.entityId===e.id&&j.fieldIndex===n?(0,O.jsx)(`input`,{type:`text`,value:P,onChange:e=>I(e.target.value),onBlur:q,onKeyDown:e=>{e.key===`Enter`&&q(),e.key===`Escape`&&J()},className:`font-mono text-xs px-1 py-0 border rounded bg-background w-24 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation()}):(0,O.jsxs)(`span`,{className:ne(`font-mono cursor-text`,t.primaryKey&&`font-bold text-primary`),onClick:r=>{r.stopPropagation(),se(e.id,n,t.name)},title:`Click to edit field name`,children:[t.primaryKey&&(0,O.jsx)(`span`,{className:`text-[0.65rem] font-semibold text-primary mr-0.5`,children:`PK`}),t.name]}),o?(0,O.jsx)(`span`,{className:`text-muted-foreground ml-auto`,children:t.type}):(0,O.jsx)(`select`,{value:t.type,onChange:t=>{t.stopPropagation(),de(e.id,n,t.target.value)},onClick:e=>e.stopPropagation(),className:`text-xs text-muted-foreground ml-auto bg-transparent border-none focus:ring-1 focus:ring-primary rounded cursor-pointer p-0`,"data-testid":`field-type-${e.id}-${n}`,children:re.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}),t.required&&(0,O.jsx)(`span`,{className:`text-destructive`,children:`*`})]},`${t.name}-${n}`))}),!o&&(0,O.jsx)(`div`,{className:`px-3 py-1 border-t`,children:(0,O.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),oe(e.id)},"aria-label":`Add field to ${e.label}`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),` Add Field`]})})]},e.id))]}),D&&f.length>0&&(0,O.jsx)(F,{items:X,canvasWidth:i.width,canvasHeight:i.height,position:`bottom-right`,size:150})]})]}),(0,O.jsxs)(`div`,{className:`w-64 border-l flex flex-col bg-background shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,O.jsxs)(`button`,{onClick:()=>E(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 border-b`,"aria-expanded":x,"aria-controls":`property-editor-panel`,children:[x?(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}),`Properties`]}),x&&(0,O.jsx)(`div`,{id:`property-editor-panel`,className:`flex-1 overflow-y-auto`,children:(0,O.jsx)(M,{title:Y?Y.label:`Properties`,fields:he,onChange:ge})})]}),(0,O.jsx)(`div`,{className:`border-t`,children:(0,O.jsxs)(`button`,{onClick:()=>k(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 w-full`,"aria-expanded":D,children:[D?(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}),`Minimap`]})})]}),(0,O.jsx)(A,{isOpen:h.isOpen,title:h.title,message:h.message,onConfirm:h.onConfirm,onCancel:h.onCancel,destructive:!0})]})}function ae(...e){return(0,a.twMerge)((0,i.clsx)(e))}var G=120,K=50;function oe(e,t){if(e.length===0)return e;let n=new Map,r=new Map;for(let t of e)n.set(t.id,0),r.set(t.id,[]);for(let e of t)n.set(e.target,(n.get(e.target)??0)+1),r.get(e.source)?.push(e.target);let i=[],a=new Set,o=e.filter(e=>(n.get(e.id)??0)===0).map(e=>e.id);for(o.length===0&&(o=[e[0].id]);o.length>0;){i.push(o);for(let e of o)a.add(e);let e=new Set;for(let t of o)for(let n of r.get(t)??[])a.has(n)||e.add(n);o=Array.from(e)}let s=e.filter(e=>!a.has(e.id)).map(e=>e.id);s.length>0&&i.push(s);let c=new Map;for(let e=0;e<i.length;e++){let t=i[e];for(let n=0;n<t.length;n++)c.set(t[n],{x:80+e*200,y:80+n*100})}return e.map(e=>({...e,position:c.get(e.id)??e.position}))}function se({processName:e=`New Process`,nodes:t=[],edges:i=[],lanes:a,canvas:o={width:1400,height:800,showGrid:!0},showMinimap:s=!0,showToolbar:c=!0,readOnly:l=!1,onNodesChange:u,onEdgesChange:d,className:f}){let p=x({nodes:t,edges:i},{maxHistory:50}),m=p.current.nodes,h=p.current.edges,g=(0,n.useCallback)((e,t)=>{p.push({nodes:e,edges:t}),u?.(e),d?.(t)},[p,u,d]),_=S(),v=C(),y=w(),b=T({initialZoom:1}),E=ee(),[D,k]=(0,n.useState)(null),[j,N]=(0,n.useState)(!1),[P,I]=(0,n.useState)(null),[L,R]=(0,n.useState)(null),[z,B]=(0,n.useState)(!0),[V,H]=(0,n.useState)(null),[U,te]=(0,n.useState)({x:0,y:0}),ne=(0,n.useRef)(null),re=(0,n.useRef)(u),ie=(0,n.useRef)(d);re.current=u,ie.current=d,(0,n.useEffect)(()=>{re.current?.(m),ie.current?.(h)},[p.current]);let W=(0,n.useCallback)((e,t)=>{if(l)return;let n={id:`node-${Date.now()}`,type:e,label:t,position:{x:200+m.length*160,y:200}};g([...m,n],h),k(n.id),v.selectOne(n.id),E?.sendOperation({type:`insert`,elementId:n.id,data:{label:t},userId:E.currentUserId??``})},[m,h,l,g,v,E]),se=(0,n.useCallback)(async e=>{if(l)return;let t=m.find(t=>t.id===e);await _.confirm(`Delete Node`,`Are you sure you want to delete "${t?.label??e}"? This will also remove all connected edges.`)&&(g(m.filter(t=>t.id!==e),h.filter(t=>t.source!==e&&t.target!==e)),D===e&&k(null),v.clearSelection(),E?.sendOperation({type:`delete`,elementId:e,data:{},userId:E.currentUserId??``}))},[m,h,D,l,g,_,v,E]),q=(0,n.useCallback)(async()=>{if(l||v.count===0||!await _.confirm(`Delete Selected Nodes`,`Are you sure you want to delete ${v.count} selected node(s) and their connected edges?`))return;let e=v.selectedIds;g(m.filter(t=>!e.has(t.id)),h.filter(t=>!e.has(t.source)&&!e.has(t.target))),k(null),v.clearSelection()},[m,h,l,g,_,v]),J=(0,n.useCallback)(()=>{let e=v.count>0?v.selectedIds:D?new Set([D]):new Set;if(e.size===0)return;let t=m.filter(t=>e.has(t.id));y.copy(t)},[m,D,v,y]),ce=(0,n.useCallback)(()=>{if(l)return;let e=y.paste();if(!e||e.length===0)return;let t=e.map(e=>({...e,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:e.position.x+40,y:e.position.y+40}}));g([...m,...t],h),v.selectMany(t.map(e=>e.id)),k(t[0].id)},[l,m,h,y,g,v]),le=(0,n.useCallback)(()=>{N(e=>e?(I(null),!1):!0)},[]),ue=(0,n.useCallback)(e=>{if(!j)return!1;if(!P)return I(e),!0;if(P===e)return!0;let t={id:`edge-${Date.now()}`,source:P,target:e};return g(m,[...h,t]),I(null),N(!1),E?.sendOperation({type:`insert`,elementId:t.id,data:{source:P,target:e},userId:E.currentUserId??``}),!0},[j,P,m,h,g,E]),de=(0,n.useCallback)(()=>{l||m.length===0||g(oe(m,h),h)},[m,h,l,g]),fe=(0,n.useCallback)((e,t)=>{if(l||!m.find(e=>e.id===t))return;H(t);let n=e.target.getBoundingClientRect();te({x:e.clientX-n.left,y:e.clientY-n.top}),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[l,m]),pe=(0,n.useCallback)(e=>{if(e.preventDefault(),l||!V)return;let t=e.currentTarget.getBoundingClientRect(),n=b.zoom,r=(e.clientX-t.left-b.panOffset.x)/n-U.x,i=(e.clientY-t.top-b.panOffset.y)/n-U.y,a=Math.max(0,Math.round(r/20)*20),o=Math.max(0,Math.round(i/20)*20);g(m.map(e=>e.id===V?{...e,position:{x:a,y:o}}:e),h),H(null)},[l,V,U,m,h,b.zoom,b.panOffset,g]),me=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),Y=(0,n.useMemo)(()=>m.find(e=>e.id===D)??null,[m,D]),he=(0,n.useMemo)(()=>Y?[{name:`label`,label:`Name`,type:`text`,value:Y.label,group:`General`},{name:`type`,label:`Type`,type:`select`,value:Y.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:Y.description??``,group:`General`}]:[],[Y]),ge=(0,n.useCallback)((e,t)=>{l||!D||g(m.map(n=>n.id===D?{...n,[e]:t}:n),h)},[l,D,m,h,g]),X=e=>{switch(e){case`start-event`:return`rounded-full bg-green-100 border-green-500 text-green-700`;case`end-event`:return`rounded-full bg-red-100 border-red-500 text-red-700`;case`exclusive-gateway`:case`parallel-gateway`:case`inclusive-gateway`:case`event-based-gateway`:return`rotate-45 bg-yellow-100 border-yellow-500 text-yellow-700`;case`user-task`:return`rounded bg-blue-100 border-blue-500 text-blue-700`;case`service-task`:case`script-task`:return`rounded bg-purple-100 border-purple-500 text-purple-700`;default:return`rounded bg-gray-100 border-gray-500 text-gray-700`}},_e=(0,n.useMemo)(()=>m.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:G,height:K,selected:v.isSelected(e.id)||e.id===D})),[m,v,D]);(0,n.useEffect)(()=>{let e=ne.current;if(!e)return;let t=e=>{let t=e.target?.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`z`&&!e.shiftKey){e.preventDefault(),p.undo();return}if(n&&e.key===`y`||n&&e.key===`z`&&e.shiftKey){e.preventDefault(),p.redo();return}if(n&&e.key===`c`){e.preventDefault(),J();return}if(n&&e.key===`v`){e.preventDefault(),ce();return}if(e.key===`Delete`||e.key===`Backspace`){v.count>0?(e.preventDefault(),q()):D&&(e.preventDefault(),se(D));return}if(e.key===`Escape`){j?(N(!1),I(null)):(k(null),v.clearSelection());return}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[D,j,v,p,J,ce,se,q]);let ve=(0,n.useCallback)(e=>{e.target===e.currentTarget&&(k(null),v.clearSelection(),j&&(N(!1),I(null)))},[j,v]);return(0,O.jsxs)(`div`,{ref:ne,tabIndex:0,className:ae(`flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background`,f),children:[(0,O.jsx)(A,{isOpen:_.isOpen,title:_.title,message:_.message,onConfirm:_.onConfirm,onCancel:_.onCancel,destructive:!0}),c&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Process toolbar`,children:[(0,O.jsx)(r.GitBranch,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,"aria-label":`Process name`,children:e}),E?.isConnected&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),E.users.length,` user`,E.users.length===1?``:`s`]}),(0,O.jsx)(`div`,{className:`flex-1`}),!l&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{onClick:()=>p.undo(),disabled:!p.canUndo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,children:(0,O.jsx)(r.Undo2,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>p.redo(),disabled:!p.canRedo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Redo (Ctrl+Y)`,"aria-label":`Redo`,children:(0,O.jsx)(r.Redo2,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:J,disabled:v.count===0&&!D,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Copy (Ctrl+C)`,"aria-label":`Copy`,children:(0,O.jsx)(r.Copy,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:ce,disabled:!y.hasContent,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Paste (Ctrl+V)`,"aria-label":`Paste`,children:(0,O.jsx)(r.Clipboard,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsxs)(`button`,{onClick:le,className:ae(`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,j&&`bg-primary text-primary-foreground`),title:`Connect nodes`,"aria-label":`Connect nodes`,"aria-pressed":j,children:[(0,O.jsx)(r.Link,{className:`h-3 w-3`}),` Connect`]}),(0,O.jsxs)(`button`,{onClick:de,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Auto layout`,"aria-label":`Auto layout`,children:[(0,O.jsx)(r.Layout,{className:`h-3 w-3`}),` Layout`]}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:b.zoomIn,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom in`,"aria-label":`Zoom in`,children:(0,O.jsx)(r.ZoomIn,{className:`h-3 w-3`})}),(0,O.jsxs)(`span`,{className:`text-xs tabular-nums min-w-[3ch] text-center`,"aria-label":`Zoom level`,children:[Math.round(b.zoom*100),`%`]}),(0,O.jsx)(`button`,{onClick:b.zoomOut,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom out`,"aria-label":`Zoom out`,children:(0,O.jsx)(r.ZoomOut,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:b.resetZoom,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Reset zoom`,"aria-label":`Reset zoom`,children:(0,O.jsx)(r.RotateCcw,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsxs)(`button`,{onClick:()=>W(`start-event`,`Start`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Start Event`,"aria-label":`Add Start Event`,children:[(0,O.jsx)(r.Play,{className:`h-3 w-3 text-green-600`}),` Start`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`user-task`,`User Task`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add User Task`,"aria-label":`Add User Task`,children:[(0,O.jsx)(r.Square,{className:`h-3 w-3 text-blue-600`}),` Task`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`exclusive-gateway`,`Decision`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Gateway`,"aria-label":`Add Gateway`,children:[(0,O.jsx)(r.Diamond,{className:`h-3 w-3 text-yellow-600`}),` Gateway`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`end-event`,`End`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add End Event`,"aria-label":`Add End Event`,children:[(0,O.jsx)(r.Square,{className:`h-3 w-3 text-red-600`}),` End`]}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:()=>B(e=>!e),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:z?`Hide properties`:`Show properties`,"aria-label":z?`Hide property panel`:`Show property panel`,"aria-expanded":z,children:z?(0,O.jsx)(r.PanelRightClose,{className:`h-3 w-3`}):(0,O.jsx)(r.PanelRightOpen,{className:`h-3 w-3`})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4`,role:`region`,"aria-label":`Process canvas`,onWheel:b.handleWheel,onMouseDown:b.startPan,children:(0,O.jsxs)(`div`,{className:`relative`,style:{...b.transformStyle,width:o.width,minHeight:o.height,backgroundImage:o.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:o.showGrid?`20px 20px`:void 0},onClick:ve,onDrop:pe,onDragOver:me,children:[(0,O.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:o.width,height:o.height,children:[(0,O.jsx)(`defs`,{children:(0,O.jsx)(`marker`,{id:`arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`10`,refY:`3.5`,orient:`auto`,children:(0,O.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground))`})})}),h.map(e=>{let t=m.find(t=>t.id===e.source),n=m.find(t=>t.id===e.target);if(!t||!n)return null;t.position.x+G/2;let r=t.position.y+K/2;n.position.x+G/2;let i=n.position.y+K/2,a=t.position.x+G,o=r,s=n.position.x,c=i;return(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`path`,{d:`M ${a} ${o} Q ${(a+s)/2} ${o}, ${(a+s)/2} ${(o+c)/2} T ${s} ${c}`,fill:`none`,stroke:`hsl(var(--foreground) / 0.5)`,strokeWidth:`2`,markerEnd:`url(#arrowhead)`}),e.label&&(0,O.jsx)(`text`,{x:(a+s)/2,y:(o+c)/2-8,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,children:e.label})]},e.id)})]}),m.length===0&&(0,O.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(e=>{let t=v.isSelected(e.id)||D===e.id,n=P===e.id,i=L===e.id,a=j||i;return(0,O.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},role:`group`,"aria-label":e.label,draggable:!l&&!j,onDragStart:t=>fe(t,e.id),onMouseEnter:()=>R(e.id),onMouseLeave:()=>R(null),onClick:t=>{ue(e.id)||(t.shiftKey?v.toggle(e.id,!0):(k(e.id),v.selectOne(e.id)))},children:[(0,O.jsx)(`div`,{className:ae(`flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow`,X(e.type),t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,j&&!n&&`cursor-crosshair`),children:(0,O.jsx)(`span`,{className:ae(`text-xs font-medium`,(e.type===`exclusive-gateway`||e.type===`parallel-gateway`||e.type===`inclusive-gateway`||e.type===`event-based-gateway`)&&`-rotate-45`),children:e.label})}),a&&!l&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{left:-6,top:K/2-6},title:`Input port`,onClick:t=>{t.stopPropagation(),ue(e.id)}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{right:-6,top:K/2-6},title:`Output port`,onClick:t=>{t.stopPropagation(),j?ue(e.id):(N(!0),I(e.id))}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:G/2-6,top:-6},title:`Port`,onClick:t=>{t.stopPropagation(),ue(e.id)}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:G/2-6,bottom:-6},title:`Port`,onClick:t=>{t.stopPropagation(),ue(e.id)}})]}),!l&&t&&!j&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),se(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":`Delete node`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3`})})]},e.id)}),s&&m.length>0&&(0,O.jsx)(F,{items:_e,canvasWidth:o.width??1400,canvasHeight:o.height??800,position:`bottom-right`})]})}),z&&!l&&(0,O.jsx)(`div`,{className:`w-64 border-l bg-background overflow-y-auto flex-shrink-0`,role:`complementary`,"aria-label":`Property panel`,children:(0,O.jsx)(M,{title:Y?`Properties: ${Y.label}`:`Properties`,fields:he,onChange:ge})})]})]})}function q(...e){return(0,a.twMerge)((0,i.clsx)(e))}var J={untitledReport:`Untitled Report`,reportCanvas:`Report canvas`,properties:`Properties`,propertiesPanel:`Properties panel`,designerToolbar:`Report designer toolbar`,selectElementPrompt:`Select an element to edit its properties`,addElementsPrompt:`Add elements using the buttons above`,addText:`Add Text`,addField:`Add Field`,addImage:`Add Image`,addChart:`Add Chart`,addTable:`Add Table`,undo:`Undo`,undoShortcut:`Undo (Ctrl+Z)`,redo:`Redo`,redoShortcut:`Redo (Ctrl+Shift+Z)`,copy:`Copy`,copyShortcut:`Copy (Ctrl+C)`,paste:`Paste`,pasteShortcut:`Paste (Ctrl+V)`,deleteSelected:`Delete selected`,deleteElement:`Delete element`,deleteElementsTitle:`Delete elements`,deleteElementMessage:e=>`Are you sure you want to delete ${e} element${e>1?`s`:``}?`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,collaborationConnected:`Connected`,sectionHeader:`Report Header`,sectionPageHeader:`Page Header`,sectionGroupHeader:`Group Header`,sectionDetail:`Detail`,sectionGroupFooter:`Group Footer`,sectionPageFooter:`Page Footer`,sectionFooter:`Report Footer`,elementText:`Text`,elementImage:`🖼 Image`,elementChart:`📊 Chart`,elementTable:`📋 Table`,propLabel:`Label`,propX:`X`,propY:`Y`,propWidth:`Width`,propHeight:`Height`,propText:`Text`,propField:`Field`,groupPosition:`Position`,groupSize:`Size`,groupContent:`Content`,groupGeneral:`General`},ce={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}},le=[{type:`header`,height:80,elements:[]},{type:`detail`,height:400,elements:[],repeat:!0},{type:`footer`,height:60,elements:[]}];function ue({reportName:e=J.untitledReport,objectName:t,pageSize:i=`A4`,orientation:a=`portrait`,margins:o={top:40,right:40,bottom:40,left:40},sections:s=[],showToolbar:c=!0,showPropertyPanel:l=!0,readOnly:u=!1,onSectionsChange:d,className:f}){let p=x(s.length>0?s:le),m=p.current,h=(0,n.useCallback)(e=>{p.push(e),d?.(e)},[p,d]),g=C(),_=(0,n.useMemo)(()=>{let e=Array.from(g.selectedIds);return e.length>0?e[0]:null},[g.selectedIds]),v=w(),y=S(),b=ee(),T=(0,n.useCallback)(e=>{b&&b.sendOperation({...e,userId:b.currentUserId??``})},[b]),[E,D]=(0,n.useState)(!0),k=(0,n.useRef)(null),j=(0,n.useRef)(null),N=ce[i],P=a===`landscape`?N.height:N.width,F=a===`landscape`?N.width:N.height,I=e=>{switch(e){case`header`:return J.sectionHeader;case`page-header`:return J.sectionPageHeader;case`group-header`:return J.sectionGroupHeader;case`detail`:return J.sectionDetail;case`group-footer`:return J.sectionGroupFooter;case`page-footer`:return J.sectionPageFooter;case`footer`:return J.sectionFooter;default:return e}},L=(0,n.useMemo)(()=>_?m.flatMap(e=>e.elements).find(e=>e.id===_):null,[_,m]),R=(0,n.useCallback)((e,t)=>{if(u)return;let n={id:`elem-${Date.now()}`,type:t,position:{x:o.left,y:10,width:200,height:30},properties:{text:t===`text`?`New Text`:void 0,field:t===`field`?`field_name`:void 0}};h(m.map((t,r)=>r===e?{...t,elements:[...t.elements,n]}:t)),g.selectOne(n.id),T({type:`insert`,elementId:n.id,data:{element:n}})},[m,o.left,u,h,g,T]),z=(0,n.useCallback)(e=>{u||(h(m.map(t=>({...t,elements:t.elements.filter(t=>t.id!==e)}))),g.isSelected(e)&&g.clearSelection(),T({type:`delete`,elementId:e,data:{}}))},[m,u,h,g,T]),B=(0,n.useCallback)(async()=>{if(u||g.count===0||!await y.confirm(J.deleteElementsTitle,J.deleteElementMessage(g.count)))return;let e=g.selectedIds;h(m.map(t=>({...t,elements:t.elements.filter(t=>!e.has(t.id))}))),g.clearSelection(),e.forEach(e=>{T({type:`delete`,elementId:e,data:{}})})},[u,g,y,m,h,T]),V=(0,n.useCallback)((e,t)=>{u||!_||(h(m.map(n=>({...n,elements:n.elements.map(n=>n.id===_?e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,properties:{...n.properties,[e]:t}}:n)}))),T({type:`update`,elementId:_,data:{[e]:t}}))},[u,_,m,h,T]),H=(0,n.useCallback)(()=>{let e=g.selectedIds;if(e.size===0)return;let t=m.flatMap(e=>e.elements).filter(t=>e.has(t.id));v.copy(t)},[g,m,v]),U=(0,n.useCallback)(()=>{if(u)return;let e=v.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`elem-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}})),r=m.findIndex(e=>e.type===`detail`),i=r>=0?r:0;h(m.map((e,t)=>t===i?{...e,elements:[...e.elements,...n]}:e)),g.selectMany(n.map(e=>e.id)),n.forEach(e=>{T({type:`insert`,elementId:e.id,data:{element:e}})})},[u,v,m,h,g,T]),te=(0,n.useCallback)((e,t,n)=>{u||(k.current={id:t.id,sectionIndex:n,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[u]),ne=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),re=(0,n.useCallback)((e,t)=>{e.preventDefault();let n=k.current;if(!n||u)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;if(n.sectionIndex===t)h(m.map((e,a)=>a===t?{...e,elements:e.elements.map(e=>e.id===n.id?{...e,position:{...e.position,x:Math.max(0,e.position.x+r),y:Math.max(0,(typeof e.position.y==`number`?e.position.y:0)+i)}}:e)}:e));else{let e=null,i=m.map((t,i)=>{if(i!==n.sectionIndex)return t;let a=t.elements.find(e=>e.id===n.id);return a&&(e={...a,position:{...a.position,x:Math.max(0,a.position.x+r),y:10}}),{...t,elements:t.elements.filter(e=>e.id!==n.id)}});e&&h(i.map((n,r)=>r===t?{...n,elements:[...n.elements,e]}:n))}T({type:`move`,elementId:n.id,data:{}}),k.current=null},[u,m,h,T]),ie=(0,n.useMemo)(()=>{if(!L)return[];let e=[{name:`x`,label:J.propX,type:`number`,value:L.position.x,group:J.groupPosition},{name:`y`,label:J.propY,type:`number`,value:L.position.y,group:J.groupPosition},{name:`width`,label:J.propWidth,type:`number`,value:L.position.width,group:J.groupSize},{name:`height`,label:J.propHeight,type:`number`,value:L.position.height,group:J.groupSize}];return L.type===`text`&&e.push({name:`text`,label:J.propText,type:`text`,value:L.properties.text??``,group:J.groupContent}),L.type===`field`&&e.push({name:`field`,label:J.propField,type:`text`,value:L.properties.field??``,group:J.groupContent}),e},[L]);return(0,n.useEffect)(()=>{let e=j.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&g.count>0&&!t){e.preventDefault(),B();return}if(e.key===`Escape`){g.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&!u){e.preventDefault(),p.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&!u){e.preventDefault(),p.redo();return}if(n&&e.key===`c`){e.preventDefault(),H();return}if(n&&e.key===`v`&&!u){e.preventDefault(),U();return}if(n&&e.key===`a`){e.preventDefault();let t=m.flatMap(e=>e.elements).map(e=>e.id);g.selectMany(t);return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g,B,u,p,H,U,m]),(0,O.jsxs)(`div`,{ref:j,tabIndex:0,className:q(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,f),children:[(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[c&&(0,O.jsxs)(`div`,{role:`toolbar`,"aria-label":J.designerToolbar,className:`flex items-center gap-2 p-2 border-b bg-muted/20`,children:[(0,O.jsx)(r.FileText,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e}),t&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t,`)`]}),!u&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!p.canUndo&&`opacity-40 pointer-events-none`),title:J.undoShortcut,"aria-label":J.undo,disabled:!p.canUndo,onClick:()=>p.undo(),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!p.canRedo&&`opacity-40 pointer-events-none`),title:J.redoShortcut,"aria-label":J.redo,disabled:!p.canRedo,onClick:()=>p.redo(),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!u&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:J.copyShortcut,"aria-label":J.copy,disabled:g.count===0,onClick:H,children:(0,O.jsx)(r.Copy,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!v.hasContent&&`opacity-40 pointer-events-none`),title:J.pasteShortcut,"aria-label":J.paste,disabled:!v.hasContent,onClick:U,children:(0,O.jsx)(r.Clipboard,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!u&&(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:J.deleteSelected,"aria-label":J.deleteSelected,disabled:g.count===0,onClick:B,children:(0,O.jsx)(r.Trash2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`flex-1`}),b?.isConnected&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),J.collaborationConnected,b.users.length>1&&` (${b.users.length})`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i,` `,a]}),l&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:E?J.collapsePanel:J.expandPanel,"aria-label":E?J.collapsePanel:J.expandPanel,onClick:()=>D(e=>!e),children:(0,O.jsx)(r.PanelRightClose,{className:q(`h-4 w-4`,!E&&`rotate-180`)})})]}),(0,O.jsx)(`div`,{role:`region`,"aria-label":J.reportCanvas,className:`flex-1 overflow-auto bg-muted/10 p-4 flex justify-center`,children:(0,O.jsx)(`div`,{className:`bg-white shadow-lg border`,style:{width:P,minHeight:F},children:m.map((e,t)=>(0,O.jsxs)(`div`,{className:`relative border-b border-dashed border-gray-300`,style:{minHeight:e.height},onDragOver:ne,onDrop:e=>re(e,t),children:[(0,O.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:[I(e.type),e.repeat&&` ↻`]}),!u&&(0,O.jsxs)(`div`,{className:`absolute right-1 top-0 flex items-center gap-0.5`,children:[(0,O.jsx)(`button`,{onClick:()=>R(t,`text`),className:`p-0.5 rounded hover:bg-accent`,title:J.addText,"aria-label":J.addText,children:(0,O.jsx)(r.Type,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`field`),className:`p-0.5 rounded hover:bg-accent`,title:J.addField,"aria-label":J.addField,children:(0,O.jsx)(r.Plus,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`image`),className:`p-0.5 rounded hover:bg-accent`,title:J.addImage,"aria-label":J.addImage,children:(0,O.jsx)(r.ImageIcon,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`chart`),className:`p-0.5 rounded hover:bg-accent`,title:J.addChart,"aria-label":J.addChart,children:(0,O.jsx)(r.BarChart3,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`table`),className:`p-0.5 rounded hover:bg-accent`,title:J.addTable,"aria-label":J.addTable,children:(0,O.jsx)(r.Table2,{className:`h-3 w-3`})})]}),(0,O.jsxs)(`div`,{className:`relative`,style:{minHeight:e.height,paddingTop:24},children:[e.elements.length===0&&(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground text-center pt-4`,children:J.addElementsPrompt}),e.elements.map(e=>{let n=g.isSelected(e.id);return(0,O.jsxs)(`div`,{draggable:!u,onDragStart:n=>te(n,e,t),className:q(`absolute border rounded px-2 py-1 text-xs cursor-pointer`,n?`border-primary ring-1 ring-primary/30 bg-primary/5`:`border-dashed border-gray-400 hover:border-primary/50`),style:{left:e.position.x,top:(typeof e.position.y==`number`?e.position.y:0)+24,width:e.position.width,height:e.position.height},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.type===`text`&&(e.properties.text??J.elementText),e.type===`field`&&`{${e.properties.field??`field`}}`,e.type===`image`&&J.elementImage,e.type===`chart`&&J.elementChart,e.type===`table`&&J.elementTable]}),!u&&n&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),z(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":J.deleteElement,children:(0,O.jsx)(r.Trash2,{className:`h-2.5 w-2.5`})})]},e.id)})]})]},`${e.type}-${t}`))})})]}),l&&(0,O.jsx)(`div`,{role:`region`,"aria-label":J.propertiesPanel,className:q(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,E?`w-56`:`w-0 overflow-hidden`),children:E&&(_&&L?(0,O.jsx)(M,{title:`${J.properties} – ${L.type}`,fields:ie,onChange:V}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:J.properties}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:J.selectElementPrompt})})]}))}),(0,O.jsx)(A,{isOpen:y.isOpen,title:y.title,message:y.message,onConfirm:y.onConfirm,onCancel:y.onCancel})]})}var de=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);X(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},fe={},pe=(e,t,n,r)=>{X(n)&&fe[n]||(X(n)&&(fe[n]=new Date),de(e,t,n,r))},me=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},Y=(e,t,n)=>{e.loadNamespaces(t,me(e,n))},he=(e,t,n,r)=>{if(X(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Y(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,me(e,r))},ge=(e,t,n={})=>!t.languages||!t.languages.length?(pe(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),X=e=>typeof e==`string`,_e=e=>typeof e==`object`&&!!e,ve=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ye={"&amp;":`&`,"&#38;":`&`,"&lt;":`<`,"&#60;":`<`,"&gt;":`>`,"&#62;":`>`,"&apos;":`'`,"&#39;":`'`,"&quot;":`"`,"&#34;":`"`,"&nbsp;":` `,"&#160;":` `,"&copy;":`©`,"&#169;":`©`,"&reg;":`®`,"&#174;":`®`,"&hellip;":`…`,"&#8230;":`…`,"&#x2F;":`/`,"&#47;":`/`},be=e=>ye[e],xe={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(ve,be),transDefaultProps:void 0},Se=()=>xe,Ce,we=()=>Ce,Te=(0,n.createContext)(),Ee=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},De=v((e=>{var t=require(`react`);function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Oe=v((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function n(e,t){d||a.startTransition===void 0||(d=!0,console.error(`You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.`));var n=t();if(!f){var i=t();o(n,i)||(console.error(`The result of getSnapshot should be cached to avoid an infinite loop`),f=!0)}i=s({inst:{value:n,getSnapshot:t}});var p=i[0].inst,m=i[1];return l(function(){p.value=n,p.getSnapshot=t,r(p)&&m({inst:p})},[e,n,t]),c(function(){return r(p)&&m({inst:p}),e(function(){r(p)&&m({inst:p})})},[e]),u(n),n}function r(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch{return!0}}function i(e,t){return t()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=require(`react`),o=typeof Object.is==`function`?Object.is:t,s=a.useState,c=a.useEffect,l=a.useLayoutEffect,u=a.useDebugValue,d=!1,f=!1,p=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?i:n;e.useSyncExternalStore=a.useSyncExternalStore===void 0?p:a.useSyncExternalStore,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),ke=v(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=De():t.exports=Oe()}))(),Ae={t:(e,t)=>{if(X(t))return t;if(_e(t)&&X(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},je=()=>()=>{},Me=(e,t={})=>{let{i18n:r}=t,{i18n:i,defaultNS:a}=(0,n.useContext)(Te)||{},o=r||i||we();o&&!o.reportNamespaces&&(o.reportNamespaces=new Ee),o||pe(o,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let s=(0,n.useMemo)(()=>({...Se(),...o?.options?.react,...t}),[o,t]),{useSuspense:c,keyPrefix:l}=s,u=e||a||o?.options?.defaultNS,d=X(u)?[u]:u||[`translation`],f=(0,n.useMemo)(()=>d,d);o?.reportNamespaces?.addUsedNamespaces?.(f);let p=(0,n.useRef)(0),m=(0,n.useCallback)(e=>{if(!o)return je;let{bindI18n:t,bindI18nStore:n}=s,r=()=>{p.current+=1,e()};return t&&o.on(t,r),n&&o.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>o.off(e,r)),n&&n.split(` `).forEach(e=>o.store.off(e,r))}},[o,s]),h=(0,n.useRef)(),g=(0,n.useCallback)(()=>{if(!o)return Ae;let e=!!(o.isInitialized||o.initializedStoreOnce)&&f.every(e=>ge(e,o,s)),n=t.lng||o.language,r=p.current,i=h.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===l&&i.revision===r)return i;let a={t:o.getFixedT(n,s.nsMode===`fallback`?f:f[0],l),ready:e,lng:n,keyPrefix:l,revision:r};return h.current=a,a},[o,f,l,s,t.lng]),[_,v]=(0,n.useState)(0),{t:y,ready:b}=(0,ke.useSyncExternalStore)(m,g,g);(0,n.useEffect)(()=>{if(o&&!b&&!c){let e=()=>v(e=>e+1);t.lng?he(o,t.lng,f,e):Y(o,f,e)}},[o,t.lng,f,b,c,_]);let x=o||{},S=(0,n.useRef)(null),C=(0,n.useRef)(),w=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,`__original`,{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},T=(0,n.useMemo)(()=>{let e=x,t=e?.language,n=e;e&&(S.current&&S.current.__original===e&&C.current===t?n=S.current:(n=w(e),S.current=n,C.current=t));let r=!b&&!c?(...e)=>(pe(o,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),y(...e)):y,i=[r,n,b];return i.t=r,i.i18n=n,i.ready=b,i},[y,x,b,x.resolvedLanguage,x.language,x.languages]);if(o&&c&&!b)throw new Promise(e=>{let n=()=>e();t.lng?he(o,t.lng,f,n):Y(o,f,n)});return T},Ne=(0,n.createContext)(null);function Pe(e){let t=(0,n.useContext)(Ne),{t:r,i18n:i}=Me(e);return{t:r,language:t?.language||i.language||`en`,changeLanguage:t?.changeLanguage||(async e=>{await i.changeLanguage(e)}),direction:t?.direction||`ltr`,i18n:i}}var Fe={"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`,"appDesigner.objectManager.title":`Object Manager`,"appDesigner.objectManager.addObject":`New Object`,"appDesigner.objectManager.searchPlaceholder":`Search objects…`,"appDesigner.objectManager.noObjects":`No objects found.`,"appDesigner.objectManager.objectName":`API Name`,"appDesigner.objectManager.objectLabel":`Label`,"appDesigner.objectManager.pluralLabel":`Plural Label`,"appDesigner.objectManager.icon":`Icon`,"appDesigner.objectManager.selectIcon":`Select icon…`,"appDesigner.objectManager.group":`Group`,"appDesigner.objectManager.noGroup":`No Group`,"appDesigner.objectManager.sortOrder":`Sort Order`,"appDesigner.objectManager.enabled":`Enabled`,"appDesigner.objectManager.relationships":`Relationships`,"appDesigner.objectManager.systemBadge":`System`,"appDesigner.objectManager.fieldCount":`{{count}} fields`,"appDesigner.objectManager.ungrouped":`Ungrouped`,"appDesigner.objectManager.deleteConfirmTitle":`Delete Object?`,"appDesigner.objectManager.deleteConfirmMessage":`This will permanently delete the object and all its fields. This action cannot be undone.`,"appDesigner.fieldDesigner.title":`Field Designer`,"appDesigner.fieldDesigner.addField":`New Field`,"appDesigner.fieldDesigner.searchPlaceholder":`Search fields…`,"appDesigner.fieldDesigner.allTypes":`All Types`,"appDesigner.fieldDesigner.noFields":`No fields found.`,"appDesigner.fieldDesigner.fieldName":`API Name`,"appDesigner.fieldDesigner.fieldLabel":`Label`,"appDesigner.fieldDesigner.fieldType":`Type`,"appDesigner.fieldDesigner.fieldGroup":`Group`,"appDesigner.fieldDesigner.description":`Description`,"appDesigner.fieldDesigner.required":`Required`,"appDesigner.fieldDesigner.unique":`Unique`,"appDesigner.fieldDesigner.readOnly":`Read Only`,"appDesigner.fieldDesigner.hidden":`Hidden`,"appDesigner.fieldDesigner.indexed":`Indexed`,"appDesigner.fieldDesigner.externalId":`External ID`,"appDesigner.fieldDesigner.trackHistory":`Track History`,"appDesigner.fieldDesigner.defaultValue":`Default Value`,"appDesigner.fieldDesigner.placeholder":`Placeholder`,"appDesigner.fieldDesigner.referenceTo":`Reference To`,"appDesigner.fieldDesigner.formula":`Formula`,"appDesigner.fieldDesigner.options":`Options`,"appDesigner.fieldDesigner.addOption":`Add Option`,"appDesigner.fieldDesigner.validationRules":`Validation Rules`,"appDesigner.fieldDesigner.addRule":`Add Rule`,"appDesigner.fieldDesigner.systemBadge":`System`,"appDesigner.fieldDesigner.ungrouped":`General`,"appDesigner.fieldDesigner.deleteConfirmTitle":`Delete Field?`,"appDesigner.fieldDesigner.deleteConfirmMessage":`This will permanently delete the field. Existing data in this field will be lost.`,"appDesigner.fieldDesigner.basicSection":`Basic`,"appDesigner.fieldDesigner.typeSpecificSection":`Type Settings`,"appDesigner.fieldDesigner.advancedSection":`Advanced`,"appDesigner.fieldDesigner.typeCategory.text":`Text`,"appDesigner.fieldDesigner.typeCategory.number":`Number`,"appDesigner.fieldDesigner.typeCategory.date":`Date & Time`,"appDesigner.fieldDesigner.typeCategory.choice":`Choice`,"appDesigner.fieldDesigner.typeCategory.relation":`Relation`,"appDesigner.fieldDesigner.typeCategory.advanced":`Advanced`,"common.edit":`Edit`};function Ie(e){return(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}function Z(){try{let e=Pe();return e.t(`appDesigner.basicInfo`)===`appDesigner.basicInfo`?{t:Ie(Fe)}:{t:e.t}}catch{return{t:Ie(Fe)}}}function Q(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Le={name:``,title:``,description:``,icon:``,template:``,layout:`sidebar`,objects:[],navigation:[],branding:{logo:``,primaryColor:`#3b82f6`,favicon:``}};function Re(e){return e.filter(e=>e.selected).map(e=>({id:e.name,type:`object`,label:e.label,icon:e.icon,objectName:e.name}))}var ze=0;function Be(e){return ze+=1,`${e}_${Date.now()}_${ze}`}function Ve({steps:e,currentIndex:t,onStepClick:i}){return(0,O.jsx)(`nav`,{className:`flex items-center justify-center gap-0 px-4 py-6`,children:e.map((e,a)=>{let o=a<t,s=a===t;return(0,O.jsxs)(n.default.Fragment,{children:[a>0&&(0,O.jsx)(`div`,{className:Q(`h-0.5 w-12 sm:w-20`,o?`bg-blue-500`:`bg-gray-200`)}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-step-${e.id}`,onClick:()=>i(a),className:Q(`flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1`,s&&`cursor-default`,!s&&`cursor-pointer`),children:[(0,O.jsx)(`div`,{className:Q(`flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors`,o&&`bg-blue-500 text-white`,s&&`bg-blue-600 text-white ring-2 ring-blue-300`,!o&&!s&&`bg-gray-200 text-gray-500`),children:o?(0,O.jsx)(r.Check,{className:`h-4 w-4`}):a+1}),(0,O.jsx)(`span`,{className:Q(`text-xs font-medium`,s?`text-blue-600`:`text-gray-500`),children:e.label})]})]},e.id)})})}function He({draft:e,templates:t,readOnly:n,onChange:i,t:a}){let s=e.name.length>0&&!(0,o.isValidAppName)(e.name);return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-basic-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`label`,{htmlFor:`app-name`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appName`),` `,(0,O.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,O.jsx)(`input`,{id:`app-name`,"data-testid":`app-name-input`,type:`text`,value:e.name,onChange:e=>i({name:e.target.value}),placeholder:`my_app`,disabled:n,className:Q(`block w-full rounded-md border px-3 py-2 text-sm shadow-sm outline-none transition-colors`,`focus:border-blue-500 focus:ring-1 focus:ring-blue-500`,`disabled:cursor-not-allowed disabled:bg-gray-50`,s?`border-red-400`:`border-gray-300`)}),s&&(0,O.jsx)(`p`,{className:`text-xs text-red-500`,children:a(`appDesigner.snakeCaseHint`)})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`label`,{htmlFor:`app-title`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appTitle`),` `,(0,O.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,O.jsx)(`input`,{id:`app-title`,"data-testid":`app-title-input`,type:`text`,value:e.title,onChange:e=>i({title:e.target.value}),placeholder:`My Application`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-description`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appDescription`)}),(0,O.jsx)(`textarea`,{id:`app-description`,"data-testid":`app-description-input`,value:e.description??``,onChange:e=>i({description:e.target.value}),rows:3,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 resize-none`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-icon`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appIcon`)}),(0,O.jsx)(`input`,{id:`app-icon`,type:`text`,value:e.icon??``,onChange:e=>i({icon:e.target.value}),placeholder:`LayoutDashboard`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),t.length>0&&(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-template`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.template`)}),(0,O.jsxs)(`select`,{id:`app-template`,value:e.template??``,onChange:e=>i({template:e.target.value}),disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:``,children:`None`}),t.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,O.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,O.jsx)(`legend`,{className:`text-sm font-medium text-gray-700`,children:a(`appDesigner.layout`)}),(0,O.jsx)(`div`,{className:`flex gap-3`,children:[{value:`sidebar`,labelKey:`appDesigner.layoutSidebar`,Icon:r.PanelLeft},{value:`header`,labelKey:`appDesigner.layoutHeader`,Icon:r.Layout},{value:`empty`,labelKey:`appDesigner.layoutEmpty`,Icon:r.LayoutTemplate}].map(({value:t,labelKey:r,Icon:o})=>(0,O.jsxs)(`label`,{"data-testid":`app-layout-${t}`,className:Q(`flex flex-1 cursor-pointer flex-col items-center gap-1.5 rounded-lg border-2 p-3 transition-colors`,e.layout===t?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,n&&`pointer-events-none opacity-60`),children:[(0,O.jsx)(o,{className:`h-5 w-5 text-gray-600`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-700`,children:a(r)}),(0,O.jsx)(`input`,{type:`radio`,name:`layout`,value:t,checked:e.layout===t,onChange:()=>i({layout:t}),disabled:n,className:`sr-only`})]},t))})]})]})}function Ue({objects:e,readOnly:t,onToggle:i,onToggleAll:a,search:o,onSearchChange:s,t:c}){let l=(0,n.useMemo)(()=>{if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.label.toLowerCase().includes(t))},[e,o]),u=e.length>0&&e.every(e=>e.selected);return e.every(e=>!e.selected),(0,O.jsxs)(`div`,{"data-testid":`wizard-step-objects-content`,className:`mx-auto max-w-2xl space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(r.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{"data-testid":`object-search`,type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:c(`appDesigner.searchObjects`),className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500`})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(!u),disabled:t,className:`rounded-md border border-gray-300 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:c(u?`appDesigner.deselectAll`:`appDesigner.selectAll`)})]}),l.length===0?(0,O.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:c(`appDesigner.noObjectsFound`)}):(0,O.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:l.map(e=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`object-card-${e.name}`,disabled:t,onClick:()=>i(e.name),className:Q(`flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors`,e.selected?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,t&&`pointer-events-none opacity-60`),children:[(0,O.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,O.jsx)(`div`,{className:Q(`flex h-5 w-5 items-center justify-center rounded border transition-colors`,e.selected?`border-blue-500 bg-blue-500 text-white`:`border-gray-300`),children:e.selected&&(0,O.jsx)(r.Check,{className:`h-3 w-3`})})]}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.name}),e.icon&&(0,O.jsx)(`span`,{className:`text-xs text-gray-400`,children:e.icon})]},e.name))})]})}var We={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 Ge({items:e,readOnly:t,onAdd:n,onRemove:i,onReorder:a,t:o}){return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-navigation-content`,className:`mx-auto max-w-lg space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-group-btn`,onClick:()=>n(`group`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.FolderOpen,{className:`h-3.5 w-3.5`}),o(`appDesigner.addGroup`)]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-url-btn`,onClick:()=>n(`url`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Link,{className:`h-3.5 w-3.5`}),o(`appDesigner.addUrl`)]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-separator-btn`,onClick:()=>n(`separator`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Minus,{className:`h-3.5 w-3.5`}),o(`appDesigner.addSeparator`)]})]}),e.length===0?(0,O.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:o(`appDesigner.noNavItemsHint`)}):(0,O.jsx)(`ul`,{className:`space-y-1.5`,children:e.map((n,c)=>(0,O.jsxs)(`li`,{"data-testid":`nav-item-${n.id}`,className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2`,children:[n.icon&&(0,O.jsx)(`span`,{className:`text-xs text-gray-400`,children:n.icon}),(0,O.jsx)(`span`,{className:`flex-1 truncate text-sm text-gray-800`,children:n.type===`separator`?o(`appDesigner.separatorLabel`):(0,s.resolveI18nLabel)(n.label)}),(0,O.jsx)(`span`,{className:Q(`rounded-full px-2 py-0.5 text-[10px] font-medium`,We[n.type]??`bg-gray-100 text-gray-600`),children:n.type}),(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(n.id,`up`),disabled:t||c===0,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(n.id,`down`),disabled:t||c===e.length-1,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>i(n.id),disabled:t,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30`,"aria-label":`Remove`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function Ke({branding:e,title:t,readOnly:n,onChange:i,t:a}){return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-branding-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-logo`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.logoUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Image,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-logo`,"data-testid":`branding-logo-input`,type:`text`,value:e.logo??``,onChange:e=>i({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-color`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.primaryColor`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Palette,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-color`,"data-testid":`branding-color-input`,type:`text`,value:e.primaryColor??`#3b82f6`,onChange:e=>i({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-favicon`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.faviconUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Globe,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:e.favicon??``,onChange:e=>i({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.preview`)}),(0,O.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.logo?(0,O.jsx)(`img`,{src:e.logo,alt:`App logo`,className:`h-8 w-8 rounded object-contain`}):(0,O.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400`,children:`Logo`}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:t||a(`appDesigner.appTitle`)})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:e.primaryColor||`#3b82f6`}}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.primaryColor||`#3b82f6`})]}),e.favicon&&(0,O.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,O.jsx)(`img`,{src:e.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:`Favicon`})]})]})]})]})}function qe({availableObjects:e=[],templates:t=[],initialDraft:i,onComplete:a,onCancel:s,onSaveDraft:c,readOnly:l=!1,className:u}){let{t:d}=Z(),f=S(),[p,m]=(0,n.useState)(0),[h,g]=(0,n.useState)(``),[_,v]=(0,n.useState)(()=>({...Le,objects:e.map(e=>({...e})),...i})),y=(0,n.useMemo)(()=>[{id:`basic`,label:d(`appDesigner.basicInfo`),description:d(`appDesigner.stepBasicDesc`),icon:`Settings`},{id:`objects`,label:d(`appDesigner.objects`),description:d(`appDesigner.stepObjectsDesc`),icon:`Database`},{id:`navigation`,label:d(`appDesigner.navigation`),description:d(`appDesigner.stepNavigationDesc`),icon:`Menu`},{id:`branding`,label:d(`appDesigner.branding`),description:d(`appDesigner.stepBrandingDesc`),icon:`Palette`}],[d]),b=p===0,x=p===y.length-1,C=(0,n.useMemo)(()=>_.name.length>0&&(0,o.isValidAppName)(_.name)&&_.title.trim().length>0,[_.name,_.title]),w=(0,n.useMemo)(()=>p===0?C:!0,[p,C]),T=(0,n.useCallback)(e=>{v(t=>({...t,...e}))},[]),E=(0,n.useCallback)(e=>{v(t=>({...t,branding:{...t.branding,...e}}))},[]),D=(0,n.useCallback)(e=>{v(t=>({...t,objects:t.objects.map(t=>t.name===e?{...t,selected:!t.selected}:t)}))},[]),k=(0,n.useCallback)(e=>{v(t=>({...t,objects:t.objects.map(t=>({...t,selected:e}))}))},[]),A=(0,n.useCallback)(e=>{let t={id:Be(e),type:e,label:e===`separator`?``:e===`group`?`New Group`:`New Link`,...e===`group`?{children:[]}:{},...e===`url`?{url:``}:{}};v(e=>({...e,navigation:[...e.navigation,t]}))},[]),j=(0,n.useCallback)(e=>{v(t=>({...t,navigation:t.navigation.filter(t=>t.id!==e)}))},[]),M=(0,n.useCallback)((e,t)=>{v(n=>{let r=[...n.navigation],i=r.findIndex(t=>t.id===e);if(i<0)return n;let a=t===`up`?i-1:i+1;return a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,navigation:r})})},[]),N=(0,n.useCallback)(()=>{x||(p===1&&v(e=>({...e,navigation:Re(e.objects)})),m(e=>e+1))},[p,x]),P=(0,n.useCallback)(()=>{b||m(e=>e-1)},[b]),F=(0,n.useCallback)(()=>{a?.(_)},[_,a]),I=(0,n.useCallback)(async()=>{(_.name.length>0||_.title.length>0)&&s?await f.confirm(d(`appDesigner.cancelConfirmTitle`),d(`appDesigner.cancelConfirmMessage`))&&s():s?.()},[_.name,_.title,s,f,d]),L=(0,n.useCallback)(()=>{c?.(_)},[_,c]),R=(0,n.useCallback)(e=>{e<=p?m(e):e===p+1&&w&&(p===1&&e===2&&v(e=>({...e,navigation:Re(e.objects)})),m(e))},[p,w]);return(0,O.jsxs)(`div`,{className:Q(`flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm`,u),children:[f.isOpen&&(0,O.jsx)(`div`,{"data-testid":`cancel-confirm-dialog`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,"aria-modal":`true`,children:(0,O.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:f.title}),(0,O.jsx)(`button`,{type:`button`,onClick:f.onCancel,className:`rounded p-1 text-gray-400 hover:text-gray-600`,"aria-label":d(`common.close`),children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:f.message}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-keep`,onClick:f.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:d(`appDesigner.keepEditing`)}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-discard`,onClick:f.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:d(`appDesigner.confirmDiscard`)})]})]})}),(0,O.jsx)(`div`,{className:`border-b border-gray-100`,children:(0,O.jsx)(Ve,{steps:y,currentIndex:p,onStepClick:R})}),(0,O.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[p===0&&(0,O.jsx)(He,{draft:_,templates:t,readOnly:l,onChange:T,t:d}),p===1&&(0,O.jsx)(Ue,{objects:_.objects,readOnly:l,onToggle:D,onToggleAll:k,search:h,onSearchChange:g,t:d}),p===2&&(0,O.jsx)(Ge,{items:_.navigation,readOnly:l,onAdd:A,onRemove:j,onReorder:M,t:d}),p===3&&(0,O.jsx)(Ke,{branding:_.branding,title:_.title,readOnly:l,onChange:E,t:d})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`wizard-cancel`,onClick:I,disabled:l,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:d(`common.cancel`)}),c&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`wizard-save-draft`,onClick:L,disabled:l,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:d(`appDesigner.saveDraft`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!b&&(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-back`,onClick:P,disabled:l,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.ChevronLeft,{className:`h-4 w-4`}),d(`common.back`)]}),x?(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-complete`,onClick:F,disabled:l||!w,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Check,{className:`h-4 w-4`}),d(`appDesigner.complete`)]}):(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-next`,onClick:N,disabled:l||!w,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:[d(`common.next`),(0,O.jsx)(r.ChevronRight,{className:`h-4 w-4`})]})]})]})]})}function Je(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Ye=0;function Xe(e){return Ye+=1,`${e}_${Date.now()}_${Ye}`}var Ze={object:{labelKey:`appDesigner.navTypeObject`,color:`bg-green-100 text-green-700`,Icon:r.Database},dashboard:{labelKey:`appDesigner.navTypeDashboard`,color:`bg-amber-100 text-amber-700`,Icon:r.LayoutDashboard},page:{labelKey:`appDesigner.navTypePage`,color:`bg-teal-100 text-teal-700`,Icon:r.FileText},report:{labelKey:`appDesigner.navTypeReport`,color:`bg-rose-100 text-rose-700`,Icon:r.BarChart3},url:{labelKey:`appDesigner.navTypeUrl`,color:`bg-sky-100 text-sky-700`,Icon:r.Link},group:{labelKey:`appDesigner.navTypeGroup`,color:`bg-purple-100 text-purple-700`,Icon:r.FolderOpen},separator:{labelKey:`appDesigner.navTypeSeparator`,color:`bg-gray-100 text-gray-600`,Icon:r.Minus},action:{labelKey:`appDesigner.navTypeAction`,color:`bg-orange-100 text-orange-700`,Icon:r.MousePointerClick}},Qe=[{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 $e({item:e,depth:t,index:i,total:a,readOnly:o,onRemove:c,onMoveUp:l,onMoveDown:u,onToggleExpand:d,onUpdateLabel:f,onUpdateIcon:p,onToggleVisible:m,onAddChild:h,expandedIds:g,t:_}){let[v,y]=(0,n.useState)(!1),[b,x]=(0,n.useState)((0,s.resolveI18nLabel)(e.label)??``),[S,C]=(0,n.useState)(!1),[w,T]=(0,n.useState)(e.icon||``),E=Ze[e.type];e.type===`group`&&e.children&&e.children.length;let D=g.has(e.id),k=e.visible===!1,A=()=>{b.trim()?f(e.id,b.trim()):x((0,s.resolveI18nLabel)(e.label)??``),y(!1)},j=()=>{p(e.id,w.trim()),C(!1)};return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`li`,{"data-testid":`nav-designer-item-${e.id}`,className:Je(`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50`,k&&`opacity-50`),style:{marginLeft:t*20},children:[(0,O.jsx)(r.GripVertical,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300`}),e.type===`group`?(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":_(D?`appDesigner.navCollapseGroup`:`appDesigner.navExpandGroup`),children:D?(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`}):(0,O.jsx)(r.ChevronRight,{className:`h-3.5 w-3.5`})}):(0,O.jsx)(`span`,{className:`w-5`}),S&&!o?(0,O.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),onBlur:j,onKeyDown:t=>{t.key===`Enter`&&j(),t.key===`Escape`&&(T(e.icon||``),C(!1))},autoFocus:!0,placeholder:_(`appDesigner.navIconPlaceholder`),"data-testid":`nav-designer-icon-input-${e.id}`,className:`w-24 rounded border border-blue-300 px-1 py-0.5 text-xs outline-none focus:ring-1 focus:ring-blue-400`}):(0,O.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,O.jsx)(E.Icon,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}),!o&&e.type!==`separator`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>{T(e.icon||``),C(!0)},className:`rounded p-0.5 text-gray-300 hover:text-blue-500`,"aria-label":_(`appDesigner.navEditIcon`),"data-testid":`nav-designer-edit-icon-${e.id}`,children:(0,O.jsx)(r.Pencil,{className:`h-2.5 w-2.5`})})]}),e.type===`separator`?(0,O.jsx)(`span`,{className:`flex-1 text-xs italic text-gray-400`,children:_(`appDesigner.separatorLabel`)}):v&&!o?(0,O.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),onBlur:A,onKeyDown:t=>{t.key===`Enter`&&A(),t.key===`Escape`&&(x((0,s.resolveI18nLabel)(e.label)??``),y(!1))},autoFocus:!0,className:`flex-1 rounded border border-blue-300 px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-blue-400`}):(0,O.jsx)(`span`,{className:Je(`flex-1 truncate text-sm text-gray-800`,!o&&`cursor-text`),onDoubleClick:()=>{!o&&e.type!==`separator`&&(x((0,s.resolveI18nLabel)(e.label)??``),y(!0))},children:(0,s.resolveI18nLabel)(e.label)}),(0,O.jsx)(`span`,{className:Je(`rounded-full px-2 py-0.5 text-[10px] font-medium`,E.color),children:_(E.labelKey)}),k&&(0,O.jsx)(`span`,{className:`rounded-full bg-gray-200 px-1.5 py-0.5 text-[10px] font-medium text-gray-500`,"data-testid":`nav-designer-hidden-badge-${e.id}`,children:_(`appDesigner.navHidden`)}),!o&&e.type!==`separator`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-700`,"aria-label":_(`appDesigner.navToggleVisible`),"data-testid":`nav-designer-toggle-visible-${e.id}`,children:k?(0,O.jsx)(r.EyeOff,{className:`h-3.5 w-3.5`}):(0,O.jsx)(r.Eye,{className:`h-3.5 w-3.5`})}),e.type===`group`&&!o&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(e.id,`page`),className:`rounded p-0.5 text-gray-400 hover:text-blue-500`,"aria-label":_(`appDesigner.navAddChild`),"data-testid":`nav-designer-add-child-${e.id}`,children:(0,O.jsx)(r.Plus,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:o||i===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":_(`appDesigner.navMoveUp`),children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),disabled:o||i===a-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":_(`appDesigner.navMoveDown`),children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:o,className:`rounded p-0.5 text-gray-400 hover:text-red-500 disabled:opacity-30`,"aria-label":_(`appDesigner.navRemove`),"data-testid":`nav-designer-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]}),e.type===`group`&&D&&e.children&&(0,O.jsx)(O.Fragment,{children:e.children.map((n,r)=>(0,O.jsx)($e,{item:n,depth:t+1,index:r,total:e.children.length,readOnly:o,onRemove:c,onMoveUp:l,onMoveDown:u,onToggleExpand:d,onUpdateLabel:f,onUpdateIcon:p,onToggleVisible:m,onAddChild:h,expandedIds:g,t:_},n.id))})]})}function et({items:e,t}){return(0,O.jsxs)(`div`,{"data-testid":`nav-designer-preview`,className:`w-56 shrink-0 rounded-lg border border-gray-200 bg-gray-50 p-3`,children:[(0,O.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase text-gray-500`,children:t(`appDesigner.navLivePreview`)}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-gray-400`,children:t(`appDesigner.navNoPreviewItems`)}):(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:e.map(e=>(0,O.jsx)(tt,{item:e,depth:0},e.id))})]})}function tt({item:e,depth:t}){let n=Ze[e.type];return e.type===`separator`?(0,O.jsx)(`li`,{className:`my-1 border-t border-gray-200`,style:{marginLeft:t*12}}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded px-2 py-1 text-xs text-gray-700 hover:bg-gray-100`,style:{marginLeft:t*12},children:[(0,O.jsx)(n.Icon,{className:`h-3 w-3 text-gray-400`}),(0,O.jsx)(`span`,{className:`truncate`,children:(0,s.resolveI18nLabel)(e.label)})]}),e.type===`group`&&e.children?.map(e=>(0,O.jsx)(tt,{item:e,depth:t+1},e.id))]})}function nt({items:e,onChange:t,readOnly:i=!1,showPreview:a=!0,className:o,onExport:s,onImport:c}){let{t:l}=Z(),u=(0,n.useRef)(null),[d,f]=(0,n.useState)(()=>new Set(e.filter(e=>e.type===`group`).map(e=>e.id))),p=(0,n.useCallback)(n=>{function r(e){return e.filter(e=>e.id!==n).map(e=>e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),m=(0,n.useCallback)((n,r)=>{function i(e){let t=e.findIndex(e=>e.id===n);if(t>=0){let n=r===`up`?t-1:t+1;if(n>=0&&n<e.length){let r=[...e];return[r[t],r[n]]=[r[n],r[t]],r}return e}return e.map(e=>e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),h=(0,n.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,label:r}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),g=(0,n.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,icon:r||void 0}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),_=(0,n.useCallback)(n=>{function r(e){return e.map(e=>e.id===n?{...e,visible:e.visible===!1}:e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),v=(0,n.useCallback)((n,r)=>{let i={id:Xe(r),type:r,label:r===`separator`?``:`New ${l(Ze[r].labelKey)}`,...r===`group`?{children:[]}:{},...r===`url`?{url:``}:{}};function a(e){return e.map(e=>e.id===n&&e.type===`group`?{...e,children:[...e.children||[],i]}:e.children?{...e,children:a(e.children)}:e)}t(a(e)),f(e=>new Set(e).add(n))},[e,t]),y=(0,n.useCallback)(n=>{let r={id:Xe(n),type:n,label:n===`separator`?``:`New ${l(Ze[n].labelKey)}`,...n===`group`?{children:[]}:{},...n===`url`?{url:``}:{}};t([...e,r])},[e,t,l]),b=(0,n.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),x=(0,n.useCallback)(()=>{if(s)s(e);else{let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`navigation-schema.json`,i.click(),URL.revokeObjectURL(r)}},[e,s]),S=(0,n.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);Array.isArray(n)&&(c?c(n):t(n))}catch{}},r.readAsText(n),u.current&&(u.current.value=``)},[t,c]);return(0,O.jsxs)(`div`,{"data-testid":`navigation-designer`,className:Je(`flex flex-col gap-4 sm:flex-row`,o),children:[(0,O.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Qe.map(({type:e,labelKey:t})=>{let{Icon:n,color:a}=Ze[e];return(0,O.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-add-${e}`,onClick:()=>y(e),disabled:i,className:Je(`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),l(t)]},e)}),(0,O.jsx)(`span`,{className:`mx-1 hidden h-4 w-px bg-gray-200 sm:block`}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-export`,onClick:x,className:`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50`,children:[(0,O.jsx)(r.Download,{className:`h-3 w-3`}),l(`appDesigner.navExportSchema`)]}),(0,O.jsxs)(`label`,{"data-testid":`nav-designer-import`,className:Je(`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`,i&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(r.Upload,{className:`h-3 w-3`}),l(`appDesigner.navImportSchema`),(0,O.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,onChange:S,disabled:i,"data-testid":`nav-designer-import-input`})]})]}),e.length===0?(0,O.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-400`,children:l(`appDesigner.navNoItems`)}):(0,O.jsx)(`ul`,{className:`space-y-1`,"data-testid":`nav-designer-tree`,children:e.map((t,n)=>(0,O.jsx)($e,{item:t,depth:0,index:n,total:e.length,readOnly:i,onRemove:p,onMoveUp:e=>m(e,`up`),onMoveDown:e=>m(e,`down`),onToggleExpand:b,onUpdateLabel:h,onUpdateIcon:g,onToggleVisible:_,onAddChild:v,expandedIds:d,t:l},t.id))})]}),a&&(0,O.jsx)(et,{items:e,t:l})]})}function rt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var it=[{value:`edit`,label:`Edit`,Icon:r.Pencil},{value:`preview`,label:`Preview`,Icon:r.Eye},{value:`code`,label:`Code`,Icon:r.Code}];function at({mode:e,onChange:t,disabled:n=!1,className:r}){return(0,O.jsx)(`div`,{"data-testid":`editor-mode-toggle`,className:rt(`inline-flex items-center rounded-lg border border-gray-200 bg-gray-50 p-0.5`,r),role:`radiogroup`,"aria-label":`Editor mode`,children:it.map(({value:r,label:i,Icon:a})=>(0,O.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,"data-testid":`editor-mode-${r}`,onClick:()=>t(r),disabled:n,className:rt(`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors`,e===r?`bg-white text-gray-900 shadow-sm`:`text-gray-500 hover:text-gray-700`,n&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(a,{className:`h-3.5 w-3.5`}),i]},r))})}function ot(...e){return(0,a.twMerge)((0,i.clsx)(e))}var st=[{type:`metric`,label:`KPI Metric`,Icon:r.TrendingUp},{type:`bar`,label:`Bar Chart`,Icon:r.BarChart3},{type:`line`,label:`Line Chart`,Icon:r.LineChart},{type:`pie`,label:`Pie Chart`,Icon:r.PieChart},{type:`table`,label:`Table`,Icon:r.Table2},{type:`grid`,label:`Grid`,Icon:r.LayoutGrid}],ct=0;function lt(){return ct+=1,`widget_${Date.now()}_${ct}`}function ut({widget:e,index:t,total:n,selected:i,readOnly:a,onSelect:o,onRemove:s,onMoveUp:c,onMoveDown:l}){let u=e.type||`metric`,d=st.find(e=>e.type===u)||st[0];return(0,O.jsxs)(`div`,{"data-testid":`dashboard-widget-${e.id}`,onClick:o,className:ot(`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:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.GripVertical,{className:`h-4 w-4 text-gray-300`}),(0,O.jsx)(d.Icon,{className:`h-4 w-4 text-gray-500`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.title||`Widget ${t+1}`})]}),!a&&(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove widget`,"data-testid":`dashboard-widget-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]}),(0,O.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:d.label}),e.object&&(0,O.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:e.object})]})]})}function dt({widget:e,readOnly:t,onChange:n,onClose:i}){let{t:a}=Z();return(0,O.jsxs)(`div`,{"data-testid":`widget-property-panel`,className:`shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:a(`appDesigner.widgetProperties`)}),(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-title`,className:`text-xs font-medium text-gray-600`,children:`Title`}),(0,O.jsx)(`input`,{id:`widget-title`,"data-testid":`widget-prop-title`,type:`text`,value:e.title??``,onChange:e=>n({title:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-type`,className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,O.jsx)(`select`,{id:`widget-type`,"data-testid":`widget-prop-type`,value:e.type??`metric`,onChange:e=>n({type:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:st.map(e=>(0,O.jsx)(`option`,{value:e.type,children:e.label},e.type))})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-object`,className:`text-xs font-medium text-gray-600`,children:`Data Source (Object)`}),(0,O.jsx)(`input`,{id:`widget-object`,"data-testid":`widget-prop-object`,type:`text`,value:e.object??``,onChange:e=>n({object:e.target.value}),disabled:t,placeholder:`e.g. orders`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-value-field`,className:`text-xs font-medium text-gray-600`,children:`Value Field`}),(0,O.jsx)(`input`,{id:`widget-value-field`,"data-testid":`widget-prop-value-field`,type:`text`,value:e.valueField??``,onChange:e=>n({valueField:e.target.value}),disabled:t,placeholder:`e.g. amount`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-aggregate`,className:`text-xs font-medium text-gray-600`,children:`Aggregate`}),(0,O.jsxs)(`select`,{id:`widget-aggregate`,"data-testid":`widget-prop-aggregate`,value:e.aggregate??`count`,onChange:e=>n({aggregate:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:`count`,children:`Count`}),(0,O.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,O.jsx)(`option`,{value:`avg`,children:`Average`}),(0,O.jsx)(`option`,{value:`min`,children:`Min`}),(0,O.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-color`,className:`text-xs font-medium text-gray-600`,children:`Color Variant`}),(0,O.jsxs)(`select`,{id:`widget-color`,"data-testid":`widget-prop-color`,value:e.colorVariant??`default`,onChange:e=>n({colorVariant:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:`default`,children:`Default`}),(0,O.jsx)(`option`,{value:`blue`,children:`Blue`}),(0,O.jsx)(`option`,{value:`teal`,children:`Teal`}),(0,O.jsx)(`option`,{value:`orange`,children:`Orange`}),(0,O.jsx)(`option`,{value:`purple`,children:`Purple`}),(0,O.jsx)(`option`,{value:`success`,children:`Success`}),(0,O.jsx)(`option`,{value:`warning`,children:`Warning`}),(0,O.jsx)(`option`,{value:`danger`,children:`Danger`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:a(`appDesigner.widgetLayoutSize`)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-width`,className:`text-[10px] text-gray-400`,children:a(`appDesigner.widgetWidth`)}),(0,O.jsx)(`input`,{id:`widget-width`,"data-testid":`widget-prop-width`,type:`number`,min:1,value:e.layout?.w??1,onChange:t=>n({layout:{...e.layout,w:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-height`,className:`text-[10px] text-gray-400`,children:a(`appDesigner.widgetHeight`)}),(0,O.jsx)(`input`,{id:`widget-height`,"data-testid":`widget-prop-height`,type:`number`,min:1,value:e.layout?.h??1,onChange:t=>n({layout:{...e.layout,h:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]})]})]})]})}function ft({schema:e}){let{t}=Z(),n=e.widgets||[];return(0,O.jsxs)(`div`,{"data-testid":`dashboard-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,O.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||t(`appDesigner.dashboardPreview`)}),n.length===0?(0,O.jsx)(`div`,{className:`text-xs text-gray-400`,children:t(`appDesigner.noWidgetsPreview`)}):(0,O.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${e.columns??2}, 1fr)`},children:n.map(e=>{let t=st.find(t=>t.type===(e.type||`metric`))||st[0];return(0,O.jsxs)(`div`,{className:`rounded-md border border-gray-200 bg-white p-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(t.Icon,{className:`h-3 w-3 text-gray-400`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.title||`Untitled`})]}),(0,O.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function pt({schema:e,onChange:t,readOnly:i=!1,className:a,onExport:o,onImport:s,selectedWidgetId:c,onWidgetSelect:l}){let{t:u}=Z(),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(!1),h=(0,n.useRef)(null),g=(0,n.useRef)(null),_=c!==void 0,v=_?c:d,y=(0,n.useCallback)(e=>{l&&l(e),_||f(e)},[_,l,f]),{current:b,canUndo:S,canRedo:C,push:w,undo:T,redo:E}=x(e),D=(0,n.useCallback)(e=>{w(e),t(e)},[w,t]),k=b.widgets||[],A=k.find(e=>e.id===v),j=(0,n.useCallback)(e=>{let t=lt(),n={id:t,title:``,type:e,layout:{x:0,y:k.length,w:b.columns??2,h:1}};D({...b,widgets:[...k,n]}),y(t)},[b,k,D,y]),M=(0,n.useCallback)(e=>{D({...b,widgets:k.filter(t=>t.id!==e)}),v===e&&y(null)},[b,k,v,D,y]),N=(0,n.useCallback)((e,t)=>{let n=k.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=k.length)return;let i=[...k];[i[n],i[r]]=[i[r],i[n]],D({...b,widgets:i})},[b,k,D]),P=(0,n.useCallback)(e=>{v&&D({...b,widgets:k.map(t=>t.id===v?{...t,...e}:t)})},[b,k,v,D]);(0,n.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{if(!i){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),T();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),E();return}if((e.key===`Delete`||e.key===`Backspace`)&&v){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),M(v)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,T,E,v,M]);let F=(0,n.useCallback)(()=>{o&&o(b)},[b,o]),I=(0,n.useCallback)(()=>{g.current?.click()},[]),L=(0,n.useCallback)(e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{try{let e=JSON.parse(n.result);e&&e.type===`dashboard`&&(D(e),s?.(e))}catch{}},n.readAsText(t),e.target.value=``},[D,s]);return(0,O.jsxs)(`div`,{ref:h,tabIndex:0,"data-testid":`dashboard-editor`,className:ot(`flex flex-col gap-4 outline-none`,a),children:[(0,O.jsx)(`input`,{ref:g,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`dashboard-import-input`,onChange:L}),A&&!p&&(0,O.jsx)(dt,{widget:A,readOnly:i,onChange:P,onClose:()=>y(null)}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[u(`appDesigner.addWidget`),`:`]}),st.map(({type:e,label:t,Icon:n})=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>j(e),disabled:i||p,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(n,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-undo`,onClick:T,disabled:!S,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":u(`appDesigner.undo`),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-redo`,onClick:E,disabled:!C,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":u(`appDesigner.redo`),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})})]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-export`,onClick:F,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":u(`appDesigner.navExportSchema`),children:(0,O.jsx)(r.Download,{className:`h-4 w-4`})}),!i&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-import`,onClick:I,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":u(`appDesigner.navImportSchema`),children:(0,O.jsx)(r.Upload,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-preview-toggle`,onClick:()=>m(e=>!e),className:ot(`rounded p-1.5 transition-colors`,p?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":u(p?`appDesigner.modeEdit`:`appDesigner.preview`),children:p?(0,O.jsx)(r.EyeOff,{className:`h-4 w-4`}):(0,O.jsx)(r.Eye,{className:`h-4 w-4`})})]})]}),p?(0,O.jsx)(ft,{schema:b}):k.length===0?(0,O.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:u(`appDesigner.noWidgets`)}):(0,O.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${b.columns??2}, 1fr)`},children:k.map((e,t)=>(0,O.jsx)(ut,{widget:e,index:t,total:k.length,selected:e.id===v,readOnly:i,onSelect:()=>y(e.id??null),onRemove:()=>M(e.id),onMoveUp:()=>N(e.id,`up`),onMoveDown:()=>N(e.id,`down`)},e.id))})]})]})}function mt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var ht=[{type:`grid`,label:`Data Grid`,Icon:r.Table2},{type:`kanban`,label:`Kanban Board`,Icon:r.Kanban},{type:`calendar`,label:`Calendar`,Icon:r.CalendarDays},{type:`gallery`,label:`Gallery`,Icon:r.GalleryHorizontalEnd},{type:`dashboard`,label:`Dashboard`,Icon:r.BarChart3},{type:`form`,label:`Form`,Icon:r.FileText},{type:`layout-grid`,label:`Grid Layout`,Icon:r.LayoutGrid}],gt=[{value:`page`,labelKey:`appDesigner.modePage`},{value:`dashboard`,labelKey:`appDesigner.modeDashboard`}],_t=0;function vt(){return _t+=1,`component_${Date.now()}_${_t}`}function yt({component:e,index:t,total:n,selected:i,readOnly:a,onSelect:o,onRemove:s,onMoveUp:c,onMoveDown:l}){let u=ht.find(t=>t.type===e.type)||ht[0];return(0,O.jsxs)(`div`,{"data-testid":`canvas-component-${e.id}`,onClick:o,className:mt(`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:[(0,O.jsx)(r.GripVertical,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300`}),(0,O.jsx)(u.Icon,{className:`h-5 w-5 shrink-0 text-gray-500`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-2 text-[10px] text-gray-400`,children:u.label})]}),!a&&(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove component`,"data-testid":`canvas-component-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]})}function bt({component:e,readOnly:t,onChange:n,onClose:i}){let{t:a}=Z();return(0,O.jsxs)(`div`,{"data-testid":`component-property-panel`,className:`w-64 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:a(`appDesigner.componentProperties`)}),(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`component-label`,className:`text-xs font-medium text-gray-600`,children:`Label`}),(0,O.jsx)(`input`,{id:`component-label`,"data-testid":`component-prop-label`,type:`text`,value:e.label,onChange:e=>n({label:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,O.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600`,children:ht.find(t=>t.type===e.type)?.label??e.type})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`ID`}),(0,O.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-xs font-mono text-gray-500`,children:e.id})]})]})}function xt({schema:e,components:t}){let{t:n}=Z();return(0,O.jsxs)(`div`,{"data-testid":`page-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,O.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||n(`appDesigner.pagePreview`)}),t.length===0?(0,O.jsx)(`div`,{className:`text-xs text-gray-400`,children:n(`appDesigner.noComponentsPreview`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=ht.find(t=>t.type===e.type)||ht[0];return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2`,children:[(0,O.jsx)(t.Icon,{className:`h-4 w-4 text-gray-400`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.label}),(0,O.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function St({schema:e,onChange:t,readOnly:i=!1,className:a,onExport:o,onImport:s}){let{t:c}=Z(),l=(0,n.useRef)(null),u=(0,n.useRef)(null),[d,f]=(0,n.useState)(()=>(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`existing_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}))),[p,m]=(0,n.useState)(null),[h,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)(`page`),y=d.find(e=>e.id===p),{canUndo:b,canRedo:S,push:C,undo:w,redo:T}=x(d),E=(0,n.useCallback)(n=>{f(n),C(n),t({...e,children:n.map(e=>({type:e.type,id:e.id,title:e.label,...e.props}))})},[e,t,C]),D=(0,n.useCallback)(e=>{let t=vt(),n={id:t,type:e,label:ht.find(t=>t.type===e)?.label||e};E([...d,n]),m(t)},[d,E]),k=(0,n.useCallback)(e=>{E(d.filter(t=>t.id!==e)),p===e&&m(null)},[d,p,E]),A=(0,n.useCallback)((e,t)=>{let n=d.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=d.length)return;let i=[...d];[i[n],i[r]]=[i[r],i[n]],E(i)},[d,E]),j=(0,n.useCallback)(e=>{p&&E(d.map(t=>t.id===p?{...t,...e}:t))},[d,p,E]);(0,n.useEffect)(()=>{let e=l.current;if(!e)return;let t=e=>{if(!i){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),w();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),T();return}if((e.key===`Delete`||e.key===`Backspace`)&&p){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),k(p)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,w,T,p,k]);let M=(0,n.useCallback)(()=>{o&&o(e)},[e,o]),N=(0,n.useCallback)(()=>{u.current?.click()},[]),P=(0,n.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let e=JSON.parse(r.result);if(e&&e.type===`page`){let n=(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`imported_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}));f(n),C(n),t(e),s?.(e)}}catch{}},r.readAsText(n),e.target.value=``},[t,C,s]);return(0,O.jsxs)(`div`,{ref:l,tabIndex:0,"data-testid":`page-canvas-editor`,className:mt(`flex flex-col gap-4 outline-none sm:flex-row`,a),children:[(0,O.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`canvas-import-input`,onChange:P}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-2 border-b border-gray-200 pb-2`,role:`tablist`,children:gt.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`tab`,"data-testid":`canvas-mode-${e.value}`,"aria-selected":_===e.value,onClick:()=>v(e.value),className:mt(`rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors`,_===e.value?`border-b-2 border-blue-500 text-blue-600`:`text-gray-500 hover:text-gray-700`),children:c(e.labelKey)},e.value))}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[c(`appDesigner.addComponent`),`:`]}),ht.map(({type:e,label:t,Icon:n})=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`canvas-add-${e}`,onClick:()=>D(e),disabled:i||h,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(n,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-undo`,onClick:w,disabled:!b,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.undo`),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-redo`,onClick:T,disabled:!S,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.redo`),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})})]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-export`,onClick:M,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navExportSchema`),children:(0,O.jsx)(r.Download,{className:`h-4 w-4`})}),!i&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-import`,onClick:N,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navImportSchema`),children:(0,O.jsx)(r.Upload,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-preview-toggle`,onClick:()=>g(e=>!e),className:mt(`rounded p-1.5 transition-colors`,h?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":c(h?`appDesigner.modeEdit`:`appDesigner.preview`),children:h?(0,O.jsx)(r.EyeOff,{className:`h-4 w-4`}):(0,O.jsx)(r.Eye,{className:`h-4 w-4`})})]})]}),h?(0,O.jsx)(xt,{schema:e,components:d}):d.length===0?(0,O.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:c(`appDesigner.emptyPage`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:d.map((e,t)=>(0,O.jsx)(yt,{component:e,index:t,total:d.length,selected:e.id===p,readOnly:i,onSelect:()=>m(e.id),onRemove:()=>k(e.id),onMoveUp:()=>A(e.id,`up`),onMoveDown:()=>A(e.id,`down`)},e.id))})]}),y&&!h&&(0,O.jsx)(bt,{component:y,readOnly:i,onChange:j,onClose:()=>m(null)})]})}function Ct(...e){return(0,a.twMerge)((0,i.clsx)(e))}var wt={grid:{label:`Grid`,Icon:r.LayoutGrid},kanban:{label:`Kanban`,Icon:r.Kanban},calendar:{label:`Calendar`,Icon:r.CalendarDays},gallery:{label:`Gallery`,Icon:r.GalleryHorizontalEnd},timeline:{label:`Timeline`,Icon:r.Clock},map:{label:`Map`,Icon:r.Map},gantt:{label:`Gantt`,Icon:r.GanttChart}},Tt=[{value:`compact`,label:`Compact`},{value:`medium`,label:`Medium`},{value:`tall`,label:`Tall`}];function Et({title:e,icon:t,defaultOpen:i=!0,children:a}){let[o,s]=(0,n.useState)(i);return(0,O.jsxs)(`div`,{className:`border-b border-gray-100 pb-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex w-full items-center gap-2 py-2 text-left`,children:[t,(0,O.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase text-gray-500`,children:e}),o?(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5 text-gray-400`}):(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5 text-gray-400`})]}),o&&(0,O.jsx)(`div`,{className:`space-y-2`,children:a})]})}function Dt({config:e,onChange:t,availableViewTypes:i=[`grid`,`kanban`,`calendar`,`gallery`,`timeline`,`map`,`gantt`],readOnly:a=!1,className:o}){let s=(0,n.useCallback)(n=>{t({...e,...n})},[e,t]),c=(0,n.useCallback)(t=>{s({columns:e.columns.map(e=>e.name===t?{...e,visible:!e.visible}:e)})},[e,s]),l=(0,n.useCallback)((t,n)=>{let r=[...e.columns],i=r.findIndex(e=>e.name===t);if(i<0)return;let a=n===`up`?i-1:i+1;a<0||a>=r.length||([r[i],r[a]]=[r[a],r[i]],s({columns:r}))},[e,s]),u=(0,n.useMemo)(()=>e.columns.filter(e=>e.visible).length,[e.columns]);return(0,O.jsxs)(`div`,{"data-testid":`object-view-configurator`,className:Ct(`w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4`,o),children:[(0,O.jsx)(Et,{title:`View Type`,icon:(0,O.jsx)(r.LayoutGrid,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(t=>{let{label:n,Icon:r}=wt[t];return(0,O.jsxs)(`button`,{type:`button`,"data-testid":`view-type-${t}`,onClick:()=>s({viewType:t}),disabled:a,className:Ct(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors`,e.viewType===t?`bg-blue-100 text-blue-700`:`text-gray-600 hover:bg-gray-100`,a&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(r,{className:`h-3 w-3`}),n]},t)})})}),(0,O.jsx)(Et,{title:`Fields (${u}/${e.columns.length})`,icon:(0,O.jsx)(r.Columns3,{className:`h-3.5 w-3.5 text-gray-500`}),children:e.columns.length===0?(0,O.jsx)(`p`,{className:`text-xs text-gray-400`,children:`No fields configured.`}):(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:e.columns.map((t,n)=>(0,O.jsxs)(`li`,{"data-testid":`view-column-${t.name}`,className:`flex items-center gap-1.5 rounded px-1.5 py-1 text-xs hover:bg-gray-50`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(t.name),disabled:a,className:Ct(`rounded p-0.5 transition-colors`,t.visible?`text-blue-500`:`text-gray-300`),"aria-label":t.visible?`Hide field`:`Show field`,children:t.visible?(0,O.jsx)(r.Eye,{className:`h-3 w-3`}):(0,O.jsx)(r.EyeOff,{className:`h-3 w-3`})}),(0,O.jsx)(`span`,{className:`flex-1 truncate text-gray-700`,children:t.label}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(t.name,`up`),disabled:a||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(t.name,`down`),disabled:a||n===e.columns.length-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`})})]},t.name))})}),(0,O.jsx)(Et,{title:`Toolbar`,icon:(0,O.jsx)(r.Filter,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showSearch,onChange:e=>s({showSearch:e.target.checked}),disabled:a,"data-testid":`view-toggle-search`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Search`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showFilters,onChange:e=>s({showFilters:e.target.checked}),disabled:a,"data-testid":`view-toggle-filters`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Filters`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showSort,onChange:e=>s({showSort:e.target.checked}),disabled:a,"data-testid":`view-toggle-sort`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Sort`})]})]})}),(0,O.jsx)(Et,{title:`Appearance`,icon:(0,O.jsx)(r.Settings2,{className:`h-3.5 w-3.5 text-gray-500`}),defaultOpen:!1,children:(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-[10px] font-medium text-gray-500`,children:`Row Height`}),(0,O.jsx)(`div`,{className:`flex gap-1`,children:Tt.map(({value:t,label:n})=>(0,O.jsx)(`button`,{type:`button`,"data-testid":`view-row-height-${t}`,onClick:()=>s({rowHeight:t}),disabled:a,className:Ct(`flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors`,e.rowHeight===t?`bg-blue-100 text-blue-700`:`bg-gray-50 text-gray-500 hover:bg-gray-100`),children:n},t))})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.striped,onChange:e=>s({striped:e.target.checked}),disabled:a,"data-testid":`view-toggle-striped`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Striped Rows`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.bordered,onChange:e=>s({bordered:e.target.checked}),disabled:a,"data-testid":`view-toggle-bordered`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Bordered`})]})]})})]})}function $(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Ot=[{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`}],kt=[`Inter`,`Roboto`,`Open Sans`,`Lato`,`Montserrat`,`Poppins`,`Source Sans Pro`,`Noto Sans`,`system-ui`];function At({branding:e,onChange:t,appTitle:i=`My App`,readOnly:a=!1,className:o,onExport:s,onImport:c}){let{t:l}=Z(),[u,d]=(0,n.useState)(`light`),{current:f,push:p,canUndo:m,canRedo:h,undo:g,redo:_}=x(e),v=(0,n.useRef)(!0);(0,n.useEffect)(()=>{if(v.current){v.current=!1;return}t(f)},[f]);let y=(0,n.useCallback)(e=>{let n={...f,...e};v.current=!0,p(n),t(n)},[f,p,t]),b=(0,n.useCallback)(()=>{if(s){s(f);return}let e=new Blob([JSON.stringify(f,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`branding.json`,n.click(),URL.revokeObjectURL(t)},[f,s]),S=(0,n.useCallback)(()=>{if(c){c(f);return}let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);if(typeof n==`object`&&n){let e={...f,...n};p(e),t(e)}}catch{}},r.readAsText(n)},e.click()},[f,p,t,c]),C=(0,n.useCallback)(e=>{a||((e.ctrlKey||e.metaKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?_():g()),(e.ctrlKey||e.metaKey)&&e.key===`y`&&(e.preventDefault(),_()))},[a,g,_]),w=f.primaryColor||`#3b82f6`,T=u===`dark`;return(0,O.jsxs)(`div`,{"data-testid":`branding-editor`,className:$(`flex flex-col gap-4 sm:gap-6`,o),onKeyDown:C,tabIndex:0,children:[(0,O.jsxs)(`div`,{"data-testid":`branding-editor-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800 mr-auto`,children:l(`appDesigner.brandingEditor`)}),(0,O.jsxs)(`button`,{"data-testid":`branding-undo`,type:`button`,onClick:g,disabled:!m||a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,m&&!a?`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:l(`appDesigner.undo`),children:[(0,O.jsx)(r.Undo2,{className:`h-3.5 w-3.5`}),l(`appDesigner.undo`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-redo`,type:`button`,onClick:_,disabled:!h||a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,h&&!a?`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:l(`appDesigner.redo`),children:[(0,O.jsx)(r.Redo2,{className:`h-3.5 w-3.5`}),l(`appDesigner.redo`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-export`,type:`button`,onClick:b,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:l(`appDesigner.brandingExport`),children:[(0,O.jsx)(r.Download,{className:`h-3.5 w-3.5`}),l(`appDesigner.brandingExport`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-import`,type:`button`,onClick:S,disabled:a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,a?`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:l(`appDesigner.brandingImport`),children:[(0,O.jsx)(r.Upload,{className:`h-3.5 w-3.5`}),l(`appDesigner.brandingImport`)]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:gap-6`,children:[(0,O.jsxs)(`div`,{className:`flex-1 space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-logo`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.logoUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Image,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-logo`,"data-testid":`branding-logo-input`,type:`text`,value:f.logo??``,onChange:e=>y({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-color`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.primaryColor`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(r.Palette,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-color`,"data-testid":`branding-color-input`,type:`text`,value:f.primaryColor??`#3b82f6`,onChange:e=>y({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,O.jsx)(`input`,{"data-testid":`branding-color-picker`,type:`color`,value:w,onChange:e=>y({primaryColor:e.target.value}),disabled:a,className:`h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:l(`appDesigner.colorPalette`)}),(0,O.jsx)(`div`,{"data-testid":`branding-color-palette`,className:`flex flex-wrap gap-1.5`,children:Ot.map(e=>(0,O.jsx)(`button`,{"data-testid":`branding-swatch-${e.hex.slice(1)}`,type:`button`,onClick:()=>!a&&y({primaryColor:e.hex}),disabled:a,className:$(`h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed`,w===e.hex?`border-gray-800 ring-2 ring-offset-1 ring-gray-400`:`border-transparent`),style:{backgroundColor:e.hex},title:e.name},e.hex))})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-favicon`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.faviconUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Globe,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:f.favicon??``,onChange:e=>y({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-font`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.fontFamily`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Type,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsxs)(`select`,{id:`be-font`,"data-testid":`branding-font-select`,value:f.fontFamily??``,onChange:e=>y({fontFamily:e.target.value||void 0}),disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none`,children:[(0,O.jsx)(`option`,{value:``,children:l(`appDesigner.fontDefault`)}),kt.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:l(`appDesigner.brandingPreview`)}),(0,O.jsxs)(`div`,{"data-testid":`branding-mode-toggle`,className:`flex rounded-md border border-gray-300 overflow-hidden`,children:[(0,O.jsxs)(`button`,{"data-testid":`branding-mode-light`,type:`button`,onClick:()=>d(`light`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,u===`light`?`bg-blue-50 text-blue-700`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,O.jsx)(r.Sun,{className:`h-3.5 w-3.5`}),l(`appDesigner.modeLight`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-mode-dark`,type:`button`,onClick:()=>d(`dark`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,u===`dark`?`bg-gray-800 text-gray-100`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,O.jsx)(r.Moon,{className:`h-3.5 w-3.5`}),l(`appDesigner.modeDark`)]})]})]}),(0,O.jsxs)(`div`,{"data-testid":`branding-preview`,className:$(`rounded-lg border p-4 transition-colors`,T?`border-gray-700 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-800`),style:{fontFamily:f.fontFamily||`inherit`},children:[(0,O.jsx)(`div`,{className:`rounded-md p-3 mb-3`,style:{backgroundColor:w},children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[f.logo?(0,O.jsx)(`img`,{src:f.logo,alt:`Logo`,className:`h-8 w-8 rounded object-contain bg-white/20`}):(0,O.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white`,children:`Logo`}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-white`,children:i})]})}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:w}}),(0,O.jsx)(`span`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:w})]}),(0,O.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:l(`appDesigner.brandingSampleButton`)}),(0,O.jsx)(`p`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:l(`appDesigner.brandingSampleText`)}),f.favicon&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`img`,{src:f.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,O.jsx)(`span`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:`Favicon`})]}),f.fontFamily&&(0,O.jsxs)(`div`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:[l(`appDesigner.fontFamily`),`: `,f.fontFamily]})]})]}),(0,O.jsxs)(`div`,{"data-testid":`branding-preview-mobile`,className:$(`mx-auto w-48 rounded-xl border-2 p-2 transition-colors`,T?`border-gray-700 bg-gray-900`:`border-gray-300 bg-white`),style:{fontFamily:f.fontFamily||`inherit`},children:[(0,O.jsx)(`div`,{className:`text-center text-[10px] font-medium text-gray-400 mb-1`,children:l(`appDesigner.mobilePreview`)}),(0,O.jsx)(`div`,{className:`rounded-md p-2 mb-1`,style:{backgroundColor:w},children:(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[f.logo?(0,O.jsx)(`img`,{src:f.logo,alt:`Logo`,className:`h-4 w-4 rounded object-contain bg-white/20`}):(0,O.jsx)(`div`,{className:`flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white`,children:`L`}),(0,O.jsx)(`span`,{className:`text-[9px] font-semibold text-white truncate`,children:i})]})}),(0,O.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,O.jsx)(`div`,{className:$(`h-2 w-3/4 rounded`,T?`bg-gray-700`:`bg-gray-200`)}),(0,O.jsx)(`div`,{className:$(`h-2 w-1/2 rounded`,T?`bg-gray-700`:`bg-gray-200`)}),(0,O.jsx)(`div`,{className:$(`h-2 w-2/3 rounded`,T?`bg-gray-700`:`bg-gray-200`)})]})]})]})]})]})}function jt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Mt=[`Custom Objects`,`System Objects`,`Integration`,`Analytics`],Nt=[`Box`,`Database`,`Users`,`FileText`,`Settings`,`ShoppingCart`,`Calendar`,`Mail`,`Briefcase`,`Building`,`Globe`,`Heart`,`Star`,`Tag`,`Bookmark`,`Folder`,`Archive`,`Package`,`Truck`,`CreditCard`];function Pt({objects:e,onObjectsChange:i,onSelectObject:a,showSystemObjects:o=!0,readOnly:s=!1,className:u}){let{t:d}=Z(),f=S(),[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),_=(0,n.useMemo)(()=>o?e:e.filter(e=>!e.isSystem),[e,o]),v=(0,n.useMemo)(()=>new t.ValueDataSource({items:_}),[_]),y=(0,n.useMemo)(()=>[{field:`name`,label:d(`appDesigner.objectManager.objectName`),width:160},{field:`label`,label:d(`appDesigner.objectManager.objectLabel`),width:160},{field:`group`,label:d(`appDesigner.objectManager.group`),width:130},{field:`fieldCount`,label:`Fields`,width:80},{field:`enabled`,label:d(`appDesigner.objectManager.enabled`),width:80}],[d]),b=(0,n.useMemo)(()=>({type:`object-grid`,objectName:`object_definition`,columns:y,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:s?void 0:{create:!0,update:!0,delete:!0}}),[y,s]),x=(0,n.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&a?.(n)},[e,a]),C=(0,n.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&(g(n),m(!0))},[e]),w=(0,n.useCallback)(async t=>{let n=e.find(e=>e.name===t.name);!n||n.isSystem||await f.confirm(d(`appDesigner.objectManager.deleteConfirmTitle`),d(`appDesigner.objectManager.deleteConfirmMessage`))&&i?.(e.filter(e=>e.id!==n.id))},[e,i,f,d]),T=(0,n.useCallback)(()=>{g(null),m(!0)},[]),E=(0,n.useCallback)(t=>{if(h){let n={...h,name:String(t.name||h.name),label:String(t.label||h.label),pluralLabel:t.pluralLabel?String(t.pluralLabel):void 0,description:t.description?String(t.description):void 0,icon:t.icon?String(t.icon):void 0,group:t.group?String(t.group):void 0,sortOrder:typeof t.sortOrder==`number`?t.sortOrder:void 0,enabled:t.enabled!==!1};i?.(e.map(e=>e.id===h.id?n:e))}else{let n={id:`obj_${Date.now()}`,name:String(t.name||`new_object_${e.length+1}`),label:String(t.label||`New Object ${e.length+1}`),pluralLabel:t.pluralLabel?String(t.pluralLabel):void 0,description:t.description?String(t.description):void 0,icon:t.icon?String(t.icon):void 0,group:t.group?String(t.group):void 0,sortOrder:typeof t.sortOrder==`number`?t.sortOrder:void 0,isSystem:!1,enabled:t.enabled!==!1,fieldCount:0};i?.([...e,n])}m(!1),g(null)},[h,e,i]),D=(0,n.useCallback)(e=>{e||(m(!1),g(null))},[]),k=(0,n.useMemo)(()=>({type:`object-form`,formType:`modal`,objectName:`object_definition`,mode:h?`edit`:`create`,title:h?`${d(`common.edit`)} — ${h.label}`:d(`appDesigner.objectManager.addObject`),open:p,onOpenChange:D,modalSize:`lg`,customFields:[{name:`name`,label:d(`appDesigner.objectManager.objectName`),type:`text`,required:!0,placeholder:`api_name`,disabled:s||(h?.isSystem??!1)},{name:`label`,label:d(`appDesigner.objectManager.objectLabel`),type:`text`,required:!0,placeholder:`Display Name`,disabled:s},{name:`pluralLabel`,label:d(`appDesigner.objectManager.pluralLabel`),type:`text`,placeholder:`Display Names`,disabled:s},{name:`description`,label:d(`appDesigner.appDescription`),type:`textarea`,disabled:s},{name:`icon`,label:d(`appDesigner.objectManager.icon`),type:`select`,options:Nt.map(e=>({label:e,value:e})),disabled:s},{name:`group`,label:d(`appDesigner.objectManager.group`),type:`select`,options:Mt.map(e=>({label:e,value:e})),disabled:s},{name:`sortOrder`,label:d(`appDesigner.objectManager.sortOrder`),type:`number`,disabled:s},{name:`enabled`,label:d(`appDesigner.objectManager.enabled`),type:`boolean`,disabled:s}],initialValues:h?{name:h.name,label:h.label,pluralLabel:h.pluralLabel||``,description:h.description||``,icon:h.icon||``,group:h.group||``,sortOrder:h.sortOrder??0,enabled:h.enabled!==!1}:{enabled:!0},onSuccess:E,onCancel:()=>D(!1),readOnly:s}),[h,p,D,E,s,d]);return(0,O.jsxs)(`div`,{"data-testid":`object-manager`,className:jt(`w-full space-y-3`,u),children:[(0,O.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.Database,{className:`h-4 w-4 text-primary`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:d(`appDesigner.objectManager.title`)}),(0,O.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:_.length})]})}),(0,O.jsx)(c.ObjectGrid,{schema:b,dataSource:v,onRowClick:x,onEdit:s?void 0:C,onDelete:s?void 0:w,onAddRecord:s?void 0:T}),p&&(0,O.jsx)(l.ModalForm,{schema:k}),(0,O.jsx)(A,{isOpen:f.isOpen,title:f.title,message:f.message,confirmLabel:d(`common.delete`),cancelLabel:d(`common.cancel`),onConfirm:f.onConfirm,onCancel:f.onCancel,destructive:!0})]})}function Ft(...e){return(0,a.twMerge)((0,i.clsx)(e))}var It={text:{label:`Text`,Icon:r.Type},textarea:{label:`Text Area`,Icon:r.FileText},number:{label:`Number`,Icon:r.Hash},boolean:{label:`Checkbox`,Icon:r.ToggleLeft},date:{label:`Date`,Icon:r.Calendar},datetime:{label:`Date/Time`,Icon:r.Calendar},time:{label:`Time`,Icon:r.Calendar},select:{label:`Picklist`,Icon:r.ListOrdered},email:{label:`Email`,Icon:r.AtSign},phone:{label:`Phone`,Icon:r.Phone},url:{label:`URL`,Icon:r.Globe},password:{label:`Password`,Icon:r.Lock},currency:{label:`Currency`,Icon:r.Hash},percent:{label:`Percent`,Icon:r.Hash},lookup:{label:`Lookup`,Icon:r.Link2},formula:{label:`Formula`,Icon:r.Code},autonumber:{label:`Auto Number`,Icon:r.Hash},file:{label:`File`,Icon:r.FileText},image:{label:`Image`,Icon:r.Image},markdown:{label:`Markdown`,Icon:r.FileText},html:{label:`Rich Text`,Icon:r.FileText},color:{label:`Color`,Icon:r.Palette},code:{label:`Code`,Icon:r.Code},location:{label:`Location`,Icon:r.MapPin},address:{label:`Address`,Icon:r.MapPin},rating:{label:`Rating`,Icon:r.Star},slider:{label:`Slider`,Icon:r.SlidersHorizontal}},Lt={text:[`text`,`textarea`,`email`,`phone`,`url`,`password`,`markdown`,`html`],number:[`number`,`currency`,`percent`,`autonumber`,`rating`,`slider`],date:[`date`,`datetime`,`time`],choice:[`boolean`,`select`],relation:[`lookup`],advanced:[`formula`,`file`,`image`,`color`,`code`,`location`,`address`]},Rt=[`text`,`number`,`date`,`choice`,`relation`,`advanced`];function zt({objectName:e,fields:i,onFieldsChange:a,readOnly:o=!1,className:s}){let{t:u}=Z(),d=S(),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),[g,_]=(0,n.useState)(``),v=(0,n.useMemo)(()=>g?i.filter(e=>e.type===g):i,[i,g]),y=(0,n.useMemo)(()=>new t.ValueDataSource({items:v}),[v]),b=(0,n.useMemo)(()=>[{field:`name`,label:u(`appDesigner.fieldDesigner.fieldName`),width:140},{field:`label`,label:u(`appDesigner.fieldDesigner.fieldLabel`),width:160},{field:`type`,label:u(`appDesigner.fieldDesigner.fieldType`),width:100},{field:`required`,label:u(`appDesigner.fieldDesigner.required`),width:80},{field:`unique`,label:u(`appDesigner.fieldDesigner.unique`),width:80},{field:`group`,label:u(`appDesigner.fieldDesigner.fieldGroup`),width:120}],[u]),x=(0,n.useMemo)(()=>({type:`object-grid`,objectName:`field_definition`,columns:b,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:o?void 0:{create:!0,update:!0,delete:!0}}),[b,o]),C=(0,n.useCallback)(e=>{let t=i.find(t=>t.name===e.name);t&&(h(t),p(!0))},[i]),w=(0,n.useCallback)(async e=>{let t=i.find(t=>t.name===e.name);!t||t.isSystem||await d.confirm(u(`appDesigner.fieldDesigner.deleteConfirmTitle`),u(`appDesigner.fieldDesigner.deleteConfirmMessage`))&&a?.(i.filter(e=>e.id!==t.id))},[i,a,d,u]),T=(0,n.useCallback)(()=>{h(null),p(!0)},[]),E=(0,n.useCallback)(e=>{if(m){let t={...m,name:String(e.name||m.name),label:String(e.label||m.label),type:e.type||m.type,group:e.group?String(e.group):void 0,description:e.description?String(e.description):void 0,required:e.required===!0,unique:e.unique===!0,readonly:e.readonly===!0,hidden:e.hidden===!0,indexed:e.indexed===!0,externalId:e.externalId===!0,trackHistory:e.trackHistory===!0,defaultValue:e.defaultValue?String(e.defaultValue):void 0,placeholder:e.placeholder?String(e.placeholder):void 0,referenceTo:e.referenceTo?String(e.referenceTo):void 0,formula:e.formula?String(e.formula):void 0};a?.(i.map(e=>e.id===m.id?t:e))}else{let t={id:`fld_${Date.now()}`,name:String(e.name||`new_field_${i.length+1}`),label:String(e.label||`New Field ${i.length+1}`),type:e.type||`text`,group:e.group?String(e.group):void 0,description:e.description?String(e.description):void 0,required:e.required===!0,unique:e.unique===!0,readonly:e.readonly===!0,hidden:e.hidden===!0,indexed:e.indexed===!0,externalId:e.externalId===!0,trackHistory:e.trackHistory===!0,defaultValue:e.defaultValue?String(e.defaultValue):void 0,placeholder:e.placeholder?String(e.placeholder):void 0,referenceTo:e.referenceTo?String(e.referenceTo):void 0,formula:e.formula?String(e.formula):void 0,isSystem:!1};a?.([...i,t])}p(!1),h(null)},[m,i,a]),D=(0,n.useCallback)(e=>{e||(p(!1),h(null))},[]),k=(0,n.useMemo)(()=>Rt.map(e=>({category:e,label:u(`appDesigner.fieldDesigner.typeCategory.${e}`),options:Lt[e].map(e=>({label:It[e].label,value:e}))})),[u]),j=(0,n.useMemo)(()=>k.flatMap(e=>e.options),[k]),M=(0,n.useMemo)(()=>({type:`object-form`,formType:`drawer`,objectName:`field_definition`,mode:m?`edit`:`create`,title:m?`${u(`common.edit`)} — ${m.label}`:u(`appDesigner.fieldDesigner.addField`),open:f,onOpenChange:D,drawerSide:`right`,drawerWidth:`480px`,sections:[{name:`basic`,label:u(`appDesigner.fieldDesigner.basicSection`),fields:[{name:`name`,label:u(`appDesigner.fieldDesigner.fieldName`),type:`text`,required:!0,placeholder:`api_name`,disabled:o||(m?.isSystem??!1)},{name:`label`,label:u(`appDesigner.fieldDesigner.fieldLabel`),type:`text`,required:!0,placeholder:`Display Label`,disabled:o},{name:`type`,label:u(`appDesigner.fieldDesigner.fieldType`),type:`select`,required:!0,options:j,disabled:o||(m?.isSystem??!1)},{name:`required`,label:u(`appDesigner.fieldDesigner.required`),type:`boolean`,disabled:o},{name:`unique`,label:u(`appDesigner.fieldDesigner.unique`),type:`boolean`,disabled:o},{name:`description`,label:u(`appDesigner.fieldDesigner.description`),type:`textarea`,disabled:o}]},{name:`typeSpecific`,label:u(`appDesigner.fieldDesigner.typeSpecificSection`),fields:[{name:`referenceTo`,label:u(`appDesigner.fieldDesigner.referenceTo`),type:`text`,placeholder:`Referenced object`,disabled:o,condition:{field:`type`,equals:`lookup`}},{name:`formula`,label:u(`appDesigner.fieldDesigner.formula`),type:`textarea`,placeholder:`e.g. price * quantity`,disabled:o,condition:{field:`type`,equals:`formula`}},{name:`defaultValue`,label:u(`appDesigner.fieldDesigner.defaultValue`),type:`text`,placeholder:`Default value`,disabled:o},{name:`placeholder`,label:u(`appDesigner.fieldDesigner.placeholder`),type:`text`,placeholder:`Placeholder text`,disabled:o},{name:`group`,label:u(`appDesigner.fieldDesigner.fieldGroup`),type:`text`,placeholder:`Field Group`,disabled:o}]},{name:`advanced`,label:u(`appDesigner.fieldDesigner.advancedSection`),collapsible:!0,collapsed:!0,fields:[{name:`indexed`,label:u(`appDesigner.fieldDesigner.indexed`),type:`boolean`,disabled:o},{name:`externalId`,label:u(`appDesigner.fieldDesigner.externalId`),type:`boolean`,disabled:o},{name:`trackHistory`,label:u(`appDesigner.fieldDesigner.trackHistory`),type:`boolean`,disabled:o},{name:`readonly`,label:u(`appDesigner.fieldDesigner.readOnly`),type:`boolean`,disabled:o},{name:`hidden`,label:u(`appDesigner.fieldDesigner.hidden`),type:`boolean`,disabled:o}]}],initialValues:m?{name:m.name,label:m.label,type:m.type,group:m.group||``,description:m.description||``,required:m.required||!1,unique:m.unique||!1,readonly:m.readonly||!1,hidden:m.hidden||!1,indexed:m.indexed||!1,externalId:m.externalId||!1,trackHistory:m.trackHistory||!1,defaultValue:m.defaultValue==null?``:String(m.defaultValue),placeholder:m.placeholder||``,referenceTo:m.referenceTo||``,formula:m.formula||``}:{type:`text`,required:!1,unique:!1},onSuccess:E,onCancel:()=>D(!1),readOnly:o}),[m,f,D,E,j,o,u]);return(0,O.jsxs)(`div`,{"data-testid":`field-designer`,className:Ft(`w-full space-y-3`,s),children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.Columns3,{className:`h-4 w-4 text-primary`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:u(`appDesigner.fieldDesigner.title`)}),e&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`— `,e]}),(0,O.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:v.length})]}),(0,O.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),"data-testid":`field-designer-type-filter`,className:`rounded-md border border-input bg-background px-2 py-1 text-xs outline-none transition-colors focus:border-primary focus:ring-1 focus:ring-primary`,children:[(0,O.jsx)(`option`,{value:``,children:u(`appDesigner.fieldDesigner.allTypes`)}),k.map(e=>(0,O.jsx)(`optgroup`,{label:e.label,children:e.options.map(e=>(0,O.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.category))]})]}),(0,O.jsx)(c.ObjectGrid,{schema:x,dataSource:y,onEdit:o?void 0:C,onDelete:o?void 0:w,onAddRecord:o?void 0:T}),f&&(0,O.jsx)(l.DrawerForm,{schema:M}),(0,O.jsx)(A,{isOpen:d.isOpen,title:d.title,message:d.message,confirmLabel:u(`common.delete`),cancelLabel:u(`common.cancel`),onConfirm:d.onConfirm,onCancel:d.onCancel,destructive:!0})]})}function Bt(...e){return(0,a.twMerge)((0,i.clsx)(e))}function Vt({versions:e,onRestore:t,className:n}){return(0,O.jsxs)(`div`,{className:Bt(`flex flex-col`,n),role:`region`,"aria-label":`Version history`,children:[(0,O.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,O.jsx)(r.History,{className:`h-4 w-4`}),`Version History`]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e.length===0?(0,O.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`No version history available`}):(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(`div`,{className:`absolute left-5 top-0 bottom-0 w-px bg-border`}),e.map(e=>(0,O.jsxs)(`div`,{className:Bt(`relative flex items-start gap-3 px-3 py-2 hover:bg-accent/50`,e.isCurrent&&`bg-accent/30`),children:[(0,O.jsx)(`div`,{className:Bt(`relative z-10 mt-1 h-2.5 w-2.5 rounded-full border-2 bg-background`,e.isCurrent?`border-primary`:`border-muted-foreground`)}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsxs)(`span`,{className:`font-medium`,children:[`v`,e.version]}),e.isCurrent&&(0,O.jsx)(`span`,{className:`px-1 py-0.5 rounded bg-primary/10 text-primary text-[0.6rem]`,children:`Current`})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[0.65rem] text-muted-foreground/70`,children:[(0,O.jsx)(r.User,{className:`h-2.5 w-2.5`}),(0,O.jsx)(`span`,{children:e.userName}),(0,O.jsx)(r.Clock,{className:`h-2.5 w-2.5 ml-1`}),(0,O.jsx)(`span`,{children:new Date(e.timestamp).toLocaleString()})]}),!e.isCurrent&&t&&(0,O.jsx)(`button`,{onClick:()=>t(e.version),className:`mt-1 text-[0.65rem] text-primary hover:underline`,children:`Restore this version`})]})]},e.version))]})})]})}var Ht=`objectui-app-wizard-draft`;function Ut(){let e=(0,u.useNavigate)(),{appName:t}=(0,u.useParams)(),{objects:r,refresh:i}=(0,s.useMetadata)(),a=(0,s.useAdapter)(),c=(r||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:!1})),l=(0,n.useCallback)(()=>{try{let e=localStorage.getItem(Ht);if(e)return JSON.parse(e)}catch{}},[]),f=(0,n.useCallback)(async t=>{try{let n=(0,o.wizardDraftToAppSchema)(t),r=a?.getClient();r&&await r.meta.saveItem(`app`,t.name,n),localStorage.removeItem(Ht),d.toast.success(`Application "${t.title}" created successfully`),await i?.(),e(`/apps/${t.name}`)}catch(e){d.toast.error(e?.message||`Failed to create application`)}},[e,i,a]),p=(0,n.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),m=(0,n.useCallback)(e=>{try{localStorage.setItem(Ht,JSON.stringify(e)),d.toast.info(`Draft saved`)}catch{}},[]);return(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`create-app-page`,children:(0,O.jsx)(qe,{availableObjects:c,initialDraft:l(),onComplete:f,onCancel:p,onSaveDraft:m})})}function Wt(){let e=(0,u.useNavigate)(),{appName:t,editAppName:r}=(0,u.useParams)(),{apps:i,objects:a,refresh:c}=(0,s.useMetadata)(),l=(0,s.useAdapter)(),f=r||t,p=i.find(e=>e.name===f),m=(a||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:p?.navigation?.some(t=>t.type===`object`&&t.objectName===e.name)??!1})),h=(0,n.useMemo)(()=>{if(p)return{name:p.name,title:p.title||p.label||``,description:p.description||``,icon:p.icon||``,layout:p.layout||`sidebar`,navigation:p.navigation||[],branding:{logo:p.branding?.logo||p.logo||``,primaryColor:p.branding?.primaryColor||`#3b82f6`,favicon:p.branding?.favicon||p.favicon||``}}},[p]),g=(0,n.useCallback)(async t=>{try{let n=(0,o.wizardDraftToAppSchema)(t),r={...p,...n},i=l?.getClient();i&&await i.meta.saveItem(`app`,t.name,r),d.toast.success(`Application "${t.title}" updated successfully`),await c?.(),e(`/apps/${t.name}`)}catch(e){d.toast.error(e?.message||`Failed to update application`)}},[e,c,l,p]),_=(0,n.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),v=(0,n.useCallback)(e=>{try{localStorage.setItem(`objectui-edit-draft-${f}`,JSON.stringify(e)),d.toast.info(`Draft saved`)}catch{}},[f]);return p?(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`edit-app-page`,children:(0,O.jsx)(qe,{availableObjects:m,initialDraft:h,onComplete:g,onCancel:_,onSaveDraft:v})}):(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4 text-center`,"data-testid":`edit-app-not-found`,children:(0,O.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Application "`,f,`" not found.`]})})}function Gt(){let e=(0,u.useNavigate)(),{pageName:t}=(0,u.useParams)(),i=(0,s.useAdapter)(),{pages:a}=(0,s.useMetadata)(),o=a?.find(e=>e.name===t),[c,l]=(0,n.useState)(()=>o||{type:`page`,name:t??``,title:t??``,children:[]}),f=(0,n.useRef)(c);f.current=c;let p=(0,n.useCallback)(async e=>{try{if(i)return await i.update(`sys_page`,t,e),!0}catch{}return!1},[i,t]),m=(0,n.useCallback)(async e=>{l(e),await p(e)},[p]);(0,n.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),p(f.current).then(e=>{e&&d.toast.success(`Page saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p]);let h=(0,n.useCallback)(e=>{let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t||`page`}.json`,i.click(),URL.revokeObjectURL(r),d.toast.success(`Page schema exported`)},[t]),g=(0,n.useCallback)(e=>{d.toast.success(`Page schema imported`),m(e)},[m]);return o?(0,O.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`page-design-page`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>e(-1),className:`rounded p-1.5 text-muted-foreground hover:text-foreground`,"aria-label":`Go back`,"data-testid":`page-design-back`,children:(0,O.jsx)(r.ArrowLeft,{className:`h-4 w-4`})}),(0,O.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Page: `,o.label||o.title||t]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(St,{schema:c,onChange:m,onExport:h,onImport:g})})]}):(0,O.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Page "`,t,`" not found`]})}function Kt(){let e=(0,u.useNavigate)(),{dashboardName:t}=(0,u.useParams)(),i=(0,s.useAdapter)(),{dashboards:a,refresh:o}=(0,s.useMetadata)(),c=a?.find(e=>e.name===t),[l,f]=(0,n.useState)(()=>c||{type:`dashboard`,name:t??``,title:t??``,columns:2,widgets:[]}),p=(0,n.useRef)(l);p.current=l;let m=(0,n.useCallback)(async e=>{try{if(i)return await i.update(`sys_dashboard`,t,e),o().catch(()=>{}),!0}catch{}return!1},[i,t,o]),h=(0,n.useCallback)(async e=>{f(e),await m(e)},[m]);(0,n.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),m(p.current).then(e=>{e&&d.toast.success(`Dashboard saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let g=(0,n.useCallback)(e=>{let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t||`dashboard`}.json`,i.click(),URL.revokeObjectURL(r),d.toast.success(`Dashboard schema exported`)},[t]),_=(0,n.useCallback)(e=>{d.toast.success(`Dashboard schema imported`),h(e)},[h]);return c?(0,O.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`dashboard-design-page`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>e(-1),className:`rounded p-1.5 text-muted-foreground hover:text-foreground`,"aria-label":`Go back`,"data-testid":`dashboard-design-back`,children:(0,O.jsx)(r.ArrowLeft,{className:`h-4 w-4`})}),(0,O.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Dashboard: `,c.label||c.title||t]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(pt,{schema:l,onChange:h,onExport:g,onImport:_})})]}):(0,O.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Dashboard "`,t,`" not found`]})}t.ComponentRegistry.register(`page-designer`,H,{label:`Page Designer`,category:`Designer`,inputs:[{name:`canvas`,type:`code`,label:`Canvas Configuration`},{name:`components`,type:`code`,label:`Components`},{name:`showComponentTree`,type:`boolean`,label:`Show Component Tree`,defaultValue:!0},{name:`undoRedo`,type:`boolean`,label:`Undo/Redo`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`data-model-designer`,W,{label:`Data Model Designer`,category:`Designer`,inputs:[{name:`entities`,type:`code`,label:`Entities`},{name:`relationships`,type:`code`,label:`Relationships`},{name:`autoLayout`,type:`boolean`,label:`Auto Layout`,defaultValue:!1},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`process-designer`,se,{label:`Process Designer (BPMN)`,category:`Designer`,inputs:[{name:`processName`,type:`string`,label:`Process Name`},{name:`nodes`,type:`code`,label:`Nodes`},{name:`edges`,type:`code`,label:`Edges`},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`report-designer`,ue,{label:`Report Designer`,category:`Designer`,inputs:[{name:`reportName`,type:`string`,label:`Report Name`},{name:`objectName`,type:`string`,label:`Data Source Object`},{name:`sections`,type:`code`,label:`Sections`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showPropertyPanel`,type:`boolean`,label:`Show Property Panel`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`app-creation-wizard`,qe,{label:`App Creation Wizard`,category:`Designer`,inputs:[{name:`availableObjects`,type:`code`,label:`Available Objects`},{name:`templates`,type:`code`,label:`Templates`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`navigation-designer`,nt,{label:`Navigation Designer`,category:`Designer`,inputs:[{name:`items`,type:`code`,label:`Navigation Items`},{name:`showPreview`,type:`boolean`,label:`Show Preview`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`dashboard-editor`,pt,{label:`Dashboard Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Dashboard Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`page-canvas-editor`,St,{label:`Page Canvas Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Page Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`object-view-configurator`,Dt,{label:`Object View Configurator`,category:`Designer`,inputs:[{name:`config`,type:`code`,label:`View Config`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`branding-editor`,At,{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}]}),t.ComponentRegistry.register(`object-manager`,Pt,{label:`Object Manager`,category:`Designer`,inputs:[{name:`objects`,type:`code`,label:`Object Definitions`},{name:`showSystemObjects`,type:`boolean`,label:`Show System Objects`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`field-designer`,zt,{label:`Field Designer`,category:`Designer`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`},{name:`fields`,type:`code`,label:`Field Definitions`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),e.AppCreationWizard=qe,e.BrandingEditor=At,e.CollaborationProvider=R,e.ConfirmDialog=A,e.ConnectionStatusIndicator=z,e.CreateAppPage=Ut,e.DashboardDesignPage=Kt,e.DashboardEditor=pt,e.DataModelDesigner=W,e.EditAppPage=Wt,e.EditorModeToggle=at,e.FieldDesigner=zt,e.Minimap=F,e.NavigationDesigner=nt,e.ObjectManager=Pt,e.ObjectViewConfigurator=Dt,e.PageCanvasEditor=St,e.PageDesignPage=Gt,e.PageDesigner=H,e.ProcessDesigner=se,e.PropertyEditor=M,e.ReportDesigner=ue,e.VersionHistory=Vt,e.useCanvasPanZoom=T,e.useClipboard=w,e.useConfirmDialog=S,e.useDesignerHistory=te,e.useMultiSelect=C,e.useUndoRedo=x});
6
+ <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),O=v(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=E():t.exports=D()}))();function k(...e){return(0,a.twMerge)((0,i.clsx)(e))}function A({isOpen:e,title:t,message:i,confirmLabel:a=`Delete`,cancelLabel:o=`Cancel`,destructive:s=!0,onConfirm:c,onCancel:l}){let u=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=u.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),e?(0,O.jsx)(`dialog`,{ref:u,className:`fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50`,onClose:l,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-message`,children:(0,O.jsxs)(`div`,{className:`w-80 p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[s&&(0,O.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10`,children:(0,O.jsx)(r.AlertTriangle,{className:`h-5 w-5 text-destructive`})}),(0,O.jsx)(`h2`,{id:`confirm-title`,className:`text-lg font-semibold`,children:t})]}),(0,O.jsx)(`p`,{id:`confirm-message`,className:`text-sm text-muted-foreground mb-6`,children:i}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{onClick:l,className:`px-4 py-2 text-sm rounded-md border hover:bg-accent`,children:o}),(0,O.jsx)(`button`,{onClick:c,className:k(`px-4 py-2 text-sm rounded-md font-medium`,s?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`),autoFocus:!0,children:a})]})]})}):null}function j(...e){return(0,a.twMerge)((0,i.clsx)(e))}function M({title:e=`Properties`,fields:t,onChange:i,className:a}){let[o,s]=(0,n.useState)(new Set),c=(0,n.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=t.reduce((e,t)=>{let n=t.group??`General`;return e[n]||(e[n]=[]),e[n].push(t),e},{});return(0,O.jsxs)(`div`,{className:j(`flex flex-col`,a),role:`region`,"aria-label":e,children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:e}),(0,O.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[Object.entries(l).map(([e,t])=>(0,O.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,O.jsxs)(`button`,{onClick:()=>c(e),className:`w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50`,children:[o.has(e)?(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}),e]}),!o.has(e)&&(0,O.jsx)(`div`,{className:`px-3 pb-2 space-y-2`,children:t.map(e=>(0,O.jsx)(N,{field:e,onChange:i},e.name))})]},e)),t.length===0&&(0,O.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`Select an element to edit its properties`})]})]})}function N({field:e,onChange:t}){let n=n=>{t(e.name,n)};return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:e.label}),e.type===`text`&&(0,O.jsx)(`input`,{type:`text`,value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`number`&&(0,O.jsx)(`input`,{type:`number`,value:Number(e.value??0),onChange:e=>n(Number(e.target.value)),className:`w-full px-2 py-1 text-xs border rounded bg-background`}),e.type===`boolean`&&(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:!!e.value,onChange:e=>n(e.target.checked),className:`rounded`}),(0,O.jsx)(`span`,{className:`text-xs`,children:e.value?`Yes`:`No`})]}),e.type===`select`&&(0,O.jsx)(`select`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background`,children:e.options?.map(e=>(0,O.jsx)(`option`,{value:e.value,children:e.label},e.value))}),e.type===`color`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`color`,value:String(e.value??`#000000`),onChange:e=>n(e.target.value),className:`h-6 w-6 rounded border cursor-pointer`}),(0,O.jsx)(`span`,{className:`text-xs font-mono`,children:String(e.value??`#000000`)})]}),e.type===`textarea`&&(0,O.jsx)(`textarea`,{value:String(e.value??``),onChange:e=>n(e.target.value),className:`w-full px-2 py-1 text-xs border rounded bg-background resize-y`,rows:3}),e.description&&(0,O.jsx)(`p`,{className:`text-[0.65rem] text-muted-foreground/70`,children:e.description})]})}function P(...e){return(0,a.twMerge)((0,i.clsx)(e))}function F({items:e,canvasWidth:t,canvasHeight:n,position:r=`bottom-right`,size:i=150,className:a}){let o=Math.min(i/t,i/n),s=t*o,c=n*o;return(0,O.jsx)(`div`,{className:P(`absolute border rounded bg-background/90 shadow-sm overflow-hidden`,{"top-left":`top-2 left-2`,"top-right":`top-2 right-2`,"bottom-left":`bottom-2 left-2`,"bottom-right":`bottom-2 right-2`}[r],a),role:`img`,"aria-label":`Canvas minimap`,children:(0,O.jsxs)(`svg`,{width:s,height:c,viewBox:`0 0 ${t} ${n}`,children:[(0,O.jsx)(`rect`,{width:t,height:n,fill:`hsl(var(--muted))`,opacity:`0.3`}),e.map(e=>(0,O.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:e.selected?`hsl(var(--primary))`:e.color??`hsl(var(--foreground) / 0.3)`,rx:`2`},e.id))]})})}function I(...e){return(0,a.twMerge)((0,i.clsx)(e))}var L=(0,n.createContext)(null);L.displayName=`CollaborationContext`;function R({config:e,user:t,onOperation:r,onPresenceChange:i,children:a}){let o=(0,n.useRef)(null),[s,c]=(0,n.useState)([]),[l,u]=(0,n.useState)(`disconnected`),d=(0,n.useRef)(0),f=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e.enabled||!t||!e.serverUrl||!(typeof WebSocket<`u`))return;function n(){let a;try{if(a=new URL(e.serverUrl),a.protocol!==`ws:`&&a.protocol!==`wss:`)return}catch{return}e.roomId&&a.searchParams.set(`room`,e.roomId),a.searchParams.set(`userId`,t.id),u(`connecting`);let s=new WebSocket(a.toString());s.onopen=()=>{u(`connected`),s.send(JSON.stringify({type:`join`,userId:t.id,userName:t.name,avatar:t.avatar}))},s.onmessage=e=>{try{let n=JSON.parse(e.data);if(n.type===`presence`){let e=n.users||[];c(e.filter(e=>e.userId!==t.id)),i?.(e)}else n.type===`operation`&&r?.(n.operation)}catch{}},s.onclose=()=>{u(`disconnected`),o.current=null,e.enabled&&(f.current=setTimeout(n,e.autoSaveInterval??3e3))},s.onerror=()=>{u(`error`)},o.current=s}return n(),()=>{f.current&&clearTimeout(f.current),o.current&&=(o.current.onclose=null,o.current.close(),null),u(`disconnected`)}},[e.enabled,e.serverUrl,e.roomId,e.autoSaveInterval,t,r,i]);let p=(0,n.useMemo)(()=>!e.enabled||!t?[]:[{userId:t.id,userName:t.name,avatar:t.avatar,color:B(t.id),status:`active`,lastActivity:new Date().toISOString()},...s],[e.enabled,t,s]),m=e.enabled&&!!t&&(e.serverUrl?l===`connected`:!0),h=(0,n.useCallback)(n=>{if(!e.enabled||!t)return;d.current+=1;let i={...n,id:`op-${Date.now()}-${d.current}`,userId:t.id,timestamp:new Date().toISOString(),version:d.current};o.current?.readyState===WebSocket.OPEN&&o.current.send(JSON.stringify({type:`operation`,operation:i})),r?.(i)},[e.enabled,t,r]),g=(0,n.useMemo)(()=>({users:p,isConnected:m,sendOperation:h,currentUserId:t?.id,connectionState:l,versionCount:d.current}),[p,m,h,t?.id,l]);return(0,O.jsx)(L.Provider,{value:g,children:a})}function ee(){return(0,n.useContext)(L)}function z({className:e}){let t=(0,n.useContext)(L);if(!t)return null;let{connectionState:r,users:i}=t,a={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:o,label:s}=a[r]??a.disconnected;return(0,O.jsxs)(`div`,{className:I(`flex items-center gap-2 text-xs`,e),role:`status`,"aria-live":`polite`,"aria-label":`Collaboration: ${s}`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${o}`}),(0,O.jsx)(`span`,{children:s}),r===`connected`&&i.length>1&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,i.length,` users)`]})]})}function B(e){let t=[`#3b82f6`,`#ef4444`,`#22c55e`,`#f59e0b`,`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f97316`,`#14b8a6`,`#f43f5e`,`#a855f7`,`#84cc16`,`#0ea5e9`,`#e879f9`,`#fb923c`,`#facc15`],n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t)|0;return t[Math.abs(n)%t.length]}function V(...e){return(0,a.twMerge)((0,i.clsx)(e))}function H({canvas:e={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:t=[],palette:i=U,showComponentTree:a=!0,undoRedo:o=!0,propertyEditor:s=!0,readOnly:c=!1,showMinimap:l=!1,onChange:u,className:d}){let f=x(t),p=f.current,m=(0,n.useCallback)(e=>{f.push(e),u?.(e)},[f,u]),h=T({initialZoom:e.zoom??1}),{zoom:g}=h,_=C(),v=(0,n.useMemo)(()=>{let e=Array.from(_.selectedIds);return e.length>0?e[0]:null},[_.selectedIds]),y=(0,n.useMemo)(()=>p.find(e=>e.id===v),[p,v]),b=w(),E=S(),D=ee(),k=(0,n.useCallback)(e=>{D&&D.sendOperation({...e,userId:D.currentUserId??``})},[D]),[j,N]=(0,n.useState)(!0),[P,I]=(0,n.useState)(!0),[L,R]=(0,n.useState)(l),z=(0,n.useRef)(null),B=(0,n.useRef)(null),H=(0,n.useCallback)(t=>!e.snapToGrid||!e.gridSize?t:Math.round(t/e.gridSize)*e.gridSize,[e.snapToGrid,e.gridSize]),te=(0,n.useCallback)((e,t)=>{if(c)return;let n=i.flatMap(e=>e.items).find(t=>t.type===e),r=n?.defaultSize,a={id:`comp-${Date.now()}`,type:e,label:t,position:{x:100,y:100,width:r?.width??200,height:r?.height??100},props:n?.defaultProps??{}};m([...p,a]),_.selectOne(a.id),k({type:`insert`,elementId:a.id,data:{component:a}})},[p,c,i,m,_,k]),ne=(0,n.useCallback)(e=>{c||(m(p.filter(t=>t.id!==e)),_.isSelected(e)&&_.clearSelection(),k({type:`delete`,elementId:e,data:{}}))},[p,c,m,_,k]),re=(0,n.useCallback)(async()=>{if(c||_.count===0||!await E.confirm(`Delete components`,`Are you sure you want to delete ${_.count} component${_.count>1?`s`:``}?`))return;let e=_.selectedIds;m(p.filter(t=>!e.has(t.id))),_.clearSelection(),e.forEach(e=>{k({type:`delete`,elementId:e,data:{}})})},[c,_,E,p,m,k]),ie=(0,n.useCallback)((e,t)=>{c||!v||(m(p.map(n=>n.id===v?e===`label`?{...n,label:String(t)}:e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,props:{...n.props,[e]:t}}:n)),k({type:`update`,elementId:v,data:{[e]:t}}))},[c,v,p,m,k]),W=(0,n.useCallback)(()=>{let e=_.selectedIds;if(e.size===0)return;let t=p.filter(t=>e.has(t.id));b.copy(t)},[_,p,b]),ae=(0,n.useCallback)(()=>{if(c)return;let e=b.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`comp-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}}));m([...p,...n]),_.selectMany(n.map(e=>e.id)),n.forEach(e=>{k({type:`insert`,elementId:e.id,data:{component:e}})})},[c,b,p,m,_,k]),G=(0,n.useCallback)((e,t)=>{c||(z.current={id:t.id,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[c]),K=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),oe=(0,n.useCallback)(e=>{e.preventDefault();let t=z.current;if(!t||c)return;let n=(e.clientX-t.startX)/g,r=(e.clientY-t.startY)/g;m(p.map(e=>e.id===t.id?{...e,position:{...e.position,x:H(e.position.x+n),y:H(e.position.y+r)}}:e)),k({type:`move`,elementId:t.id,data:{}}),z.current=null},[c,g,p,m,H,k]),se=(0,n.useMemo)(()=>y?[{name:`label`,label:`Label`,type:`text`,value:y.label??``,group:`General`},{name:`x`,label:`X`,type:`number`,value:y.position.x,group:`Position`},{name:`y`,label:`Y`,type:`number`,value:y.position.y,group:`Position`},{name:`width`,label:`Width`,type:`number`,value:y.position.width,group:`Size`},{name:`height`,label:`Height`,type:`number`,value:y.position.height,group:`Size`}]:[],[y]),q=(0,n.useMemo)(()=>p.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:typeof e.position.width==`number`?e.position.width:100,height:typeof e.position.height==`number`?e.position.height:50,selected:_.isSelected(e.id)})),[p,_]);return(0,n.useEffect)(()=>{let e=B.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&_.count>0&&!t){e.preventDefault(),re();return}if(e.key===`Escape`){_.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&o&&!c){e.preventDefault(),f.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&o&&!c){e.preventDefault(),f.redo();return}if(n&&e.key===`c`){e.preventDefault(),W();return}if(n&&e.key===`v`&&!c){e.preventDefault(),ae();return}if(n&&e.key===`a`){e.preventDefault(),_.selectMany(p.map(e=>e.id));return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[_,re,o,c,f,W,ae,p]),(0,O.jsxs)(`div`,{ref:B,tabIndex:0,className:V(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,d),children:[!c&&(0,O.jsx)(`div`,{className:V(`border-r bg-muted/30 flex flex-col transition-[width] duration-200`,j?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component palette`,children:j&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:`Components`}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:i.map(e=>(0,O.jsxs)(`div`,{className:`mb-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-2 py-1 uppercase`,children:e.label}),e.items.map(e=>(0,O.jsxs)(`button`,{onClick:()=>te(e.type,e.label),className:`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),e.label]},e.type))]},e.name))})]})}),(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Designer toolbar`,children:[!c&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:j?`Collapse palette`:`Expand palette`,"aria-label":j?`Collapse palette`:`Expand palette`,onClick:()=>N(e=>!e),children:(0,O.jsx)(r.PanelLeftClose,{className:V(`h-4 w-4`,!j&&`rotate-180`)})}),o&&!c&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!f.canUndo&&`opacity-40 pointer-events-none`),title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,disabled:!f.canUndo,onClick:()=>f.undo(),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!f.canRedo&&`opacity-40 pointer-events-none`),title:`Redo (Ctrl+Shift+Z)`,"aria-label":`Redo`,disabled:!f.canRedo,onClick:()=>f.redo(),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,_.count===0&&`opacity-40 pointer-events-none`),title:`Copy (Ctrl+C)`,"aria-label":`Copy`,disabled:_.count===0,onClick:W,children:(0,O.jsx)(r.Copy,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,!b.hasContent&&`opacity-40 pointer-events-none`),title:`Paste (Ctrl+V)`,"aria-label":`Paste`,disabled:!b.hasContent,onClick:ae,children:(0,O.jsx)(r.Clipboard,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,_.count===0&&`opacity-40 pointer-events-none`),title:`Delete selected`,"aria-label":`Delete selected`,disabled:_.count===0,onClick:re,children:(0,O.jsx)(r.Trash2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:`Preview`,"aria-label":`Preview`,children:(0,O.jsx)(r.Eye,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:V(`p-1.5 rounded hover:bg-accent`,L&&`bg-accent`),title:`Toggle minimap`,"aria-label":`Toggle minimap`,onClick:()=>R(e=>!e),children:(0,O.jsx)(r.Map,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`flex-1`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom out`,onClick:h.zoomOut,children:(0,O.jsx)(r.Minus,{className:`h-3 w-3`})}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground w-10 text-center`,children:[Math.round(g*100),`%`]}),(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom in`,onClick:h.zoomIn,children:(0,O.jsx)(r.Plus,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Reset zoom`,onClick:h.resetZoom,children:(0,O.jsx)(r.Maximize2,{className:`h-3 w-3`})})]}),a&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:P?`Collapse panel`:`Expand panel`,"aria-label":P?`Collapse panel`:`Expand panel`,onClick:()=>I(e=>!e),children:(0,O.jsx)(r.PanelRightClose,{className:V(`h-4 w-4`,!P&&`rotate-180`)})})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,role:`region`,"aria-label":`Design canvas`,onWheel:h.handleWheel,onMouseDown:h.startPan,onDragOver:K,onDrop:oe,children:(0,O.jsxs)(`div`,{className:`relative bg-background border rounded shadow-sm mx-auto`,style:{width:e.width*g,height:e.height*g,transform:`translate(${h.panOffset.x}px, ${h.panOffset.y}px)`,backgroundImage:e.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:e.showGrid&&e.gridSize?`${e.gridSize*g}px ${e.gridSize*g}px`:void 0},children:[p.map(e=>{let t=_.isSelected(e.id);return(0,O.jsxs)(`div`,{draggable:!c,onDragStart:t=>G(t,e),className:V(`absolute border rounded cursor-move select-none transition-shadow`,t?`border-primary ring-2 ring-primary/20 shadow-md`:`border-border hover:border-primary/50`),style:{left:e.position.x*g,top:e.position.y*g,width:typeof e.position.width==`number`?e.position.width*g:e.position.width,height:typeof e.position.height==`number`?e.position.height*g:e.position.height},onClick:t=>_.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b`,children:[(0,O.jsx)(r.GripVertical,{className:`h-3 w-3 text-muted-foreground`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.label??e.type}),!c&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ne(e.id)},className:`ml-auto p-0.5 rounded hover:bg-destructive/10`,"aria-label":`Delete ${e.label??e.type}`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3 text-destructive`})})]}),(0,O.jsx)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:e.type})]},e.id)}),L&&(0,O.jsx)(F,{items:q,canvasWidth:e.width,canvasHeight:e.height})]})})]}),a&&(0,O.jsx)(`div`,{className:V(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,P?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component tree`,children:P&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,O.jsx)(r.Layers,{className:`h-4 w-4`}),`Component Tree`]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:p.length===0?(0,O.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.`}):p.map(e=>(0,O.jsx)(`button`,{onClick:t=>_.toggle(e.id,t.shiftKey),className:V(`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left`,_.isSelected(e.id)?`bg-accent`:`hover:bg-accent/50`),children:(0,O.jsx)(`span`,{className:`truncate`,children:e.label??e.type})},e.id))}),s&&y?(0,O.jsx)(`div`,{className:`border-t`,children:(0,O.jsx)(M,{title:`Properties – ${y.label??y.type}`,fields:se,onChange:ie})}):y&&(0,O.jsxs)(`div`,{className:`border-t p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium mb-2`,children:`Properties`}),(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,O.jsxs)(`div`,{children:[`Type: `,y.type]}),(0,O.jsxs)(`div`,{children:[`ID: `,y.id]}),(0,O.jsxs)(`div`,{children:[`Position: `,y.position.x,`,`,` `,y.position.y]}),(0,O.jsxs)(`div`,{children:[`Size: `,y.position.width,` ×`,` `,y.position.height]})]})]})]})}),(0,O.jsx)(A,{isOpen:E.isOpen,title:E.title,message:E.message,onConfirm:E.onConfirm,onCancel:E.onCancel})]})}var U=[{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 te(e,t={}){return x(e,t)}function ne(...e){return(0,a.twMerge)((0,i.clsx)(e))}var re=[`text`,`number`,`boolean`,`date`,`datetime`,`uuid`,`email`,`url`,`phone`,`json`,`integer`,`float`,`decimal`,`currency`,`percent`,`textarea`,`select`,`multiselect`,`lookup`,`attachment`,`formula`,`autonumber`];function ie(e,t=4,n=280,r=250,i=50,a=50){return e.map((e,o)=>({...e,position:{x:i+o%t*n,y:a+Math.floor(o/t)*r}}))}function W({entities:e=[],relationships:t=[],canvas:i={width:1200,height:800,showGrid:!0},showRelationshipLabels:a=!0,readOnly:o=!1,onEntitiesChange:s,onRelationshipsChange:c,className:l}){let u=(0,n.useRef)(null),d=te({entities:e,relationships:t},{maxHistory:50}),{entities:f,relationships:p}=d.current,m=(0,n.useCallback)(e=>{d.push(e),s?.(e.entities),c?.(e.relationships)},[d,s,c]),h=S(),g=C(),_=g.count>0?Array.from(g.selectedIds)[0]:null,v=w(),y=T({minZoom:.25,maxZoom:3,zoomStep:.1}),b=ee(),[x,E]=(0,n.useState)(!0),[D,k]=(0,n.useState)(!0),[j,N]=(0,n.useState)(null),[P,I]=(0,n.useState)(``),[L,R]=(0,n.useState)(null),[z,B]=(0,n.useState)(``),V=(0,n.useRef)(null),H=(0,n.useCallback)(()=>{if(o)return;let e=d.current,t={id:`entity-${Date.now()}`,name:`new_entity_${e.entities.length+1}`,label:`New Entity ${e.entities.length+1}`,fields:[{name:`id`,type:`uuid`,primaryKey:!0,required:!0},{name:`created_at`,type:`datetime`,required:!0},{name:`updated_at`,type:`datetime`,required:!0}],position:{x:50+e.entities.length%4*280,y:50+Math.floor(e.entities.length/4)*250}};m({entities:[...e.entities,t],relationships:e.relationships}),g.selectOne(t.id),b?.sendOperation({type:`insert`,userId:b?.currentUserId??``,elementId:t.id,data:{name:t.name,label:t.label}})},[o,d,m,g,b]),U=(0,n.useCallback)(async e=>{if(o)return;let t=f.find(t=>t.id===e);if(!await h.confirm(`Delete Entity`,`Are you sure you want to delete "${t?.label??e}"? This action cannot be undone.`))return;let n=d.current;m({entities:n.entities.filter(t=>t.id!==e),relationships:n.relationships.filter(t=>t.sourceEntity!==e&&t.targetEntity!==e)}),g.isSelected(e)&&g.clearSelection(),b?.sendOperation({type:`delete`,userId:b?.currentUserId??``,elementId:e,data:{}})},[o,f,h,d,m,g,b]),W=(0,n.useCallback)(async()=>{if(o||g.count===0)return;let e=Array.from(g.selectedIds);if(!await h.confirm(`Delete Entities`,`Are you sure you want to delete ${e.length} selected entity(s)? This action cannot be undone.`))return;let t=d.current,n=new Set(e);m({entities:t.entities.filter(e=>!n.has(e.id)),relationships:t.relationships.filter(e=>!n.has(e.sourceEntity)&&!n.has(e.targetEntity))}),g.clearSelection()},[o,g,h,d,m]),ae=(0,n.useCallback)(()=>{if(o)return;let e=d.current;m({entities:ie(e.entities),relationships:e.relationships})},[o,d,m]),G=(0,n.useCallback)(()=>{let e=f.filter(e=>g.isSelected(e.id));e.length>0&&v.copy(e)},[f,g,v]),K=(0,n.useCallback)(()=>{if(o)return;let e=v.paste();if(!e||e.length===0)return;let t=d.current,n=e.map((e,t)=>({...e,id:`entity-${Date.now()}-${t}`,name:`${e.name}_copy`,label:`${e.label} (Copy)`,position:{x:e.position.x+30,y:e.position.y+30}}));m({entities:[...t.entities,...n],relationships:t.relationships}),g.selectMany(n.map(e=>e.id))},[o,v,d,m,g]),oe=(0,n.useCallback)(e=>{if(o)return;let t=d.current;m({entities:t.entities.map(t=>{if(t.id!==e)return t;let n={name:`field_${t.fields.length+1}`,type:`text`,required:!1};return{...t,fields:[...t.fields,n]}}),relationships:t.relationships})},[o,d,m]),se=(0,n.useCallback)((e,t,n)=>{o||(N({entityId:e,fieldIndex:t}),I(n))},[o]),q=(0,n.useCallback)(()=>{if(!j)return;let e=P.trim();if(e===``){N(null);return}let t=d.current;m({entities:t.entities.map(t=>{if(t.id!==j.entityId)return t;let n=t.fields.map((t,n)=>n===j.fieldIndex?{...t,name:e}:t);return{...t,fields:n}}),relationships:t.relationships}),N(null)},[j,P,d,m]),J=(0,n.useCallback)(()=>{N(null)},[]),ce=(0,n.useCallback)((e,t)=>{o||(R(e),B(t))},[o]),le=(0,n.useCallback)(()=>{if(!L)return;let e=z.trim();if(e===``){R(null);return}let t=d.current;m({entities:t.entities.map(t=>t.id===L?{...t,label:e}:t),relationships:t.relationships}),R(null)},[L,z,d,m]),ue=(0,n.useCallback)(()=>{R(null)},[]),de=(0,n.useCallback)((e,t,n)=>{if(o)return;let r=d.current;m({entities:r.entities.map(r=>{if(r.id!==e)return r;let i=r.fields.map((e,r)=>r===t?{...e,type:n}:e);return{...r,fields:i}}),relationships:r.relationships})},[o,d,m]),fe=(0,n.useCallback)((e,t)=>{if(o||!f.find(e=>e.id===t))return;let n=e.target.getBoundingClientRect();V.current={entityId:t,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[o,f]),pe=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),me=(0,n.useCallback)(e=>{if(e.preventDefault(),!V.current)return;let t=e.currentTarget.getBoundingClientRect(),n=y.zoom,r=(e.clientX-t.left-y.panOffset.x)/n-V.current.offsetX,i=(e.clientY-t.top-y.panOffset.y)/n-V.current.offsetY,a=d.current;m({entities:a.entities.map(e=>e.id===V.current.entityId?{...e,position:{x:Math.max(0,Math.round(r)),y:Math.max(0,Math.round(i))}}:e),relationships:a.relationships}),V.current=null},[y.zoom,y.panOffset,d,m]),Y=_?f.find(e=>e.id===_):null,he=Y?[{name:`name`,label:`Name`,type:`text`,value:Y.name,group:`General`},{name:`label`,label:`Label`,type:`text`,value:Y.label,group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:Y.description??``,group:`General`},{name:`color`,label:`Color`,type:`color`,value:Y.color??`#3b82f6`,group:`Appearance`},{name:`position.x`,label:`X Position`,type:`number`,value:Y.position.x,group:`Position`},{name:`position.y`,label:`Y Position`,type:`number`,value:Y.position.y,group:`Position`}]:[],ge=(0,n.useCallback)((e,t)=>{if(!_)return;let n=d.current;m({entities:n.entities.map(n=>n.id===_?e===`position.x`?{...n,position:{...n.position,x:Number(t)}}:e===`position.y`?{...n,position:{...n.position,y:Number(t)}}:{...n,[e]:t}:n),relationships:n.relationships})},[_,d,m]);(0,n.useEffect)(()=>{let e=u.current;if(!e)return;let t=e=>{let t=e.target.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;n&&e.key===`z`?(e.preventDefault(),d.undo()):n&&(e.key===`y`||e.shiftKey&&e.key===`Z`)?(e.preventDefault(),d.redo()):n&&e.key===`c`?(e.preventDefault(),G()):n&&e.key===`v`?(e.preventDefault(),K()):(e.key===`Delete`||e.key===`Backspace`)&&g.count>0?(e.preventDefault(),W()):e.key===`Escape`&&(g.clearSelection(),N(null),R(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[d,G,K,W,g]);let X=f.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:240,height:40+e.fields.length*24,color:e.color,selected:g.isSelected(e.id)}));return(0,O.jsxs)(`div`,{ref:u,tabIndex:0,className:ne(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,l),children:[(0,O.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{role:`toolbar`,"aria-label":`Designer toolbar`,className:`flex items-center gap-2 p-2 border-b bg-muted/20 flex-wrap`,children:[(0,O.jsx)(r.Database,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:`Data Model Designer`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ml-2 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:()=>d.undo(),disabled:!d.canUndo,"aria-label":`Undo`,title:`Undo (Ctrl+Z)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Undo2,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:()=>d.redo(),disabled:!d.canRedo,"aria-label":`Redo`,title:`Redo (Ctrl+Y)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Redo2,{className:`h-3.5 w-3.5`})})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:y.zoomOut,"aria-label":`Zoom Out`,title:`Zoom Out`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.ZoomOut,{className:`h-3.5 w-3.5`})}),(0,O.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-center`,children:[Math.round(y.zoom*100),`%`]}),(0,O.jsx)(`button`,{onClick:y.zoomIn,"aria-label":`Zoom In`,title:`Zoom In`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.ZoomIn,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:y.resetZoom,"aria-label":`Reset Zoom`,title:`Reset Zoom`,className:`p-1 rounded hover:bg-accent`,children:(0,O.jsx)(r.RotateCcw,{className:`h-3 w-3`})})]}),!o&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,O.jsx)(`button`,{onClick:G,disabled:g.count===0,"aria-label":`Copy`,title:`Copy (Ctrl+C)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Copy,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{onClick:K,disabled:!v.hasContent,"aria-label":`Paste`,title:`Paste (Ctrl+V)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,O.jsx)(r.Clipboard,{className:`h-3.5 w-3.5`})})]}),!o&&(0,O.jsxs)(`button`,{onClick:ae,"aria-label":`Auto Layout`,title:`Auto Layout`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded border hover:bg-accent`,children:[(0,O.jsx)(r.Grid3X3,{className:`h-3 w-3`}),` Auto Layout`]}),(0,O.jsx)(`div`,{className:`flex-1`}),b?.isConnected&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,O.jsx)(r.Users,{className:`h-3 w-3`}),(0,O.jsxs)(`span`,{children:[b.users.length,` user`,b.users.length===1?``:`s`]})]}),g.count>1&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[g.count,` selected`]}),!o&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`button`,{onClick:H,"aria-label":`Add Entity`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),` Add Entity`]}),(0,O.jsxs)(`button`,{"aria-label":`Add Relationship`,title:`Add Relationship (coming soon)`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-secondary text-secondary-foreground hover:bg-secondary/80`,children:[(0,O.jsx)(r.Link2,{className:`h-3 w-3`}),` Add Relationship`]})]})]}),(0,O.jsxs)(`div`,{role:`region`,"aria-label":`Canvas`,className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,onWheel:y.handleWheel,onMouseDown:y.startPan,onDragOver:pe,onDrop:me,children:[(0,O.jsxs)(`div`,{className:`relative`,style:{width:i.width,minHeight:i.height,...y.transformStyle,backgroundImage:i.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:i.showGrid?`20px 20px`:void 0},children:[(0,O.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:i.width,height:i.height,children:p.map(e=>{let t=f.find(t=>t.id===e.sourceEntity),n=f.find(t=>t.id===e.targetEntity);return!t||!n?null:(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:t.position.x+120,y1:t.position.y+50,x2:n.position.x+120,y2:n.position.y+50,stroke:`hsl(var(--primary))`,strokeWidth:`2`,strokeDasharray:e.type===`many-to-many`?`5,5`:void 0}),a&&e.label&&(0,O.jsx)(`text`,{x:(t.position.x+n.position.x)/2+120,y:(t.position.y+n.position.y)/2+50-8,textAnchor:`middle`,className:`text-xs fill-muted-foreground`,children:e.label})]},e.id)})}),f.length===0&&(0,O.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.`}),f.map(e=>(0,O.jsxs)(`div`,{role:`group`,"aria-label":e.label,draggable:!o,onDragStart:t=>fe(t,e.id),className:ne(`absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing`,g.isSelected(e.id)?`border-primary ring-2 ring-primary/20`:`border-border hover:border-primary/50`),style:{left:e.position.x,top:e.position.y},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm`,style:{backgroundColor:e.color??`hsl(var(--primary) / 0.1)`},children:[(0,O.jsx)(r.Database,{className:`h-3.5 w-3.5`}),L===e.id?(0,O.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),onBlur:le,onKeyDown:e=>{e.key===`Enter`&&le(),e.key===`Escape`&&ue()},className:`text-sm font-medium px-1 py-0 border rounded bg-background w-32 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation(),"data-testid":`entity-label-input-${e.id}`}):(0,O.jsx)(`span`,{className:`truncate cursor-text`,onDoubleClick:t=>{t.stopPropagation(),ce(e.id,e.label)},title:`Double-click to edit label`,"data-testid":`entity-label-${e.id}`,children:e.label}),!o&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),U(e.id)},"aria-label":`Delete ${e.label}`,className:`ml-auto p-0.5 rounded hover:bg-destructive/20`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3 text-destructive`})})]}),(0,O.jsx)(`div`,{className:`px-3 py-1 divide-y`,children:e.fields.map((t,n)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs`,children:[j&&j.entityId===e.id&&j.fieldIndex===n?(0,O.jsx)(`input`,{type:`text`,value:P,onChange:e=>I(e.target.value),onBlur:q,onKeyDown:e=>{e.key===`Enter`&&q(),e.key===`Escape`&&J()},className:`font-mono text-xs px-1 py-0 border rounded bg-background w-24 focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0,onClick:e=>e.stopPropagation()}):(0,O.jsxs)(`span`,{className:ne(`font-mono cursor-text`,t.primaryKey&&`font-bold text-primary`),onClick:r=>{r.stopPropagation(),se(e.id,n,t.name)},title:`Click to edit field name`,children:[t.primaryKey&&(0,O.jsx)(`span`,{className:`text-[0.65rem] font-semibold text-primary mr-0.5`,children:`PK`}),t.name]}),o?(0,O.jsx)(`span`,{className:`text-muted-foreground ml-auto`,children:t.type}):(0,O.jsx)(`select`,{value:t.type,onChange:t=>{t.stopPropagation(),de(e.id,n,t.target.value)},onClick:e=>e.stopPropagation(),className:`text-xs text-muted-foreground ml-auto bg-transparent border-none focus:ring-1 focus:ring-primary rounded cursor-pointer p-0`,"data-testid":`field-type-${e.id}-${n}`,children:re.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}),t.required&&(0,O.jsx)(`span`,{className:`text-destructive`,children:`*`})]},`${t.name}-${n}`))}),!o&&(0,O.jsx)(`div`,{className:`px-3 py-1 border-t`,children:(0,O.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),oe(e.id)},"aria-label":`Add field to ${e.label}`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5`,children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),` Add Field`]})})]},e.id))]}),D&&f.length>0&&(0,O.jsx)(F,{items:X,canvasWidth:i.width,canvasHeight:i.height,position:`bottom-right`,size:150})]})]}),(0,O.jsxs)(`div`,{className:`w-64 border-l flex flex-col bg-background shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,O.jsxs)(`button`,{onClick:()=>E(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 border-b`,"aria-expanded":x,"aria-controls":`property-editor-panel`,children:[x?(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}),`Properties`]}),x&&(0,O.jsx)(`div`,{id:`property-editor-panel`,className:`flex-1 overflow-y-auto`,children:(0,O.jsx)(M,{title:Y?Y.label:`Properties`,fields:he,onChange:ge})})]}),(0,O.jsx)(`div`,{className:`border-t`,children:(0,O.jsxs)(`button`,{onClick:()=>k(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 w-full`,"aria-expanded":D,children:[D?(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`}):(0,O.jsx)(r.ChevronRight,{className:`h-3 w-3`}),`Minimap`]})})]}),(0,O.jsx)(A,{isOpen:h.isOpen,title:h.title,message:h.message,onConfirm:h.onConfirm,onCancel:h.onCancel,destructive:!0})]})}function ae(...e){return(0,a.twMerge)((0,i.clsx)(e))}var G=120,K=50;function oe(e,t){if(e.length===0)return e;let n=new Map,r=new Map;for(let t of e)n.set(t.id,0),r.set(t.id,[]);for(let e of t)n.set(e.target,(n.get(e.target)??0)+1),r.get(e.source)?.push(e.target);let i=[],a=new Set,o=e.filter(e=>(n.get(e.id)??0)===0).map(e=>e.id);for(o.length===0&&(o=[e[0].id]);o.length>0;){i.push(o);for(let e of o)a.add(e);let e=new Set;for(let t of o)for(let n of r.get(t)??[])a.has(n)||e.add(n);o=Array.from(e)}let s=e.filter(e=>!a.has(e.id)).map(e=>e.id);s.length>0&&i.push(s);let c=new Map;for(let e=0;e<i.length;e++){let t=i[e];for(let n=0;n<t.length;n++)c.set(t[n],{x:80+e*200,y:80+n*100})}return e.map(e=>({...e,position:c.get(e.id)??e.position}))}function se({processName:e=`New Process`,nodes:t=[],edges:i=[],lanes:a,canvas:o={width:1400,height:800,showGrid:!0},showMinimap:s=!0,showToolbar:c=!0,readOnly:l=!1,onNodesChange:u,onEdgesChange:d,className:f}){let p=x({nodes:t,edges:i},{maxHistory:50}),m=p.current.nodes,h=p.current.edges,g=(0,n.useCallback)((e,t)=>{p.push({nodes:e,edges:t}),u?.(e),d?.(t)},[p,u,d]),_=S(),v=C(),y=w(),b=T({initialZoom:1}),E=ee(),[D,k]=(0,n.useState)(null),[j,N]=(0,n.useState)(!1),[P,I]=(0,n.useState)(null),[L,R]=(0,n.useState)(null),[z,B]=(0,n.useState)(!0),[V,H]=(0,n.useState)(null),[U,te]=(0,n.useState)({x:0,y:0}),ne=(0,n.useRef)(null),re=(0,n.useRef)(u),ie=(0,n.useRef)(d);re.current=u,ie.current=d,(0,n.useEffect)(()=>{re.current?.(m),ie.current?.(h)},[p.current]);let W=(0,n.useCallback)((e,t)=>{if(l)return;let n={id:`node-${Date.now()}`,type:e,label:t,position:{x:200+m.length*160,y:200}};g([...m,n],h),k(n.id),v.selectOne(n.id),E?.sendOperation({type:`insert`,elementId:n.id,data:{label:t},userId:E.currentUserId??``})},[m,h,l,g,v,E]),se=(0,n.useCallback)(async e=>{if(l)return;let t=m.find(t=>t.id===e);await _.confirm(`Delete Node`,`Are you sure you want to delete "${t?.label??e}"? This will also remove all connected edges.`)&&(g(m.filter(t=>t.id!==e),h.filter(t=>t.source!==e&&t.target!==e)),D===e&&k(null),v.clearSelection(),E?.sendOperation({type:`delete`,elementId:e,data:{},userId:E.currentUserId??``}))},[m,h,D,l,g,_,v,E]),q=(0,n.useCallback)(async()=>{if(l||v.count===0||!await _.confirm(`Delete Selected Nodes`,`Are you sure you want to delete ${v.count} selected node(s) and their connected edges?`))return;let e=v.selectedIds;g(m.filter(t=>!e.has(t.id)),h.filter(t=>!e.has(t.source)&&!e.has(t.target))),k(null),v.clearSelection()},[m,h,l,g,_,v]),J=(0,n.useCallback)(()=>{let e=v.count>0?v.selectedIds:D?new Set([D]):new Set;if(e.size===0)return;let t=m.filter(t=>e.has(t.id));y.copy(t)},[m,D,v,y]),ce=(0,n.useCallback)(()=>{if(l)return;let e=y.paste();if(!e||e.length===0)return;let t=e.map(e=>({...e,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:e.position.x+40,y:e.position.y+40}}));g([...m,...t],h),v.selectMany(t.map(e=>e.id)),k(t[0].id)},[l,m,h,y,g,v]),le=(0,n.useCallback)(()=>{N(e=>e?(I(null),!1):!0)},[]),ue=(0,n.useCallback)(e=>{if(!j)return!1;if(!P)return I(e),!0;if(P===e)return!0;let t={id:`edge-${Date.now()}`,source:P,target:e};return g(m,[...h,t]),I(null),N(!1),E?.sendOperation({type:`insert`,elementId:t.id,data:{source:P,target:e},userId:E.currentUserId??``}),!0},[j,P,m,h,g,E]),de=(0,n.useCallback)(()=>{l||m.length===0||g(oe(m,h),h)},[m,h,l,g]),fe=(0,n.useCallback)((e,t)=>{if(l||!m.find(e=>e.id===t))return;H(t);let n=e.target.getBoundingClientRect();te({x:e.clientX-n.left,y:e.clientY-n.top}),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[l,m]),pe=(0,n.useCallback)(e=>{if(e.preventDefault(),l||!V)return;let t=e.currentTarget.getBoundingClientRect(),n=b.zoom,r=(e.clientX-t.left-b.panOffset.x)/n-U.x,i=(e.clientY-t.top-b.panOffset.y)/n-U.y,a=Math.max(0,Math.round(r/20)*20),o=Math.max(0,Math.round(i/20)*20);g(m.map(e=>e.id===V?{...e,position:{x:a,y:o}}:e),h),H(null)},[l,V,U,m,h,b.zoom,b.panOffset,g]),me=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),Y=(0,n.useMemo)(()=>m.find(e=>e.id===D)??null,[m,D]),he=(0,n.useMemo)(()=>Y?[{name:`label`,label:`Name`,type:`text`,value:Y.label,group:`General`},{name:`type`,label:`Type`,type:`select`,value:Y.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:Y.description??``,group:`General`}]:[],[Y]),ge=(0,n.useCallback)((e,t)=>{l||!D||g(m.map(n=>n.id===D?{...n,[e]:t}:n),h)},[l,D,m,h,g]),X=e=>{switch(e){case`start-event`:return`rounded-full bg-green-100 border-green-500 text-green-700`;case`end-event`:return`rounded-full bg-red-100 border-red-500 text-red-700`;case`exclusive-gateway`:case`parallel-gateway`:case`inclusive-gateway`:case`event-based-gateway`:return`rotate-45 bg-yellow-100 border-yellow-500 text-yellow-700`;case`user-task`:return`rounded bg-blue-100 border-blue-500 text-blue-700`;case`service-task`:case`script-task`:return`rounded bg-purple-100 border-purple-500 text-purple-700`;default:return`rounded bg-gray-100 border-gray-500 text-gray-700`}},_e=(0,n.useMemo)(()=>m.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:G,height:K,selected:v.isSelected(e.id)||e.id===D})),[m,v,D]);(0,n.useEffect)(()=>{let e=ne.current;if(!e)return;let t=e=>{let t=e.target?.tagName;if(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`)return;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`z`&&!e.shiftKey){e.preventDefault(),p.undo();return}if(n&&e.key===`y`||n&&e.key===`z`&&e.shiftKey){e.preventDefault(),p.redo();return}if(n&&e.key===`c`){e.preventDefault(),J();return}if(n&&e.key===`v`){e.preventDefault(),ce();return}if(e.key===`Delete`||e.key===`Backspace`){v.count>0?(e.preventDefault(),q()):D&&(e.preventDefault(),se(D));return}if(e.key===`Escape`){j?(N(!1),I(null)):(k(null),v.clearSelection());return}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[D,j,v,p,J,ce,se,q]);let ve=(0,n.useCallback)(e=>{e.target===e.currentTarget&&(k(null),v.clearSelection(),j&&(N(!1),I(null)))},[j,v]);return(0,O.jsxs)(`div`,{ref:ne,tabIndex:0,className:ae(`flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background`,f),children:[(0,O.jsx)(A,{isOpen:_.isOpen,title:_.title,message:_.message,onConfirm:_.onConfirm,onCancel:_.onCancel,destructive:!0}),c&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Process toolbar`,children:[(0,O.jsx)(r.GitBranch,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,"aria-label":`Process name`,children:e}),E?.isConnected&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),E.users.length,` user`,E.users.length===1?``:`s`]}),(0,O.jsx)(`div`,{className:`flex-1`}),!l&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{onClick:()=>p.undo(),disabled:!p.canUndo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,children:(0,O.jsx)(r.Undo2,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>p.redo(),disabled:!p.canRedo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Redo (Ctrl+Y)`,"aria-label":`Redo`,children:(0,O.jsx)(r.Redo2,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:J,disabled:v.count===0&&!D,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Copy (Ctrl+C)`,"aria-label":`Copy`,children:(0,O.jsx)(r.Copy,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:ce,disabled:!y.hasContent,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Paste (Ctrl+V)`,"aria-label":`Paste`,children:(0,O.jsx)(r.Clipboard,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsxs)(`button`,{onClick:le,className:ae(`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,j&&`bg-primary text-primary-foreground`),title:`Connect nodes`,"aria-label":`Connect nodes`,"aria-pressed":j,children:[(0,O.jsx)(r.Link,{className:`h-3 w-3`}),` Connect`]}),(0,O.jsxs)(`button`,{onClick:de,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Auto layout`,"aria-label":`Auto layout`,children:[(0,O.jsx)(r.Layout,{className:`h-3 w-3`}),` Layout`]}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:b.zoomIn,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom in`,"aria-label":`Zoom in`,children:(0,O.jsx)(r.ZoomIn,{className:`h-3 w-3`})}),(0,O.jsxs)(`span`,{className:`text-xs tabular-nums min-w-[3ch] text-center`,"aria-label":`Zoom level`,children:[Math.round(b.zoom*100),`%`]}),(0,O.jsx)(`button`,{onClick:b.zoomOut,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Zoom out`,"aria-label":`Zoom out`,children:(0,O.jsx)(r.ZoomOut,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:b.resetZoom,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Reset zoom`,"aria-label":`Reset zoom`,children:(0,O.jsx)(r.RotateCcw,{className:`h-3 w-3`})}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsxs)(`button`,{onClick:()=>W(`start-event`,`Start`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Start Event`,"aria-label":`Add Start Event`,children:[(0,O.jsx)(r.Play,{className:`h-3 w-3 text-green-600`}),` Start`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`user-task`,`User Task`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add User Task`,"aria-label":`Add User Task`,children:[(0,O.jsx)(r.Square,{className:`h-3 w-3 text-blue-600`}),` Task`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`exclusive-gateway`,`Decision`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Gateway`,"aria-label":`Add Gateway`,children:[(0,O.jsx)(r.Diamond,{className:`h-3 w-3 text-yellow-600`}),` Gateway`]}),(0,O.jsxs)(`button`,{onClick:()=>W(`end-event`,`End`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add End Event`,"aria-label":`Add End Event`,children:[(0,O.jsx)(r.Square,{className:`h-3 w-3 text-red-600`}),` End`]}),(0,O.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,O.jsx)(`button`,{onClick:()=>B(e=>!e),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:z?`Hide properties`:`Show properties`,"aria-label":z?`Hide property panel`:`Show property panel`,"aria-expanded":z,children:z?(0,O.jsx)(r.PanelRightClose,{className:`h-3 w-3`}):(0,O.jsx)(r.PanelRightOpen,{className:`h-3 w-3`})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4`,role:`region`,"aria-label":`Process canvas`,onWheel:b.handleWheel,onMouseDown:b.startPan,children:(0,O.jsxs)(`div`,{className:`relative`,style:{...b.transformStyle,width:o.width,minHeight:o.height,backgroundImage:o.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:o.showGrid?`20px 20px`:void 0},onClick:ve,onDrop:pe,onDragOver:me,children:[(0,O.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:o.width,height:o.height,children:[(0,O.jsx)(`defs`,{children:(0,O.jsx)(`marker`,{id:`arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`10`,refY:`3.5`,orient:`auto`,children:(0,O.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground))`})})}),h.map(e=>{let t=m.find(t=>t.id===e.source),n=m.find(t=>t.id===e.target);if(!t||!n)return null;t.position.x+G/2;let r=t.position.y+K/2;n.position.x+G/2;let i=n.position.y+K/2,a=t.position.x+G,o=r,s=n.position.x,c=i;return(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`path`,{d:`M ${a} ${o} Q ${(a+s)/2} ${o}, ${(a+s)/2} ${(o+c)/2} T ${s} ${c}`,fill:`none`,stroke:`hsl(var(--foreground) / 0.5)`,strokeWidth:`2`,markerEnd:`url(#arrowhead)`}),e.label&&(0,O.jsx)(`text`,{x:(a+s)/2,y:(o+c)/2-8,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,children:e.label})]},e.id)})]}),m.length===0&&(0,O.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(e=>{let t=v.isSelected(e.id)||D===e.id,n=P===e.id,i=L===e.id,a=j||i;return(0,O.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},role:`group`,"aria-label":e.label,draggable:!l&&!j,onDragStart:t=>fe(t,e.id),onMouseEnter:()=>R(e.id),onMouseLeave:()=>R(null),onClick:t=>{ue(e.id)||(t.shiftKey?v.toggle(e.id,!0):(k(e.id),v.selectOne(e.id)))},children:[(0,O.jsx)(`div`,{className:ae(`flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow`,X(e.type),t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,j&&!n&&`cursor-crosshair`),children:(0,O.jsx)(`span`,{className:ae(`text-xs font-medium`,(e.type===`exclusive-gateway`||e.type===`parallel-gateway`||e.type===`inclusive-gateway`||e.type===`event-based-gateway`)&&`-rotate-45`),children:e.label})}),a&&!l&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{left:-6,top:K/2-6},title:`Input port`,onClick:t=>{t.stopPropagation(),ue(e.id)}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{right:-6,top:K/2-6},title:`Output port`,onClick:t=>{t.stopPropagation(),j?ue(e.id):(N(!0),I(e.id))}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:G/2-6,top:-6},title:`Port`,onClick:t=>{t.stopPropagation(),ue(e.id)}}),(0,O.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:G/2-6,bottom:-6},title:`Port`,onClick:t=>{t.stopPropagation(),ue(e.id)}})]}),!l&&t&&!j&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),se(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":`Delete node`,children:(0,O.jsx)(r.Trash2,{className:`h-3 w-3`})})]},e.id)}),s&&m.length>0&&(0,O.jsx)(F,{items:_e,canvasWidth:o.width??1400,canvasHeight:o.height??800,position:`bottom-right`})]})}),z&&!l&&(0,O.jsx)(`div`,{className:`w-64 border-l bg-background overflow-y-auto flex-shrink-0`,role:`complementary`,"aria-label":`Property panel`,children:(0,O.jsx)(M,{title:Y?`Properties: ${Y.label}`:`Properties`,fields:he,onChange:ge})})]})]})}function q(...e){return(0,a.twMerge)((0,i.clsx)(e))}var J={untitledReport:`Untitled Report`,reportCanvas:`Report canvas`,properties:`Properties`,propertiesPanel:`Properties panel`,designerToolbar:`Report designer toolbar`,selectElementPrompt:`Select an element to edit its properties`,addElementsPrompt:`Add elements using the buttons above`,addText:`Add Text`,addField:`Add Field`,addImage:`Add Image`,addChart:`Add Chart`,addTable:`Add Table`,undo:`Undo`,undoShortcut:`Undo (Ctrl+Z)`,redo:`Redo`,redoShortcut:`Redo (Ctrl+Shift+Z)`,copy:`Copy`,copyShortcut:`Copy (Ctrl+C)`,paste:`Paste`,pasteShortcut:`Paste (Ctrl+V)`,deleteSelected:`Delete selected`,deleteElement:`Delete element`,deleteElementsTitle:`Delete elements`,deleteElementMessage:e=>`Are you sure you want to delete ${e} element${e>1?`s`:``}?`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,collaborationConnected:`Connected`,sectionHeader:`Report Header`,sectionPageHeader:`Page Header`,sectionGroupHeader:`Group Header`,sectionDetail:`Detail`,sectionGroupFooter:`Group Footer`,sectionPageFooter:`Page Footer`,sectionFooter:`Report Footer`,elementText:`Text`,elementImage:`🖼 Image`,elementChart:`📊 Chart`,elementTable:`📋 Table`,propLabel:`Label`,propX:`X`,propY:`Y`,propWidth:`Width`,propHeight:`Height`,propText:`Text`,propField:`Field`,groupPosition:`Position`,groupSize:`Size`,groupContent:`Content`,groupGeneral:`General`},ce={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}},le=[{type:`header`,height:80,elements:[]},{type:`detail`,height:400,elements:[],repeat:!0},{type:`footer`,height:60,elements:[]}];function ue({reportName:e=J.untitledReport,objectName:t,pageSize:i=`A4`,orientation:a=`portrait`,margins:o={top:40,right:40,bottom:40,left:40},sections:s=[],showToolbar:c=!0,showPropertyPanel:l=!0,readOnly:u=!1,onSectionsChange:d,className:f}){let p=x(s.length>0?s:le),m=p.current,h=(0,n.useCallback)(e=>{p.push(e),d?.(e)},[p,d]),g=C(),_=(0,n.useMemo)(()=>{let e=Array.from(g.selectedIds);return e.length>0?e[0]:null},[g.selectedIds]),v=w(),y=S(),b=ee(),T=(0,n.useCallback)(e=>{b&&b.sendOperation({...e,userId:b.currentUserId??``})},[b]),[E,D]=(0,n.useState)(!0),k=(0,n.useRef)(null),j=(0,n.useRef)(null),N=ce[i],P=a===`landscape`?N.height:N.width,F=a===`landscape`?N.width:N.height,I=e=>{switch(e){case`header`:return J.sectionHeader;case`page-header`:return J.sectionPageHeader;case`group-header`:return J.sectionGroupHeader;case`detail`:return J.sectionDetail;case`group-footer`:return J.sectionGroupFooter;case`page-footer`:return J.sectionPageFooter;case`footer`:return J.sectionFooter;default:return e}},L=(0,n.useMemo)(()=>_?m.flatMap(e=>e.elements).find(e=>e.id===_):null,[_,m]),R=(0,n.useCallback)((e,t)=>{if(u)return;let n={id:`elem-${Date.now()}`,type:t,position:{x:o.left,y:10,width:200,height:30},properties:{text:t===`text`?`New Text`:void 0,field:t===`field`?`field_name`:void 0}};h(m.map((t,r)=>r===e?{...t,elements:[...t.elements,n]}:t)),g.selectOne(n.id),T({type:`insert`,elementId:n.id,data:{element:n}})},[m,o.left,u,h,g,T]),z=(0,n.useCallback)(e=>{u||(h(m.map(t=>({...t,elements:t.elements.filter(t=>t.id!==e)}))),g.isSelected(e)&&g.clearSelection(),T({type:`delete`,elementId:e,data:{}}))},[m,u,h,g,T]),B=(0,n.useCallback)(async()=>{if(u||g.count===0||!await y.confirm(J.deleteElementsTitle,J.deleteElementMessage(g.count)))return;let e=g.selectedIds;h(m.map(t=>({...t,elements:t.elements.filter(t=>!e.has(t.id))}))),g.clearSelection(),e.forEach(e=>{T({type:`delete`,elementId:e,data:{}})})},[u,g,y,m,h,T]),V=(0,n.useCallback)((e,t)=>{u||!_||(h(m.map(n=>({...n,elements:n.elements.map(n=>n.id===_?e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,properties:{...n.properties,[e]:t}}:n)}))),T({type:`update`,elementId:_,data:{[e]:t}}))},[u,_,m,h,T]),H=(0,n.useCallback)(()=>{let e=g.selectedIds;if(e.size===0)return;let t=m.flatMap(e=>e.elements).filter(t=>e.has(t.id));v.copy(t)},[g,m,v]),U=(0,n.useCallback)(()=>{if(u)return;let e=v.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`elem-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}})),r=m.findIndex(e=>e.type===`detail`),i=r>=0?r:0;h(m.map((e,t)=>t===i?{...e,elements:[...e.elements,...n]}:e)),g.selectMany(n.map(e=>e.id)),n.forEach(e=>{T({type:`insert`,elementId:e.id,data:{element:e}})})},[u,v,m,h,g,T]),te=(0,n.useCallback)((e,t,n)=>{u||(k.current={id:t.id,sectionIndex:n,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[u]),ne=(0,n.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),re=(0,n.useCallback)((e,t)=>{e.preventDefault();let n=k.current;if(!n||u)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;if(n.sectionIndex===t)h(m.map((e,a)=>a===t?{...e,elements:e.elements.map(e=>e.id===n.id?{...e,position:{...e.position,x:Math.max(0,e.position.x+r),y:Math.max(0,(typeof e.position.y==`number`?e.position.y:0)+i)}}:e)}:e));else{let e=null,i=m.map((t,i)=>{if(i!==n.sectionIndex)return t;let a=t.elements.find(e=>e.id===n.id);return a&&(e={...a,position:{...a.position,x:Math.max(0,a.position.x+r),y:10}}),{...t,elements:t.elements.filter(e=>e.id!==n.id)}});e&&h(i.map((n,r)=>r===t?{...n,elements:[...n.elements,e]}:n))}T({type:`move`,elementId:n.id,data:{}}),k.current=null},[u,m,h,T]),ie=(0,n.useMemo)(()=>{if(!L)return[];let e=[{name:`x`,label:J.propX,type:`number`,value:L.position.x,group:J.groupPosition},{name:`y`,label:J.propY,type:`number`,value:L.position.y,group:J.groupPosition},{name:`width`,label:J.propWidth,type:`number`,value:L.position.width,group:J.groupSize},{name:`height`,label:J.propHeight,type:`number`,value:L.position.height,group:J.groupSize}];return L.type===`text`&&e.push({name:`text`,label:J.propText,type:`text`,value:L.properties.text??``,group:J.groupContent}),L.type===`field`&&e.push({name:`field`,label:J.propField,type:`text`,value:L.properties.field??``,group:J.groupContent}),e},[L]);return(0,n.useEffect)(()=>{let e=j.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&g.count>0&&!t){e.preventDefault(),B();return}if(e.key===`Escape`){g.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&!u){e.preventDefault(),p.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&!u){e.preventDefault(),p.redo();return}if(n&&e.key===`c`){e.preventDefault(),H();return}if(n&&e.key===`v`&&!u){e.preventDefault(),U();return}if(n&&e.key===`a`){e.preventDefault();let t=m.flatMap(e=>e.elements).map(e=>e.id);g.selectMany(t);return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g,B,u,p,H,U,m]),(0,O.jsxs)(`div`,{ref:j,tabIndex:0,className:q(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,f),children:[(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[c&&(0,O.jsxs)(`div`,{role:`toolbar`,"aria-label":J.designerToolbar,className:`flex items-center gap-2 p-2 border-b bg-muted/20`,children:[(0,O.jsx)(r.FileText,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e}),t&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t,`)`]}),!u&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!p.canUndo&&`opacity-40 pointer-events-none`),title:J.undoShortcut,"aria-label":J.undo,disabled:!p.canUndo,onClick:()=>p.undo(),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!p.canRedo&&`opacity-40 pointer-events-none`),title:J.redoShortcut,"aria-label":J.redo,disabled:!p.canRedo,onClick:()=>p.redo(),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!u&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:J.copyShortcut,"aria-label":J.copy,disabled:g.count===0,onClick:H,children:(0,O.jsx)(r.Copy,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,!v.hasContent&&`opacity-40 pointer-events-none`),title:J.pasteShortcut,"aria-label":J.paste,disabled:!v.hasContent,onClick:U,children:(0,O.jsx)(r.Clipboard,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!u&&(0,O.jsx)(`button`,{className:q(`p-1.5 rounded hover:bg-accent`,g.count===0&&`opacity-40 pointer-events-none`),title:J.deleteSelected,"aria-label":J.deleteSelected,disabled:g.count===0,onClick:B,children:(0,O.jsx)(r.Trash2,{className:`h-4 w-4`})}),(0,O.jsx)(`div`,{className:`flex-1`}),b?.isConnected&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),J.collaborationConnected,b.users.length>1&&` (${b.users.length})`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i,` `,a]}),l&&(0,O.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:E?J.collapsePanel:J.expandPanel,"aria-label":E?J.collapsePanel:J.expandPanel,onClick:()=>D(e=>!e),children:(0,O.jsx)(r.PanelRightClose,{className:q(`h-4 w-4`,!E&&`rotate-180`)})})]}),(0,O.jsx)(`div`,{role:`region`,"aria-label":J.reportCanvas,className:`flex-1 overflow-auto bg-muted/10 p-4 flex justify-center`,children:(0,O.jsx)(`div`,{className:`bg-white shadow-lg border`,style:{width:P,minHeight:F},children:m.map((e,t)=>(0,O.jsxs)(`div`,{className:`relative border-b border-dashed border-gray-300`,style:{minHeight:e.height},onDragOver:ne,onDrop:e=>re(e,t),children:[(0,O.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:[I(e.type),e.repeat&&` ↻`]}),!u&&(0,O.jsxs)(`div`,{className:`absolute right-1 top-0 flex items-center gap-0.5`,children:[(0,O.jsx)(`button`,{onClick:()=>R(t,`text`),className:`p-0.5 rounded hover:bg-accent`,title:J.addText,"aria-label":J.addText,children:(0,O.jsx)(r.Type,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`field`),className:`p-0.5 rounded hover:bg-accent`,title:J.addField,"aria-label":J.addField,children:(0,O.jsx)(r.Plus,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`image`),className:`p-0.5 rounded hover:bg-accent`,title:J.addImage,"aria-label":J.addImage,children:(0,O.jsx)(r.ImageIcon,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`chart`),className:`p-0.5 rounded hover:bg-accent`,title:J.addChart,"aria-label":J.addChart,children:(0,O.jsx)(r.BarChart3,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{onClick:()=>R(t,`table`),className:`p-0.5 rounded hover:bg-accent`,title:J.addTable,"aria-label":J.addTable,children:(0,O.jsx)(r.Table2,{className:`h-3 w-3`})})]}),(0,O.jsxs)(`div`,{className:`relative`,style:{minHeight:e.height,paddingTop:24},children:[e.elements.length===0&&(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground text-center pt-4`,children:J.addElementsPrompt}),e.elements.map(e=>{let n=g.isSelected(e.id);return(0,O.jsxs)(`div`,{draggable:!u,onDragStart:n=>te(n,e,t),className:q(`absolute border rounded px-2 py-1 text-xs cursor-pointer`,n?`border-primary ring-1 ring-primary/30 bg-primary/5`:`border-dashed border-gray-400 hover:border-primary/50`),style:{left:e.position.x,top:(typeof e.position.y==`number`?e.position.y:0)+24,width:e.position.width,height:e.position.height},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.type===`text`&&(e.properties.text??J.elementText),e.type===`field`&&`{${e.properties.field??`field`}}`,e.type===`image`&&J.elementImage,e.type===`chart`&&J.elementChart,e.type===`table`&&J.elementTable]}),!u&&n&&(0,O.jsx)(`button`,{onClick:t=>{t.stopPropagation(),z(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":J.deleteElement,children:(0,O.jsx)(r.Trash2,{className:`h-2.5 w-2.5`})})]},e.id)})]})]},`${e.type}-${t}`))})})]}),l&&(0,O.jsx)(`div`,{role:`region`,"aria-label":J.propertiesPanel,className:q(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,E?`w-56`:`w-0 overflow-hidden`),children:E&&(_&&L?(0,O.jsx)(M,{title:`${J.properties} – ${L.type}`,fields:ie,onChange:V}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:J.properties}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:J.selectElementPrompt})})]}))}),(0,O.jsx)(A,{isOpen:y.isOpen,title:y.title,message:y.message,onConfirm:y.onConfirm,onCancel:y.onCancel})]})}var de=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);X(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},fe={},pe=(e,t,n,r)=>{X(n)&&fe[n]||(X(n)&&(fe[n]=new Date),de(e,t,n,r))},me=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},Y=(e,t,n)=>{e.loadNamespaces(t,me(e,n))},he=(e,t,n,r)=>{if(X(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Y(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,me(e,r))},ge=(e,t,n={})=>!t.languages||!t.languages.length?(pe(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),X=e=>typeof e==`string`,_e=e=>typeof e==`object`&&!!e,ve=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ye={"&amp;":`&`,"&#38;":`&`,"&lt;":`<`,"&#60;":`<`,"&gt;":`>`,"&#62;":`>`,"&apos;":`'`,"&#39;":`'`,"&quot;":`"`,"&#34;":`"`,"&nbsp;":` `,"&#160;":` `,"&copy;":`©`,"&#169;":`©`,"&reg;":`®`,"&#174;":`®`,"&hellip;":`…`,"&#8230;":`…`,"&#x2F;":`/`,"&#47;":`/`},be=e=>ye[e],xe={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(ve,be),transDefaultProps:void 0},Se=()=>xe,Ce,we=()=>Ce,Te=(0,n.createContext)(),Ee=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},De=v((e=>{var t=require(`react`);function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Oe=v((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function n(e,t){d||a.startTransition===void 0||(d=!0,console.error(`You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.`));var n=t();if(!f){var i=t();o(n,i)||(console.error(`The result of getSnapshot should be cached to avoid an infinite loop`),f=!0)}i=s({inst:{value:n,getSnapshot:t}});var p=i[0].inst,m=i[1];return l(function(){p.value=n,p.getSnapshot=t,r(p)&&m({inst:p})},[e,n,t]),c(function(){return r(p)&&m({inst:p}),e(function(){r(p)&&m({inst:p})})},[e]),u(n),n}function r(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch{return!0}}function i(e,t){return t()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=require(`react`),o=typeof Object.is==`function`?Object.is:t,s=a.useState,c=a.useEffect,l=a.useLayoutEffect,u=a.useDebugValue,d=!1,f=!1,p=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?i:n;e.useSyncExternalStore=a.useSyncExternalStore===void 0?p:a.useSyncExternalStore,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),ke=v(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=De():t.exports=Oe()}))(),Ae={t:(e,t)=>{if(X(t))return t;if(_e(t)&&X(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},je=()=>()=>{},Me=(e,t={})=>{let{i18n:r}=t,{i18n:i,defaultNS:a}=(0,n.useContext)(Te)||{},o=r||i||we();o&&!o.reportNamespaces&&(o.reportNamespaces=new Ee),o||pe(o,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let s=(0,n.useMemo)(()=>({...Se(),...o?.options?.react,...t}),[o,t]),{useSuspense:c,keyPrefix:l}=s,u=e||a||o?.options?.defaultNS,d=X(u)?[u]:u||[`translation`],f=(0,n.useMemo)(()=>d,d);o?.reportNamespaces?.addUsedNamespaces?.(f);let p=(0,n.useRef)(0),m=(0,n.useCallback)(e=>{if(!o)return je;let{bindI18n:t,bindI18nStore:n}=s,r=()=>{p.current+=1,e()};return t&&o.on(t,r),n&&o.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>o.off(e,r)),n&&n.split(` `).forEach(e=>o.store.off(e,r))}},[o,s]),h=(0,n.useRef)(),g=(0,n.useCallback)(()=>{if(!o)return Ae;let e=!!(o.isInitialized||o.initializedStoreOnce)&&f.every(e=>ge(e,o,s)),n=t.lng||o.language,r=p.current,i=h.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===l&&i.revision===r)return i;let a={t:o.getFixedT(n,s.nsMode===`fallback`?f:f[0],l),ready:e,lng:n,keyPrefix:l,revision:r};return h.current=a,a},[o,f,l,s,t.lng]),[_,v]=(0,n.useState)(0),{t:y,ready:b}=(0,ke.useSyncExternalStore)(m,g,g);(0,n.useEffect)(()=>{if(o&&!b&&!c){let e=()=>v(e=>e+1);t.lng?he(o,t.lng,f,e):Y(o,f,e)}},[o,t.lng,f,b,c,_]);let x=o||{},S=(0,n.useRef)(null),C=(0,n.useRef)(),w=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,`__original`,{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},T=(0,n.useMemo)(()=>{let e=x,t=e?.language,n=e;e&&(S.current&&S.current.__original===e&&C.current===t?n=S.current:(n=w(e),S.current=n,C.current=t));let r=!b&&!c?(...e)=>(pe(o,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),y(...e)):y,i=[r,n,b];return i.t=r,i.i18n=n,i.ready=b,i},[y,x,b,x.resolvedLanguage,x.language,x.languages]);if(o&&c&&!b)throw new Promise(e=>{let n=()=>e();t.lng?he(o,t.lng,f,n):Y(o,f,n)});return T},Ne=(0,n.createContext)(null);function Pe(e){let t=(0,n.useContext)(Ne),{t:r,i18n:i}=Me(e);return{t:r,language:t?.language||i.language||`en`,changeLanguage:t?.changeLanguage||(async e=>{await i.changeLanguage(e)}),direction:t?.direction||`ltr`,i18n:i}}var Fe={"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`,"appDesigner.objectManager.title":`Object Manager`,"appDesigner.objectManager.addObject":`New Object`,"appDesigner.objectManager.searchPlaceholder":`Search objects…`,"appDesigner.objectManager.noObjects":`No objects found.`,"appDesigner.objectManager.objectName":`API Name`,"appDesigner.objectManager.objectLabel":`Label`,"appDesigner.objectManager.pluralLabel":`Plural Label`,"appDesigner.objectManager.icon":`Icon`,"appDesigner.objectManager.selectIcon":`Select icon…`,"appDesigner.objectManager.group":`Group`,"appDesigner.objectManager.noGroup":`No Group`,"appDesigner.objectManager.sortOrder":`Sort Order`,"appDesigner.objectManager.enabled":`Enabled`,"appDesigner.objectManager.relationships":`Relationships`,"appDesigner.objectManager.systemBadge":`System`,"appDesigner.objectManager.fieldCount":`{{count}} fields`,"appDesigner.objectManager.ungrouped":`Ungrouped`,"appDesigner.objectManager.deleteConfirmTitle":`Delete Object?`,"appDesigner.objectManager.deleteConfirmMessage":`This will permanently delete the object and all its fields. This action cannot be undone.`,"appDesigner.fieldDesigner.title":`Field Designer`,"appDesigner.fieldDesigner.addField":`New Field`,"appDesigner.fieldDesigner.searchPlaceholder":`Search fields…`,"appDesigner.fieldDesigner.allTypes":`All Types`,"appDesigner.fieldDesigner.noFields":`No fields found.`,"appDesigner.fieldDesigner.fieldName":`API Name`,"appDesigner.fieldDesigner.fieldLabel":`Label`,"appDesigner.fieldDesigner.fieldType":`Type`,"appDesigner.fieldDesigner.fieldGroup":`Group`,"appDesigner.fieldDesigner.description":`Description`,"appDesigner.fieldDesigner.required":`Required`,"appDesigner.fieldDesigner.unique":`Unique`,"appDesigner.fieldDesigner.readOnly":`Read Only`,"appDesigner.fieldDesigner.hidden":`Hidden`,"appDesigner.fieldDesigner.indexed":`Indexed`,"appDesigner.fieldDesigner.externalId":`External ID`,"appDesigner.fieldDesigner.trackHistory":`Track History`,"appDesigner.fieldDesigner.defaultValue":`Default Value`,"appDesigner.fieldDesigner.placeholder":`Placeholder`,"appDesigner.fieldDesigner.referenceTo":`Reference To`,"appDesigner.fieldDesigner.formula":`Formula`,"appDesigner.fieldDesigner.options":`Options`,"appDesigner.fieldDesigner.addOption":`Add Option`,"appDesigner.fieldDesigner.validationRules":`Validation Rules`,"appDesigner.fieldDesigner.addRule":`Add Rule`,"appDesigner.fieldDesigner.systemBadge":`System`,"appDesigner.fieldDesigner.ungrouped":`General`,"appDesigner.fieldDesigner.deleteConfirmTitle":`Delete Field?`,"appDesigner.fieldDesigner.deleteConfirmMessage":`This will permanently delete the field. Existing data in this field will be lost.`,"appDesigner.fieldDesigner.basicSection":`Basic`,"appDesigner.fieldDesigner.typeSpecificSection":`Type Settings`,"appDesigner.fieldDesigner.advancedSection":`Advanced`,"appDesigner.fieldDesigner.typeCategory.text":`Text`,"appDesigner.fieldDesigner.typeCategory.number":`Number`,"appDesigner.fieldDesigner.typeCategory.date":`Date & Time`,"appDesigner.fieldDesigner.typeCategory.choice":`Choice`,"appDesigner.fieldDesigner.typeCategory.relation":`Relation`,"appDesigner.fieldDesigner.typeCategory.advanced":`Advanced`,"common.edit":`Edit`};function Ie(e){return(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}function Z(){try{let e=Pe();return e.t(`appDesigner.basicInfo`)===`appDesigner.basicInfo`?{t:Ie(Fe)}:{t:e.t}}catch{return{t:Ie(Fe)}}}function Q(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Le={name:``,title:``,description:``,icon:``,template:``,layout:`sidebar`,objects:[],navigation:[],branding:{logo:``,primaryColor:`#3b82f6`,favicon:``}};function Re(e){return e.filter(e=>e.selected).map(e=>({id:e.name,type:`object`,label:e.label,icon:e.icon,objectName:e.name}))}var ze=0;function Be(e){return ze+=1,`${e}_${Date.now()}_${ze}`}function Ve({steps:e,currentIndex:t,onStepClick:i}){return(0,O.jsx)(`nav`,{className:`flex items-center justify-center gap-0 px-4 py-6`,children:e.map((e,a)=>{let o=a<t,s=a===t;return(0,O.jsxs)(n.default.Fragment,{children:[a>0&&(0,O.jsx)(`div`,{className:Q(`h-0.5 w-12 sm:w-20`,o?`bg-blue-500`:`bg-gray-200`)}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-step-${e.id}`,onClick:()=>i(a),className:Q(`flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1`,s&&`cursor-default`,!s&&`cursor-pointer`),children:[(0,O.jsx)(`div`,{className:Q(`flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors`,o&&`bg-blue-500 text-white`,s&&`bg-blue-600 text-white ring-2 ring-blue-300`,!o&&!s&&`bg-gray-200 text-gray-500`),children:o?(0,O.jsx)(r.Check,{className:`h-4 w-4`}):a+1}),(0,O.jsx)(`span`,{className:Q(`text-xs font-medium`,s?`text-blue-600`:`text-gray-500`),children:e.label})]})]},e.id)})})}function He({draft:e,templates:t,readOnly:n,onChange:i,t:a}){let s=e.name.length>0&&!(0,o.isValidAppName)(e.name);return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-basic-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`label`,{htmlFor:`app-name`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appName`),` `,(0,O.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,O.jsx)(`input`,{id:`app-name`,"data-testid":`app-name-input`,type:`text`,value:e.name,onChange:e=>i({name:e.target.value}),placeholder:`my_app`,disabled:n,className:Q(`block w-full rounded-md border px-3 py-2 text-sm shadow-sm outline-none transition-colors`,`focus:border-blue-500 focus:ring-1 focus:ring-blue-500`,`disabled:cursor-not-allowed disabled:bg-gray-50`,s?`border-red-400`:`border-gray-300`)}),s&&(0,O.jsx)(`p`,{className:`text-xs text-red-500`,children:a(`appDesigner.snakeCaseHint`)})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`label`,{htmlFor:`app-title`,className:`block text-sm font-medium text-gray-700`,children:[a(`appDesigner.appTitle`),` `,(0,O.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,O.jsx)(`input`,{id:`app-title`,"data-testid":`app-title-input`,type:`text`,value:e.title,onChange:e=>i({title:e.target.value}),placeholder:`My Application`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-description`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appDescription`)}),(0,O.jsx)(`textarea`,{id:`app-description`,"data-testid":`app-description-input`,value:e.description??``,onChange:e=>i({description:e.target.value}),rows:3,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 resize-none`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-icon`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.appIcon`)}),(0,O.jsx)(`input`,{id:`app-icon`,type:`text`,value:e.icon??``,onChange:e=>i({icon:e.target.value}),placeholder:`LayoutDashboard`,disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),t.length>0&&(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`app-template`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.template`)}),(0,O.jsxs)(`select`,{id:`app-template`,value:e.template??``,onChange:e=>i({template:e.target.value}),disabled:n,className:`block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:``,children:`None`}),t.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,O.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,O.jsx)(`legend`,{className:`text-sm font-medium text-gray-700`,children:a(`appDesigner.layout`)}),(0,O.jsx)(`div`,{className:`flex gap-3`,children:[{value:`sidebar`,labelKey:`appDesigner.layoutSidebar`,Icon:r.PanelLeft},{value:`header`,labelKey:`appDesigner.layoutHeader`,Icon:r.Layout},{value:`empty`,labelKey:`appDesigner.layoutEmpty`,Icon:r.LayoutTemplate}].map(({value:t,labelKey:r,Icon:o})=>(0,O.jsxs)(`label`,{"data-testid":`app-layout-${t}`,className:Q(`flex flex-1 cursor-pointer flex-col items-center gap-1.5 rounded-lg border-2 p-3 transition-colors`,e.layout===t?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,n&&`pointer-events-none opacity-60`),children:[(0,O.jsx)(o,{className:`h-5 w-5 text-gray-600`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-700`,children:a(r)}),(0,O.jsx)(`input`,{type:`radio`,name:`layout`,value:t,checked:e.layout===t,onChange:()=>i({layout:t}),disabled:n,className:`sr-only`})]},t))})]})]})}function Ue({objects:e,readOnly:t,onToggle:i,onToggleAll:a,search:o,onSearchChange:s,t:c}){let l=(0,n.useMemo)(()=>{if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.label.toLowerCase().includes(t))},[e,o]),u=e.length>0&&e.every(e=>e.selected);return e.every(e=>!e.selected),(0,O.jsxs)(`div`,{"data-testid":`wizard-step-objects-content`,className:`mx-auto max-w-2xl space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(r.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{"data-testid":`object-search`,type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:c(`appDesigner.searchObjects`),className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500`})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(!u),disabled:t,className:`rounded-md border border-gray-300 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:c(u?`appDesigner.deselectAll`:`appDesigner.selectAll`)})]}),l.length===0?(0,O.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:c(`appDesigner.noObjectsFound`)}):(0,O.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:l.map(e=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`object-card-${e.name}`,disabled:t,onClick:()=>i(e.name),className:Q(`flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors`,e.selected?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,t&&`pointer-events-none opacity-60`),children:[(0,O.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,O.jsx)(`div`,{className:Q(`flex h-5 w-5 items-center justify-center rounded border transition-colors`,e.selected?`border-blue-500 bg-blue-500 text-white`:`border-gray-300`),children:e.selected&&(0,O.jsx)(r.Check,{className:`h-3 w-3`})})]}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.name}),e.icon&&(0,O.jsx)(`span`,{className:`text-xs text-gray-400`,children:e.icon})]},e.name))})]})}var We={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 Ge({items:e,readOnly:t,onAdd:n,onRemove:i,onReorder:a,t:o}){return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-navigation-content`,className:`mx-auto max-w-lg space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-group-btn`,onClick:()=>n(`group`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.FolderOpen,{className:`h-3.5 w-3.5`}),o(`appDesigner.addGroup`)]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-url-btn`,onClick:()=>n(`url`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Link,{className:`h-3.5 w-3.5`}),o(`appDesigner.addUrl`)]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`add-separator-btn`,onClick:()=>n(`separator`),disabled:t,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Minus,{className:`h-3.5 w-3.5`}),o(`appDesigner.addSeparator`)]})]}),e.length===0?(0,O.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:o(`appDesigner.noNavItemsHint`)}):(0,O.jsx)(`ul`,{className:`space-y-1.5`,children:e.map((n,c)=>(0,O.jsxs)(`li`,{"data-testid":`nav-item-${n.id}`,className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2`,children:[n.icon&&(0,O.jsx)(`span`,{className:`text-xs text-gray-400`,children:n.icon}),(0,O.jsx)(`span`,{className:`flex-1 truncate text-sm text-gray-800`,children:n.type===`separator`?o(`appDesigner.separatorLabel`):(0,s.resolveI18nLabel)(n.label)}),(0,O.jsx)(`span`,{className:Q(`rounded-full px-2 py-0.5 text-[10px] font-medium`,We[n.type]??`bg-gray-100 text-gray-600`),children:n.type}),(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(n.id,`up`),disabled:t||c===0,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(n.id,`down`),disabled:t||c===e.length-1,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>i(n.id),disabled:t,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30`,"aria-label":`Remove`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function Ke({branding:e,title:t,readOnly:n,onChange:i,t:a}){return(0,O.jsxs)(`div`,{"data-testid":`wizard-step-branding-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-logo`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.logoUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Image,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-logo`,"data-testid":`branding-logo-input`,type:`text`,value:e.logo??``,onChange:e=>i({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-color`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.primaryColor`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Palette,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-color`,"data-testid":`branding-color-input`,type:`text`,value:e.primaryColor??`#3b82f6`,onChange:e=>i({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`branding-favicon`,className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.faviconUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Globe,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`branding-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:e.favicon??``,onChange:e=>i({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-medium text-gray-700`,children:a(`appDesigner.preview`)}),(0,O.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.logo?(0,O.jsx)(`img`,{src:e.logo,alt:`App logo`,className:`h-8 w-8 rounded object-contain`}):(0,O.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400`,children:`Logo`}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:t||a(`appDesigner.appTitle`)})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:e.primaryColor||`#3b82f6`}}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.primaryColor||`#3b82f6`})]}),e.favicon&&(0,O.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,O.jsx)(`img`,{src:e.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:`Favicon`})]})]})]})]})}function qe({availableObjects:e=[],templates:t=[],initialDraft:i,onComplete:a,onCancel:s,onSaveDraft:c,readOnly:l=!1,className:u}){let{t:d}=Z(),f=S(),[p,m]=(0,n.useState)(0),[h,g]=(0,n.useState)(``),[_,v]=(0,n.useState)(()=>({...Le,objects:e.map(e=>({...e})),...i})),y=(0,n.useMemo)(()=>[{id:`basic`,label:d(`appDesigner.basicInfo`),description:d(`appDesigner.stepBasicDesc`),icon:`Settings`},{id:`objects`,label:d(`appDesigner.objects`),description:d(`appDesigner.stepObjectsDesc`),icon:`Database`},{id:`navigation`,label:d(`appDesigner.navigation`),description:d(`appDesigner.stepNavigationDesc`),icon:`Menu`},{id:`branding`,label:d(`appDesigner.branding`),description:d(`appDesigner.stepBrandingDesc`),icon:`Palette`}],[d]),b=p===0,x=p===y.length-1,C=(0,n.useMemo)(()=>_.name.length>0&&(0,o.isValidAppName)(_.name)&&_.title.trim().length>0,[_.name,_.title]),w=(0,n.useMemo)(()=>p===0?C:!0,[p,C]),T=(0,n.useCallback)(e=>{v(t=>({...t,...e}))},[]),E=(0,n.useCallback)(e=>{v(t=>({...t,branding:{...t.branding,...e}}))},[]),D=(0,n.useCallback)(e=>{v(t=>({...t,objects:t.objects.map(t=>t.name===e?{...t,selected:!t.selected}:t)}))},[]),k=(0,n.useCallback)(e=>{v(t=>({...t,objects:t.objects.map(t=>({...t,selected:e}))}))},[]),A=(0,n.useCallback)(e=>{let t={id:Be(e),type:e,label:e===`separator`?``:e===`group`?`New Group`:`New Link`,...e===`group`?{children:[]}:{},...e===`url`?{url:``}:{}};v(e=>({...e,navigation:[...e.navigation,t]}))},[]),j=(0,n.useCallback)(e=>{v(t=>({...t,navigation:t.navigation.filter(t=>t.id!==e)}))},[]),M=(0,n.useCallback)((e,t)=>{v(n=>{let r=[...n.navigation],i=r.findIndex(t=>t.id===e);if(i<0)return n;let a=t===`up`?i-1:i+1;return a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,navigation:r})})},[]),N=(0,n.useCallback)(()=>{x||(p===1&&v(e=>({...e,navigation:Re(e.objects)})),m(e=>e+1))},[p,x]),P=(0,n.useCallback)(()=>{b||m(e=>e-1)},[b]),F=(0,n.useCallback)(()=>{a?.(_)},[_,a]),I=(0,n.useCallback)(async()=>{(_.name.length>0||_.title.length>0)&&s?await f.confirm(d(`appDesigner.cancelConfirmTitle`),d(`appDesigner.cancelConfirmMessage`))&&s():s?.()},[_.name,_.title,s,f,d]),L=(0,n.useCallback)(()=>{c?.(_)},[_,c]),R=(0,n.useCallback)(e=>{e<=p?m(e):e===p+1&&w&&(p===1&&e===2&&v(e=>({...e,navigation:Re(e.objects)})),m(e))},[p,w]);return(0,O.jsxs)(`div`,{className:Q(`flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm`,u),children:[f.isOpen&&(0,O.jsx)(`div`,{"data-testid":`cancel-confirm-dialog`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,"aria-modal":`true`,children:(0,O.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:f.title}),(0,O.jsx)(`button`,{type:`button`,onClick:f.onCancel,className:`rounded p-1 text-gray-400 hover:text-gray-600`,"aria-label":d(`common.close`),children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:f.message}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-keep`,onClick:f.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:d(`appDesigner.keepEditing`)}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-discard`,onClick:f.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:d(`appDesigner.confirmDiscard`)})]})]})}),(0,O.jsx)(`div`,{className:`border-b border-gray-100`,children:(0,O.jsx)(Ve,{steps:y,currentIndex:p,onStepClick:R})}),(0,O.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[p===0&&(0,O.jsx)(He,{draft:_,templates:t,readOnly:l,onChange:T,t:d}),p===1&&(0,O.jsx)(Ue,{objects:_.objects,readOnly:l,onToggle:D,onToggleAll:k,search:h,onSearchChange:g,t:d}),p===2&&(0,O.jsx)(Ge,{items:_.navigation,readOnly:l,onAdd:A,onRemove:j,onReorder:M,t:d}),p===3&&(0,O.jsx)(Ke,{branding:_.branding,title:_.title,readOnly:l,onChange:E,t:d})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`wizard-cancel`,onClick:I,disabled:l,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:d(`common.cancel`)}),c&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`wizard-save-draft`,onClick:L,disabled:l,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:d(`appDesigner.saveDraft`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!b&&(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-back`,onClick:P,disabled:l,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.ChevronLeft,{className:`h-4 w-4`}),d(`common.back`)]}),x?(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-complete`,onClick:F,disabled:l||!w,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(r.Check,{className:`h-4 w-4`}),d(`appDesigner.complete`)]}):(0,O.jsxs)(`button`,{type:`button`,"data-testid":`wizard-next`,onClick:N,disabled:l||!w,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:[d(`common.next`),(0,O.jsx)(r.ChevronRight,{className:`h-4 w-4`})]})]})]})]})}function Je(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Ye=0;function Xe(e){return Ye+=1,`${e}_${Date.now()}_${Ye}`}var Ze={object:{labelKey:`appDesigner.navTypeObject`,color:`bg-green-100 text-green-700`,Icon:r.Database},dashboard:{labelKey:`appDesigner.navTypeDashboard`,color:`bg-amber-100 text-amber-700`,Icon:r.LayoutDashboard},page:{labelKey:`appDesigner.navTypePage`,color:`bg-teal-100 text-teal-700`,Icon:r.FileText},report:{labelKey:`appDesigner.navTypeReport`,color:`bg-rose-100 text-rose-700`,Icon:r.BarChart3},url:{labelKey:`appDesigner.navTypeUrl`,color:`bg-sky-100 text-sky-700`,Icon:r.Link},group:{labelKey:`appDesigner.navTypeGroup`,color:`bg-purple-100 text-purple-700`,Icon:r.FolderOpen},separator:{labelKey:`appDesigner.navTypeSeparator`,color:`bg-gray-100 text-gray-600`,Icon:r.Minus},action:{labelKey:`appDesigner.navTypeAction`,color:`bg-orange-100 text-orange-700`,Icon:r.MousePointerClick}},Qe=[{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 $e({item:e,depth:t,index:i,total:a,readOnly:o,onRemove:c,onMoveUp:l,onMoveDown:u,onToggleExpand:d,onUpdateLabel:f,onUpdateIcon:p,onToggleVisible:m,onAddChild:h,expandedIds:g,t:_}){let[v,y]=(0,n.useState)(!1),[b,x]=(0,n.useState)((0,s.resolveI18nLabel)(e.label)??``),[S,C]=(0,n.useState)(!1),[w,T]=(0,n.useState)(e.icon||``),E=Ze[e.type];e.type===`group`&&e.children&&e.children.length;let D=g.has(e.id),k=e.visible===!1,A=()=>{b.trim()?f(e.id,b.trim()):x((0,s.resolveI18nLabel)(e.label)??``),y(!1)},j=()=>{p(e.id,w.trim()),C(!1)};return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`li`,{"data-testid":`nav-designer-item-${e.id}`,className:Je(`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50`,k&&`opacity-50`),style:{marginLeft:t*20},children:[(0,O.jsx)(r.GripVertical,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300`}),e.type===`group`?(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":_(D?`appDesigner.navCollapseGroup`:`appDesigner.navExpandGroup`),children:D?(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`}):(0,O.jsx)(r.ChevronRight,{className:`h-3.5 w-3.5`})}):(0,O.jsx)(`span`,{className:`w-5`}),S&&!o?(0,O.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),onBlur:j,onKeyDown:t=>{t.key===`Enter`&&j(),t.key===`Escape`&&(T(e.icon||``),C(!1))},autoFocus:!0,placeholder:_(`appDesigner.navIconPlaceholder`),"data-testid":`nav-designer-icon-input-${e.id}`,className:`w-24 rounded border border-blue-300 px-1 py-0.5 text-xs outline-none focus:ring-1 focus:ring-blue-400`}):(0,O.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,O.jsx)(E.Icon,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}),!o&&e.type!==`separator`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>{T(e.icon||``),C(!0)},className:`rounded p-0.5 text-gray-300 hover:text-blue-500`,"aria-label":_(`appDesigner.navEditIcon`),"data-testid":`nav-designer-edit-icon-${e.id}`,children:(0,O.jsx)(r.Pencil,{className:`h-2.5 w-2.5`})})]}),e.type===`separator`?(0,O.jsx)(`span`,{className:`flex-1 text-xs italic text-gray-400`,children:_(`appDesigner.separatorLabel`)}):v&&!o?(0,O.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),onBlur:A,onKeyDown:t=>{t.key===`Enter`&&A(),t.key===`Escape`&&(x((0,s.resolveI18nLabel)(e.label)??``),y(!1))},autoFocus:!0,className:`flex-1 rounded border border-blue-300 px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-blue-400`}):(0,O.jsx)(`span`,{className:Je(`flex-1 truncate text-sm text-gray-800`,!o&&`cursor-text`),onDoubleClick:()=>{!o&&e.type!==`separator`&&(x((0,s.resolveI18nLabel)(e.label)??``),y(!0))},children:(0,s.resolveI18nLabel)(e.label)}),(0,O.jsx)(`span`,{className:Je(`rounded-full px-2 py-0.5 text-[10px] font-medium`,E.color),children:_(E.labelKey)}),k&&(0,O.jsx)(`span`,{className:`rounded-full bg-gray-200 px-1.5 py-0.5 text-[10px] font-medium text-gray-500`,"data-testid":`nav-designer-hidden-badge-${e.id}`,children:_(`appDesigner.navHidden`)}),!o&&e.type!==`separator`&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-700`,"aria-label":_(`appDesigner.navToggleVisible`),"data-testid":`nav-designer-toggle-visible-${e.id}`,children:k?(0,O.jsx)(r.EyeOff,{className:`h-3.5 w-3.5`}):(0,O.jsx)(r.Eye,{className:`h-3.5 w-3.5`})}),e.type===`group`&&!o&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(e.id,`page`),className:`rounded p-0.5 text-gray-400 hover:text-blue-500`,"aria-label":_(`appDesigner.navAddChild`),"data-testid":`nav-designer-add-child-${e.id}`,children:(0,O.jsx)(r.Plus,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:o||i===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":_(`appDesigner.navMoveUp`),children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),disabled:o||i===a-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":_(`appDesigner.navMoveDown`),children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:o,className:`rounded p-0.5 text-gray-400 hover:text-red-500 disabled:opacity-30`,"aria-label":_(`appDesigner.navRemove`),"data-testid":`nav-designer-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]}),e.type===`group`&&D&&e.children&&(0,O.jsx)(O.Fragment,{children:e.children.map((n,r)=>(0,O.jsx)($e,{item:n,depth:t+1,index:r,total:e.children.length,readOnly:o,onRemove:c,onMoveUp:l,onMoveDown:u,onToggleExpand:d,onUpdateLabel:f,onUpdateIcon:p,onToggleVisible:m,onAddChild:h,expandedIds:g,t:_},n.id))})]})}function et({items:e,t}){return(0,O.jsxs)(`div`,{"data-testid":`nav-designer-preview`,className:`w-56 shrink-0 rounded-lg border border-gray-200 bg-gray-50 p-3`,children:[(0,O.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase text-gray-500`,children:t(`appDesigner.navLivePreview`)}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-gray-400`,children:t(`appDesigner.navNoPreviewItems`)}):(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:e.map(e=>(0,O.jsx)(tt,{item:e,depth:0},e.id))})]})}function tt({item:e,depth:t}){let n=Ze[e.type];return e.type===`separator`?(0,O.jsx)(`li`,{className:`my-1 border-t border-gray-200`,style:{marginLeft:t*12}}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded px-2 py-1 text-xs text-gray-700 hover:bg-gray-100`,style:{marginLeft:t*12},children:[(0,O.jsx)(n.Icon,{className:`h-3 w-3 text-gray-400`}),(0,O.jsx)(`span`,{className:`truncate`,children:(0,s.resolveI18nLabel)(e.label)})]}),e.type===`group`&&e.children?.map(e=>(0,O.jsx)(tt,{item:e,depth:t+1},e.id))]})}function nt({items:e,onChange:t,readOnly:i=!1,showPreview:a=!0,className:o,onExport:s,onImport:c}){let{t:l}=Z(),u=(0,n.useRef)(null),[d,f]=(0,n.useState)(()=>new Set(e.filter(e=>e.type===`group`).map(e=>e.id))),p=(0,n.useCallback)(n=>{function r(e){return e.filter(e=>e.id!==n).map(e=>e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),m=(0,n.useCallback)((n,r)=>{function i(e){let t=e.findIndex(e=>e.id===n);if(t>=0){let n=r===`up`?t-1:t+1;if(n>=0&&n<e.length){let r=[...e];return[r[t],r[n]]=[r[n],r[t]],r}return e}return e.map(e=>e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),h=(0,n.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,label:r}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),g=(0,n.useCallback)((n,r)=>{function i(e){return e.map(e=>e.id===n?{...e,icon:r||void 0}:e.children?{...e,children:i(e.children)}:e)}t(i(e))},[e,t]),_=(0,n.useCallback)(n=>{function r(e){return e.map(e=>e.id===n?{...e,visible:e.visible===!1}:e.children?{...e,children:r(e.children)}:e)}t(r(e))},[e,t]),v=(0,n.useCallback)((n,r)=>{let i={id:Xe(r),type:r,label:r===`separator`?``:`New ${l(Ze[r].labelKey)}`,...r===`group`?{children:[]}:{},...r===`url`?{url:``}:{}};function a(e){return e.map(e=>e.id===n&&e.type===`group`?{...e,children:[...e.children||[],i]}:e.children?{...e,children:a(e.children)}:e)}t(a(e)),f(e=>new Set(e).add(n))},[e,t]),y=(0,n.useCallback)(n=>{let r={id:Xe(n),type:n,label:n===`separator`?``:`New ${l(Ze[n].labelKey)}`,...n===`group`?{children:[]}:{},...n===`url`?{url:``}:{}};t([...e,r])},[e,t,l]),b=(0,n.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),x=(0,n.useCallback)(()=>{if(s)s(e);else{let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`navigation-schema.json`,i.click(),URL.revokeObjectURL(r)}},[e,s]),S=(0,n.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);Array.isArray(n)&&(c?c(n):t(n))}catch{}},r.readAsText(n),u.current&&(u.current.value=``)},[t,c]);return(0,O.jsxs)(`div`,{"data-testid":`navigation-designer`,className:Je(`flex flex-col gap-4 sm:flex-row`,o),children:[(0,O.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Qe.map(({type:e,labelKey:t})=>{let{Icon:n,color:a}=Ze[e];return(0,O.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-add-${e}`,onClick:()=>y(e),disabled:i,className:Je(`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,O.jsx)(r.Plus,{className:`h-3 w-3`}),l(t)]},e)}),(0,O.jsx)(`span`,{className:`mx-1 hidden h-4 w-px bg-gray-200 sm:block`}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-export`,onClick:x,className:`inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50`,children:[(0,O.jsx)(r.Download,{className:`h-3 w-3`}),l(`appDesigner.navExportSchema`)]}),(0,O.jsxs)(`label`,{"data-testid":`nav-designer-import`,className:Je(`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`,i&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(r.Upload,{className:`h-3 w-3`}),l(`appDesigner.navImportSchema`),(0,O.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,onChange:S,disabled:i,"data-testid":`nav-designer-import-input`})]})]}),e.length===0?(0,O.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-400`,children:l(`appDesigner.navNoItems`)}):(0,O.jsx)(`ul`,{className:`space-y-1`,"data-testid":`nav-designer-tree`,children:e.map((t,n)=>(0,O.jsx)($e,{item:t,depth:0,index:n,total:e.length,readOnly:i,onRemove:p,onMoveUp:e=>m(e,`up`),onMoveDown:e=>m(e,`down`),onToggleExpand:b,onUpdateLabel:h,onUpdateIcon:g,onToggleVisible:_,onAddChild:v,expandedIds:d,t:l},t.id))})]}),a&&(0,O.jsx)(et,{items:e,t:l})]})}function rt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var it=[{value:`edit`,label:`Edit`,Icon:r.Pencil},{value:`preview`,label:`Preview`,Icon:r.Eye},{value:`code`,label:`Code`,Icon:r.Code}];function at({mode:e,onChange:t,disabled:n=!1,className:r}){return(0,O.jsx)(`div`,{"data-testid":`editor-mode-toggle`,className:rt(`inline-flex items-center rounded-lg border border-gray-200 bg-gray-50 p-0.5`,r),role:`radiogroup`,"aria-label":`Editor mode`,children:it.map(({value:r,label:i,Icon:a})=>(0,O.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,"data-testid":`editor-mode-${r}`,onClick:()=>t(r),disabled:n,className:rt(`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors`,e===r?`bg-white text-gray-900 shadow-sm`:`text-gray-500 hover:text-gray-700`,n&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(a,{className:`h-3.5 w-3.5`}),i]},r))})}function ot(...e){return(0,a.twMerge)((0,i.clsx)(e))}var st=[{type:`metric`,label:`KPI Metric`,Icon:r.TrendingUp},{type:`bar`,label:`Bar Chart`,Icon:r.BarChart3},{type:`line`,label:`Line Chart`,Icon:r.LineChart},{type:`pie`,label:`Pie Chart`,Icon:r.PieChart},{type:`table`,label:`Table`,Icon:r.Table2},{type:`grid`,label:`Grid`,Icon:r.LayoutGrid}],ct=0;function lt(){return ct+=1,`widget_${Date.now()}_${ct}`}function ut({widget:e,index:t,total:n,selected:i,readOnly:a,onSelect:o,onRemove:s,onMoveUp:c,onMoveDown:l}){let u=e.type||`metric`,d=st.find(e=>e.type===u)||st[0];return(0,O.jsxs)(`div`,{"data-testid":`dashboard-widget-${e.id}`,onClick:o,className:ot(`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:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.GripVertical,{className:`h-4 w-4 text-gray-300`}),(0,O.jsx)(d.Icon,{className:`h-4 w-4 text-gray-500`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.title||`Widget ${t+1}`})]}),!a&&(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove widget`,"data-testid":`dashboard-widget-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]}),(0,O.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:d.label}),e.object&&(0,O.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:e.object})]})]})}function dt({widget:e,readOnly:t,onChange:n,onClose:i}){let{t:a}=Z();return(0,O.jsxs)(`div`,{"data-testid":`widget-property-panel`,className:`shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:a(`appDesigner.widgetProperties`)}),(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-title`,className:`text-xs font-medium text-gray-600`,children:`Title`}),(0,O.jsx)(`input`,{id:`widget-title`,"data-testid":`widget-prop-title`,type:`text`,value:e.title??``,onChange:e=>n({title:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-type`,className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,O.jsx)(`select`,{id:`widget-type`,"data-testid":`widget-prop-type`,value:e.type??`metric`,onChange:e=>n({type:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:st.map(e=>(0,O.jsx)(`option`,{value:e.type,children:e.label},e.type))})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-object`,className:`text-xs font-medium text-gray-600`,children:`Data Source (Object)`}),(0,O.jsx)(`input`,{id:`widget-object`,"data-testid":`widget-prop-object`,type:`text`,value:e.object??``,onChange:e=>n({object:e.target.value}),disabled:t,placeholder:`e.g. orders`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-value-field`,className:`text-xs font-medium text-gray-600`,children:`Value Field`}),(0,O.jsx)(`input`,{id:`widget-value-field`,"data-testid":`widget-prop-value-field`,type:`text`,value:e.valueField??``,onChange:e=>n({valueField:e.target.value}),disabled:t,placeholder:`e.g. amount`,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-aggregate`,className:`text-xs font-medium text-gray-600`,children:`Aggregate`}),(0,O.jsxs)(`select`,{id:`widget-aggregate`,"data-testid":`widget-prop-aggregate`,value:e.aggregate??`count`,onChange:e=>n({aggregate:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:`count`,children:`Count`}),(0,O.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,O.jsx)(`option`,{value:`avg`,children:`Average`}),(0,O.jsx)(`option`,{value:`min`,children:`Min`}),(0,O.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-color`,className:`text-xs font-medium text-gray-600`,children:`Color Variant`}),(0,O.jsxs)(`select`,{id:`widget-color`,"data-testid":`widget-prop-color`,value:e.colorVariant??`default`,onChange:e=>n({colorVariant:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`,children:[(0,O.jsx)(`option`,{value:`default`,children:`Default`}),(0,O.jsx)(`option`,{value:`blue`,children:`Blue`}),(0,O.jsx)(`option`,{value:`teal`,children:`Teal`}),(0,O.jsx)(`option`,{value:`orange`,children:`Orange`}),(0,O.jsx)(`option`,{value:`purple`,children:`Purple`}),(0,O.jsx)(`option`,{value:`success`,children:`Success`}),(0,O.jsx)(`option`,{value:`warning`,children:`Warning`}),(0,O.jsx)(`option`,{value:`danger`,children:`Danger`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:a(`appDesigner.widgetLayoutSize`)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-width`,className:`text-[10px] text-gray-400`,children:a(`appDesigner.widgetWidth`)}),(0,O.jsx)(`input`,{id:`widget-width`,"data-testid":`widget-prop-width`,type:`number`,min:1,value:e.layout?.w??1,onChange:t=>n({layout:{...e.layout,w:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`label`,{htmlFor:`widget-height`,className:`text-[10px] text-gray-400`,children:a(`appDesigner.widgetHeight`)}),(0,O.jsx)(`input`,{id:`widget-height`,"data-testid":`widget-prop-height`,type:`number`,min:1,value:e.layout?.h??1,onChange:t=>n({layout:{...e.layout,h:Number(t.target.value)||1}}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]})]})]})]})}function ft({schema:e}){let{t}=Z(),n=e.widgets||[];return(0,O.jsxs)(`div`,{"data-testid":`dashboard-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,O.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||t(`appDesigner.dashboardPreview`)}),n.length===0?(0,O.jsx)(`div`,{className:`text-xs text-gray-400`,children:t(`appDesigner.noWidgetsPreview`)}):(0,O.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${e.columns??2}, 1fr)`},children:n.map(e=>{let t=st.find(t=>t.type===(e.type||`metric`))||st[0];return(0,O.jsxs)(`div`,{className:`rounded-md border border-gray-200 bg-white p-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(t.Icon,{className:`h-3 w-3 text-gray-400`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.title||`Untitled`})]}),(0,O.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function pt({schema:e,onChange:t,readOnly:i=!1,className:a,onExport:o,onImport:s,selectedWidgetId:c,onWidgetSelect:l}){let{t:u}=Z(),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(!1),h=(0,n.useRef)(null),g=(0,n.useRef)(null),_=c!==void 0,v=_?c:d,y=(0,n.useCallback)(e=>{l&&l(e),_||f(e)},[_,l,f]),{current:b,canUndo:S,canRedo:C,push:w,undo:T,redo:E}=x(e),D=(0,n.useCallback)(e=>{w(e),t(e)},[w,t]),k=b.widgets||[],A=k.find(e=>e.id===v),j=(0,n.useCallback)(e=>{let t=lt(),n={id:t,title:``,type:e,layout:{x:0,y:k.length,w:b.columns??2,h:1}};D({...b,widgets:[...k,n]}),y(t)},[b,k,D,y]),M=(0,n.useCallback)(e=>{D({...b,widgets:k.filter(t=>t.id!==e)}),v===e&&y(null)},[b,k,v,D,y]),N=(0,n.useCallback)((e,t)=>{let n=k.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=k.length)return;let i=[...k];[i[n],i[r]]=[i[r],i[n]],D({...b,widgets:i})},[b,k,D]),P=(0,n.useCallback)(e=>{v&&D({...b,widgets:k.map(t=>t.id===v?{...t,...e}:t)})},[b,k,v,D]);(0,n.useEffect)(()=>{let e=h.current;if(!e)return;let t=e=>{if(!i){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),T();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),E();return}if((e.key===`Delete`||e.key===`Backspace`)&&v){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),M(v)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,T,E,v,M]);let F=(0,n.useCallback)(()=>{o&&o(b)},[b,o]),I=(0,n.useCallback)(()=>{g.current?.click()},[]),L=(0,n.useCallback)(e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{try{let e=JSON.parse(n.result);e&&e.type===`dashboard`&&(D(e),s?.(e))}catch{}},n.readAsText(t),e.target.value=``},[D,s]);return(0,O.jsxs)(`div`,{ref:h,tabIndex:0,"data-testid":`dashboard-editor`,className:ot(`flex flex-col gap-4 outline-none`,a),children:[(0,O.jsx)(`input`,{ref:g,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`dashboard-import-input`,onChange:L}),A&&!p&&(0,O.jsx)(dt,{widget:A,readOnly:i,onChange:P,onClose:()=>y(null)}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[u(`appDesigner.addWidget`),`:`]}),st.map(({type:e,label:t,Icon:n})=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>j(e),disabled:i||p,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(n,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-undo`,onClick:T,disabled:!S,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":u(`appDesigner.undo`),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-redo`,onClick:E,disabled:!C,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":u(`appDesigner.redo`),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})})]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-export`,onClick:F,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":u(`appDesigner.navExportSchema`),children:(0,O.jsx)(r.Download,{className:`h-4 w-4`})}),!i&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-import`,onClick:I,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":u(`appDesigner.navImportSchema`),children:(0,O.jsx)(r.Upload,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`dashboard-preview-toggle`,onClick:()=>m(e=>!e),className:ot(`rounded p-1.5 transition-colors`,p?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":u(p?`appDesigner.modeEdit`:`appDesigner.preview`),children:p?(0,O.jsx)(r.EyeOff,{className:`h-4 w-4`}):(0,O.jsx)(r.Eye,{className:`h-4 w-4`})})]})]}),p?(0,O.jsx)(ft,{schema:b}):k.length===0?(0,O.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:u(`appDesigner.noWidgets`)}):(0,O.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${b.columns??2}, 1fr)`},children:k.map((e,t)=>(0,O.jsx)(ut,{widget:e,index:t,total:k.length,selected:e.id===v,readOnly:i,onSelect:()=>y(e.id??null),onRemove:()=>M(e.id),onMoveUp:()=>N(e.id,`up`),onMoveDown:()=>N(e.id,`down`)},e.id))})]})]})}function mt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var ht=[{type:`grid`,label:`Data Grid`,Icon:r.Table2},{type:`kanban`,label:`Kanban Board`,Icon:r.Kanban},{type:`calendar`,label:`Calendar`,Icon:r.CalendarDays},{type:`gallery`,label:`Gallery`,Icon:r.GalleryHorizontalEnd},{type:`dashboard`,label:`Dashboard`,Icon:r.BarChart3},{type:`form`,label:`Form`,Icon:r.FileText},{type:`layout-grid`,label:`Grid Layout`,Icon:r.LayoutGrid}],gt=[{value:`page`,labelKey:`appDesigner.modePage`},{value:`dashboard`,labelKey:`appDesigner.modeDashboard`}],_t=0;function vt(){return _t+=1,`component_${Date.now()}_${_t}`}function yt({component:e,index:t,total:n,selected:i,readOnly:a,onSelect:o,onRemove:s,onMoveUp:c,onMoveDown:l}){let u=ht.find(t=>t.type===e.type)||ht[0];return(0,O.jsxs)(`div`,{"data-testid":`canvas-component-${e.id}`,onClick:o,className:mt(`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:[(0,O.jsx)(r.GripVertical,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300`}),(0,O.jsx)(u.Icon,{className:`h-5 w-5 shrink-0 text-gray-500`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,O.jsx)(`span`,{className:`ml-2 text-[10px] text-gray-400`,children:u.label})]}),!a&&(0,O.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove component`,"data-testid":`canvas-component-remove-${e.id}`,children:(0,O.jsx)(r.Trash2,{className:`h-3.5 w-3.5`})})]})]})}function bt({component:e,readOnly:t,onChange:n,onClose:i}){let{t:a}=Z();return(0,O.jsxs)(`div`,{"data-testid":`component-property-panel`,className:`w-64 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:a(`appDesigner.componentProperties`)}),(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,O.jsx)(r.X,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{htmlFor:`component-label`,className:`text-xs font-medium text-gray-600`,children:`Label`}),(0,O.jsx)(`input`,{id:`component-label`,"data-testid":`component-prop-label`,type:`text`,value:e.label,onChange:e=>n({label:e.target.value}),disabled:t,className:`block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,O.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600`,children:ht.find(t=>t.type===e.type)?.label??e.type})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`ID`}),(0,O.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-xs font-mono text-gray-500`,children:e.id})]})]})}function xt({schema:e,components:t}){let{t:n}=Z();return(0,O.jsxs)(`div`,{"data-testid":`page-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,O.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||n(`appDesigner.pagePreview`)}),t.length===0?(0,O.jsx)(`div`,{className:`text-xs text-gray-400`,children:n(`appDesigner.noComponentsPreview`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=ht.find(t=>t.type===e.type)||ht[0];return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2`,children:[(0,O.jsx)(t.Icon,{className:`h-4 w-4 text-gray-400`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.label}),(0,O.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function St({schema:e,onChange:t,readOnly:i=!1,className:a,onExport:o,onImport:s}){let{t:c}=Z(),l=(0,n.useRef)(null),u=(0,n.useRef)(null),[d,f]=(0,n.useState)(()=>(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`existing_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}))),[p,m]=(0,n.useState)(null),[h,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)(`page`),y=d.find(e=>e.id===p),{canUndo:b,canRedo:S,push:C,undo:w,redo:T}=x(d),E=(0,n.useCallback)(n=>{f(n),C(n),t({...e,children:n.map(e=>({type:e.type,id:e.id,title:e.label,...e.props}))})},[e,t,C]),D=(0,n.useCallback)(e=>{let t=vt(),n={id:t,type:e,label:ht.find(t=>t.type===e)?.label||e};E([...d,n]),m(t)},[d,E]),k=(0,n.useCallback)(e=>{E(d.filter(t=>t.id!==e)),p===e&&m(null)},[d,p,E]),A=(0,n.useCallback)((e,t)=>{let n=d.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=d.length)return;let i=[...d];[i[n],i[r]]=[i[r],i[n]],E(i)},[d,E]),j=(0,n.useCallback)(e=>{p&&E(d.map(t=>t.id===p?{...t,...e}:t))},[d,p,E]);(0,n.useEffect)(()=>{let e=l.current;if(!e)return;let t=e=>{if(!i){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),w();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),T();return}if((e.key===`Delete`||e.key===`Backspace`)&&p){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),k(p)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,w,T,p,k]);let M=(0,n.useCallback)(()=>{o&&o(e)},[e,o]),N=(0,n.useCallback)(()=>{u.current?.click()},[]),P=(0,n.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let e=JSON.parse(r.result);if(e&&e.type===`page`){let n=(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`imported_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}));f(n),C(n),t(e),s?.(e)}}catch{}},r.readAsText(n),e.target.value=``},[t,C,s]);return(0,O.jsxs)(`div`,{ref:l,tabIndex:0,"data-testid":`page-canvas-editor`,className:mt(`flex flex-col gap-4 outline-none sm:flex-row`,a),children:[(0,O.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`canvas-import-input`,onChange:P}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-2 border-b border-gray-200 pb-2`,role:`tablist`,children:gt.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`tab`,"data-testid":`canvas-mode-${e.value}`,"aria-selected":_===e.value,onClick:()=>v(e.value),className:mt(`rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors`,_===e.value?`border-b-2 border-blue-500 text-blue-600`:`text-gray-500 hover:text-gray-700`),children:c(e.labelKey)},e.value))}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[c(`appDesigner.addComponent`),`:`]}),ht.map(({type:e,label:t,Icon:n})=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`canvas-add-${e}`,onClick:()=>D(e),disabled:i||h,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,O.jsx)(n,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-undo`,onClick:w,disabled:!b,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.undo`),children:(0,O.jsx)(r.Undo2,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-redo`,onClick:T,disabled:!S,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.redo`),children:(0,O.jsx)(r.Redo2,{className:`h-4 w-4`})})]}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-export`,onClick:M,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navExportSchema`),children:(0,O.jsx)(r.Download,{className:`h-4 w-4`})}),!i&&(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-import`,onClick:N,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navImportSchema`),children:(0,O.jsx)(r.Upload,{className:`h-4 w-4`})}),(0,O.jsx)(`button`,{type:`button`,"data-testid":`canvas-preview-toggle`,onClick:()=>g(e=>!e),className:mt(`rounded p-1.5 transition-colors`,h?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":c(h?`appDesigner.modeEdit`:`appDesigner.preview`),children:h?(0,O.jsx)(r.EyeOff,{className:`h-4 w-4`}):(0,O.jsx)(r.Eye,{className:`h-4 w-4`})})]})]}),h?(0,O.jsx)(xt,{schema:e,components:d}):d.length===0?(0,O.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:c(`appDesigner.emptyPage`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:d.map((e,t)=>(0,O.jsx)(yt,{component:e,index:t,total:d.length,selected:e.id===p,readOnly:i,onSelect:()=>m(e.id),onRemove:()=>k(e.id),onMoveUp:()=>A(e.id,`up`),onMoveDown:()=>A(e.id,`down`)},e.id))})]}),y&&!h&&(0,O.jsx)(bt,{component:y,readOnly:i,onChange:j,onClose:()=>m(null)})]})}function Ct(...e){return(0,a.twMerge)((0,i.clsx)(e))}var wt={grid:{label:`Grid`,Icon:r.LayoutGrid},kanban:{label:`Kanban`,Icon:r.Kanban},calendar:{label:`Calendar`,Icon:r.CalendarDays},gallery:{label:`Gallery`,Icon:r.GalleryHorizontalEnd},timeline:{label:`Timeline`,Icon:r.Clock},map:{label:`Map`,Icon:r.Map},gantt:{label:`Gantt`,Icon:r.GanttChart}},Tt=[{value:`compact`,label:`Compact`},{value:`medium`,label:`Medium`},{value:`tall`,label:`Tall`}];function Et({title:e,icon:t,defaultOpen:i=!0,children:a}){let[o,s]=(0,n.useState)(i);return(0,O.jsxs)(`div`,{className:`border-b border-gray-100 pb-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex w-full items-center gap-2 py-2 text-left`,children:[t,(0,O.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase text-gray-500`,children:e}),o?(0,O.jsx)(r.ChevronUp,{className:`h-3.5 w-3.5 text-gray-400`}):(0,O.jsx)(r.ChevronDown,{className:`h-3.5 w-3.5 text-gray-400`})]}),o&&(0,O.jsx)(`div`,{className:`space-y-2`,children:a})]})}function Dt({config:e,onChange:t,availableViewTypes:i=[`grid`,`kanban`,`calendar`,`gallery`,`timeline`,`map`,`gantt`],readOnly:a=!1,className:o}){let s=(0,n.useCallback)(n=>{t({...e,...n})},[e,t]),c=(0,n.useCallback)(t=>{s({columns:e.columns.map(e=>e.name===t?{...e,visible:!e.visible}:e)})},[e,s]),l=(0,n.useCallback)((t,n)=>{let r=[...e.columns],i=r.findIndex(e=>e.name===t);if(i<0)return;let a=n===`up`?i-1:i+1;a<0||a>=r.length||([r[i],r[a]]=[r[a],r[i]],s({columns:r}))},[e,s]),u=(0,n.useMemo)(()=>e.columns.filter(e=>e.visible).length,[e.columns]);return(0,O.jsxs)(`div`,{"data-testid":`object-view-configurator`,className:Ct(`w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4`,o),children:[(0,O.jsx)(Et,{title:`View Type`,icon:(0,O.jsx)(r.LayoutGrid,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(t=>{let{label:n,Icon:r}=wt[t];return(0,O.jsxs)(`button`,{type:`button`,"data-testid":`view-type-${t}`,onClick:()=>s({viewType:t}),disabled:a,className:Ct(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors`,e.viewType===t?`bg-blue-100 text-blue-700`:`text-gray-600 hover:bg-gray-100`,a&&`cursor-not-allowed opacity-50`),children:[(0,O.jsx)(r,{className:`h-3 w-3`}),n]},t)})})}),(0,O.jsx)(Et,{title:`Fields (${u}/${e.columns.length})`,icon:(0,O.jsx)(r.Columns3,{className:`h-3.5 w-3.5 text-gray-500`}),children:e.columns.length===0?(0,O.jsx)(`p`,{className:`text-xs text-gray-400`,children:`No fields configured.`}):(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:e.columns.map((t,n)=>(0,O.jsxs)(`li`,{"data-testid":`view-column-${t.name}`,className:`flex items-center gap-1.5 rounded px-1.5 py-1 text-xs hover:bg-gray-50`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(t.name),disabled:a,className:Ct(`rounded p-0.5 transition-colors`,t.visible?`text-blue-500`:`text-gray-300`),"aria-label":t.visible?`Hide field`:`Show field`,children:t.visible?(0,O.jsx)(r.Eye,{className:`h-3 w-3`}):(0,O.jsx)(r.EyeOff,{className:`h-3 w-3`})}),(0,O.jsx)(`span`,{className:`flex-1 truncate text-gray-700`,children:t.label}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(t.name,`up`),disabled:a||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,O.jsx)(r.ChevronUp,{className:`h-3 w-3`})}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(t.name,`down`),disabled:a||n===e.columns.length-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,O.jsx)(r.ChevronDown,{className:`h-3 w-3`})})]},t.name))})}),(0,O.jsx)(Et,{title:`Toolbar`,icon:(0,O.jsx)(r.Filter,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showSearch,onChange:e=>s({showSearch:e.target.checked}),disabled:a,"data-testid":`view-toggle-search`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Search`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showFilters,onChange:e=>s({showFilters:e.target.checked}),disabled:a,"data-testid":`view-toggle-filters`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Filters`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.showSort,onChange:e=>s({showSort:e.target.checked}),disabled:a,"data-testid":`view-toggle-sort`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Sort`})]})]})}),(0,O.jsx)(Et,{title:`Appearance`,icon:(0,O.jsx)(r.Settings2,{className:`h-3.5 w-3.5 text-gray-500`}),defaultOpen:!1,children:(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`label`,{className:`text-[10px] font-medium text-gray-500`,children:`Row Height`}),(0,O.jsx)(`div`,{className:`flex gap-1`,children:Tt.map(({value:t,label:n})=>(0,O.jsx)(`button`,{type:`button`,"data-testid":`view-row-height-${t}`,onClick:()=>s({rowHeight:t}),disabled:a,className:Ct(`flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors`,e.rowHeight===t?`bg-blue-100 text-blue-700`:`bg-gray-50 text-gray-500 hover:bg-gray-100`),children:n},t))})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.striped,onChange:e=>s({striped:e.target.checked}),disabled:a,"data-testid":`view-toggle-striped`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Striped Rows`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.bordered,onChange:e=>s({bordered:e.target.checked}),disabled:a,"data-testid":`view-toggle-bordered`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,O.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Bordered`})]})]})})]})}function $(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Ot=[{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`}],kt=[`Inter`,`Roboto`,`Open Sans`,`Lato`,`Montserrat`,`Poppins`,`Source Sans Pro`,`Noto Sans`,`system-ui`];function At({branding:e,onChange:t,appTitle:i=`My App`,readOnly:a=!1,className:o,onExport:s,onImport:c}){let{t:l}=Z(),[u,d]=(0,n.useState)(`light`),{current:f,push:p,canUndo:m,canRedo:h,undo:g,redo:_}=x(e),v=(0,n.useRef)(!0);(0,n.useEffect)(()=>{if(v.current){v.current=!1;return}t(f)},[f]);let y=(0,n.useCallback)(e=>{let n={...f,...e};v.current=!0,p(n),t(n)},[f,p,t]),b=(0,n.useCallback)(()=>{if(s){s(f);return}let e=new Blob([JSON.stringify(f,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`branding.json`,n.click(),URL.revokeObjectURL(t)},[f,s]),S=(0,n.useCallback)(()=>{if(c){c(f);return}let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);if(typeof n==`object`&&n){let e={...f,...n};p(e),t(e)}}catch{}},r.readAsText(n)},e.click()},[f,p,t,c]),C=(0,n.useCallback)(e=>{a||((e.ctrlKey||e.metaKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?_():g()),(e.ctrlKey||e.metaKey)&&e.key===`y`&&(e.preventDefault(),_()))},[a,g,_]),w=f.primaryColor||`#3b82f6`,T=u===`dark`;return(0,O.jsxs)(`div`,{"data-testid":`branding-editor`,className:$(`flex flex-col gap-4 sm:gap-6`,o),onKeyDown:C,tabIndex:0,children:[(0,O.jsxs)(`div`,{"data-testid":`branding-editor-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800 mr-auto`,children:l(`appDesigner.brandingEditor`)}),(0,O.jsxs)(`button`,{"data-testid":`branding-undo`,type:`button`,onClick:g,disabled:!m||a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,m&&!a?`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:l(`appDesigner.undo`),children:[(0,O.jsx)(r.Undo2,{className:`h-3.5 w-3.5`}),l(`appDesigner.undo`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-redo`,type:`button`,onClick:_,disabled:!h||a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,h&&!a?`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:l(`appDesigner.redo`),children:[(0,O.jsx)(r.Redo2,{className:`h-3.5 w-3.5`}),l(`appDesigner.redo`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-export`,type:`button`,onClick:b,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:l(`appDesigner.brandingExport`),children:[(0,O.jsx)(r.Download,{className:`h-3.5 w-3.5`}),l(`appDesigner.brandingExport`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-import`,type:`button`,onClick:S,disabled:a,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,a?`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:l(`appDesigner.brandingImport`),children:[(0,O.jsx)(r.Upload,{className:`h-3.5 w-3.5`}),l(`appDesigner.brandingImport`)]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:gap-6`,children:[(0,O.jsxs)(`div`,{className:`flex-1 space-y-5`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-logo`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.logoUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Image,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-logo`,"data-testid":`branding-logo-input`,type:`text`,value:f.logo??``,onChange:e=>y({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-color`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.primaryColor`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(r.Palette,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-color`,"data-testid":`branding-color-input`,type:`text`,value:f.primaryColor??`#3b82f6`,onChange:e=>y({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,O.jsx)(`input`,{"data-testid":`branding-color-picker`,type:`color`,value:w,onChange:e=>y({primaryColor:e.target.value}),disabled:a,className:`h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed`})]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(`span`,{className:`text-xs text-gray-500`,children:l(`appDesigner.colorPalette`)}),(0,O.jsx)(`div`,{"data-testid":`branding-color-palette`,className:`flex flex-wrap gap-1.5`,children:Ot.map(e=>(0,O.jsx)(`button`,{"data-testid":`branding-swatch-${e.hex.slice(1)}`,type:`button`,onClick:()=>!a&&y({primaryColor:e.hex}),disabled:a,className:$(`h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed`,w===e.hex?`border-gray-800 ring-2 ring-offset-1 ring-gray-400`:`border-transparent`),style:{backgroundColor:e.hex},title:e.name},e.hex))})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-favicon`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.faviconUrl`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Globe,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{id:`be-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:f.favicon??``,onChange:e=>y({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`be-font`,className:`block text-sm font-medium text-gray-700`,children:l(`appDesigner.fontFamily`)}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(r.Type,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,O.jsxs)(`select`,{id:`be-font`,"data-testid":`branding-font-select`,value:f.fontFamily??``,onChange:e=>y({fontFamily:e.target.value||void 0}),disabled:a,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none`,children:[(0,O.jsx)(`option`,{value:``,children:l(`appDesigner.fontDefault`)}),kt.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,O.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:l(`appDesigner.brandingPreview`)}),(0,O.jsxs)(`div`,{"data-testid":`branding-mode-toggle`,className:`flex rounded-md border border-gray-300 overflow-hidden`,children:[(0,O.jsxs)(`button`,{"data-testid":`branding-mode-light`,type:`button`,onClick:()=>d(`light`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,u===`light`?`bg-blue-50 text-blue-700`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,O.jsx)(r.Sun,{className:`h-3.5 w-3.5`}),l(`appDesigner.modeLight`)]}),(0,O.jsxs)(`button`,{"data-testid":`branding-mode-dark`,type:`button`,onClick:()=>d(`dark`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,u===`dark`?`bg-gray-800 text-gray-100`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,O.jsx)(r.Moon,{className:`h-3.5 w-3.5`}),l(`appDesigner.modeDark`)]})]})]}),(0,O.jsxs)(`div`,{"data-testid":`branding-preview`,className:$(`rounded-lg border p-4 transition-colors`,T?`border-gray-700 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-800`),style:{fontFamily:f.fontFamily||`inherit`},children:[(0,O.jsx)(`div`,{className:`rounded-md p-3 mb-3`,style:{backgroundColor:w},children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[f.logo?(0,O.jsx)(`img`,{src:f.logo,alt:`Logo`,className:`h-8 w-8 rounded object-contain bg-white/20`}):(0,O.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white`,children:`Logo`}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-white`,children:i})]})}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:w}}),(0,O.jsx)(`span`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:w})]}),(0,O.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:l(`appDesigner.brandingSampleButton`)}),(0,O.jsx)(`p`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:l(`appDesigner.brandingSampleText`)}),f.favicon&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`img`,{src:f.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,O.jsx)(`span`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:`Favicon`})]}),f.fontFamily&&(0,O.jsxs)(`div`,{className:$(`text-xs`,T?`text-gray-400`:`text-gray-500`),children:[l(`appDesigner.fontFamily`),`: `,f.fontFamily]})]})]}),(0,O.jsxs)(`div`,{"data-testid":`branding-preview-mobile`,className:$(`mx-auto w-48 rounded-xl border-2 p-2 transition-colors`,T?`border-gray-700 bg-gray-900`:`border-gray-300 bg-white`),style:{fontFamily:f.fontFamily||`inherit`},children:[(0,O.jsx)(`div`,{className:`text-center text-[10px] font-medium text-gray-400 mb-1`,children:l(`appDesigner.mobilePreview`)}),(0,O.jsx)(`div`,{className:`rounded-md p-2 mb-1`,style:{backgroundColor:w},children:(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[f.logo?(0,O.jsx)(`img`,{src:f.logo,alt:`Logo`,className:`h-4 w-4 rounded object-contain bg-white/20`}):(0,O.jsx)(`div`,{className:`flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white`,children:`L`}),(0,O.jsx)(`span`,{className:`text-[9px] font-semibold text-white truncate`,children:i})]})}),(0,O.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,O.jsx)(`div`,{className:$(`h-2 w-3/4 rounded`,T?`bg-gray-700`:`bg-gray-200`)}),(0,O.jsx)(`div`,{className:$(`h-2 w-1/2 rounded`,T?`bg-gray-700`:`bg-gray-200`)}),(0,O.jsx)(`div`,{className:$(`h-2 w-2/3 rounded`,T?`bg-gray-700`:`bg-gray-200`)})]})]})]})]})]})}function jt(...e){return(0,a.twMerge)((0,i.clsx)(e))}var Mt=[`Custom Objects`,`System Objects`,`Integration`,`Analytics`],Nt=[`Box`,`Database`,`Users`,`FileText`,`Settings`,`ShoppingCart`,`Calendar`,`Mail`,`Briefcase`,`Building`,`Globe`,`Heart`,`Star`,`Tag`,`Bookmark`,`Folder`,`Archive`,`Package`,`Truck`,`CreditCard`];function Pt({objects:e,onObjectsChange:i,onSelectObject:a,showSystemObjects:o=!0,readOnly:s=!1,className:u}){let{t:d}=Z(),f=S(),[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(null),_=(0,n.useMemo)(()=>o?e:e.filter(e=>!e.isSystem),[e,o]),v=(0,n.useMemo)(()=>new t.ValueDataSource({items:_}),[_]),y=(0,n.useMemo)(()=>[{field:`name`,label:d(`appDesigner.objectManager.objectName`),width:160},{field:`label`,label:d(`appDesigner.objectManager.objectLabel`),width:160},{field:`group`,label:d(`appDesigner.objectManager.group`),width:130},{field:`fieldCount`,label:`Fields`,width:80},{field:`enabled`,label:d(`appDesigner.objectManager.enabled`),width:80}],[d]),b=(0,n.useMemo)(()=>({type:`object-grid`,objectName:`object_definition`,columns:y,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:s?void 0:{create:!0,update:!0,delete:!0}}),[y,s]),x=(0,n.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&a?.(n)},[e,a]),C=(0,n.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&(g(n),m(!0))},[e]),w=(0,n.useCallback)(async t=>{let n=e.find(e=>e.name===t.name);!n||n.isSystem||await f.confirm(d(`appDesigner.objectManager.deleteConfirmTitle`),d(`appDesigner.objectManager.deleteConfirmMessage`))&&i?.(e.filter(e=>e.id!==n.id))},[e,i,f,d]),T=(0,n.useCallback)(()=>{g(null),m(!0)},[]),E=(0,n.useCallback)(t=>{if(h){let n={...h,name:String(t.name||h.name),label:String(t.label||h.label),pluralLabel:t.pluralLabel?String(t.pluralLabel):void 0,description:t.description?String(t.description):void 0,icon:t.icon?String(t.icon):void 0,group:t.group?String(t.group):void 0,sortOrder:typeof t.sortOrder==`number`?t.sortOrder:void 0,enabled:t.enabled!==!1};i?.(e.map(e=>e.id===h.id?n:e))}else{let n={id:`obj_${Date.now()}`,name:String(t.name||`new_object_${e.length+1}`),label:String(t.label||`New Object ${e.length+1}`),pluralLabel:t.pluralLabel?String(t.pluralLabel):void 0,description:t.description?String(t.description):void 0,icon:t.icon?String(t.icon):void 0,group:t.group?String(t.group):void 0,sortOrder:typeof t.sortOrder==`number`?t.sortOrder:void 0,isSystem:!1,enabled:t.enabled!==!1,fieldCount:0};i?.([...e,n])}m(!1),g(null)},[h,e,i]),D=(0,n.useCallback)(e=>{e||(m(!1),g(null))},[]),k=(0,n.useMemo)(()=>({type:`object-form`,formType:`modal`,objectName:`object_definition`,mode:h?`edit`:`create`,title:h?`${d(`common.edit`)} — ${h.label}`:d(`appDesigner.objectManager.addObject`),open:p,onOpenChange:D,modalSize:`lg`,customFields:[{name:`name`,label:d(`appDesigner.objectManager.objectName`),type:`text`,required:!0,placeholder:`api_name`,disabled:s||(h?.isSystem??!1)},{name:`label`,label:d(`appDesigner.objectManager.objectLabel`),type:`text`,required:!0,placeholder:`Display Name`,disabled:s},{name:`pluralLabel`,label:d(`appDesigner.objectManager.pluralLabel`),type:`text`,placeholder:`Display Names`,disabled:s},{name:`description`,label:d(`appDesigner.appDescription`),type:`textarea`,disabled:s},{name:`icon`,label:d(`appDesigner.objectManager.icon`),type:`select`,options:Nt.map(e=>({label:e,value:e})),disabled:s},{name:`group`,label:d(`appDesigner.objectManager.group`),type:`select`,options:Mt.map(e=>({label:e,value:e})),disabled:s},{name:`sortOrder`,label:d(`appDesigner.objectManager.sortOrder`),type:`number`,disabled:s},{name:`enabled`,label:d(`appDesigner.objectManager.enabled`),type:`boolean`,disabled:s}],initialValues:h?{name:h.name,label:h.label,pluralLabel:h.pluralLabel||``,description:h.description||``,icon:h.icon||``,group:h.group||``,sortOrder:h.sortOrder??0,enabled:h.enabled!==!1}:{enabled:!0},onSuccess:E,onCancel:()=>D(!1),readOnly:s}),[h,p,D,E,s,d]);return(0,O.jsxs)(`div`,{"data-testid":`object-manager`,className:jt(`w-full space-y-3`,u),children:[(0,O.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.Database,{className:`h-4 w-4 text-primary`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:d(`appDesigner.objectManager.title`)}),(0,O.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:_.length})]})}),(0,O.jsx)(c.ObjectGrid,{schema:b,dataSource:v,onRowClick:x,onEdit:s?void 0:C,onDelete:s?void 0:w,onAddRecord:s?void 0:T}),p&&(0,O.jsx)(l.ModalForm,{schema:k}),(0,O.jsx)(A,{isOpen:f.isOpen,title:f.title,message:f.message,confirmLabel:d(`common.delete`),cancelLabel:d(`common.cancel`),onConfirm:f.onConfirm,onCancel:f.onCancel,destructive:!0})]})}function Ft(...e){return(0,a.twMerge)((0,i.clsx)(e))}var It={text:{label:`Text`,Icon:r.Type},textarea:{label:`Text Area`,Icon:r.FileText},number:{label:`Number`,Icon:r.Hash},boolean:{label:`Checkbox`,Icon:r.ToggleLeft},date:{label:`Date`,Icon:r.Calendar},datetime:{label:`Date/Time`,Icon:r.Calendar},time:{label:`Time`,Icon:r.Calendar},select:{label:`Picklist`,Icon:r.ListOrdered},email:{label:`Email`,Icon:r.AtSign},phone:{label:`Phone`,Icon:r.Phone},url:{label:`URL`,Icon:r.Globe},password:{label:`Password`,Icon:r.Lock},currency:{label:`Currency`,Icon:r.Hash},percent:{label:`Percent`,Icon:r.Hash},lookup:{label:`Lookup`,Icon:r.Link2},formula:{label:`Formula`,Icon:r.Code},autonumber:{label:`Auto Number`,Icon:r.Hash},file:{label:`File`,Icon:r.FileText},image:{label:`Image`,Icon:r.Image},markdown:{label:`Markdown`,Icon:r.FileText},html:{label:`Rich Text`,Icon:r.FileText},color:{label:`Color`,Icon:r.Palette},code:{label:`Code`,Icon:r.Code},location:{label:`Location`,Icon:r.MapPin},address:{label:`Address`,Icon:r.MapPin},rating:{label:`Rating`,Icon:r.Star},slider:{label:`Slider`,Icon:r.SlidersHorizontal}},Lt={text:[`text`,`textarea`,`email`,`phone`,`url`,`password`,`markdown`,`html`],number:[`number`,`currency`,`percent`,`autonumber`,`rating`,`slider`],date:[`date`,`datetime`,`time`],choice:[`boolean`,`select`],relation:[`lookup`],advanced:[`formula`,`file`,`image`,`color`,`code`,`location`,`address`]},Rt=[`text`,`number`,`date`,`choice`,`relation`,`advanced`];function zt({objectName:e,fields:i,onFieldsChange:a,readOnly:o=!1,className:s}){let{t:u}=Z(),d=S(),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),[g,_]=(0,n.useState)(``),v=(0,n.useMemo)(()=>g?i.filter(e=>e.type===g):i,[i,g]),y=(0,n.useMemo)(()=>new t.ValueDataSource({items:v}),[v]),b=(0,n.useMemo)(()=>[{field:`name`,label:u(`appDesigner.fieldDesigner.fieldName`),width:140},{field:`label`,label:u(`appDesigner.fieldDesigner.fieldLabel`),width:160},{field:`type`,label:u(`appDesigner.fieldDesigner.fieldType`),width:100},{field:`required`,label:u(`appDesigner.fieldDesigner.required`),width:80},{field:`unique`,label:u(`appDesigner.fieldDesigner.unique`),width:80},{field:`group`,label:u(`appDesigner.fieldDesigner.fieldGroup`),width:120}],[u]),x=(0,n.useMemo)(()=>({type:`object-grid`,objectName:`field_definition`,columns:b,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:o?void 0:{create:!0,update:!0,delete:!0}}),[b,o]),C=(0,n.useCallback)(e=>{let t=i.find(t=>t.name===e.name);t&&(h(t),p(!0))},[i]),w=(0,n.useCallback)(async e=>{let t=i.find(t=>t.name===e.name);!t||t.isSystem||await d.confirm(u(`appDesigner.fieldDesigner.deleteConfirmTitle`),u(`appDesigner.fieldDesigner.deleteConfirmMessage`))&&a?.(i.filter(e=>e.id!==t.id))},[i,a,d,u]),T=(0,n.useCallback)(()=>{h(null),p(!0)},[]),E=(0,n.useCallback)(e=>{if(m){let t={...m,name:String(e.name||m.name),label:String(e.label||m.label),type:e.type||m.type,group:e.group?String(e.group):void 0,description:e.description?String(e.description):void 0,required:e.required===!0,unique:e.unique===!0,readonly:e.readonly===!0,hidden:e.hidden===!0,indexed:e.indexed===!0,externalId:e.externalId===!0,trackHistory:e.trackHistory===!0,defaultValue:e.defaultValue?String(e.defaultValue):void 0,placeholder:e.placeholder?String(e.placeholder):void 0,referenceTo:e.referenceTo?String(e.referenceTo):void 0,formula:e.formula?String(e.formula):void 0};a?.(i.map(e=>e.id===m.id?t:e))}else{let t={id:`fld_${Date.now()}`,name:String(e.name||`new_field_${i.length+1}`),label:String(e.label||`New Field ${i.length+1}`),type:e.type||`text`,group:e.group?String(e.group):void 0,description:e.description?String(e.description):void 0,required:e.required===!0,unique:e.unique===!0,readonly:e.readonly===!0,hidden:e.hidden===!0,indexed:e.indexed===!0,externalId:e.externalId===!0,trackHistory:e.trackHistory===!0,defaultValue:e.defaultValue?String(e.defaultValue):void 0,placeholder:e.placeholder?String(e.placeholder):void 0,referenceTo:e.referenceTo?String(e.referenceTo):void 0,formula:e.formula?String(e.formula):void 0,isSystem:!1};a?.([...i,t])}p(!1),h(null)},[m,i,a]),D=(0,n.useCallback)(e=>{e||(p(!1),h(null))},[]),k=(0,n.useMemo)(()=>Rt.map(e=>({category:e,label:u(`appDesigner.fieldDesigner.typeCategory.${e}`),options:Lt[e].map(e=>({label:It[e].label,value:e}))})),[u]),j=(0,n.useMemo)(()=>k.flatMap(e=>e.options),[k]),M=(0,n.useMemo)(()=>({type:`object-form`,formType:`drawer`,objectName:`field_definition`,mode:m?`edit`:`create`,title:m?`${u(`common.edit`)} — ${m.label}`:u(`appDesigner.fieldDesigner.addField`),open:f,onOpenChange:D,drawerSide:`right`,drawerWidth:`480px`,sections:[{name:`basic`,label:u(`appDesigner.fieldDesigner.basicSection`),fields:[{name:`name`,label:u(`appDesigner.fieldDesigner.fieldName`),type:`text`,required:!0,placeholder:`api_name`,disabled:o||(m?.isSystem??!1)},{name:`label`,label:u(`appDesigner.fieldDesigner.fieldLabel`),type:`text`,required:!0,placeholder:`Display Label`,disabled:o},{name:`type`,label:u(`appDesigner.fieldDesigner.fieldType`),type:`select`,required:!0,options:j,disabled:o||(m?.isSystem??!1)},{name:`required`,label:u(`appDesigner.fieldDesigner.required`),type:`boolean`,disabled:o},{name:`unique`,label:u(`appDesigner.fieldDesigner.unique`),type:`boolean`,disabled:o},{name:`description`,label:u(`appDesigner.fieldDesigner.description`),type:`textarea`,disabled:o}]},{name:`typeSpecific`,label:u(`appDesigner.fieldDesigner.typeSpecificSection`),fields:[{name:`referenceTo`,label:u(`appDesigner.fieldDesigner.referenceTo`),type:`text`,placeholder:`Referenced object`,disabled:o,condition:{field:`type`,equals:`lookup`}},{name:`formula`,label:u(`appDesigner.fieldDesigner.formula`),type:`textarea`,placeholder:`e.g. price * quantity`,disabled:o,condition:{field:`type`,equals:`formula`}},{name:`defaultValue`,label:u(`appDesigner.fieldDesigner.defaultValue`),type:`text`,placeholder:`Default value`,disabled:o},{name:`placeholder`,label:u(`appDesigner.fieldDesigner.placeholder`),type:`text`,placeholder:`Placeholder text`,disabled:o},{name:`group`,label:u(`appDesigner.fieldDesigner.fieldGroup`),type:`text`,placeholder:`Field Group`,disabled:o}]},{name:`advanced`,label:u(`appDesigner.fieldDesigner.advancedSection`),collapsible:!0,collapsed:!0,fields:[{name:`indexed`,label:u(`appDesigner.fieldDesigner.indexed`),type:`boolean`,disabled:o},{name:`externalId`,label:u(`appDesigner.fieldDesigner.externalId`),type:`boolean`,disabled:o},{name:`trackHistory`,label:u(`appDesigner.fieldDesigner.trackHistory`),type:`boolean`,disabled:o},{name:`readonly`,label:u(`appDesigner.fieldDesigner.readOnly`),type:`boolean`,disabled:o},{name:`hidden`,label:u(`appDesigner.fieldDesigner.hidden`),type:`boolean`,disabled:o}]}],initialValues:m?{name:m.name,label:m.label,type:m.type,group:m.group||``,description:m.description||``,required:m.required||!1,unique:m.unique||!1,readonly:m.readonly||!1,hidden:m.hidden||!1,indexed:m.indexed||!1,externalId:m.externalId||!1,trackHistory:m.trackHistory||!1,defaultValue:m.defaultValue==null?``:String(m.defaultValue),placeholder:m.placeholder||``,referenceTo:m.referenceTo||``,formula:m.formula||``}:{type:`text`,required:!1,unique:!1},onSuccess:E,onCancel:()=>D(!1),readOnly:o}),[m,f,D,E,j,o,u]);return(0,O.jsxs)(`div`,{"data-testid":`field-designer`,className:Ft(`w-full space-y-3`,s),children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(r.Columns3,{className:`h-4 w-4 text-primary`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:u(`appDesigner.fieldDesigner.title`)}),e&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`— `,e]}),(0,O.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:v.length})]}),(0,O.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),"data-testid":`field-designer-type-filter`,className:`rounded-md border border-input bg-background px-2 py-1 text-xs outline-none transition-colors focus:border-primary focus:ring-1 focus:ring-primary`,children:[(0,O.jsx)(`option`,{value:``,children:u(`appDesigner.fieldDesigner.allTypes`)}),k.map(e=>(0,O.jsx)(`optgroup`,{label:e.label,children:e.options.map(e=>(0,O.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.category))]})]}),(0,O.jsx)(c.ObjectGrid,{schema:x,dataSource:y,onEdit:o?void 0:C,onDelete:o?void 0:w,onAddRecord:o?void 0:T}),f&&(0,O.jsx)(l.DrawerForm,{schema:M}),(0,O.jsx)(A,{isOpen:d.isOpen,title:d.title,message:d.message,confirmLabel:u(`common.delete`),cancelLabel:u(`common.cancel`),onConfirm:d.onConfirm,onCancel:d.onCancel,destructive:!0})]})}function Bt(...e){return(0,a.twMerge)((0,i.clsx)(e))}function Vt({versions:e,onRestore:t,className:n}){return(0,O.jsxs)(`div`,{className:Bt(`flex flex-col`,n),role:`region`,"aria-label":`Version history`,children:[(0,O.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,O.jsx)(r.History,{className:`h-4 w-4`}),`Version History`]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e.length===0?(0,O.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`No version history available`}):(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(`div`,{className:`absolute left-5 top-0 bottom-0 w-px bg-border`}),e.map(e=>(0,O.jsxs)(`div`,{className:Bt(`relative flex items-start gap-3 px-3 py-2 hover:bg-accent/50`,e.isCurrent&&`bg-accent/30`),children:[(0,O.jsx)(`div`,{className:Bt(`relative z-10 mt-1 h-2.5 w-2.5 rounded-full border-2 bg-background`,e.isCurrent?`border-primary`:`border-muted-foreground`)}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsxs)(`span`,{className:`font-medium`,children:[`v`,e.version]}),e.isCurrent&&(0,O.jsx)(`span`,{className:`px-1 py-0.5 rounded bg-primary/10 text-primary text-[0.6rem]`,children:`Current`})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[0.65rem] text-muted-foreground/70`,children:[(0,O.jsx)(r.User,{className:`h-2.5 w-2.5`}),(0,O.jsx)(`span`,{children:e.userName}),(0,O.jsx)(r.Clock,{className:`h-2.5 w-2.5 ml-1`}),(0,O.jsx)(`span`,{children:new Date(e.timestamp).toLocaleString()})]}),!e.isCurrent&&t&&(0,O.jsx)(`button`,{onClick:()=>t(e.version),className:`mt-1 text-[0.65rem] text-primary hover:underline`,children:`Restore this version`})]})]},e.version))]})})]})}var Ht=`objectui-app-wizard-draft`;function Ut(){let e=(0,u.useNavigate)(),{appName:t}=(0,u.useParams)(),{objects:r,refresh:i}=(0,s.useMetadata)(),a=(0,s.useAdapter)(),c=(r||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:!1})),l=(0,n.useCallback)(()=>{try{let e=localStorage.getItem(Ht);if(e)return JSON.parse(e)}catch{}},[]),f=(0,n.useCallback)(async t=>{try{let n=(0,o.wizardDraftToAppSchema)(t),r=a?.getClient();r&&await r.meta.saveItem(`app`,t.name,n),localStorage.removeItem(Ht),d.toast.success(`Application "${t.title}" created successfully`),await i?.(),e(`/apps/${t.name}`)}catch(e){d.toast.error(e?.message||`Failed to create application`)}},[e,i,a]),p=(0,n.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),m=(0,n.useCallback)(e=>{try{localStorage.setItem(Ht,JSON.stringify(e)),d.toast.info(`Draft saved`)}catch{}},[]);return(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`create-app-page`,children:(0,O.jsx)(qe,{availableObjects:c,initialDraft:l(),onComplete:f,onCancel:p,onSaveDraft:m})})}function Wt(){let e=(0,u.useNavigate)(),{appName:t,editAppName:r}=(0,u.useParams)(),{apps:i,objects:a,refresh:c}=(0,s.useMetadata)(),l=(0,s.useAdapter)(),f=r||t,p=i.find(e=>e.name===f),m=(a||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:p?.navigation?.some(t=>t.type===`object`&&t.objectName===e.name)??!1})),h=(0,n.useMemo)(()=>{if(p)return{name:p.name,title:p.title||p.label||``,description:p.description||``,icon:p.icon||``,layout:p.layout||`sidebar`,navigation:p.navigation||[],branding:{logo:p.branding?.logo||p.logo||``,primaryColor:p.branding?.primaryColor||`#3b82f6`,favicon:p.branding?.favicon||p.favicon||``}}},[p]),g=(0,n.useCallback)(async t=>{try{let n=(0,o.wizardDraftToAppSchema)(t),r={...p,...n},i=l?.getClient();i&&await i.meta.saveItem(`app`,t.name,r),d.toast.success(`Application "${t.title}" updated successfully`),await c?.(),e(`/apps/${t.name}`)}catch(e){d.toast.error(e?.message||`Failed to update application`)}},[e,c,l,p]),_=(0,n.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),v=(0,n.useCallback)(e=>{try{localStorage.setItem(`objectui-edit-draft-${f}`,JSON.stringify(e)),d.toast.info(`Draft saved`)}catch{}},[f]);return p?(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`edit-app-page`,children:(0,O.jsx)(qe,{availableObjects:m,initialDraft:h,onComplete:g,onCancel:_,onSaveDraft:v})}):(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4 text-center`,"data-testid":`edit-app-not-found`,children:(0,O.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Application "`,f,`" not found.`]})})}function Gt(){let e=(0,u.useNavigate)(),{pageName:t}=(0,u.useParams)(),i=(0,s.useAdapter)(),{pages:a}=(0,s.useMetadata)(),o=a?.find(e=>e.name===t),[c,l]=(0,n.useState)(()=>o||{type:`page`,name:t??``,title:t??``,children:[]}),f=(0,n.useRef)(c);f.current=c;let p=(0,n.useCallback)(async e=>{try{if(i)return await i.update(`sys_page`,t,e),!0}catch{}return!1},[i,t]),m=(0,n.useCallback)(async e=>{l(e),await p(e)},[p]);(0,n.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),p(f.current).then(e=>{e&&d.toast.success(`Page saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p]);let h=(0,n.useCallback)(e=>{let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t||`page`}.json`,i.click(),URL.revokeObjectURL(r),d.toast.success(`Page schema exported`)},[t]),g=(0,n.useCallback)(e=>{d.toast.success(`Page schema imported`),m(e)},[m]);return o?(0,O.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`page-design-page`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>e(-1),className:`rounded p-1.5 text-muted-foreground hover:text-foreground`,"aria-label":`Go back`,"data-testid":`page-design-back`,children:(0,O.jsx)(r.ArrowLeft,{className:`h-4 w-4`})}),(0,O.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Page: `,o.label||o.title||t]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(St,{schema:c,onChange:m,onExport:h,onImport:g})})]}):(0,O.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Page "`,t,`" not found`]})}function Kt(){let e=(0,u.useNavigate)(),{dashboardName:t}=(0,u.useParams)(),i=(0,s.useAdapter)(),{dashboards:a,refresh:o}=(0,s.useMetadata)(),c=a?.find(e=>e.name===t),[l,f]=(0,n.useState)(()=>c||{type:`dashboard`,name:t??``,title:t??``,columns:2,widgets:[]}),p=(0,n.useRef)(l);p.current=l;let m=(0,n.useCallback)(async e=>{try{if(i)return await i.update(`sys_dashboard`,t,e),o().catch(()=>{}),!0}catch{}return!1},[i,t,o]),h=(0,n.useCallback)(async e=>{f(e),await m(e)},[m]);(0,n.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),m(p.current).then(e=>{e&&d.toast.success(`Dashboard saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let g=(0,n.useCallback)(e=>{let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t||`dashboard`}.json`,i.click(),URL.revokeObjectURL(r),d.toast.success(`Dashboard schema exported`)},[t]),_=(0,n.useCallback)(e=>{d.toast.success(`Dashboard schema imported`),h(e)},[h]);return c?(0,O.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`dashboard-design-page`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>e(-1),className:`rounded p-1.5 text-muted-foreground hover:text-foreground`,"aria-label":`Go back`,"data-testid":`dashboard-design-back`,children:(0,O.jsx)(r.ArrowLeft,{className:`h-4 w-4`})}),(0,O.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Dashboard: `,c.label||c.title||t]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(pt,{schema:l,onChange:h,onExport:g,onImport:_})})]}):(0,O.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Dashboard "`,t,`" not found`]})}t.ComponentRegistry.register(`page-designer`,H,{namespace:`plugin-designer`,label:`Page Designer`,category:`Designer`,inputs:[{name:`canvas`,type:`code`,label:`Canvas Configuration`},{name:`components`,type:`code`,label:`Components`},{name:`showComponentTree`,type:`boolean`,label:`Show Component Tree`,defaultValue:!0},{name:`undoRedo`,type:`boolean`,label:`Undo/Redo`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`data-model-designer`,W,{namespace:`plugin-designer`,label:`Data Model Designer`,category:`Designer`,inputs:[{name:`entities`,type:`code`,label:`Entities`},{name:`relationships`,type:`code`,label:`Relationships`},{name:`autoLayout`,type:`boolean`,label:`Auto Layout`,defaultValue:!1},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`process-designer`,se,{namespace:`plugin-designer`,label:`Process Designer (BPMN)`,category:`Designer`,inputs:[{name:`processName`,type:`string`,label:`Process Name`},{name:`nodes`,type:`code`,label:`Nodes`},{name:`edges`,type:`code`,label:`Edges`},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`report-designer`,ue,{namespace:`plugin-designer`,label:`Report Designer`,category:`Designer`,inputs:[{name:`reportName`,type:`string`,label:`Report Name`},{name:`objectName`,type:`string`,label:`Data Source Object`},{name:`sections`,type:`code`,label:`Sections`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showPropertyPanel`,type:`boolean`,label:`Show Property Panel`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`app-creation-wizard`,qe,{namespace:`plugin-designer`,label:`App Creation Wizard`,category:`Designer`,inputs:[{name:`availableObjects`,type:`code`,label:`Available Objects`},{name:`templates`,type:`code`,label:`Templates`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`navigation-designer`,nt,{namespace:`plugin-designer`,label:`Navigation Designer`,category:`Designer`,inputs:[{name:`items`,type:`code`,label:`Navigation Items`},{name:`showPreview`,type:`boolean`,label:`Show Preview`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`dashboard-editor`,pt,{namespace:`plugin-designer`,label:`Dashboard Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Dashboard Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`page-canvas-editor`,St,{namespace:`plugin-designer`,label:`Page Canvas Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Page Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`object-view-configurator`,Dt,{namespace:`plugin-designer`,label:`Object View Configurator`,category:`Designer`,inputs:[{name:`config`,type:`code`,label:`View Config`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`branding-editor`,At,{namespace:`plugin-designer`,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}]}),t.ComponentRegistry.register(`object-manager`,Pt,{namespace:`plugin-designer`,label:`Object Manager`,category:`Designer`,inputs:[{name:`objects`,type:`code`,label:`Object Definitions`},{name:`showSystemObjects`,type:`boolean`,label:`Show System Objects`,defaultValue:!0},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),t.ComponentRegistry.register(`field-designer`,zt,{namespace:`plugin-designer`,label:`Field Designer`,category:`Designer`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`},{name:`fields`,type:`code`,label:`Field Definitions`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),e.AppCreationWizard=qe,e.BrandingEditor=At,e.CollaborationProvider=R,e.ConfirmDialog=A,e.ConnectionStatusIndicator=z,e.CreateAppPage=Ut,e.DashboardDesignPage=Kt,e.DashboardEditor=pt,e.DataModelDesigner=W,e.EditAppPage=Wt,e.EditorModeToggle=at,e.FieldDesigner=zt,e.Minimap=F,e.NavigationDesigner=nt,e.ObjectManager=Pt,e.ObjectViewConfigurator=Dt,e.PageCanvasEditor=St,e.PageDesignPage=Gt,e.PageDesigner=H,e.ProcessDesigner=se,e.PropertyEditor=M,e.ReportDesigner=ue,e.VersionHistory=Vt,e.useCanvasPanZoom=T,e.useClipboard=w,e.useConfirmDialog=S,e.useDesignerHistory=te,e.useMultiSelect=C,e.useUndoRedo=x});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-designer",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Visual designer plugin for Object UI with page, data model, process, and report designers plus collaborative editing.",
@@ -33,14 +33,14 @@
33
33
  "lucide-react": "^1.14.0",
34
34
  "sonner": "^2.0.7",
35
35
  "tailwind-merge": "^3.5.0",
36
- "@object-ui/components": "4.0.1",
37
- "@object-ui/core": "4.0.1",
38
- "@object-ui/fields": "4.0.1",
39
- "@object-ui/i18n": "4.0.1",
40
- "@object-ui/plugin-form": "4.0.1",
41
- "@object-ui/plugin-grid": "4.0.1",
42
- "@object-ui/react": "4.0.1",
43
- "@object-ui/types": "4.0.1"
36
+ "@object-ui/components": "4.0.3",
37
+ "@object-ui/core": "4.0.3",
38
+ "@object-ui/fields": "4.0.3",
39
+ "@object-ui/i18n": "4.0.3",
40
+ "@object-ui/plugin-form": "4.0.3",
41
+ "@object-ui/plugin-grid": "4.0.3",
42
+ "@object-ui/react": "4.0.3",
43
+ "@object-ui/types": "4.0.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.6.0",