@object-ui/console 4.0.5 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AppManagementPage-ynJLzxVY.js → AppManagementPage-DvZRhEu3.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-C2rFxE3n.js → ConsoleFloatingChatbot-DSk3VUa6.js} +1 -1
- package/dist/assets/DashboardView-ClGhVUz7.js +1 -0
- package/dist/assets/{MetadataDetailPage-B9EzoQgu.js → MetadataDetailPage-Dn8QJ3Hw.js} +1 -1
- package/dist/assets/{MetadataFormDialog-BebGlAr3.js → MetadataFormDialog-Bf5wwigQ.js} +1 -1
- package/dist/assets/MetadataManagerPage-CLb0l4Pw.js +1 -0
- package/dist/assets/{PageView-C2GS-SQP.js → PageView-_R84mPfp.js} +2 -2
- package/dist/assets/ProfilePage-BFhufxnO.js +1 -0
- package/dist/assets/RecordDetailView-DROfHlhL.js +1 -0
- package/dist/assets/{RecordFormPage-B6mEBKMB.js → RecordFormPage-BqCa2Cez.js} +1 -1
- package/dist/assets/{ReportView-B16PsGer.js → ReportView-bv8vOOKb.js} +2 -2
- package/dist/assets/{SearchResultsPage-932jfRUX.js → SearchResultsPage-KJr5yhgC.js} +1 -1
- package/dist/assets/{SystemHubPage-CqrYgpYf.js → SystemHubPage-LGgCwgTn.js} +1 -1
- package/dist/assets/{data-adapter-BwfAq_h0.js → data-adapter-ChK5QXoY.js} +1 -1
- package/dist/assets/{getIcon-DF6zJOtU.js → getIcon-BKYKFGnN.js} +1 -1
- package/dist/assets/index-C_jWdyY_.css +2 -0
- package/dist/assets/index-DTdi5Ufa.js +2 -0
- package/dist/assets/{plugin-calendar-D1bCBBwe.js → plugin-calendar-CQkP8bUI.js} +1 -1
- package/dist/assets/{plugin-charts-x_9Q2-i_.js → plugin-charts-CJxtgGBd.js} +1 -1
- package/dist/assets/{plugin-chatbot-CgNZnFch.js → plugin-chatbot-CgD9fZFI.js} +14 -14
- package/dist/assets/plugin-form-BFt_k4to.js +1 -0
- package/dist/assets/plugin-gantt-BKC7uDlF.js +1 -0
- package/dist/assets/plugin-grid-C9RnYppl.js +8 -0
- package/dist/assets/plugin-kanban-Bi-sR7AW.js +1 -0
- package/dist/assets/{plugin-map-DZdVR1tc.js → plugin-map-zYnfrqC_.js} +1 -1
- package/dist/assets/{plugin-markdown-BlHuacDq.js → plugin-markdown-D1ozhgoT.js} +1 -1
- package/dist/assets/{plugin-timeline-OEB0nyvd.js → plugin-timeline-B93E4n2x.js} +1 -1
- package/dist/assets/plugin-view-B94g0Ssh.js +1 -0
- package/dist/assets/plugins-views-Bi5okDge.js +63 -0
- package/dist/assets/src-DwuebCF9.js +1 -0
- package/dist/assets/ui-components-BL3SEdAz.css +1 -0
- package/dist/assets/ui-components-DSSaN2w_.js +36 -0
- package/dist/assets/{ui-layout-jqAD528v.js → ui-layout-iDLUMX7R.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +30 -30
- package/dist/assets/DashboardView-x75VLMQW.js +0 -1
- package/dist/assets/MetadataManagerPage-B0xfI-4w.js +0 -1
- package/dist/assets/ProfilePage-BO3TRbTV.js +0 -1
- package/dist/assets/RecordDetailView-Clze41HE.js +0 -1
- package/dist/assets/index-CPatxDwz.js +0 -2
- package/dist/assets/index-vbGrAsEJ.css +0 -2
- package/dist/assets/plugin-form-DOfn-uRa.js +0 -1
- package/dist/assets/plugin-gantt-CHZ4HLjh.js +0 -1
- package/dist/assets/plugin-grid-Cn_T_wpz.js +0 -8
- package/dist/assets/plugin-kanban-BsgjJQam.js +0 -1
- package/dist/assets/plugin-view-CJFsgQ9v.js +0 -1
- package/dist/assets/plugins-views-DqZMtAOw.js +0 -63
- package/dist/assets/src-D5NTzWsi.js +0 -1
- package/dist/assets/ui-components-B5ROGaJH.css +0 -1
- package/dist/assets/ui-components-B7mlp0en.js +0 -36
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-B1k2FF9f.js";import{H as o,O as s,P as c,a as l,f as u,n as d,p as f,t as p}from"./framework-CoXA0nY6.js";import{i as m,o as h,r as g}from"./vendor-ui-utils-Dyl9EYZi.js";import{$A as _,AO as v,CO as y,C_ as b,Cr as x,FC as S,FF as C,FS as w,Fo as T,Jm as E,Jy as D,La as O,Lf as k,Lh as A,Mh as j,NC as M,Nv as N,OD as P,Oc as F,Oj as ee,Pm as I,Py as te,Qb as L,Qs as R,RS as ne,Rd as z,Sk as re,Ta as ie,Td as ae,Tu as oe,Va as se,Vr as ce,Vs as B,XS as le,Xy as ue,YA as de,ZA as fe,_D as pe,ao as V,aw as me,cE as H,cI as he,cT as U,dh as ge,ea as _e,fS as ve,gC as ye,gx as be,hc as xe,i_ as Se,jj as Ce,kM as we,kh as Te,kv as Ee,mM as De,mb as Oe,mm as ke,mo as W,nO as Ae,no as je,pj as Me,pp as Ne,py as Pe,qE as Fe,qg as Ie,rj as G,rk as Le,uE as Re,um as ze,vj as Be,wb as Ve,wh as He,wv as Ue,xb as We,xh as Ge,xj as Ke,xr as qe,yb as Je}from"./ui-components-B7mlp0en.js";import{n as Ye}from"./plugin-grid-Cn_T_wpz.js";import{n as Xe,r as Ze}from"./plugin-form-DOfn-uRa.js";var K=t(n(),1);function Qe(e){return e||(typeof window<`u`&&window.sessionStorage?window.sessionStorage:null)}function $e(e,t={}){let{maxHistory:n=50,persistKey:r,storage:i}=t,a=Qe(i),o=(()=>{if(!r||!a)return null;try{let e=a.getItem(r);if(!e)return null;let t=JSON.parse(e);if(t&&t.v===1&&Array.isArray(t.past)&&Array.isArray(t.future))return t}catch{}return null})(),[s,c]=(0,K.useState)(o?.current??e),l=(0,K.useRef)(o?.past??[]),u=(0,K.useRef)(o?.future??[]),[,d]=(0,K.useState)(0),f=(0,K.useCallback)(()=>d(e=>e+1),[]);(0,K.useEffect)(()=>{if(!(!r||!a))try{let e={v:1,past:l.current,current:s,future:u.current};a.setItem(r,JSON.stringify(e))}catch{}},[s,r,a]);let p=(0,K.useCallback)(e=>{c(t=>(l.current=[...l.current.slice(-(n-1)),t],u.current=[],e)),f()},[n,f]),m=(0,K.useCallback)(()=>{l.current.length!==0&&(c(e=>{let t=[...l.current],n=t.pop();return l.current=t,u.current=[e,...u.current],n}),f())},[f]),h=(0,K.useCallback)(()=>{u.current.length!==0&&(c(e=>{let t=[...u.current],n=t.shift();return u.current=t,l.current=[...l.current,e],n}),f())},[f]),g=(0,K.useCallback)(e=>{l.current=[],u.current=[],c(e),f()},[f]),_=(0,K.useCallback)(()=>{if(!(!r||!a))try{a.removeItem(r)}catch{}},[r,a]),v=(0,K.useCallback)(e=>{let t=l.current.length+1+u.current.length;e<0||e>=t||e!==l.current.length&&(c(t=>{let n=[...l.current,t,...u.current],r=n[e];return l.current=n.slice(0,e),u.current=n.slice(e+1),r}),f())},[f]);return{current:s,canUndo:l.current.length>0,canRedo:u.current.length>0,undoCount:l.current.length,redoCount:u.current.length,timeline:[...l.current,s,...u.current],currentIndex:l.current.length,push:p,undo:m,redo:h,reset:g,jumpTo:v,clearPersisted:_}}function et(){let[e,t]=(0,K.useState)(!1),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(``),o=(0,K.useRef)(null);return{isOpen:e,title:n,message:i,confirm:(0,K.useCallback)((e,n)=>(r(e),a(n),t(!0),new Promise(e=>{o.current=e})),[]),onConfirm:(0,K.useCallback)(()=>{t(!1),o.current?.(!0),o.current=null},[]),onCancel:(0,K.useCallback)(()=>{t(!1),o.current?.(!1),o.current=null},[])}}function tt(){let[e,t]=(0,K.useState)(new Set);return{selectedIds:e,toggle:(0,K.useCallback)((e,n=!1)=>{t(t=>{let r=new Set(n?t:[]);return t.has(e)&&n?r.delete(e):r.add(e),r})},[]),selectOne:(0,K.useCallback)(e=>{t(new Set([e]))},[]),selectMany:(0,K.useCallback)(e=>{t(new Set(e))},[]),clearSelection:(0,K.useCallback)(()=>{t(new Set)},[]),isSelected:(0,K.useCallback)(t=>e.has(t),[e]),count:e.size}}function nt(){let[e,t]=(0,K.useState)(null);return{clipboard:e,copy:(0,K.useCallback)(e=>{t(structuredClone(e))},[]),paste:(0,K.useCallback)(()=>e?structuredClone(e):null,[e]),hasContent:e!==null}}function rt(e={}){let{minZoom:t=.25,maxZoom:n=3,zoomStep:r=.1,initialZoom:i=1}=e,[a,o]=(0,K.useState)(i),[s,c]=(0,K.useState)({x:0,y:0}),l=(0,K.useRef)(!1),u=(0,K.useRef)({x:0,y:0}),d=(0,K.useCallback)(e=>Math.min(n,Math.max(t,+e.toFixed(2))),[t,n]);return{zoom:a,panOffset:s,zoomIn:(0,K.useCallback)(()=>o(e=>d(e+r)),[d,r]),zoomOut:(0,K.useCallback)(()=>o(e=>d(e-r)),[d,r]),resetZoom:(0,K.useCallback)(()=>{o(1),c({x:0,y:0})},[]),setZoom:(0,K.useCallback)(e=>o(d(e)),[d]),handleWheel:(0,K.useCallback)(e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY>0?-r:r;o(e=>d(e+t))}},[d,r]),startPan:(0,K.useCallback)(e=>{if(e.button===1||e.button===0&&e.altKey){e.preventDefault(),l.current=!0,u.current={x:e.clientX,y:e.clientY};let t=e=>{if(!l.current)return;let t=e.clientX-u.current.x,n=e.clientY-u.current.y;u.current={x:e.clientX,y:e.clientY},c(e=>({x:e.x+t,y:e.y+n}))},n=()=>{l.current=!1,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)}},[]),transformStyle:{transform:`translate(${s.x}px, ${s.y}px) scale(${a})`,transformOrigin:`0 0`}}}var q=i();function it(...e){return g(m(e))}function at({isOpen:e,title:t,message:n,confirmLabel:r=`Delete`,cancelLabel:i=`Cancel`,destructive:a=!0,onConfirm:o,onCancel:s}){let c=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let t=c.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),e?(0,q.jsx)(`dialog`,{ref:c,className:`fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50`,onClose:s,"aria-labelledby":`confirm-title`,"aria-describedby":`confirm-message`,children:(0,q.jsxs)(`div`,{className:`w-80 p-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[a&&(0,q.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10`,children:(0,q.jsx)(je,{className:`h-5 w-5 text-destructive`})}),(0,q.jsx)(`h2`,{id:`confirm-title`,className:`text-lg font-semibold`,children:t})]}),(0,q.jsx)(`p`,{id:`confirm-message`,className:`text-sm text-muted-foreground mb-6`,children:n}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{onClick:s,className:`px-4 py-2 text-sm rounded-md border hover:bg-accent`,children:i}),(0,q.jsx)(`button`,{onClick:o,className:it(`px-4 py-2 text-sm rounded-md font-medium`,a?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`),autoFocus:!0,children:r})]})]})}):null}function ot(...e){return g(m(e))}function st({title:e=`Properties`,fields:t,onChange:n,className:r}){let[i,a]=(0,K.useState)(new Set),o=(0,K.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=t.reduce((e,t)=>{let n=t.group??`General`;return e[n]||(e[n]=[]),e[n].push(t),e},{});return(0,q.jsxs)(`div`,{className:ot(`flex flex-col`,r),role:`region`,"aria-label":e,children:[(0,q.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:e}),(0,q.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[Object.entries(s).map(([e,t])=>(0,q.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,q.jsxs)(`button`,{onClick:()=>o(e),className:`w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50`,children:[i.has(e)?(0,q.jsx)(fe,{className:`h-3 w-3`}):(0,q.jsx)(G,{className:`h-3 w-3`}),e]}),!i.has(e)&&(0,q.jsx)(`div`,{className:`px-3 pb-2 space-y-2`,children:t.map(e=>(0,q.jsx)(ct,{field:e,onChange:n},e.name))})]},e)),t.length===0&&(0,q.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground text-center`,children:`Select an element to edit its properties`})]})]})}function ct({field:e,onChange:t}){let n=n=>{t(e.name,n)};return(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:e.label}),e.type===`text`&&(0,q.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,q.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,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!e.value,onChange:e=>n(e.target.checked),className:`rounded`}),(0,q.jsx)(`span`,{className:`text-xs`,children:e.value?`Yes`:`No`})]}),e.type===`select`&&(0,q.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,q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),e.type===`color`&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.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,q.jsx)(`span`,{className:`text-xs font-mono`,children:String(e.value??`#000000`)})]}),e.type===`textarea`&&(0,q.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,q.jsx)(`p`,{className:`text-[0.65rem] text-muted-foreground/70`,children:e.description})]})}function lt(...e){return g(m(e))}function ut({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,q.jsx)(`div`,{className:lt(`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,q.jsxs)(`svg`,{width:s,height:c,viewBox:`0 0 ${t} ${n}`,children:[(0,q.jsx)(`rect`,{width:t,height:n,fill:`hsl(var(--muted))`,opacity:`0.3`}),e.map(e=>(0,q.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:e.selected?`hsl(var(--primary))`:e.color??`hsl(var(--foreground) / 0.3)`,rx:`2`},e.id))]})})}var dt=(0,K.createContext)(null);dt.displayName=`CollaborationContext`;function ft(){return(0,K.useContext)(dt)}function J(...e){return g(m(e))}function pt({canvas:e={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:t=[],palette:n=mt,showComponentTree:r=!0,undoRedo:i=!0,propertyEditor:a=!0,readOnly:o=!1,showMinimap:s=!1,onChange:c,className:l}){let u=$e(t),d=u.current,f=(0,K.useCallback)(e=>{u.push(e),c?.(e)},[u,c]),p=rt({initialZoom:e.zoom??1}),{zoom:m}=p,h=tt(),g=(0,K.useMemo)(()=>{let e=Array.from(h.selectedIds);return e.length>0?e[0]:null},[h.selectedIds]),_=(0,K.useMemo)(()=>d.find(e=>e.id===g),[d,g]),v=nt(),y=et(),x=ft(),S=(0,K.useCallback)(e=>{x&&x.sendOperation({...e,userId:x.currentUserId??``})},[x]),[C,T]=(0,K.useState)(!0),[E,D]=(0,K.useState)(!0),[k,A]=(0,K.useState)(s),M=(0,K.useRef)(null),N=(0,K.useRef)(null),P=(0,K.useCallback)(t=>!e.snapToGrid||!e.gridSize?t:Math.round(t/e.gridSize)*e.gridSize,[e.snapToGrid,e.gridSize]),F=(0,K.useCallback)((e,t)=>{if(o)return;let r=n.flatMap(e=>e.items).find(t=>t.type===e),i=r?.defaultSize,a={id:`comp-${Date.now()}`,type:e,label:t,position:{x:100,y:100,width:i?.width??200,height:i?.height??100},props:r?.defaultProps??{}};f([...d,a]),h.selectOne(a.id),S({type:`insert`,elementId:a.id,data:{component:a}})},[d,o,n,f,h,S]),ee=(0,K.useCallback)(e=>{o||(f(d.filter(t=>t.id!==e)),h.isSelected(e)&&h.clearSelection(),S({type:`delete`,elementId:e,data:{}}))},[d,o,f,h,S]),I=(0,K.useCallback)(async()=>{if(o||h.count===0||!await y.confirm(`Delete components`,`Are you sure you want to delete ${h.count} component${h.count>1?`s`:``}?`))return;let e=h.selectedIds;f(d.filter(t=>!e.has(t.id))),h.clearSelection(),e.forEach(e=>{S({type:`delete`,elementId:e,data:{}})})},[o,h,y,d,f,S]),te=(0,K.useCallback)((e,t)=>{o||!g||(f(d.map(n=>n.id===g?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)),S({type:`update`,elementId:g,data:{[e]:t}}))},[o,g,d,f,S]),L=(0,K.useCallback)(()=>{let e=h.selectedIds;if(e.size===0)return;let t=d.filter(t=>e.has(t.id));v.copy(t)},[h,d,v]),R=(0,K.useCallback)(()=>{if(o)return;let e=v.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}}));f([...d,...n]),h.selectMany(n.map(e=>e.id)),n.forEach(e=>{S({type:`insert`,elementId:e.id,data:{component:e}})})},[o,v,d,f,h,S]),ne=(0,K.useCallback)((e,t)=>{o||(M.current={id:t.id,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[o]),z=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),ie=(0,K.useCallback)(e=>{e.preventDefault();let t=M.current;if(!t||o)return;let n=(e.clientX-t.startX)/m,r=(e.clientY-t.startY)/m;f(d.map(e=>e.id===t.id?{...e,position:{...e.position,x:P(e.position.x+n),y:P(e.position.y+r)}}:e)),S({type:`move`,elementId:t.id,data:{}}),M.current=null},[o,m,d,f,P,S]),ae=(0,K.useMemo)(()=>_?[{name:`label`,label:`Label`,type:`text`,value:_.label??``,group:`General`},{name:`x`,label:`X`,type:`number`,value:_.position.x,group:`Position`},{name:`y`,label:`Y`,type:`number`,value:_.position.y,group:`Position`},{name:`width`,label:`Width`,type:`number`,value:_.position.width,group:`Size`},{name:`height`,label:`Height`,type:`number`,value:_.position.height,group:`Size`}]:[],[_]),oe=(0,K.useMemo)(()=>d.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:h.isSelected(e.id)})),[d,h]);return(0,K.useEffect)(()=>{let e=N.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`)&&h.count>0&&!t){e.preventDefault(),I();return}if(e.key===`Escape`){h.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&i&&!o){e.preventDefault(),u.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&i&&!o){e.preventDefault(),u.redo();return}if(n&&e.key===`c`){e.preventDefault(),L();return}if(n&&e.key===`v`&&!o){e.preventDefault(),R();return}if(n&&e.key===`a`){e.preventDefault(),h.selectMany(d.map(e=>e.id));return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[h,I,i,o,u,L,R,d]),(0,q.jsxs)(`div`,{ref:N,tabIndex:0,className:J(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,l),children:[!o&&(0,q.jsx)(`div`,{className:J(`border-r bg-muted/30 flex flex-col transition-[width] duration-200`,C?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component palette`,children:C&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:`Components`}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:n.map(e=>(0,q.jsxs)(`div`,{className:`mb-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-2 py-1 uppercase`,children:e.label}),e.items.map(e=>(0,q.jsxs)(`button`,{onClick:()=>F(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,q.jsx)(ze,{className:`h-3 w-3`}),e.label]},e.type))]},e.name))})]})}),(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Designer toolbar`,children:[!o&&(0,q.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:C?`Collapse palette`:`Expand palette`,"aria-label":C?`Collapse palette`:`Expand palette`,onClick:()=>T(e=>!e),children:(0,q.jsx)(j,{className:J(`h-4 w-4`,!C&&`rotate-180`)})}),i&&!o&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,!u.canUndo&&`opacity-40 pointer-events-none`),title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,disabled:!u.canUndo,onClick:()=>u.undo(),children:(0,q.jsx)(O,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,!u.canRedo&&`opacity-40 pointer-events-none`),title:`Redo (Ctrl+Shift+Z)`,"aria-label":`Redo`,disabled:!u.canRedo,onClick:()=>u.redo(),children:(0,q.jsx)(Ne,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!o&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,h.count===0&&`opacity-40 pointer-events-none`),title:`Copy (Ctrl+C)`,"aria-label":`Copy`,disabled:h.count===0,onClick:L,children:(0,q.jsx)(Ae,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,!v.hasContent&&`opacity-40 pointer-events-none`),title:`Paste (Ctrl+V)`,"aria-label":`Paste`,disabled:!v.hasContent,onClick:R,children:(0,q.jsx)(re,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!o&&(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,h.count===0&&`opacity-40 pointer-events-none`),title:`Delete selected`,"aria-label":`Delete selected`,disabled:h.count===0,onClick:I,children:(0,q.jsx)(W,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:`Preview`,"aria-label":`Preview`,children:(0,q.jsx)(H,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,k&&`bg-accent`),title:`Toggle minimap`,"aria-label":`Toggle minimap`,onClick:()=>A(e=>!e),children:(0,q.jsx)(Ee,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom out`,onClick:p.zoomOut,children:(0,q.jsx)(b,{className:`h-3 w-3`})}),(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground w-10 text-center`,children:[Math.round(m*100),`%`]}),(0,q.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Zoom in`,onClick:p.zoomIn,children:(0,q.jsx)(ze,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{className:`p-1 rounded hover:bg-accent text-xs`,"aria-label":`Reset zoom`,onClick:p.resetZoom,children:(0,q.jsx)(Ue,{className:`h-3 w-3`})})]}),r&&(0,q.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:E?`Collapse panel`:`Expand panel`,"aria-label":E?`Collapse panel`:`Expand panel`,onClick:()=>D(e=>!e),children:(0,q.jsx)(He,{className:J(`h-4 w-4`,!E&&`rotate-180`)})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,role:`region`,"aria-label":`Design canvas`,onWheel:p.handleWheel,onMouseDown:p.startPan,onDragOver:z,onDrop:ie,children:(0,q.jsxs)(`div`,{className:`relative bg-background border rounded shadow-sm mx-auto`,style:{width:e.width*m,height:e.height*m,transform:`translate(${p.panOffset.x}px, ${p.panOffset.y}px)`,backgroundImage:e.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:e.showGrid&&e.gridSize?`${e.gridSize*m}px ${e.gridSize*m}px`:void 0},children:[d.map(e=>{let t=h.isSelected(e.id);return(0,q.jsxs)(`div`,{draggable:!o,onDragStart:t=>ne(t,e),className:J(`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*m,top:e.position.y*m,width:typeof e.position.width==`number`?e.position.width*m:e.position.width,height:typeof e.position.height==`number`?e.position.height*m:e.position.height},onClick:t=>h.toggle(e.id,t.shiftKey),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b`,children:[(0,q.jsx)(w,{className:`h-3 w-3 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.label??e.type}),!o&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ee(e.id)},className:`ml-auto p-0.5 rounded hover:bg-destructive/10`,"aria-label":`Delete ${e.label??e.type}`,children:(0,q.jsx)(W,{className:`h-3 w-3 text-destructive`})})]}),(0,q.jsx)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:e.type})]},e.id)}),k&&(0,q.jsx)(ut,{items:oe,canvasWidth:e.width,canvasHeight:e.height})]})})]}),r&&(0,q.jsx)(`div`,{className:J(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,E?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component tree`,children:E&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`p-3 border-b font-medium text-sm flex items-center gap-2`,children:[(0,q.jsx)(Ve,{className:`h-4 w-4`}),`Component Tree`]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:d.length===0?(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No components added yet. Click a component in the palette to add it to the canvas.`}):d.map(e=>(0,q.jsx)(`button`,{onClick:t=>h.toggle(e.id,t.shiftKey),className:J(`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left`,h.isSelected(e.id)?`bg-accent`:`hover:bg-accent/50`),children:(0,q.jsx)(`span`,{className:`truncate`,children:e.label??e.type})},e.id))}),a&&_?(0,q.jsx)(`div`,{className:`border-t`,children:(0,q.jsx)(st,{title:`Properties – ${_.label??_.type}`,fields:ae,onChange:te})}):_&&(0,q.jsxs)(`div`,{className:`border-t p-3`,children:[(0,q.jsx)(`div`,{className:`text-xs font-medium mb-2`,children:`Properties`}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-1`,children:[(0,q.jsxs)(`div`,{children:[`Type: `,_.type]}),(0,q.jsxs)(`div`,{children:[`ID: `,_.id]}),(0,q.jsxs)(`div`,{children:[`Position: `,_.position.x,`,`,` `,_.position.y]}),(0,q.jsxs)(`div`,{children:[`Size: `,_.position.width,` ×`,` `,_.position.height]})]})]})]})}),(0,q.jsx)(at,{isOpen:y.isOpen,title:y.title,message:y.message,onConfirm:y.onConfirm,onCancel:y.onCancel})]})}var mt=[{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 ht(e,t={}){return $e(e,t)}function gt(...e){return g(m(e))}var _t=[`text`,`number`,`boolean`,`date`,`datetime`,`uuid`,`email`,`url`,`phone`,`json`,`integer`,`float`,`decimal`,`currency`,`percent`,`textarea`,`select`,`multiselect`,`lookup`,`attachment`,`formula`,`autonumber`];function vt(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 yt({entities:e=[],relationships:t=[],canvas:n={width:1200,height:800,showGrid:!0},showRelationshipLabels:r=!0,readOnly:i=!1,onEntitiesChange:a,onRelationshipsChange:o,className:s}){let c=(0,K.useRef)(null),l=ht({entities:e,relationships:t},{maxHistory:50}),{entities:u,relationships:d}=l.current,f=(0,K.useCallback)(e=>{l.push(e),a?.(e.entities),o?.(e.relationships)},[l,a,o]),p=et(),m=tt(),h=m.count>0?Array.from(m.selectedIds)[0]:null,g=nt(),_=rt({minZoom:.25,maxZoom:3,zoomStep:.1}),v=ft(),[y,b]=(0,K.useState)(!0),[S,C]=(0,K.useState)(!0),[w,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(``),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(``),F=(0,K.useRef)(null),ee=(0,K.useCallback)(()=>{if(i)return;let e=l.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}};f({entities:[...e.entities,t],relationships:e.relationships}),m.selectOne(t.id),v?.sendOperation({type:`insert`,userId:v?.currentUserId??``,elementId:t.id,data:{name:t.name,label:t.label}})},[i,l,f,m,v]),I=(0,K.useCallback)(async e=>{if(i)return;let t=u.find(t=>t.id===e);if(!await p.confirm(`Delete Entity`,`Are you sure you want to delete "${t?.label??e}"? This action cannot be undone.`))return;let n=l.current;f({entities:n.entities.filter(t=>t.id!==e),relationships:n.relationships.filter(t=>t.sourceEntity!==e&&t.targetEntity!==e)}),m.isSelected(e)&&m.clearSelection(),v?.sendOperation({type:`delete`,userId:v?.currentUserId??``,elementId:e,data:{}})},[i,u,p,l,f,m,v]),te=(0,K.useCallback)(async()=>{if(i||m.count===0)return;let e=Array.from(m.selectedIds);if(!await p.confirm(`Delete Entities`,`Are you sure you want to delete ${e.length} selected entity(s)? This action cannot be undone.`))return;let t=l.current,n=new Set(e);f({entities:t.entities.filter(e=>!n.has(e.id)),relationships:t.relationships.filter(e=>!n.has(e.sourceEntity)&&!n.has(e.targetEntity))}),m.clearSelection()},[i,m,p,l,f]),L=(0,K.useCallback)(()=>{if(i)return;let e=l.current;f({entities:vt(e.entities),relationships:e.relationships})},[i,l,f]),R=(0,K.useCallback)(()=>{let e=u.filter(e=>m.isSelected(e.id));e.length>0&&g.copy(e)},[u,m,g]),z=(0,K.useCallback)(()=>{if(i)return;let e=g.paste();if(!e||e.length===0)return;let t=l.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}}));f({entities:[...t.entities,...n],relationships:t.relationships}),m.selectMany(n.map(e=>e.id))},[i,g,l,f,m]),ie=(0,K.useCallback)(e=>{if(i)return;let t=l.current;f({entities:t.entities.map(t=>{if(t.id!==e)return t;let n={name:`field_${t.fields.length+1}`,type:`text`,required:!1};return{...t,fields:[...t.fields,n]}}),relationships:t.relationships})},[i,l,f]),ae=(0,K.useCallback)((e,t,n)=>{i||(T({entityId:e,fieldIndex:t}),D(n))},[i]),oe=(0,K.useCallback)(()=>{if(!w)return;let e=E.trim();if(e===``){T(null);return}let t=l.current;f({entities:t.entities.map(t=>{if(t.id!==w.entityId)return t;let n=t.fields.map((t,n)=>n===w.fieldIndex?{...t,name:e}:t);return{...t,fields:n}}),relationships:t.relationships}),T(null)},[w,E,l,f]),se=(0,K.useCallback)(()=>{T(null)},[]),ce=(0,K.useCallback)((e,t)=>{i||(j(e),N(t))},[i]),B=(0,K.useCallback)(()=>{if(!A)return;let e=M.trim();if(e===``){j(null);return}let t=l.current;f({entities:t.entities.map(t=>t.id===A?{...t,label:e}:t),relationships:t.relationships}),j(null)},[A,M,l,f]),le=(0,K.useCallback)(()=>{j(null)},[]),de=(0,K.useCallback)((e,t,n)=>{if(i)return;let r=l.current;f({entities:r.entities.map(r=>{if(r.id!==e)return r;let i=r.fields.map((e,r)=>r===t?{...e,type:n}:e);return{...r,fields:i}}),relationships:r.relationships})},[i,l,f]),pe=(0,K.useCallback)((e,t)=>{if(i||!u.find(e=>e.id===t))return;let n=e.target.getBoundingClientRect();F.current={entityId:t,offsetX:e.clientX-n.left,offsetY:e.clientY-n.top},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[i,u]),V=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),me=(0,K.useCallback)(e=>{if(e.preventDefault(),!F.current)return;let t=e.currentTarget.getBoundingClientRect(),n=_.zoom,r=(e.clientX-t.left-_.panOffset.x)/n-F.current.offsetX,i=(e.clientY-t.top-_.panOffset.y)/n-F.current.offsetY,a=l.current;f({entities:a.entities.map(e=>e.id===F.current.entityId?{...e,position:{x:Math.max(0,Math.round(r)),y:Math.max(0,Math.round(i))}}:e),relationships:a.relationships}),F.current=null},[_.zoom,_.panOffset,l,f]),H=h?u.find(e=>e.id===h):null,he=H?[{name:`name`,label:`Name`,type:`text`,value:H.name,group:`General`},{name:`label`,label:`Label`,type:`text`,value:H.label,group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:H.description??``,group:`General`},{name:`color`,label:`Color`,type:`color`,value:H.color??`#3b82f6`,group:`Appearance`},{name:`position.x`,label:`X Position`,type:`number`,value:H.position.x,group:`Position`},{name:`position.y`,label:`Y Position`,type:`number`,value:H.position.y,group:`Position`}]:[],U=(0,K.useCallback)((e,t)=>{if(!h)return;let n=l.current;f({entities:n.entities.map(n=>n.id===h?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})},[h,l,f]);(0,K.useEffect)(()=>{let e=c.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(),l.undo()):n&&(e.key===`y`||e.shiftKey&&e.key===`Z`)?(e.preventDefault(),l.redo()):n&&e.key===`c`?(e.preventDefault(),R()):n&&e.key===`v`?(e.preventDefault(),z()):(e.key===`Delete`||e.key===`Backspace`)&&m.count>0?(e.preventDefault(),te()):e.key===`Escape`&&(m.clearSelection(),T(null),j(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[l,R,z,te,m]);let ge=u.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:m.isSelected(e.id)}));return(0,q.jsxs)(`div`,{ref:c,tabIndex:0,className:gt(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,s),children:[(0,q.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,q.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,q.jsx)(P,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`font-medium text-sm`,children:`Data Model Designer`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 ml-2 border-l pl-2`,children:[(0,q.jsx)(`button`,{onClick:()=>l.undo(),disabled:!l.canUndo,"aria-label":`Undo`,title:`Undo (Ctrl+Z)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{onClick:()=>l.redo(),disabled:!l.canRedo,"aria-label":`Redo`,title:`Redo (Ctrl+Y)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(Ne,{className:`h-3.5 w-3.5`})})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,q.jsx)(`button`,{onClick:_.zoomOut,"aria-label":`Zoom Out`,title:`Zoom Out`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-center`,children:[Math.round(_.zoom*100),`%`]}),(0,q.jsx)(`button`,{onClick:_.zoomIn,"aria-label":`Zoom In`,title:`Zoom In`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{onClick:_.resetZoom,"aria-label":`Reset Zoom`,title:`Reset Zoom`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(k,{className:`h-3 w-3`})})]}),!i&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:[(0,q.jsx)(`button`,{onClick:R,disabled:m.count===0,"aria-label":`Copy`,title:`Copy (Ctrl+C)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(Ae,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{onClick:z,disabled:!g.hasContent,"aria-label":`Paste`,title:`Paste (Ctrl+V)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(re,{className:`h-3.5 w-3.5`})})]}),!i&&(0,q.jsxs)(`button`,{onClick:L,"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,q.jsx)(ne,{className:`h-3 w-3`}),` Auto Layout`]}),(0,q.jsx)(`div`,{className:`flex-1`}),v?.isConnected&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,q.jsx)(_e,{className:`h-3 w-3`}),(0,q.jsxs)(`span`,{children:[v.users.length,` user`,v.users.length===1?``:`s`]})]}),m.count>1&&(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[m.count,` selected`]}),!i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{onClick:ee,"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,q.jsx)(ze,{className:`h-3 w-3`}),` Add Entity`]}),(0,q.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,q.jsx)(ue,{className:`h-3 w-3`}),` Add Relationship`]})]})]}),(0,q.jsxs)(`div`,{role:`region`,"aria-label":`Canvas`,className:`flex-1 overflow-auto bg-muted/10 p-4 relative`,onWheel:_.handleWheel,onMouseDown:_.startPan,onDragOver:V,onDrop:me,children:[(0,q.jsxs)(`div`,{className:`relative`,style:{width:n.width,minHeight:n.height,..._.transformStyle,backgroundImage:n.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:n.showGrid?`20px 20px`:void 0},children:[(0,q.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:n.width,height:n.height,children:d.map(e=>{let t=u.find(t=>t.id===e.sourceEntity),n=u.find(t=>t.id===e.targetEntity);return!t||!n?null:(0,q.jsxs)(`g`,{children:[(0,q.jsx)(`line`,{x1:t.position.x+120,y1:t.position.y+50,x2:n.position.x+120,y2:n.position.y+50,stroke:`hsl(var(--primary))`,strokeWidth:`2`,strokeDasharray:e.type===`many-to-many`?`5,5`:void 0}),r&&e.label&&(0,q.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)})}),u.length===0&&(0,q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground text-sm`,children:`No entities in the model. Click 'Add Entity' to create your first entity.`}),u.map(e=>(0,q.jsxs)(`div`,{role:`group`,"aria-label":e.label,draggable:!i,onDragStart:t=>pe(t,e.id),className:gt(`absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing`,m.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=>m.toggle(e.id,t.shiftKey),children:[(0,q.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,q.jsx)(P,{className:`h-3.5 w-3.5`}),A===e.id?(0,q.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),onBlur:B,onKeyDown:e=>{e.key===`Enter`&&B(),e.key===`Escape`&&le()},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,q.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}),!i&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),I(e.id)},"aria-label":`Delete ${e.label}`,className:`ml-auto p-0.5 rounded hover:bg-destructive/20`,children:(0,q.jsx)(W,{className:`h-3 w-3 text-destructive`})})]}),(0,q.jsx)(`div`,{className:`px-3 py-1 divide-y`,children:e.fields.map((t,n)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs`,children:[w&&w.entityId===e.id&&w.fieldIndex===n?(0,q.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),onBlur:oe,onKeyDown:e=>{e.key===`Enter`&&oe(),e.key===`Escape`&&se()},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,q.jsxs)(`span`,{className:gt(`font-mono cursor-text`,t.primaryKey&&`font-bold text-primary`),onClick:r=>{r.stopPropagation(),ae(e.id,n,t.name)},title:`Click to edit field name`,children:[t.primaryKey&&(0,q.jsx)(`span`,{className:`text-[0.65rem] font-semibold text-primary mr-0.5`,children:`PK`}),t.name]}),i?(0,q.jsx)(`span`,{className:`text-muted-foreground ml-auto`,children:t.type}):(0,q.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:_t.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))}),t.required&&(0,q.jsx)(`span`,{className:`text-destructive`,children:`*`})]},`${t.name}-${n}`))}),!i&&(0,q.jsx)(`div`,{className:`px-3 py-1 border-t`,children:(0,q.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),ie(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,q.jsx)(ze,{className:`h-3 w-3`}),` Add Field`]})})]},e.id))]}),S&&u.length>0&&(0,q.jsx)(ut,{items:ge,canvasWidth:n.width,canvasHeight:n.height,position:`bottom-right`,size:150})]})]}),(0,q.jsxs)(`div`,{className:`w-64 border-l flex flex-col bg-background shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,q.jsxs)(`button`,{onClick:()=>b(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":y,"aria-controls":`property-editor-panel`,children:[y?(0,q.jsx)(G,{className:`h-3 w-3`}):(0,q.jsx)(fe,{className:`h-3 w-3`}),`Properties`]}),y&&(0,q.jsx)(`div`,{id:`property-editor-panel`,className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(st,{title:H?H.label:`Properties`,fields:he,onChange:U})})]}),(0,q.jsx)(`div`,{className:`border-t`,children:(0,q.jsxs)(`button`,{onClick:()=>C(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":S,children:[S?(0,q.jsx)(G,{className:`h-3 w-3`}):(0,q.jsx)(fe,{className:`h-3 w-3`}),`Minimap`]})})]}),(0,q.jsx)(at,{isOpen:p.isOpen,title:p.title,message:p.message,onConfirm:p.onConfirm,onCancel:p.onCancel,destructive:!0})]})}function bt(...e){return g(m(e))}var xt=120,St=50;function Ct(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 wt({processName:e=`New Process`,nodes:t=[],edges:n=[],lanes:r,canvas:i={width:1400,height:800,showGrid:!0},showMinimap:a=!0,showToolbar:o=!0,readOnly:s=!1,onNodesChange:c,onEdgesChange:l,className:u}){let d=$e({nodes:t,edges:n},{maxHistory:50}),f=d.current.nodes,p=d.current.edges,m=(0,K.useCallback)((e,t)=>{d.push({nodes:e,edges:t}),c?.(e),l?.(t)},[d,c,l]),h=et(),g=tt(),_=nt(),v=rt({initialZoom:1}),y=ft(),[b,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(!1),[T,E]=(0,K.useState)(null),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(!0),[P,ee]=(0,K.useState)(null),[I,te]=(0,K.useState)({x:0,y:0}),L=(0,K.useRef)(null),R=(0,K.useRef)(c),ne=(0,K.useRef)(l);R.current=c,ne.current=l,(0,K.useEffect)(()=>{R.current?.(f),ne.current?.(p)},[d.current]);let z=(0,K.useCallback)((e,t)=>{if(s)return;let n={id:`node-${Date.now()}`,type:e,label:t,position:{x:200+f.length*160,y:200}};m([...f,n],p),S(n.id),g.selectOne(n.id),y?.sendOperation({type:`insert`,elementId:n.id,data:{label:t},userId:y.currentUserId??``})},[f,p,s,m,g,y]),ie=(0,K.useCallback)(async e=>{if(s)return;let t=f.find(t=>t.id===e);await h.confirm(`Delete Node`,`Are you sure you want to delete "${t?.label??e}"? This will also remove all connected edges.`)&&(m(f.filter(t=>t.id!==e),p.filter(t=>t.source!==e&&t.target!==e)),b===e&&S(null),g.clearSelection(),y?.sendOperation({type:`delete`,elementId:e,data:{},userId:y.currentUserId??``}))},[f,p,b,s,m,h,g,y]),ae=(0,K.useCallback)(async()=>{if(s||g.count===0||!await h.confirm(`Delete Selected Nodes`,`Are you sure you want to delete ${g.count} selected node(s) and their connected edges?`))return;let e=g.selectedIds;m(f.filter(t=>!e.has(t.id)),p.filter(t=>!e.has(t.source)&&!e.has(t.target))),S(null),g.clearSelection()},[f,p,s,m,h,g]),oe=(0,K.useCallback)(()=>{let e=g.count>0?g.selectedIds:b?new Set([b]):new Set;if(e.size===0)return;let t=f.filter(t=>e.has(t.id));_.copy(t)},[f,b,g,_]),se=(0,K.useCallback)(()=>{if(s)return;let e=_.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}}));m([...f,...t],p),g.selectMany(t.map(e=>e.id)),S(t[0].id)},[s,f,p,_,m,g]),ce=(0,K.useCallback)(()=>{w(e=>e?(E(null),!1):!0)},[]),B=(0,K.useCallback)(e=>{if(!C)return!1;if(!T)return E(e),!0;if(T===e)return!0;let t={id:`edge-${Date.now()}`,source:T,target:e};return m(f,[...p,t]),E(null),w(!1),y?.sendOperation({type:`insert`,elementId:t.id,data:{source:T,target:e},userId:y.currentUserId??``}),!0},[C,T,f,p,m,y]),le=(0,K.useCallback)(()=>{s||f.length===0||m(Ct(f,p),p)},[f,p,s,m]),ue=(0,K.useCallback)((e,t)=>{if(s||!f.find(e=>e.id===t))return;ee(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)},[s,f]),de=(0,K.useCallback)(e=>{if(e.preventDefault(),s||!P)return;let t=e.currentTarget.getBoundingClientRect(),n=v.zoom,r=(e.clientX-t.left-v.panOffset.x)/n-I.x,i=(e.clientY-t.top-v.panOffset.y)/n-I.y,a=Math.max(0,Math.round(r/20)*20),o=Math.max(0,Math.round(i/20)*20);m(f.map(e=>e.id===P?{...e,position:{x:a,y:o}}:e),p),ee(null)},[s,P,I,f,p,v.zoom,v.panOffset,m]),fe=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),V=(0,K.useMemo)(()=>f.find(e=>e.id===b)??null,[f,b]),me=(0,K.useMemo)(()=>V?[{name:`label`,label:`Name`,type:`text`,value:V.label,group:`General`},{name:`type`,label:`Type`,type:`select`,value:V.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:V.description??``,group:`General`}]:[],[V]),H=(0,K.useCallback)((e,t)=>{s||!b||m(f.map(n=>n.id===b?{...n,[e]:t}:n),p)},[s,b,f,p,m]),he=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`}},U=(0,K.useMemo)(()=>f.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:xt,height:St,selected:g.isSelected(e.id)||e.id===b})),[f,g,b]);(0,K.useEffect)(()=>{let e=L.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(),d.undo();return}if(n&&e.key===`y`||n&&e.key===`z`&&e.shiftKey){e.preventDefault(),d.redo();return}if(n&&e.key===`c`){e.preventDefault(),oe();return}if(n&&e.key===`v`){e.preventDefault(),se();return}if(e.key===`Delete`||e.key===`Backspace`){g.count>0?(e.preventDefault(),ae()):b&&(e.preventDefault(),ie(b));return}if(e.key===`Escape`){C?(w(!1),E(null)):(S(null),g.clearSelection());return}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[b,C,g,d,oe,se,ie,ae]);let _e=(0,K.useCallback)(e=>{e.target===e.currentTarget&&(S(null),g.clearSelection(),C&&(w(!1),E(null)))},[C,g]);return(0,q.jsxs)(`div`,{ref:L,tabIndex:0,className:bt(`flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background`,u),children:[(0,q.jsx)(at,{isOpen:h.isOpen,title:h.title,message:h.message,onConfirm:h.onConfirm,onCancel:h.onCancel,destructive:!0}),o&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b bg-muted/20`,role:`toolbar`,"aria-label":`Process toolbar`,children:[(0,q.jsx)(ye,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`font-medium text-sm`,"aria-label":`Process name`,children:e}),y?.isConnected&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,role:`status`,"aria-label":`Collaboration active`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),y.users.length,` user`,y.users.length===1?``:`s`]}),(0,q.jsx)(`div`,{className:`flex-1`}),!s&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{onClick:()=>d.undo(),disabled:!d.canUndo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Undo (Ctrl+Z)`,"aria-label":`Undo`,children:(0,q.jsx)(O,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>d.redo(),disabled:!d.canRedo,className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40`,title:`Redo (Ctrl+Y)`,"aria-label":`Redo`,children:(0,q.jsx)(Ne,{className:`h-3 w-3`})}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsx)(`button`,{onClick:oe,disabled:g.count===0&&!b,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,q.jsx)(Ae,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:se,disabled:!_.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,q.jsx)(re,{className:`h-3 w-3`})}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsxs)(`button`,{onClick:ce,className:bt(`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,C&&`bg-primary text-primary-foreground`),title:`Connect nodes`,"aria-label":`Connect nodes`,"aria-pressed":C,children:[(0,q.jsx)(D,{className:`h-3 w-3`}),` Connect`]}),(0,q.jsxs)(`button`,{onClick:le,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,q.jsx)(ge,{className:`h-3 w-3`}),` Layout`]}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsx)(`button`,{onClick:v.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,q.jsx)(x,{className:`h-3 w-3`})}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums min-w-[3ch] text-center`,"aria-label":`Zoom level`,children:[Math.round(v.zoom*100),`%`]}),(0,q.jsx)(`button`,{onClick:v.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,q.jsx)(qe,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:v.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,q.jsx)(k,{className:`h-3 w-3`})}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsxs)(`button`,{onClick:()=>z(`start-event`,`Start`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Start Event`,"aria-label":`Add Start Event`,children:[(0,q.jsx)(ke,{className:`h-3 w-3 text-green-600`}),` Start`]}),(0,q.jsxs)(`button`,{onClick:()=>z(`user-task`,`User Task`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add User Task`,"aria-label":`Add User Task`,children:[(0,q.jsx)(F,{className:`h-3 w-3 text-blue-600`}),` Task`]}),(0,q.jsxs)(`button`,{onClick:()=>z(`exclusive-gateway`,`Decision`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add Gateway`,"aria-label":`Add Gateway`,children:[(0,q.jsx)(pe,{className:`h-3 w-3 text-yellow-600`}),` Gateway`]}),(0,q.jsxs)(`button`,{onClick:()=>z(`end-event`,`End`),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:`Add End Event`,"aria-label":`Add End Event`,children:[(0,q.jsx)(F,{className:`h-3 w-3 text-red-600`}),` End`]}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsx)(`button`,{onClick:()=>N(e=>!e),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:M?`Hide properties`:`Show properties`,"aria-label":M?`Hide property panel`:`Show property panel`,"aria-expanded":M,children:M?(0,q.jsx)(He,{className:`h-3 w-3`}):(0,q.jsx)(Ge,{className:`h-3 w-3`})})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex-1 overflow-auto bg-muted/10 p-4`,role:`region`,"aria-label":`Process canvas`,onWheel:v.handleWheel,onMouseDown:v.startPan,children:(0,q.jsxs)(`div`,{className:`relative`,style:{...v.transformStyle,width:i.width,minHeight:i.height,backgroundImage:i.showGrid?`radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)`:void 0,backgroundSize:i.showGrid?`20px 20px`:void 0},onClick:_e,onDrop:de,onDragOver:fe,children:[(0,q.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:i.width,height:i.height,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`marker`,{id:`arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`10`,refY:`3.5`,orient:`auto`,children:(0,q.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground))`})})}),p.map(e=>{let t=f.find(t=>t.id===e.source),n=f.find(t=>t.id===e.target);if(!t||!n)return null;t.position.x+xt/2;let r=t.position.y+St/2;n.position.x+xt/2;let i=n.position.y+St/2,a=t.position.x+xt,o=r,s=n.position.x,c=i;return(0,q.jsxs)(`g`,{children:[(0,q.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,q.jsx)(`text`,{x:(a+s)/2,y:(o+c)/2-8,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,children:e.label})]},e.id)})]}),f.length===0&&(0,q.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.`}),f.map(e=>{let t=g.isSelected(e.id)||b===e.id,n=T===e.id,r=A===e.id,i=C||r;return(0,q.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},role:`group`,"aria-label":e.label,draggable:!s&&!C,onDragStart:t=>ue(t,e.id),onMouseEnter:()=>j(e.id),onMouseLeave:()=>j(null),onClick:t=>{B(e.id)||(t.shiftKey?g.toggle(e.id,!0):(S(e.id),g.selectOne(e.id)))},children:[(0,q.jsx)(`div`,{className:bt(`flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow`,he(e.type),t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,C&&!n&&`cursor-crosshair`),children:(0,q.jsx)(`span`,{className:bt(`text-xs font-medium`,(e.type===`exclusive-gateway`||e.type===`parallel-gateway`||e.type===`inclusive-gateway`||e.type===`event-based-gateway`)&&`-rotate-45`),children:e.label})}),i&&!s&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{left:-6,top:St/2-6},title:`Input port`,onClick:t=>{t.stopPropagation(),B(e.id)}}),(0,q.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair`,style:{right:-6,top:St/2-6},title:`Output port`,onClick:t=>{t.stopPropagation(),C?B(e.id):(w(!0),E(e.id))}}),(0,q.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:xt/2-6,top:-6},title:`Port`,onClick:t=>{t.stopPropagation(),B(e.id)}}),(0,q.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair`,style:{left:xt/2-6,bottom:-6},title:`Port`,onClick:t=>{t.stopPropagation(),B(e.id)}})]}),!s&&t&&!C&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ie(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,q.jsx)(W,{className:`h-3 w-3`})})]},e.id)}),a&&f.length>0&&(0,q.jsx)(ut,{items:U,canvasWidth:i.width??1400,canvasHeight:i.height??800,position:`bottom-right`})]})}),M&&!s&&(0,q.jsx)(`div`,{className:`w-64 border-l bg-background overflow-y-auto flex-shrink-0`,role:`complementary`,"aria-label":`Property panel`,children:(0,q.jsx)(st,{title:V?`Properties: ${V.label}`:`Properties`,fields:me,onChange:H})})]})]})}function Y(...e){return g(m(e))}var X={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`},Tt={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}},Et=[{type:`header`,height:80,elements:[]},{type:`detail`,height:400,elements:[],repeat:!0},{type:`footer`,height:60,elements:[]}];function Dt({reportName:e=X.untitledReport,objectName:t,pageSize:n=`A4`,orientation:r=`portrait`,margins:i={top:40,right:40,bottom:40,left:40},sections:a=[],showToolbar:o=!0,showPropertyPanel:s=!0,readOnly:c=!1,onSectionsChange:l,className:u}){let d=$e(a.length>0?a:Et),f=d.current,p=(0,K.useCallback)(e=>{d.push(e),l?.(e)},[d,l]),m=tt(),h=(0,K.useMemo)(()=>{let e=Array.from(m.selectedIds);return e.length>0?e[0]:null},[m.selectedIds]),g=nt(),_=et(),v=ft(),y=(0,K.useCallback)(e=>{v&&v.sendOperation({...e,userId:v.currentUserId??``})},[v]),[b,x]=(0,K.useState)(!0),S=(0,K.useRef)(null),C=(0,K.useRef)(null),w=Tt[n],T=r===`landscape`?w.height:w.width,E=r===`landscape`?w.width:w.height,D=e=>{switch(e){case`header`:return X.sectionHeader;case`page-header`:return X.sectionPageHeader;case`group-header`:return X.sectionGroupHeader;case`detail`:return X.sectionDetail;case`group-footer`:return X.sectionGroupFooter;case`page-footer`:return X.sectionPageFooter;case`footer`:return X.sectionFooter;default:return e}},k=(0,K.useMemo)(()=>h?f.flatMap(e=>e.elements).find(e=>e.id===h):null,[h,f]),A=(0,K.useCallback)((e,t)=>{if(c)return;let n={id:`elem-${Date.now()}`,type:t,position:{x:i.left,y:10,width:200,height:30},properties:{text:t===`text`?`New Text`:void 0,field:t===`field`?`field_name`:void 0}};p(f.map((t,r)=>r===e?{...t,elements:[...t.elements,n]}:t)),m.selectOne(n.id),y({type:`insert`,elementId:n.id,data:{element:n}})},[f,i.left,c,p,m,y]),j=(0,K.useCallback)(e=>{c||(p(f.map(t=>({...t,elements:t.elements.filter(t=>t.id!==e)}))),m.isSelected(e)&&m.clearSelection(),y({type:`delete`,elementId:e,data:{}}))},[f,c,p,m,y]),M=(0,K.useCallback)(async()=>{if(c||m.count===0||!await _.confirm(X.deleteElementsTitle,X.deleteElementMessage(m.count)))return;let e=m.selectedIds;p(f.map(t=>({...t,elements:t.elements.filter(t=>!e.has(t.id))}))),m.clearSelection(),e.forEach(e=>{y({type:`delete`,elementId:e,data:{}})})},[c,m,_,f,p,y]),N=(0,K.useCallback)((e,t)=>{c||!h||(p(f.map(n=>({...n,elements:n.elements.map(n=>n.id===h?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)}))),y({type:`update`,elementId:h,data:{[e]:t}}))},[c,h,f,p,y]),P=(0,K.useCallback)(()=>{let e=m.selectedIds;if(e.size===0)return;let t=f.flatMap(e=>e.elements).filter(t=>e.has(t.id));g.copy(t)},[m,f,g]),F=(0,K.useCallback)(()=>{if(c)return;let e=g.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=f.findIndex(e=>e.type===`detail`),i=r>=0?r:0;p(f.map((e,t)=>t===i?{...e,elements:[...e.elements,...n]}:e)),m.selectMany(n.map(e=>e.id)),n.forEach(e=>{y({type:`insert`,elementId:e.id,data:{element:e}})})},[c,g,f,p,m,y]),ee=(0,K.useCallback)((e,t,n)=>{c||(S.current={id:t.id,sectionIndex:n,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[c]),I=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),te=(0,K.useCallback)((e,t)=>{e.preventDefault();let n=S.current;if(!n||c)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;if(n.sectionIndex===t)p(f.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=f.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&&p(i.map((n,r)=>r===t?{...n,elements:[...n.elements,e]}:n))}y({type:`move`,elementId:n.id,data:{}}),S.current=null},[c,f,p,y]),L=(0,K.useMemo)(()=>{if(!k)return[];let e=[{name:`x`,label:X.propX,type:`number`,value:k.position.x,group:X.groupPosition},{name:`y`,label:X.propY,type:`number`,value:k.position.y,group:X.groupPosition},{name:`width`,label:X.propWidth,type:`number`,value:k.position.width,group:X.groupSize},{name:`height`,label:X.propHeight,type:`number`,value:k.position.height,group:X.groupSize}];return k.type===`text`&&e.push({name:`text`,label:X.propText,type:`text`,value:k.properties.text??``,group:X.groupContent}),k.type===`field`&&e.push({name:`field`,label:X.propField,type:`text`,value:k.properties.field??``,group:X.groupContent}),e},[k]);return(0,K.useEffect)(()=>{let e=C.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`)&&m.count>0&&!t){e.preventDefault(),M();return}if(e.key===`Escape`){m.clearSelection();return}if(!t){if(n&&e.key===`z`&&!e.shiftKey&&!c){e.preventDefault(),d.undo();return}if(n&&(e.key===`z`&&e.shiftKey||e.key===`y`)&&!c){e.preventDefault(),d.redo();return}if(n&&e.key===`c`){e.preventDefault(),P();return}if(n&&e.key===`v`&&!c){e.preventDefault(),F();return}if(n&&e.key===`a`){e.preventDefault();let t=f.flatMap(e=>e.elements).map(e=>e.id);m.selectMany(t);return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[m,M,c,d,P,F,f]),(0,q.jsxs)(`div`,{ref:C,tabIndex:0,className:Y(`flex h-full w-full border rounded-lg overflow-hidden bg-background`,u),children:[(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[o&&(0,q.jsxs)(`div`,{role:`toolbar`,"aria-label":X.designerToolbar,className:`flex items-center gap-2 p-2 border-b bg-muted/20`,children:[(0,q.jsx)(U,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`font-medium text-sm`,children:e}),t&&(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t,`)`]}),!c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`}),(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!d.canUndo&&`opacity-40 pointer-events-none`),title:X.undoShortcut,"aria-label":X.undo,disabled:!d.canUndo,onClick:()=>d.undo(),children:(0,q.jsx)(O,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!d.canRedo&&`opacity-40 pointer-events-none`),title:X.redoShortcut,"aria-label":X.redo,disabled:!d.canRedo,onClick:()=>d.redo(),children:(0,q.jsx)(Ne,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,m.count===0&&`opacity-40 pointer-events-none`),title:X.copyShortcut,"aria-label":X.copy,disabled:m.count===0,onClick:P,children:(0,q.jsx)(Ae,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!g.hasContent&&`opacity-40 pointer-events-none`),title:X.pasteShortcut,"aria-label":X.paste,disabled:!g.hasContent,onClick:F,children:(0,q.jsx)(re,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`w-px h-5 bg-border mx-1`})]}),!c&&(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,m.count===0&&`opacity-40 pointer-events-none`),title:X.deleteSelected,"aria-label":X.deleteSelected,disabled:m.count===0,onClick:M,children:(0,q.jsx)(W,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`flex-1`}),v?.isConnected&&(0,q.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-green-500`}),X.collaborationConnected,v.users.length>1&&` (${v.users.length})`]}),(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` `,r]}),s&&(0,q.jsx)(`button`,{className:`p-1.5 rounded hover:bg-accent`,title:b?X.collapsePanel:X.expandPanel,"aria-label":b?X.collapsePanel:X.expandPanel,onClick:()=>x(e=>!e),children:(0,q.jsx)(He,{className:Y(`h-4 w-4`,!b&&`rotate-180`)})})]}),(0,q.jsx)(`div`,{role:`region`,"aria-label":X.reportCanvas,className:`flex-1 overflow-auto bg-muted/10 p-4 flex justify-center`,children:(0,q.jsx)(`div`,{className:`bg-white shadow-lg border`,style:{width:T,minHeight:E},children:f.map((e,t)=>(0,q.jsxs)(`div`,{className:`relative border-b border-dashed border-gray-300`,style:{minHeight:e.height},onDragOver:I,onDrop:e=>te(e,t),children:[(0,q.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:[D(e.type),e.repeat&&` ↻`]}),!c&&(0,q.jsxs)(`div`,{className:`absolute right-1 top-0 flex items-center gap-0.5`,children:[(0,q.jsx)(`button`,{onClick:()=>A(t,`text`),className:`p-0.5 rounded hover:bg-accent`,title:X.addText,"aria-label":X.addText,children:(0,q.jsx)(se,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>A(t,`field`),className:`p-0.5 rounded hover:bg-accent`,title:X.addField,"aria-label":X.addField,children:(0,q.jsx)(ze,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>A(t,`image`),className:`p-0.5 rounded hover:bg-accent`,title:X.addImage,"aria-label":X.addImage,children:(0,q.jsx)(be,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>A(t,`chart`),className:`p-0.5 rounded hover:bg-accent`,title:X.addChart,"aria-label":X.addChart,children:(0,q.jsx)(Ce,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>A(t,`table`),className:`p-0.5 rounded hover:bg-accent`,title:X.addTable,"aria-label":X.addTable,children:(0,q.jsx)(B,{className:`h-3 w-3`})})]}),(0,q.jsxs)(`div`,{className:`relative`,style:{minHeight:e.height,paddingTop:24},children:[e.elements.length===0&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground text-center pt-4`,children:X.addElementsPrompt}),e.elements.map(e=>{let n=m.isSelected(e.id);return(0,q.jsxs)(`div`,{draggable:!c,onDragStart:n=>ee(n,e,t),className:Y(`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=>m.toggle(e.id,t.shiftKey),children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.type===`text`&&(e.properties.text??X.elementText),e.type===`field`&&`{${e.properties.field??`field`}}`,e.type===`image`&&X.elementImage,e.type===`chart`&&X.elementChart,e.type===`table`&&X.elementTable]}),!c&&n&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),j(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":X.deleteElement,children:(0,q.jsx)(W,{className:`h-2.5 w-2.5`})})]},e.id)})]})]},`${e.type}-${t}`))})})]}),s&&(0,q.jsx)(`div`,{role:`region`,"aria-label":X.propertiesPanel,className:Y(`border-l bg-muted/30 flex flex-col transition-[width] duration-200`,b?`w-56`:`w-0 overflow-hidden`),children:b&&(h&&k?(0,q.jsx)(st,{title:`${X.properties} – ${k.type}`,fields:L,onChange:N}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`p-3 border-b font-medium text-sm`,children:X.properties}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-4`,children:X.selectElementPrompt})})]}))}),(0,q.jsx)(at,{isOpen:_.isOpen,title:_.title,message:_.message,onConfirm:_.onConfirm,onCancel:_.onCancel})]})}var Ot={"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 kt(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=l();return e.t(`appDesigner.basicInfo`)===`appDesigner.basicInfo`?{t:kt(Ot)}:{t:e.t}}catch{return{t:kt(Ot)}}}function Q(...e){return g(m(e))}var At={name:``,title:``,description:``,icon:``,template:``,layout:`sidebar`,objects:[],navigation:[],branding:{logo:``,primaryColor:`#3b82f6`,favicon:``}};function jt(e){return e.filter(e=>e.selected).map(e=>({id:e.name,type:`object`,label:e.label,icon:e.icon,objectName:e.name}))}var Mt=0;function Nt(e){return Mt+=1,`${e}_${Date.now()}_${Mt}`}function Pt({steps:e,currentIndex:t,onStepClick:n}){return(0,q.jsx)(`nav`,{className:`flex items-center justify-center gap-0 px-4 py-6`,children:e.map((e,r)=>{let i=r<t,a=r===t;return(0,q.jsxs)(K.Fragment,{children:[r>0&&(0,q.jsx)(`div`,{className:Q(`h-0.5 w-12 sm:w-20`,i?`bg-blue-500`:`bg-gray-200`)}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wizard-step-${e.id}`,onClick:()=>n(r),className:Q(`flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1`,a&&`cursor-default`,!a&&`cursor-pointer`),children:[(0,q.jsx)(`div`,{className:Q(`flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors`,i&&`bg-blue-500 text-white`,a&&`bg-blue-600 text-white ring-2 ring-blue-300`,!i&&!a&&`bg-gray-200 text-gray-500`),children:i?(0,q.jsx)(Me,{className:`h-4 w-4`}):r+1}),(0,q.jsx)(`span`,{className:Q(`text-xs font-medium`,a?`text-blue-600`:`text-gray-500`),children:e.label})]})]},e.id)})})}function Ft({draft:e,templates:t,readOnly:n,onChange:r,t:i}){let a=e.name.length>0&&!p(e.name);return(0,q.jsxs)(`div`,{"data-testid":`wizard-step-basic-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`app-name`,className:`block text-sm font-medium text-gray-700`,children:[i(`appDesigner.appName`),` `,(0,q.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,q.jsx)(`input`,{id:`app-name`,"data-testid":`app-name-input`,type:`text`,value:e.name,onChange:e=>r({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`,a?`border-red-400`:`border-gray-300`)}),a&&(0,q.jsx)(`p`,{className:`text-xs text-red-500`,children:i(`appDesigner.snakeCaseHint`)})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`app-title`,className:`block text-sm font-medium text-gray-700`,children:[i(`appDesigner.appTitle`),` `,(0,q.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,q.jsx)(`input`,{id:`app-title`,"data-testid":`app-title-input`,type:`text`,value:e.title,onChange:e=>r({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,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`app-description`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.appDescription`)}),(0,q.jsx)(`textarea`,{id:`app-description`,"data-testid":`app-description-input`,value:e.description??``,onChange:e=>r({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,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`app-icon`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.appIcon`)}),(0,q.jsx)(`input`,{id:`app-icon`,type:`text`,value:e.icon??``,onChange:e=>r({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,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`app-template`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.template`)}),(0,q.jsxs)(`select`,{id:`app-template`,value:e.template??``,onChange:e=>r({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,q.jsx)(`option`,{value:``,children:`None`}),t.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,q.jsx)(`legend`,{className:`text-sm font-medium text-gray-700`,children:i(`appDesigner.layout`)}),(0,q.jsx)(`div`,{className:`flex gap-3`,children:[{value:`sidebar`,labelKey:`appDesigner.layoutSidebar`,Icon:Te},{value:`header`,labelKey:`appDesigner.layoutHeader`,Icon:ge},{value:`empty`,labelKey:`appDesigner.layoutEmpty`,Icon:Oe}].map(({value:t,labelKey:a,Icon:o})=>(0,q.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,q.jsx)(o,{className:`h-5 w-5 text-gray-600`}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-gray-700`,children:i(a)}),(0,q.jsx)(`input`,{type:`radio`,name:`layout`,value:t,checked:e.layout===t,onChange:()=>r({layout:t}),disabled:n,className:`sr-only`})]},t))})]})]})}function It({objects:e,readOnly:t,onToggle:n,onToggleAll:r,search:i,onSearchChange:a,t:o}){let s=(0,K.useMemo)(()=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.label.toLowerCase().includes(t))},[e,i]),c=e.length>0&&e.every(e=>e.selected);return e.every(e=>!e.selected),(0,q.jsxs)(`div`,{"data-testid":`wizard-step-objects-content`,className:`mx-auto max-w-2xl space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(z,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{"data-testid":`object-search`,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:o(`appDesigner.searchObjects`),className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(!c),disabled:t,className:`rounded-md border border-gray-300 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:o(c?`appDesigner.deselectAll`:`appDesigner.selectAll`)})]}),s.length===0?(0,q.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:o(`appDesigner.noObjectsFound`)}):(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:s.map(e=>(0,q.jsxs)(`button`,{type:`button`,"data-testid":`object-card-${e.name}`,disabled:t,onClick:()=>n(e.name),className:Q(`flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors`,e.selected?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`,t&&`pointer-events-none opacity-60`),children:[(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,q.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,q.jsx)(Me,{className:`h-3 w-3`})})]}),(0,q.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.name}),e.icon&&(0,q.jsx)(`span`,{className:`text-xs text-gray-400`,children:e.icon})]},e.name))})]})}var Lt={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 Rt({items:e,readOnly:t,onAdd:n,onRemove:r,onReorder:i,t:a}){return(0,q.jsxs)(`div`,{"data-testid":`wizard-step-navigation-content`,className:`mx-auto max-w-lg space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.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,q.jsx)(me,{className:`h-3.5 w-3.5`}),a(`appDesigner.addGroup`)]}),(0,q.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,q.jsx)(D,{className:`h-3.5 w-3.5`}),a(`appDesigner.addUrl`)]}),(0,q.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,q.jsx)(b,{className:`h-3.5 w-3.5`}),a(`appDesigner.addSeparator`)]})]}),e.length===0?(0,q.jsx)(`p`,{className:`py-8 text-center text-sm text-gray-400`,children:a(`appDesigner.noNavItemsHint`)}):(0,q.jsx)(`ul`,{className:`space-y-1.5`,children:e.map((n,o)=>(0,q.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,q.jsx)(`span`,{className:`text-xs text-gray-400`,children:n.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate text-sm text-gray-800`,children:n.type===`separator`?a(`appDesigner.separatorLabel`):s(n.label)}),(0,q.jsx)(`span`,{className:Q(`rounded-full px-2 py-0.5 text-[10px] font-medium`,Lt[n.type]??`bg-gray-100 text-gray-600`),children:n.type}),(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(n.id,`up`),disabled:t||o===0,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(n.id,`down`),disabled:t||o===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,q.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(n.id),disabled:t,className:`rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30`,"aria-label":`Remove`,children:(0,q.jsx)(W,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function zt({branding:e,title:t,readOnly:n,onChange:r,t:i}){return(0,q.jsxs)(`div`,{"data-testid":`wizard-step-branding-content`,className:`mx-auto max-w-lg space-y-5`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`branding-logo`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.logoUrl`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(be,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`branding-logo`,"data-testid":`branding-logo-input`,type:`text`,value:e.logo??``,onChange:e=>r({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`branding-color`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.primaryColor`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(A,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`branding-color`,"data-testid":`branding-color-input`,type:`text`,value:e.primaryColor??`#3b82f6`,onChange:e=>r({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`branding-favicon`,className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.faviconUrl`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(le,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`branding-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:e.favicon??``,onChange:e=>r({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:n,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`span`,{className:`block text-sm font-medium text-gray-700`,children:i(`appDesigner.preview`)}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.logo?(0,q.jsx)(`img`,{src:e.logo,alt:`App logo`,className:`h-8 w-8 rounded object-contain`}):(0,q.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400`,children:`Logo`}),(0,q.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:t||i(`appDesigner.appTitle`)})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:e.primaryColor||`#3b82f6`}}),(0,q.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.primaryColor||`#3b82f6`})]}),e.favicon&&(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,q.jsx)(`img`,{src:e.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-500`,children:`Favicon`})]})]})]})]})}function Bt({availableObjects:e=[],templates:t=[],initialDraft:n,onComplete:r,onCancel:i,onSaveDraft:a,readOnly:o=!1,className:s}){let{t:c}=Z(),l=et(),[u,d]=(0,K.useState)(0),[f,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(()=>({...At,objects:e.map(e=>({...e})),...n})),v=(0,K.useMemo)(()=>[{id:`basic`,label:c(`appDesigner.basicInfo`),description:c(`appDesigner.stepBasicDesc`),icon:`Settings`},{id:`objects`,label:c(`appDesigner.objects`),description:c(`appDesigner.stepObjectsDesc`),icon:`Database`},{id:`navigation`,label:c(`appDesigner.navigation`),description:c(`appDesigner.stepNavigationDesc`),icon:`Menu`},{id:`branding`,label:c(`appDesigner.branding`),description:c(`appDesigner.stepBrandingDesc`),icon:`Palette`}],[c]),y=u===0,b=u===v.length-1,x=(0,K.useMemo)(()=>h.name.length>0&&p(h.name)&&h.title.trim().length>0,[h.name,h.title]),S=(0,K.useMemo)(()=>u===0?x:!0,[u,x]),C=(0,K.useCallback)(e=>{g(t=>({...t,...e}))},[]),w=(0,K.useCallback)(e=>{g(t=>({...t,branding:{...t.branding,...e}}))},[]),T=(0,K.useCallback)(e=>{g(t=>({...t,objects:t.objects.map(t=>t.name===e?{...t,selected:!t.selected}:t)}))},[]),E=(0,K.useCallback)(e=>{g(t=>({...t,objects:t.objects.map(t=>({...t,selected:e}))}))},[]),D=(0,K.useCallback)(e=>{let t={id:Nt(e),type:e,label:e===`separator`?``:e===`group`?`New Group`:`New Link`,...e===`group`?{children:[]}:{},...e===`url`?{url:``}:{}};g(e=>({...e,navigation:[...e.navigation,t]}))},[]),O=(0,K.useCallback)(e=>{g(t=>({...t,navigation:t.navigation.filter(t=>t.id!==e)}))},[]),k=(0,K.useCallback)((e,t)=>{g(n=>{let r=[...n.navigation],i=r.findIndex(t=>t.id===e);if(i<0)return n;let a=t===`up`?i-1:i+1;return a<0||a>=r.length?n:([r[i],r[a]]=[r[a],r[i]],{...n,navigation:r})})},[]),A=(0,K.useCallback)(()=>{b||(u===1&&g(e=>({...e,navigation:jt(e.objects)})),d(e=>e+1))},[u,b]),j=(0,K.useCallback)(()=>{y||d(e=>e-1)},[y]),M=(0,K.useCallback)(()=>{r?.(h)},[h,r]),N=(0,K.useCallback)(async()=>{(h.name.length>0||h.title.length>0)&&i?await l.confirm(c(`appDesigner.cancelConfirmTitle`),c(`appDesigner.cancelConfirmMessage`))&&i():i?.()},[h.name,h.title,i,l,c]),P=(0,K.useCallback)(()=>{a?.(h)},[h,a]),F=(0,K.useCallback)(e=>{e<=u?d(e):e===u+1&&S&&(u===1&&e===2&&g(e=>({...e,navigation:jt(e.objects)})),d(e))},[u,S]);return(0,q.jsxs)(`div`,{className:Q(`flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm`,s),children:[l.isOpen&&(0,q.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,q.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,q.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:l.title}),(0,q.jsx)(`button`,{type:`button`,onClick:l.onCancel,className:`rounded p-1 text-gray-400 hover:text-gray-600`,"aria-label":c(`common.close`),children:(0,q.jsx)(ce,{className:`h-4 w-4`})})]}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:l.message}),(0,q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-keep`,onClick:l.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:c(`appDesigner.keepEditing`)}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`cancel-confirm-discard`,onClick:l.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:c(`appDesigner.confirmDiscard`)})]})]})}),(0,q.jsx)(`div`,{className:`border-b border-gray-100`,children:(0,q.jsx)(Pt,{steps:v,currentIndex:u,onStepClick:F})}),(0,q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[u===0&&(0,q.jsx)(Ft,{draft:h,templates:t,readOnly:o,onChange:C,t:c}),u===1&&(0,q.jsx)(It,{objects:h.objects,readOnly:o,onToggle:T,onToggleAll:E,search:f,onSearchChange:m,t:c}),u===2&&(0,q.jsx)(Rt,{items:h.navigation,readOnly:o,onAdd:D,onRemove:O,onReorder:k,t:c}),u===3&&(0,q.jsx)(zt,{branding:h.branding,title:h.title,readOnly:o,onChange:w,t:c})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,"data-testid":`wizard-cancel`,onClick:N,disabled:o,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:c(`common.cancel`)}),a&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`wizard-save-draft`,onClick:P,disabled:o,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:c(`appDesigner.saveDraft`)})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!y&&(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wizard-back`,onClick:j,disabled:o,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,q.jsx)(_,{className:`h-4 w-4`}),c(`common.back`)]}),b?(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wizard-complete`,onClick:M,disabled:o||!S,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,q.jsx)(Me,{className:`h-4 w-4`}),c(`appDesigner.complete`)]}):(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wizard-next`,onClick:A,disabled:o||!S,className:`inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50`,children:[c(`common.next`),(0,q.jsx)(fe,{className:`h-4 w-4`})]})]})]})]})}function Vt(...e){return g(m(e))}var Ht=0;function Ut(e){return Ht+=1,`${e}_${Date.now()}_${Ht}`}var Wt={object:{labelKey:`appDesigner.navTypeObject`,color:`bg-green-100 text-green-700`,Icon:P},dashboard:{labelKey:`appDesigner.navTypeDashboard`,color:`bg-amber-100 text-amber-700`,Icon:We},page:{labelKey:`appDesigner.navTypePage`,color:`bg-teal-100 text-teal-700`,Icon:U},report:{labelKey:`appDesigner.navTypeReport`,color:`bg-rose-100 text-rose-700`,Icon:Ce},url:{labelKey:`appDesigner.navTypeUrl`,color:`bg-sky-100 text-sky-700`,Icon:D},group:{labelKey:`appDesigner.navTypeGroup`,color:`bg-purple-100 text-purple-700`,Icon:me},separator:{labelKey:`appDesigner.navTypeSeparator`,color:`bg-gray-100 text-gray-600`,Icon:b},action:{labelKey:`appDesigner.navTypeAction`,color:`bg-orange-100 text-orange-700`,Icon:Ie}},Gt=[{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 Kt({item:e,depth:t,index:n,total:r,readOnly:i,onRemove:a,onMoveUp:o,onMoveDown:c,onToggleExpand:l,onUpdateLabel:u,onUpdateIcon:d,onToggleVisible:f,onAddChild:p,expandedIds:m,t:h}){let[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(s(e.label)??``),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(e.icon||``),T=Wt[e.type];e.type===`group`&&e.children&&e.children.length;let D=m.has(e.id),O=e.visible===!1,k=()=>{v.trim()?u(e.id,v.trim()):y(s(e.label)??``),_(!1)},A=()=>{d(e.id,S.trim()),x(!1)};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`li`,{"data-testid":`nav-designer-item-${e.id}`,className:Vt(`flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50`,O&&`opacity-50`),style:{marginLeft:t*20},children:[(0,q.jsx)(w,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300`}),e.type===`group`?(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":h(D?`appDesigner.navCollapseGroup`:`appDesigner.navExpandGroup`),children:D?(0,q.jsx)(G,{className:`h-3.5 w-3.5`}):(0,q.jsx)(fe,{className:`h-3.5 w-3.5`})}):(0,q.jsx)(`span`,{className:`w-5`}),b&&!i?(0,q.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),onBlur:A,onKeyDown:t=>{t.key===`Enter`&&A(),t.key===`Escape`&&(C(e.icon||``),x(!1))},autoFocus:!0,placeholder:h(`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,q.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,q.jsx)(T.Icon,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}),!i&&e.type!==`separator`&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>{C(e.icon||``),x(!0)},className:`rounded p-0.5 text-gray-300 hover:text-blue-500`,"aria-label":h(`appDesigner.navEditIcon`),"data-testid":`nav-designer-edit-icon-${e.id}`,children:(0,q.jsx)(E,{className:`h-2.5 w-2.5`})})]}),e.type===`separator`?(0,q.jsx)(`span`,{className:`flex-1 text-xs italic text-gray-400`,children:h(`appDesigner.separatorLabel`)}):g&&!i?(0,q.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),onBlur:k,onKeyDown:t=>{t.key===`Enter`&&k(),t.key===`Escape`&&(y(s(e.label)??``),_(!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,q.jsx)(`span`,{className:Vt(`flex-1 truncate text-sm text-gray-800`,!i&&`cursor-text`),onDoubleClick:()=>{!i&&e.type!==`separator`&&(y(s(e.label)??``),_(!0))},children:s(e.label)}),(0,q.jsx)(`span`,{className:Vt(`rounded-full px-2 py-0.5 text-[10px] font-medium`,T.color),children:h(T.labelKey)}),O&&(0,q.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:h(`appDesigner.navHidden`)}),!i&&e.type!==`separator`&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:`rounded p-0.5 text-gray-400 hover:text-gray-700`,"aria-label":h(`appDesigner.navToggleVisible`),"data-testid":`nav-designer-toggle-visible-${e.id}`,children:O?(0,q.jsx)(Re,{className:`h-3.5 w-3.5`}):(0,q.jsx)(H,{className:`h-3.5 w-3.5`})}),e.type===`group`&&!i&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>p(e.id,`page`),className:`rounded p-0.5 text-gray-400 hover:text-blue-500`,"aria-label":h(`appDesigner.navAddChild`),"data-testid":`nav-designer-add-child-${e.id}`,children:(0,q.jsx)(ze,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:i||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":h(`appDesigner.navMoveUp`),children:(0,q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:i||n===r-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":h(`appDesigner.navMoveDown`),children:(0,q.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),disabled:i,className:`rounded p-0.5 text-gray-400 hover:text-red-500 disabled:opacity-30`,"aria-label":h(`appDesigner.navRemove`),"data-testid":`nav-designer-remove-${e.id}`,children:(0,q.jsx)(W,{className:`h-3.5 w-3.5`})})]}),e.type===`group`&&D&&e.children&&(0,q.jsx)(q.Fragment,{children:e.children.map((n,r)=>(0,q.jsx)(Kt,{item:n,depth:t+1,index:r,total:e.children.length,readOnly:i,onRemove:a,onMoveUp:o,onMoveDown:c,onToggleExpand:l,onUpdateLabel:u,onUpdateIcon:d,onToggleVisible:f,onAddChild:p,expandedIds:m,t:h},n.id))})]})}function qt({items:e,t}){return(0,q.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,q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase text-gray-500`,children:t(`appDesigner.navLivePreview`)}),e.length===0?(0,q.jsx)(`p`,{className:`text-xs text-gray-400`,children:t(`appDesigner.navNoPreviewItems`)}):(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:e.map(e=>(0,q.jsx)(Jt,{item:e,depth:0},e.id))})]})}function Jt({item:e,depth:t}){let n=Wt[e.type];return e.type===`separator`?(0,q.jsx)(`li`,{className:`my-1 border-t border-gray-200`,style:{marginLeft:t*12}}):(0,q.jsxs)(q.Fragment,{children:[(0,q.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,q.jsx)(n.Icon,{className:`h-3 w-3 text-gray-400`}),(0,q.jsx)(`span`,{className:`truncate`,children:s(e.label)})]}),e.type===`group`&&e.children?.map(e=>(0,q.jsx)(Jt,{item:e,depth:t+1},e.id))]})}function Yt({items:e,onChange:t,readOnly:n=!1,showPreview:r=!0,className:i,onExport:a,onImport:o}){let{t:s}=Z(),c=(0,K.useRef)(null),[l,u]=(0,K.useState)(()=>new Set(e.filter(e=>e.type===`group`).map(e=>e.id))),d=(0,K.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]),f=(0,K.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]),p=(0,K.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]),m=(0,K.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]),h=(0,K.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]),g=(0,K.useCallback)((n,r)=>{let i={id:Ut(r),type:r,label:r===`separator`?``:`New ${s(Wt[r].labelKey)}`,...r===`group`?{children:[]}:{},...r===`url`?{url:``}:{}};function a(e){return e.map(e=>e.id===n&&e.type===`group`?{...e,children:[...e.children||[],i]}:e.children?{...e,children:a(e.children)}:e)}t(a(e)),u(e=>new Set(e).add(n))},[e,t]),_=(0,K.useCallback)(n=>{let r={id:Ut(n),type:n,label:n===`separator`?``:`New ${s(Wt[n].labelKey)}`,...n===`group`?{children:[]}:{},...n===`url`?{url:``}:{}};t([...e,r])},[e,t,s]),v=(0,K.useCallback)(e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=(0,K.useCallback)(()=>{if(a)a(e);else{let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`navigation-schema.json`,i.click(),URL.revokeObjectURL(r)}},[e,a]),b=(0,K.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);Array.isArray(n)&&(o?o(n):t(n))}catch{}},r.readAsText(n),c.current&&(c.current.value=``)},[t,o]);return(0,q.jsxs)(`div`,{"data-testid":`navigation-designer`,className:Vt(`flex flex-col gap-4 sm:flex-row`,i),children:[(0,q.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[Gt.map(({type:e,labelKey:t})=>{let{Icon:r,color:i}=Wt[e];return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-add-${e}`,onClick:()=>_(e),disabled:n,className:Vt(`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,q.jsx)(ze,{className:`h-3 w-3`}),s(t)]},e)}),(0,q.jsx)(`span`,{className:`mx-1 hidden h-4 w-px bg-gray-200 sm:block`}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-export`,onClick:y,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,q.jsx)(Fe,{className:`h-3 w-3`}),s(`appDesigner.navExportSchema`)]}),(0,q.jsxs)(`label`,{"data-testid":`nav-designer-import`,className:Vt(`inline-flex cursor-pointer items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50`,n&&`cursor-not-allowed opacity-50`),children:[(0,q.jsx)(ie,{className:`h-3 w-3`}),s(`appDesigner.navImportSchema`),(0,q.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,onChange:b,disabled:n,"data-testid":`nav-designer-import-input`})]})]}),e.length===0?(0,q.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-400`,children:s(`appDesigner.navNoItems`)}):(0,q.jsx)(`ul`,{className:`space-y-1`,"data-testid":`nav-designer-tree`,children:e.map((t,r)=>(0,q.jsx)(Kt,{item:t,depth:0,index:r,total:e.length,readOnly:n,onRemove:d,onMoveUp:e=>f(e,`up`),onMoveDown:e=>f(e,`down`),onToggleExpand:v,onUpdateLabel:p,onUpdateIcon:m,onToggleVisible:h,onAddChild:g,expandedIds:l,t:s},t.id))})]}),r&&(0,q.jsx)(qt,{items:e,t:s})]})}function Xt(...e){return g(m(e))}var Zt=[{type:`metric`,label:`KPI Metric`,Icon:V},{type:`bar`,label:`Bar Chart`,Icon:Ce},{type:`line`,label:`Line Chart`,Icon:ee},{type:`pie`,label:`Pie Chart`,Icon:Be},{type:`table`,label:`Table`,Icon:B},{type:`grid`,label:`Grid`,Icon:Je}],Qt=0;function $t(){return Qt+=1,`widget_${Date.now()}_${Qt}`}function en({widget:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=e.type||`metric`,u=Zt.find(e=>e.type===l)||Zt[0];return(0,q.jsxs)(`div`,{"data-testid":`dashboard-widget-${e.id}`,onClick:a,className:Xt(`group cursor-pointer rounded-lg border-2 p-3 transition-colors`,r?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`),children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(w,{className:`h-4 w-4 text-gray-300`}),(0,q.jsx)(u.Icon,{className:`h-4 w-4 text-gray-500`}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.title||`Widget ${t+1}`})]}),!i&&(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,q.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove widget`,"data-testid":`dashboard-widget-remove-${e.id}`,children:(0,q.jsx)(W,{className:`h-3.5 w-3.5`})})]})]}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:u.label}),e.object&&(0,q.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:e.object})]})]})}function tn({widget:e,readOnly:t,onChange:n,onClose:r}){let{t:i}=Z();return(0,q.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,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:i(`appDesigner.widgetProperties`)}),(0,q.jsx)(`button`,{type:`button`,onClick:r,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,q.jsx)(ce,{className:`h-4 w-4`})})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-title`,className:`text-xs font-medium text-gray-600`,children:`Title`}),(0,q.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,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-type`,className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,q.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:Zt.map(e=>(0,q.jsx)(`option`,{value:e.type,children:e.label},e.type))})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-object`,className:`text-xs font-medium text-gray-600`,children:`Data Source (Object)`}),(0,q.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,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-value-field`,className:`text-xs font-medium text-gray-600`,children:`Value Field`}),(0,q.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,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-aggregate`,className:`text-xs font-medium text-gray-600`,children:`Aggregate`}),(0,q.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,q.jsx)(`option`,{value:`count`,children:`Count`}),(0,q.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,q.jsx)(`option`,{value:`avg`,children:`Average`}),(0,q.jsx)(`option`,{value:`min`,children:`Min`}),(0,q.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-color`,className:`text-xs font-medium text-gray-600`,children:`Color Variant`}),(0,q.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,q.jsx)(`option`,{value:`default`,children:`Default`}),(0,q.jsx)(`option`,{value:`blue`,children:`Blue`}),(0,q.jsx)(`option`,{value:`teal`,children:`Teal`}),(0,q.jsx)(`option`,{value:`orange`,children:`Orange`}),(0,q.jsx)(`option`,{value:`purple`,children:`Purple`}),(0,q.jsx)(`option`,{value:`success`,children:`Success`}),(0,q.jsx)(`option`,{value:`warning`,children:`Warning`}),(0,q.jsx)(`option`,{value:`danger`,children:`Danger`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:i(`appDesigner.widgetLayoutSize`)}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-width`,className:`text-[10px] text-gray-400`,children:i(`appDesigner.widgetWidth`)}),(0,q.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,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`label`,{htmlFor:`widget-height`,className:`text-[10px] text-gray-400`,children:i(`appDesigner.widgetHeight`)}),(0,q.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 nn({schema:e}){let{t}=Z(),n=e.widgets||[];return(0,q.jsxs)(`div`,{"data-testid":`dashboard-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,q.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||t(`appDesigner.dashboardPreview`)}),n.length===0?(0,q.jsx)(`div`,{className:`text-xs text-gray-400`,children:t(`appDesigner.noWidgetsPreview`)}):(0,q.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(${e.columns??2}, 1fr)`},children:n.map(e=>{let t=Zt.find(t=>t.type===(e.type||`metric`))||Zt[0];return(0,q.jsxs)(`div`,{className:`rounded-md border border-gray-200 bg-white p-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(t.Icon,{className:`h-3 w-3 text-gray-400`}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.title||`Untitled`})]}),(0,q.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function rn({schema:e,onChange:t,readOnly:n=!1,className:r,onExport:i,onImport:a,selectedWidgetId:o,onWidgetSelect:s}){let{t:c}=Z(),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(!1),p=(0,K.useRef)(null),m=(0,K.useRef)(null),h=o!==void 0,g=h?o:l,_=(0,K.useCallback)(e=>{s&&s(e),h||u(e)},[h,s,u]),{current:v,canUndo:y,canRedo:b,push:x,undo:S,redo:C}=$e(e),w=(0,K.useCallback)(e=>{x(e),t(e)},[x,t]),T=v.widgets||[],E=T.find(e=>e.id===g),D=(0,K.useCallback)(e=>{let t=$t(),n={id:t,title:``,type:e,layout:{x:0,y:T.length,w:v.columns??2,h:1}};w({...v,widgets:[...T,n]}),_(t)},[v,T,w,_]),k=(0,K.useCallback)(e=>{w({...v,widgets:T.filter(t=>t.id!==e)}),g===e&&_(null)},[v,T,g,w,_]),A=(0,K.useCallback)((e,t)=>{let n=T.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=T.length)return;let i=[...T];[i[n],i[r]]=[i[r],i[n]],w({...v,widgets:i})},[v,T,w]),j=(0,K.useCallback)(e=>{g&&w({...v,widgets:T.map(t=>t.id===g?{...t,...e}:t)})},[v,T,g,w]);(0,K.useEffect)(()=>{let e=p.current;if(!e)return;let t=e=>{if(!n){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),S();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),C();return}if((e.key===`Delete`||e.key===`Backspace`)&&g){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),k(g)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[n,S,C,g,k]);let M=(0,K.useCallback)(()=>{i&&i(v)},[v,i]),N=(0,K.useCallback)(()=>{m.current?.click()},[]),P=(0,K.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`&&(w(e),a?.(e))}catch{}},n.readAsText(t),e.target.value=``},[w,a]);return(0,q.jsxs)(`div`,{ref:p,tabIndex:0,"data-testid":`dashboard-editor`,className:Xt(`flex flex-col gap-4 outline-none`,r),children:[(0,q.jsx)(`input`,{ref:m,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`dashboard-import-input`,onChange:P}),E&&!d&&(0,q.jsx)(tn,{widget:E,readOnly:n,onChange:j,onClose:()=>_(null)}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[c(`appDesigner.addWidget`),`:`]}),Zt.map(({type:e,label:t,Icon:r})=>(0,q.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>D(e),disabled:n||d,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,q.jsx)(r,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!n&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-undo`,onClick:S,disabled:!y,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.undo`),children:(0,q.jsx)(O,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-redo`,onClick:C,disabled:!b,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":c(`appDesigner.redo`),children:(0,q.jsx)(Ne,{className:`h-4 w-4`})})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-export`,onClick:M,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navExportSchema`),children:(0,q.jsx)(Fe,{className:`h-4 w-4`})}),!n&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-import`,onClick:N,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navImportSchema`),children:(0,q.jsx)(ie,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-preview-toggle`,onClick:()=>f(e=>!e),className:Xt(`rounded p-1.5 transition-colors`,d?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":c(d?`appDesigner.modeEdit`:`appDesigner.preview`),children:d?(0,q.jsx)(Re,{className:`h-4 w-4`}):(0,q.jsx)(H,{className:`h-4 w-4`})})]})]}),d?(0,q.jsx)(nn,{schema:v}):T.length===0?(0,q.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:c(`appDesigner.noWidgets`)}):(0,q.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(${v.columns??2}, 1fr)`},children:T.map((e,t)=>(0,q.jsx)(en,{widget:e,index:t,total:T.length,selected:e.id===g,readOnly:n,onSelect:()=>_(e.id??null),onRemove:()=>k(e.id),onMoveUp:()=>A(e.id,`up`),onMoveDown:()=>A(e.id,`down`)},e.id))})]})]})}function an(...e){return g(m(e))}var on=[{type:`grid`,label:`Data Grid`,Icon:B},{type:`kanban`,label:`Kanban Board`,Icon:L},{type:`calendar`,label:`Calendar`,Icon:we},{type:`gallery`,label:`Gallery`,Icon:M},{type:`dashboard`,label:`Dashboard`,Icon:Ce},{type:`form`,label:`Form`,Icon:U},{type:`layout-grid`,label:`Grid Layout`,Icon:Je}],sn=[{value:`page`,labelKey:`appDesigner.modePage`},{value:`dashboard`,labelKey:`appDesigner.modeDashboard`}],cn=0;function ln(){return cn+=1,`component_${Date.now()}_${cn}`}function un({component:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=on.find(t=>t.type===e.type)||on[0];return(0,q.jsxs)(`div`,{"data-testid":`canvas-component-${e.id}`,onClick:a,className:an(`group flex cursor-pointer items-center gap-3 rounded-lg border-2 px-3 py-3 transition-colors`,r?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300`),children:[(0,q.jsx)(w,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300`}),(0,q.jsx)(l.Icon,{className:`h-5 w-5 shrink-0 text-gray-500`}),(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-gray-800`,children:e.label}),(0,q.jsx)(`span`,{className:`ml-2 text-[10px] text-gray-400`,children:l.label})]}),!i&&(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:t===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,q.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:t===n-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,q.jsx)(G,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},className:`rounded p-0.5 text-gray-400 hover:text-red-500`,"aria-label":`Remove component`,"data-testid":`canvas-component-remove-${e.id}`,children:(0,q.jsx)(W,{className:`h-3.5 w-3.5`})})]})]})}function dn({component:e,readOnly:t,onChange:n,onClose:r}){let{t:i}=Z();return(0,q.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,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-800`,children:i(`appDesigner.componentProperties`)}),(0,q.jsx)(`button`,{type:`button`,onClick:r,className:`rounded p-0.5 text-gray-400 hover:text-gray-600`,"aria-label":`Close`,children:(0,q.jsx)(ce,{className:`h-4 w-4`})})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{htmlFor:`component-label`,className:`text-xs font-medium text-gray-600`,children:`Label`}),(0,q.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,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`Type`}),(0,q.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600`,children:on.find(t=>t.type===e.type)?.label??e.type})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{className:`text-xs font-medium text-gray-600`,children:`ID`}),(0,q.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 fn({schema:e,components:t}){let{t:n}=Z();return(0,q.jsxs)(`div`,{"data-testid":`page-preview`,className:`rounded-lg border border-gray-200 bg-gray-50 p-4`,children:[(0,q.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-gray-700`,children:e.title||n(`appDesigner.pagePreview`)}),t.length===0?(0,q.jsx)(`div`,{className:`text-xs text-gray-400`,children:n(`appDesigner.noComponentsPreview`)}):(0,q.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>{let t=on.find(t=>t.type===e.type)||on[0];return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2`,children:[(0,q.jsx)(t.Icon,{className:`h-4 w-4 text-gray-400`}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-gray-600`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:t.label})]},e.id)})})]})}function pn({schema:e,onChange:t,readOnly:n=!1,className:r,onExport:i,onImport:a}){let{t:o}=Z(),s=(0,K.useRef)(null),c=(0,K.useRef)(null),[l,u]=(0,K.useState)(()=>(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`existing_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}))),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(`page`),_=l.find(e=>e.id===d),{canUndo:v,canRedo:y,push:b,undo:x,redo:S}=$e(l),C=(0,K.useCallback)(n=>{u(n),b(n),t({...e,children:n.map(e=>({type:e.type,id:e.id,title:e.label,...e.props}))})},[e,t,b]),w=(0,K.useCallback)(e=>{let t=ln(),n={id:t,type:e,label:on.find(t=>t.type===e)?.label||e};C([...l,n]),f(t)},[l,C]),T=(0,K.useCallback)(e=>{C(l.filter(t=>t.id!==e)),d===e&&f(null)},[l,d,C]),E=(0,K.useCallback)((e,t)=>{let n=l.findIndex(t=>t.id===e);if(n<0)return;let r=t===`up`?n-1:n+1;if(r<0||r>=l.length)return;let i=[...l];[i[n],i[r]]=[i[r],i[n]],C(i)},[l,C]),D=(0,K.useCallback)(e=>{d&&C(l.map(t=>t.id===d?{...t,...e}:t))},[l,d,C]);(0,K.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>{if(!n){if((e.ctrlKey||e.metaKey)&&e.key===`z`&&!e.shiftKey){e.preventDefault(),x();return}if((e.ctrlKey||e.metaKey)&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),S();return}if((e.key===`Delete`||e.key===`Backspace`)&&d){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`)return;e.preventDefault(),T(d)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[n,x,S,d,T]);let k=(0,K.useCallback)(()=>{i&&i(e)},[e,i]),A=(0,K.useCallback)(()=>{c.current?.click()},[]),j=(0,K.useCallback)(e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=()=>{try{let e=JSON.parse(r.result);if(e&&e.type===`page`){let n=(e.children?Array.isArray(e.children)?e.children:[e.children]:[]).map((e,t)=>({id:e.id||`imported_${t}`,type:e.type||`grid`,label:e.title||e.label||`Component ${t+1}`,props:e}));u(n),b(n),t(e),a?.(e)}}catch{}},r.readAsText(n),e.target.value=``},[t,b,a]);return(0,q.jsxs)(`div`,{ref:s,tabIndex:0,"data-testid":`page-canvas-editor`,className:an(`flex flex-col gap-4 outline-none sm:flex-row`,r),children:[(0,q.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,"data-testid":`canvas-import-input`,onChange:j}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2 border-b border-gray-200 pb-2`,role:`tablist`,children:sn.map(e=>(0,q.jsx)(`button`,{type:`button`,role:`tab`,"data-testid":`canvas-mode-${e.value}`,"aria-selected":h===e.value,onClick:()=>g(e.value),className:an(`rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors`,h===e.value?`border-b-2 border-blue-500 text-blue-600`:`text-gray-500 hover:text-gray-700`),children:o(e.labelKey)},e.value))}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[o(`appDesigner.addComponent`),`:`]}),on.map(({type:e,label:t,Icon:r})=>(0,q.jsxs)(`button`,{type:`button`,"data-testid":`canvas-add-${e}`,onClick:()=>w(e),disabled:n||p,className:`inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,q.jsx)(r,{className:`h-3.5 w-3.5`}),t]},e))]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!n&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-undo`,onClick:x,disabled:!v,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":o(`appDesigner.undo`),children:(0,q.jsx)(O,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-redo`,onClick:S,disabled:!y,className:`rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":o(`appDesigner.redo`),children:(0,q.jsx)(Ne,{className:`h-4 w-4`})})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-export`,onClick:k,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navExportSchema`),children:(0,q.jsx)(Fe,{className:`h-4 w-4`})}),!n&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-import`,onClick:A,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navImportSchema`),children:(0,q.jsx)(ie,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-preview-toggle`,onClick:()=>m(e=>!e),className:an(`rounded p-1.5 transition-colors`,p?`bg-blue-100 text-blue-600`:`text-gray-400 hover:text-gray-700`),"aria-label":o(p?`appDesigner.modeEdit`:`appDesigner.preview`),children:p?(0,q.jsx)(Re,{className:`h-4 w-4`}):(0,q.jsx)(H,{className:`h-4 w-4`})})]})]}),p?(0,q.jsx)(fn,{schema:e,components:l}):l.length===0?(0,q.jsx)(`div`,{className:`flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400`,children:o(`appDesigner.emptyPage`)}):(0,q.jsx)(`div`,{className:`space-y-2`,children:l.map((e,t)=>(0,q.jsx)(un,{component:e,index:t,total:l.length,selected:e.id===d,readOnly:n,onSelect:()=>f(e.id),onRemove:()=>T(e.id),onMoveUp:()=>E(e.id,`up`),onMoveDown:()=>E(e.id,`down`)},e.id))})]}),_&&!p&&(0,q.jsx)(dn,{component:_,readOnly:n,onChange:D,onClose:()=>f(null)})]})}function mn(...e){return g(m(e))}var hn={grid:{label:`Grid`,Icon:Je},kanban:{label:`Kanban`,Icon:L},calendar:{label:`Calendar`,Icon:we},gallery:{label:`Gallery`,Icon:M},timeline:{label:`Timeline`,Icon:Le},map:{label:`Map`,Icon:Ee},gantt:{label:`Gantt`,Icon:Ke}},gn=[{value:`compact`,label:`Compact`},{value:`medium`,label:`Medium`},{value:`tall`,label:`Tall`}];function _n({title:e,icon:t,defaultOpen:n=!0,children:r}){let[i,a]=(0,K.useState)(n);return(0,q.jsxs)(`div`,{className:`border-b border-gray-100 pb-3`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 py-2 text-left`,children:[t,(0,q.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase text-gray-500`,children:e}),i?(0,q.jsx)(de,{className:`h-3.5 w-3.5 text-gray-400`}):(0,q.jsx)(G,{className:`h-3.5 w-3.5 text-gray-400`})]}),i&&(0,q.jsx)(`div`,{className:`space-y-2`,children:r})]})}function vn({config:e,onChange:t,availableViewTypes:n=[`grid`,`kanban`,`calendar`,`gallery`,`timeline`,`map`,`gantt`],readOnly:r=!1,className:i}){let a=(0,K.useCallback)(n=>{t({...e,...n})},[e,t]),o=(0,K.useCallback)(t=>{a({columns:e.columns.map(e=>e.name===t?{...e,visible:!e.visible}:e)})},[e,a]),s=(0,K.useCallback)((t,n)=>{let r=[...e.columns],i=r.findIndex(e=>e.name===t);if(i<0)return;let o=n===`up`?i-1:i+1;o<0||o>=r.length||([r[i],r[o]]=[r[o],r[i]],a({columns:r}))},[e,a]),c=(0,K.useMemo)(()=>e.columns.filter(e=>e.visible).length,[e.columns]);return(0,q.jsxs)(`div`,{"data-testid":`object-view-configurator`,className:mn(`w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4`,i),children:[(0,q.jsx)(_n,{title:`View Type`,icon:(0,q.jsx)(Je,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(t=>{let{label:n,Icon:i}=hn[t];return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`view-type-${t}`,onClick:()=>a({viewType:t}),disabled:r,className:mn(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors`,e.viewType===t?`bg-blue-100 text-blue-700`:`text-gray-600 hover:bg-gray-100`,r&&`cursor-not-allowed opacity-50`),children:[(0,q.jsx)(i,{className:`h-3 w-3`}),n]},t)})})}),(0,q.jsx)(_n,{title:`Fields (${c}/${e.columns.length})`,icon:(0,q.jsx)(y,{className:`h-3.5 w-3.5 text-gray-500`}),children:e.columns.length===0?(0,q.jsx)(`p`,{className:`text-xs text-gray-400`,children:`No fields configured.`}):(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:e.columns.map((t,n)=>(0,q.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,q.jsx)(`button`,{type:`button`,onClick:()=>o(t.name),disabled:r,className:mn(`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,q.jsx)(H,{className:`h-3 w-3`}):(0,q.jsx)(Re,{className:`h-3 w-3`})}),(0,q.jsx)(`span`,{className:`flex-1 truncate text-gray-700`,children:t.label}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(t.name,`up`),disabled:r||n===0,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move up`,children:(0,q.jsx)(de,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(t.name,`down`),disabled:r||n===e.columns.length-1,className:`rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30`,"aria-label":`Move down`,children:(0,q.jsx)(G,{className:`h-3 w-3`})})]},t.name))})}),(0,q.jsx)(_n,{title:`Toolbar`,icon:(0,q.jsx)(S,{className:`h-3.5 w-3.5 text-gray-500`}),children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.showSearch,onChange:e=>a({showSearch:e.target.checked}),disabled:r,"data-testid":`view-toggle-search`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Search`})]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.showFilters,onChange:e=>a({showFilters:e.target.checked}),disabled:r,"data-testid":`view-toggle-filters`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Filters`})]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.showSort,onChange:e=>a({showSort:e.target.checked}),disabled:r,"data-testid":`view-toggle-sort`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Show Sort`})]})]})}),(0,q.jsx)(_n,{title:`Appearance`,icon:(0,q.jsx)(ae,{className:`h-3.5 w-3.5 text-gray-500`}),defaultOpen:!1,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`label`,{className:`text-[10px] font-medium text-gray-500`,children:`Row Height`}),(0,q.jsx)(`div`,{className:`flex gap-1`,children:gn.map(({value:t,label:n})=>(0,q.jsx)(`button`,{type:`button`,"data-testid":`view-row-height-${t}`,onClick:()=>a({rowHeight:t}),disabled:r,className:mn(`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,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.striped,onChange:e=>a({striped:e.target.checked}),disabled:r,"data-testid":`view-toggle-striped`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Striped Rows`})]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:e.bordered,onChange:e=>a({bordered:e.target.checked}),disabled:r,"data-testid":`view-toggle-bordered`,className:`h-3.5 w-3.5 rounded border-gray-300`}),(0,q.jsx)(`span`,{className:`text-xs text-gray-700`,children:`Bordered`})]})]})})]})}function $(...e){return g(m(e))}var yn=[{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`}],bn=[`Inter`,`Roboto`,`Open Sans`,`Lato`,`Montserrat`,`Poppins`,`Source Sans Pro`,`Noto Sans`,`system-ui`];function xn({branding:e,onChange:t,appTitle:n=`My App`,readOnly:r=!1,className:i,onExport:a,onImport:o}){let{t:s}=Z(),[c,l]=(0,K.useState)(`light`),{current:u,push:d,canUndo:f,canRedo:p,undo:m,redo:h}=$e(e),g=(0,K.useRef)(!0);(0,K.useEffect)(()=>{if(g.current){g.current=!1;return}t(u)},[u]);let _=(0,K.useCallback)(e=>{let n={...u,...e};g.current=!0,d(n),t(n)},[u,d,t]),v=(0,K.useCallback)(()=>{if(a){a(u);return}let e=new Blob([JSON.stringify(u,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`branding.json`,n.click(),URL.revokeObjectURL(t)},[u,a]),y=(0,K.useCallback)(()=>{if(o){o(u);return}let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=e=>{let n=e.target.files?.[0];if(!n)return;let r=new FileReader;r.onload=e=>{try{let n=JSON.parse(e.target?.result);if(typeof n==`object`&&n){let e={...u,...n};d(e),t(e)}}catch{}},r.readAsText(n)},e.click()},[u,d,t,o]),b=(0,K.useCallback)(e=>{r||((e.ctrlKey||e.metaKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?h():m()),(e.ctrlKey||e.metaKey)&&e.key===`y`&&(e.preventDefault(),h()))},[r,m,h]),x=u.primaryColor||`#3b82f6`,S=c===`dark`;return(0,q.jsxs)(`div`,{"data-testid":`branding-editor`,className:$(`flex flex-col gap-4 sm:gap-6`,i),onKeyDown:b,tabIndex:0,children:[(0,q.jsxs)(`div`,{"data-testid":`branding-editor-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800 mr-auto`,children:s(`appDesigner.brandingEditor`)}),(0,q.jsxs)(`button`,{"data-testid":`branding-undo`,type:`button`,onClick:m,disabled:!f||r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,f&&!r?`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`:`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`),title:s(`appDesigner.undo`),children:[(0,q.jsx)(O,{className:`h-3.5 w-3.5`}),s(`appDesigner.undo`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-redo`,type:`button`,onClick:h,disabled:!p||r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,p&&!r?`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`:`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`),title:s(`appDesigner.redo`),children:[(0,q.jsx)(Ne,{className:`h-3.5 w-3.5`}),s(`appDesigner.redo`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-export`,type:`button`,onClick:v,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50`,title:s(`appDesigner.brandingExport`),children:[(0,q.jsx)(Fe,{className:`h-3.5 w-3.5`}),s(`appDesigner.brandingExport`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-import`,type:`button`,onClick:y,disabled:r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,r?`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`:`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`),title:s(`appDesigner.brandingImport`),children:[(0,q.jsx)(ie,{className:`h-3.5 w-3.5`}),s(`appDesigner.brandingImport`)]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:gap-6`,children:[(0,q.jsxs)(`div`,{className:`flex-1 space-y-5`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`be-logo`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.logoUrl`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(be,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`be-logo`,"data-testid":`branding-logo-input`,type:`text`,value:u.logo??``,onChange:e=>_({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`be-color`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.primaryColor`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,q.jsx)(A,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`be-color`,"data-testid":`branding-color-input`,type:`text`,value:u.primaryColor??`#3b82f6`,onChange:e=>_({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,q.jsx)(`input`,{"data-testid":`branding-color-picker`,type:`color`,value:x,onChange:e=>_({primaryColor:e.target.value}),disabled:r,className:`h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed`})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`span`,{className:`text-xs text-gray-500`,children:s(`appDesigner.colorPalette`)}),(0,q.jsx)(`div`,{"data-testid":`branding-color-palette`,className:`flex flex-wrap gap-1.5`,children:yn.map(e=>(0,q.jsx)(`button`,{"data-testid":`branding-swatch-${e.hex.slice(1)}`,type:`button`,onClick:()=>!r&&_({primaryColor:e.hex}),disabled:r,className:$(`h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed`,x===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,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`be-favicon`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.faviconUrl`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(le,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsx)(`input`,{id:`be-favicon`,"data-testid":`branding-favicon-input`,type:`text`,value:u.favicon??``,onChange:e=>_({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`be-font`,className:`block text-sm font-medium text-gray-700`,children:s(`appDesigner.fontFamily`)}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(se,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-gray-400`}),(0,q.jsxs)(`select`,{id:`be-font`,"data-testid":`branding-font-select`,value:u.fontFamily??``,onChange:e=>_({fontFamily:e.target.value||void 0}),disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none`,children:[(0,q.jsx)(`option`,{value:``,children:s(`appDesigner.fontDefault`)}),bn.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:s(`appDesigner.brandingPreview`)}),(0,q.jsxs)(`div`,{"data-testid":`branding-mode-toggle`,className:`flex rounded-md border border-gray-300 overflow-hidden`,children:[(0,q.jsxs)(`button`,{"data-testid":`branding-mode-light`,type:`button`,onClick:()=>l(`light`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,c===`light`?`bg-blue-50 text-blue-700`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,q.jsx)(R,{className:`h-3.5 w-3.5`}),s(`appDesigner.modeLight`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-mode-dark`,type:`button`,onClick:()=>l(`dark`),className:$(`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors`,c===`dark`?`bg-gray-800 text-gray-100`:`bg-white text-gray-600 hover:bg-gray-50`),children:[(0,q.jsx)(Se,{className:`h-3.5 w-3.5`}),s(`appDesigner.modeDark`)]})]})]}),(0,q.jsxs)(`div`,{"data-testid":`branding-preview`,className:$(`rounded-lg border p-4 transition-colors`,S?`border-gray-700 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-800`),style:{fontFamily:u.fontFamily||`inherit`},children:[(0,q.jsx)(`div`,{className:`rounded-md p-3 mb-3`,style:{backgroundColor:x},children:(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[u.logo?(0,q.jsx)(`img`,{src:u.logo,alt:`Logo`,className:`h-8 w-8 rounded object-contain bg-white/20`}):(0,q.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white`,children:`Logo`}),(0,q.jsx)(`span`,{className:`text-sm font-semibold text-white`,children:n})]})}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-gray-200`,style:{backgroundColor:x}}),(0,q.jsx)(`span`,{className:$(`text-xs`,S?`text-gray-400`:`text-gray-500`),children:x})]}),(0,q.jsx)(`button`,{type:`button`,className:`rounded-md px-3 py-1.5 text-xs font-medium text-white transition-colors`,style:{backgroundColor:x},tabIndex:-1,children:s(`appDesigner.brandingSampleButton`)}),(0,q.jsx)(`p`,{className:$(`text-xs`,S?`text-gray-400`:`text-gray-500`),children:s(`appDesigner.brandingSampleText`)}),u.favicon&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`img`,{src:u.favicon,alt:`Favicon`,className:`h-4 w-4 rounded object-contain`}),(0,q.jsx)(`span`,{className:$(`text-xs`,S?`text-gray-400`:`text-gray-500`),children:`Favicon`})]}),u.fontFamily&&(0,q.jsxs)(`div`,{className:$(`text-xs`,S?`text-gray-400`:`text-gray-500`),children:[s(`appDesigner.fontFamily`),`: `,u.fontFamily]})]})]}),(0,q.jsxs)(`div`,{"data-testid":`branding-preview-mobile`,className:$(`mx-auto w-48 rounded-xl border-2 p-2 transition-colors`,S?`border-gray-700 bg-gray-900`:`border-gray-300 bg-white`),style:{fontFamily:u.fontFamily||`inherit`},children:[(0,q.jsx)(`div`,{className:`text-center text-[10px] font-medium text-gray-400 mb-1`,children:s(`appDesigner.mobilePreview`)}),(0,q.jsx)(`div`,{className:`rounded-md p-2 mb-1`,style:{backgroundColor:x},children:(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[u.logo?(0,q.jsx)(`img`,{src:u.logo,alt:`Logo`,className:`h-4 w-4 rounded object-contain bg-white/20`}):(0,q.jsx)(`div`,{className:`flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white`,children:`L`}),(0,q.jsx)(`span`,{className:`text-[9px] font-semibold text-white truncate`,children:n})]})}),(0,q.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,q.jsx)(`div`,{className:$(`h-2 w-3/4 rounded`,S?`bg-gray-700`:`bg-gray-200`)}),(0,q.jsx)(`div`,{className:$(`h-2 w-1/2 rounded`,S?`bg-gray-700`:`bg-gray-200`)}),(0,q.jsx)(`div`,{className:$(`h-2 w-2/3 rounded`,S?`bg-gray-700`:`bg-gray-200`)})]})]})]})]})]})}function Sn(...e){return g(m(e))}var Cn=[`Custom Objects`,`System Objects`,`Integration`,`Analytics`],wn=[`Box`,`Database`,`Users`,`FileText`,`Settings`,`ShoppingCart`,`Calendar`,`Mail`,`Briefcase`,`Building`,`Globe`,`Heart`,`Star`,`Tag`,`Bookmark`,`Folder`,`Archive`,`Package`,`Truck`,`CreditCard`];function Tn({objects:e,onObjectsChange:t,onSelectObject:n,showSystemObjects:r=!0,readOnly:i=!1,className:a}){let{t:o}=Z(),s=et(),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(null),p=(0,K.useMemo)(()=>r?e:e.filter(e=>!e.isSystem),[e,r]),m=(0,K.useMemo)(()=>new c({items:p}),[p]),h=(0,K.useMemo)(()=>[{field:`name`,label:o(`appDesigner.objectManager.objectName`),width:160},{field:`label`,label:o(`appDesigner.objectManager.objectLabel`),width:160},{field:`group`,label:o(`appDesigner.objectManager.group`),width:130},{field:`fieldCount`,label:`Fields`,width:80},{field:`enabled`,label:o(`appDesigner.objectManager.enabled`),width:80}],[o]),g=(0,K.useMemo)(()=>({type:`object-grid`,objectName:`object_definition`,columns:h,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:i?void 0:{create:!0,update:!0,delete:!0}}),[h,i]),_=(0,K.useCallback)(t=>{let r=e.find(e=>e.name===t.name);r&&n?.(r)},[e,n]),v=(0,K.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&(f(n),u(!0))},[e]),y=(0,K.useCallback)(async n=>{let r=e.find(e=>e.name===n.name);!r||r.isSystem||await s.confirm(o(`appDesigner.objectManager.deleteConfirmTitle`),o(`appDesigner.objectManager.deleteConfirmMessage`))&&t?.(e.filter(e=>e.id!==r.id))},[e,t,s,o]),b=(0,K.useCallback)(()=>{f(null),u(!0)},[]),x=(0,K.useCallback)(n=>{if(d){let r={...d,name:String(n.name||d.name),label:String(n.label||d.label),pluralLabel:n.pluralLabel?String(n.pluralLabel):void 0,description:n.description?String(n.description):void 0,icon:n.icon?String(n.icon):void 0,group:n.group?String(n.group):void 0,sortOrder:typeof n.sortOrder==`number`?n.sortOrder:void 0,enabled:n.enabled!==!1};t?.(e.map(e=>e.id===d.id?r:e))}else{let r={id:`obj_${Date.now()}`,name:String(n.name||`new_object_${e.length+1}`),label:String(n.label||`New Object ${e.length+1}`),pluralLabel:n.pluralLabel?String(n.pluralLabel):void 0,description:n.description?String(n.description):void 0,icon:n.icon?String(n.icon):void 0,group:n.group?String(n.group):void 0,sortOrder:typeof n.sortOrder==`number`?n.sortOrder:void 0,isSystem:!1,enabled:n.enabled!==!1,fieldCount:0};t?.([...e,r])}u(!1),f(null)},[d,e,t]),S=(0,K.useCallback)(e=>{e||(u(!1),f(null))},[]),C=(0,K.useMemo)(()=>({type:`object-form`,formType:`modal`,objectName:`object_definition`,mode:d?`edit`:`create`,title:d?`${o(`common.edit`)} — ${d.label}`:o(`appDesigner.objectManager.addObject`),open:l,onOpenChange:S,modalSize:`lg`,customFields:[{name:`name`,label:o(`appDesigner.objectManager.objectName`),type:`text`,required:!0,placeholder:`api_name`,disabled:i||(d?.isSystem??!1)},{name:`label`,label:o(`appDesigner.objectManager.objectLabel`),type:`text`,required:!0,placeholder:`Display Name`,disabled:i},{name:`pluralLabel`,label:o(`appDesigner.objectManager.pluralLabel`),type:`text`,placeholder:`Display Names`,disabled:i},{name:`description`,label:o(`appDesigner.appDescription`),type:`textarea`,disabled:i},{name:`icon`,label:o(`appDesigner.objectManager.icon`),type:`select`,options:wn.map(e=>({label:e,value:e})),disabled:i},{name:`group`,label:o(`appDesigner.objectManager.group`),type:`select`,options:Cn.map(e=>({label:e,value:e})),disabled:i},{name:`sortOrder`,label:o(`appDesigner.objectManager.sortOrder`),type:`number`,disabled:i},{name:`enabled`,label:o(`appDesigner.objectManager.enabled`),type:`boolean`,disabled:i}],initialValues:d?{name:d.name,label:d.label,pluralLabel:d.pluralLabel||``,description:d.description||``,icon:d.icon||``,group:d.group||``,sortOrder:d.sortOrder??0,enabled:d.enabled!==!1}:{enabled:!0},onSuccess:x,onCancel:()=>S(!1),readOnly:i}),[d,l,S,x,i,o]);return(0,q.jsxs)(`div`,{"data-testid":`object-manager`,className:Sn(`w-full space-y-3`,a),children:[(0,q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(P,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`appDesigner.objectManager.title`)}),(0,q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:p.length})]})}),(0,q.jsx)(Ye,{schema:g,dataSource:m,onRowClick:_,onEdit:i?void 0:v,onDelete:i?void 0:y,onAddRecord:i?void 0:b}),l&&(0,q.jsx)(Xe,{schema:C}),(0,q.jsx)(at,{isOpen:s.isOpen,title:s.title,message:s.message,confirmLabel:o(`common.delete`),cancelLabel:o(`common.cancel`),onConfirm:s.onConfirm,onCancel:s.onCancel,destructive:!0})]})}function En(...e){return g(m(e))}var Dn={text:{label:`Text`,Icon:se},textarea:{label:`Text Area`,Icon:U},number:{label:`Number`,Icon:ve},boolean:{label:`Checkbox`,Icon:T},date:{label:`Date`,Icon:De},datetime:{label:`Date/Time`,Icon:De},time:{label:`Time`,Icon:De},select:{label:`Picklist`,Icon:te},email:{label:`Email`,Icon:C},phone:{label:`Phone`,Icon:I},url:{label:`URL`,Icon:le},password:{label:`Password`,Icon:Pe},currency:{label:`Currency`,Icon:ve},percent:{label:`Percent`,Icon:ve},lookup:{label:`Lookup`,Icon:ue},formula:{label:`Formula`,Icon:v},autonumber:{label:`Auto Number`,Icon:ve},file:{label:`File`,Icon:U},image:{label:`Image`,Icon:be},markdown:{label:`Markdown`,Icon:U},html:{label:`Rich Text`,Icon:U},color:{label:`Color`,Icon:A},code:{label:`Code`,Icon:v},location:{label:`Location`,Icon:N},address:{label:`Address`,Icon:N},rating:{label:`Rating`,Icon:xe},slider:{label:`Slider`,Icon:oe}},On={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`]},kn=[`text`,`number`,`date`,`choice`,`relation`,`advanced`];function An({objectName:e,fields:t,onFieldsChange:n,readOnly:r=!1,className:i}){let{t:a}=Z(),o=et(),[s,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(``),m=(0,K.useMemo)(()=>f?t.filter(e=>e.type===f):t,[t,f]),h=(0,K.useMemo)(()=>new c({items:m}),[m]),g=(0,K.useMemo)(()=>[{field:`name`,label:a(`appDesigner.fieldDesigner.fieldName`),width:140},{field:`label`,label:a(`appDesigner.fieldDesigner.fieldLabel`),width:160},{field:`type`,label:a(`appDesigner.fieldDesigner.fieldType`),width:100},{field:`required`,label:a(`appDesigner.fieldDesigner.required`),width:80},{field:`unique`,label:a(`appDesigner.fieldDesigner.unique`),width:80},{field:`group`,label:a(`appDesigner.fieldDesigner.fieldGroup`),width:120}],[a]),_=(0,K.useMemo)(()=>({type:`object-grid`,objectName:`field_definition`,columns:g,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:r?void 0:{create:!0,update:!0,delete:!0}}),[g,r]),v=(0,K.useCallback)(e=>{let n=t.find(t=>t.name===e.name);n&&(d(n),l(!0))},[t]),b=(0,K.useCallback)(async e=>{let r=t.find(t=>t.name===e.name);!r||r.isSystem||await o.confirm(a(`appDesigner.fieldDesigner.deleteConfirmTitle`),a(`appDesigner.fieldDesigner.deleteConfirmMessage`))&&n?.(t.filter(e=>e.id!==r.id))},[t,n,o,a]),x=(0,K.useCallback)(()=>{d(null),l(!0)},[]),S=(0,K.useCallback)(e=>{if(u){let r={...u,name:String(e.name||u.name),label:String(e.label||u.label),type:e.type||u.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};n?.(t.map(e=>e.id===u.id?r:e))}else{let r={id:`fld_${Date.now()}`,name:String(e.name||`new_field_${t.length+1}`),label:String(e.label||`New Field ${t.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};n?.([...t,r])}l(!1),d(null)},[u,t,n]),C=(0,K.useCallback)(e=>{e||(l(!1),d(null))},[]),w=(0,K.useMemo)(()=>kn.map(e=>({category:e,label:a(`appDesigner.fieldDesigner.typeCategory.${e}`),options:On[e].map(e=>({label:Dn[e].label,value:e}))})),[a]),T=(0,K.useMemo)(()=>w.flatMap(e=>e.options),[w]),E=(0,K.useMemo)(()=>({type:`object-form`,formType:`drawer`,objectName:`field_definition`,mode:u?`edit`:`create`,title:u?`${a(`common.edit`)} — ${u.label}`:a(`appDesigner.fieldDesigner.addField`),open:s,onOpenChange:C,drawerSide:`right`,drawerWidth:`480px`,sections:[{name:`basic`,label:a(`appDesigner.fieldDesigner.basicSection`),fields:[{name:`name`,label:a(`appDesigner.fieldDesigner.fieldName`),type:`text`,required:!0,placeholder:`api_name`,disabled:r||(u?.isSystem??!1)},{name:`label`,label:a(`appDesigner.fieldDesigner.fieldLabel`),type:`text`,required:!0,placeholder:`Display Label`,disabled:r},{name:`type`,label:a(`appDesigner.fieldDesigner.fieldType`),type:`select`,required:!0,options:T,disabled:r||(u?.isSystem??!1)},{name:`required`,label:a(`appDesigner.fieldDesigner.required`),type:`boolean`,disabled:r},{name:`unique`,label:a(`appDesigner.fieldDesigner.unique`),type:`boolean`,disabled:r},{name:`description`,label:a(`appDesigner.fieldDesigner.description`),type:`textarea`,disabled:r}]},{name:`typeSpecific`,label:a(`appDesigner.fieldDesigner.typeSpecificSection`),fields:[{name:`referenceTo`,label:a(`appDesigner.fieldDesigner.referenceTo`),type:`text`,placeholder:`Referenced object`,disabled:r,condition:{field:`type`,equals:`lookup`}},{name:`formula`,label:a(`appDesigner.fieldDesigner.formula`),type:`textarea`,placeholder:`e.g. price * quantity`,disabled:r,condition:{field:`type`,equals:`formula`}},{name:`defaultValue`,label:a(`appDesigner.fieldDesigner.defaultValue`),type:`text`,placeholder:`Default value`,disabled:r},{name:`placeholder`,label:a(`appDesigner.fieldDesigner.placeholder`),type:`text`,placeholder:`Placeholder text`,disabled:r},{name:`group`,label:a(`appDesigner.fieldDesigner.fieldGroup`),type:`text`,placeholder:`Field Group`,disabled:r}]},{name:`advanced`,label:a(`appDesigner.fieldDesigner.advancedSection`),collapsible:!0,collapsed:!0,fields:[{name:`indexed`,label:a(`appDesigner.fieldDesigner.indexed`),type:`boolean`,disabled:r},{name:`externalId`,label:a(`appDesigner.fieldDesigner.externalId`),type:`boolean`,disabled:r},{name:`trackHistory`,label:a(`appDesigner.fieldDesigner.trackHistory`),type:`boolean`,disabled:r},{name:`readonly`,label:a(`appDesigner.fieldDesigner.readOnly`),type:`boolean`,disabled:r},{name:`hidden`,label:a(`appDesigner.fieldDesigner.hidden`),type:`boolean`,disabled:r}]}],initialValues:u?{name:u.name,label:u.label,type:u.type,group:u.group||``,description:u.description||``,required:u.required||!1,unique:u.unique||!1,readonly:u.readonly||!1,hidden:u.hidden||!1,indexed:u.indexed||!1,externalId:u.externalId||!1,trackHistory:u.trackHistory||!1,defaultValue:u.defaultValue==null?``:String(u.defaultValue),placeholder:u.placeholder||``,referenceTo:u.referenceTo||``,formula:u.formula||``}:{type:`text`,required:!1,unique:!1},onSuccess:S,onCancel:()=>C(!1),readOnly:r}),[u,s,C,S,T,r,a]);return(0,q.jsxs)(`div`,{"data-testid":`field-designer`,className:En(`w-full space-y-3`,i),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(y,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`appDesigner.fieldDesigner.title`)}),e&&(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`— `,e]}),(0,q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:m.length})]}),(0,q.jsxs)(`select`,{value:f,onChange:e=>p(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,q.jsx)(`option`,{value:``,children:a(`appDesigner.fieldDesigner.allTypes`)}),w.map(e=>(0,q.jsx)(`optgroup`,{label:e.label,children:e.options.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.category))]})]}),(0,q.jsx)(Ye,{schema:_,dataSource:h,onEdit:r?void 0:v,onDelete:r?void 0:b,onAddRecord:r?void 0:x}),s&&(0,q.jsx)(Ze,{schema:E}),(0,q.jsx)(at,{isOpen:o.isOpen,title:o.title,message:o.message,confirmLabel:a(`common.delete`),cancelLabel:a(`common.cancel`),onConfirm:o.onConfirm,onCancel:o.onCancel,destructive:!0})]})}var jn=`objectui-app-wizard-draft`;function Mn(){let e=a(),{appName:t}=r(),{objects:n,refresh:i}=f(),o=u(),s=(n||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:!1})),c=(0,K.useCallback)(()=>{try{let e=localStorage.getItem(jn);if(e)return JSON.parse(e)}catch{}},[]),l=(0,K.useCallback)(async t=>{try{let n=d(t),r=o?.getClient();r&&await r.meta.saveItem(`app`,t.name,n),localStorage.removeItem(jn),h.success(`Application "${t.title}" created successfully`),await i?.(),e(`/apps/${t.name}`)}catch(e){h.error(e?.message||`Failed to create application`)}},[e,i,o]),p=(0,K.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),m=(0,K.useCallback)(e=>{try{localStorage.setItem(jn,JSON.stringify(e)),h.info(`Draft saved`)}catch{}},[]);return(0,q.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`create-app-page`,children:(0,q.jsx)(Bt,{availableObjects:s,initialDraft:c(),onComplete:l,onCancel:p,onSaveDraft:m})})}function Nn(){let e=a(),{appName:t,editAppName:n}=r(),{apps:i,objects:o,refresh:s}=f(),c=u(),l=n||t,p=i.find(e=>e.name===l),m=(o||[]).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})),g=(0,K.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]),_=(0,K.useCallback)(async t=>{try{let n=d(t),r={...p,...n},i=c?.getClient();i&&await i.meta.saveItem(`app`,t.name,r),h.success(`Application "${t.title}" updated successfully`),await s?.(),e(`/apps/${t.name}`)}catch(e){h.error(e?.message||`Failed to update application`)}},[e,s,c,p]),v=(0,K.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),y=(0,K.useCallback)(e=>{try{localStorage.setItem(`objectui-edit-draft-${l}`,JSON.stringify(e)),h.info(`Draft saved`)}catch{}},[l]);return p?(0,q.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`edit-app-page`,children:(0,q.jsx)(Bt,{availableObjects:m,initialDraft:g,onComplete:_,onCancel:v,onSaveDraft:y})}):(0,q.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4 text-center`,"data-testid":`edit-app-not-found`,children:(0,q.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Application "`,l,`" not found.`]})})}function Pn(){let e=a(),{pageName:t}=r(),n=u(),{pages:i}=f(),o=i?.find(e=>e.name===t),[s,c]=(0,K.useState)(()=>o||{type:`page`,name:t??``,title:t??``,children:[]}),l=(0,K.useRef)(s);l.current=s;let d=(0,K.useCallback)(async e=>{try{if(n)return await n.update(`sys_page`,t,e),!0}catch{}return!1},[n,t]),p=(0,K.useCallback)(async e=>{c(e),await d(e)},[d]);(0,K.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),d(l.current).then(e=>{e&&h.success(`Page saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d]);let m=(0,K.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),h.success(`Page schema exported`)},[t]),g=(0,K.useCallback)(e=>{h.success(`Page schema imported`),p(e)},[p]);return o?(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`page-design-page`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,q.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,q.jsx)(he,{className:`h-4 w-4`})}),(0,q.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Page: `,o.label||o.title||t]})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,q.jsx)(pn,{schema:s,onChange:p,onExport:m,onImport:g})})]}):(0,q.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Page "`,t,`" not found`]})}function Fn(){let e=a(),{dashboardName:t}=r(),n=u(),{dashboards:i,refresh:o}=f(),s=i?.find(e=>e.name===t),[c,l]=(0,K.useState)(()=>s||{type:`dashboard`,name:t??``,title:t??``,columns:2,widgets:[]}),d=(0,K.useRef)(c);d.current=c;let p=(0,K.useCallback)(async e=>{try{if(n)return await n.update(`sys_dashboard`,t,e),o().catch(()=>{}),!0}catch{}return!1},[n,t,o]),m=(0,K.useCallback)(async e=>{l(e),await p(e)},[p]);(0,K.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),p(d.current).then(e=>{e&&h.success(`Dashboard saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p]);let g=(0,K.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),h.success(`Dashboard schema exported`)},[t]),_=(0,K.useCallback)(e=>{h.success(`Dashboard schema imported`),m(e)},[m]);return s?(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`dashboard-design-page`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 sm:px-6`,children:[(0,q.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,q.jsx)(he,{className:`h-4 w-4`})}),(0,q.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Dashboard: `,s.label||s.title||t]})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,q.jsx)(rn,{schema:c,onChange:m,onExport:g,onImport:_})})]}):(0,q.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Dashboard "`,t,`" not found`]})}var In=e({AppCreationWizard:()=>Bt,BrandingEditor:()=>xn,CreateAppPage:()=>Mn,DashboardDesignPage:()=>Fn,DashboardEditor:()=>rn,DataModelDesigner:()=>yt,EditAppPage:()=>Nn,FieldDesigner:()=>An,NavigationDesigner:()=>Yt,ObjectManager:()=>Tn,ObjectViewConfigurator:()=>vn,PageCanvasEditor:()=>pn,PageDesignPage:()=>Pn,PageDesigner:()=>pt,ProcessDesigner:()=>wt,ReportDesigner:()=>Dt});o.register(`page-designer`,pt,{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}]}),o.register(`data-model-designer`,yt,{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}]}),o.register(`process-designer`,wt,{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}]}),o.register(`report-designer`,Dt,{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}]}),o.register(`app-creation-wizard`,Bt,{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}]}),o.register(`navigation-designer`,Yt,{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}]}),o.register(`dashboard-editor`,rn,{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}]}),o.register(`page-canvas-editor`,pn,{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}]}),o.register(`object-view-configurator`,vn,{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}]}),o.register(`branding-editor`,xn,{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}]}),o.register(`object-manager`,Tn,{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}]}),o.register(`field-designer`,An,{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}]});export{An as n,Tn as r,In as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:w-\[--sidebar-width-icon\]{width:var(--sidebar-width-icon)}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:w-\[--sidebar-width-icon\]{width:var(--sidebar-width)}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:w-\[calc\(var\(--sidebar-width-icon\)_\+_theme\(spacing\.4\)\)\]{width:calc(var(--sidebar-width-icon) + 1rem)}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:w-\[calc\(var\(--sidebar-width-icon\)_\+_theme\(spacing\.4\)\)\]{width:var(--sidebar-width)}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:w-\[calc\(var\(--sidebar-width-icon\)_\+_theme\(spacing\.4\)_\+2px\)\]{width:calc(var(--sidebar-width-icon) + 1rem + 2px)}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:w-\[calc\(var\(--sidebar-width-icon\)_\+_theme\(spacing\.4\)_\+2px\)\]{width:var(--sidebar-width)}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:opacity-0{opacity:0}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:opacity-0{opacity:1}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:-mt-8{margin-top:-2rem}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:-mt-8{margin-top:0}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:hidden{display:none}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:hidden{display:block}.group[data-collapsible=icon][data-state=collapsed] .group-data-\[collapsible\=icon\]\:overflow-hidden{overflow:hidden}.group[data-collapsible=icon][data-state=expanded] .group-data-\[collapsible\=icon\]\:overflow-hidden{overflow:auto}.group[data-collapsible=icon][data-state=collapsed] .sidebar-menu-button-icon-mode{width:2rem!important;height:2rem!important;padding:.5rem!important}.group[data-collapsible=icon][data-state=expanded] .sidebar-menu-button-icon-mode{width:100%;height:auto;padding:.5rem}.group[data-collapsible=icon][data-state=collapsed] .sidebar-menu-button-icon-mode-lg{padding:0!important}.group[data-collapsible=icon][data-state=expanded] .sidebar-menu-button-icon-mode-lg{padding:.5rem}.group[data-collapsible=offcanvas] .group-data-\[collapsible\=offcanvas\]\:w-0{width:0}
|