@object-ui/console 3.1.5 → 3.3.1
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/README.md +16 -0
- package/dist/assets/AdapterProvider-Cd4HYb7q.js +1 -0
- package/dist/assets/AdvancedChartImpl-AY6sVw1n.js +7 -0
- package/dist/assets/AppManagementPage-6l5ZKnv5.js +1 -0
- package/dist/assets/ChartImpl-DiKY5voi.js +1 -0
- package/dist/assets/DashboardView-BnX2k5Kx.js +1 -0
- package/dist/assets/KanbanEnhanced-BKCx2XIr.js +1 -0
- package/dist/assets/KanbanImpl-e9jzV-UD.js +1 -0
- package/dist/assets/MarkdownImpl-B-r7jSIS.js +1 -0
- package/dist/assets/MetadataDetailPage--3o8VI1T.js +1 -0
- package/dist/assets/MetadataFormDialog-Cy7k0Y55.js +1 -0
- package/dist/assets/MetadataInspector-DVtCDQtx.js +1 -0
- package/dist/assets/MetadataManagerPage-CYfvXG6X.js +1 -0
- package/dist/assets/MetadataProvider-Dvc9BxbC.js +1 -0
- package/dist/assets/PageView-CUDEz8Xo.js +2 -0
- package/dist/assets/ProfilePage-B0BXoAus.js +1 -0
- package/dist/assets/RecordDetailView-CYgcTNQp.js +1 -0
- package/dist/assets/ReportView-ovWyjJsZ.js +1 -0
- package/dist/assets/SearchResultsPage-B-NchFoJ.js +1 -0
- package/dist/assets/SystemHubPage-D8S1hN1a.js +1 -0
- package/dist/assets/data-adapter-v22lWuhc.js +39 -0
- package/dist/assets/framework-BW6KsEI0.js +2 -0
- package/dist/assets/getIcon-N5xWCMJy.js +1 -0
- package/dist/assets/index-DATdOX6r.js +59 -0
- package/dist/assets/index-nwlbpqhl.css +2 -0
- package/dist/assets/infrastructure-94fpO8jL.js +3 -0
- package/dist/assets/maplibre-gl-BR3qC6SX.js +748 -0
- package/dist/assets/plugins-core-B5ROGaJH.css +1 -0
- package/dist/assets/plugins-core-Ccvbi6db.js +105 -0
- package/dist/assets/plugins-views-CbLIJkBs.js +62 -0
- package/dist/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/assets/{skeletons-DcGqw3b1.js → skeletons-CIQE_YYE.js} +1 -1
- package/dist/assets/src-BGoL_8qF.js +1 -0
- package/dist/assets/ui-layout-CYz0tyDf.js +3 -0
- package/dist/assets/vendor-charts-D1AP0-EV.js +33 -0
- package/dist/assets/vendor-icons-CrSf7tAH.js +1 -0
- package/dist/assets/vendor-objectstack-Dhrq31KF.js +1 -0
- package/dist/assets/{vendor-react-BwtAzZZ3.js → vendor-react-ryfytPb-.js} +2 -2
- package/dist/assets/vendor-zod-Dfb8LXKF.js +64 -0
- package/dist/index.html +26 -15
- package/package.json +48 -64
- package/plugin.js +2 -2
- package/plugin.ts +2 -2
- package/dist/assets/AddressField-BLYuFwUv.js +0 -1
- package/dist/assets/AdvancedChartImpl-Dvg6YIfN.js +0 -7
- package/dist/assets/AppManagementPage-C5q5QBar.js +0 -1
- package/dist/assets/AuditLogPage-BpLFTD-b.js +0 -1
- package/dist/assets/AuthPageLayout-DDjJTsQ6.js +0 -1
- package/dist/assets/AutoNumberField-DLmi_0fk.js +0 -1
- package/dist/assets/AvatarField-BfoEDA_D.js +0 -1
- package/dist/assets/BooleanField-W3_x7RAZ.js +0 -1
- package/dist/assets/ChartImpl-Cwo6IWnY.js +0 -1
- package/dist/assets/CodeField-BWFqblAU.js +0 -1
- package/dist/assets/ColorField-Y8WM1wXE.js +0 -1
- package/dist/assets/CreateAppPage-A-VfItcx.js +0 -1
- package/dist/assets/CurrencyField-BeuE1bRa.js +0 -1
- package/dist/assets/DashboardDesignPage-N8NL-jkM.js +0 -1
- package/dist/assets/DashboardView-Dy0d2kFj.js +0 -1
- package/dist/assets/DateField-2Lf9jstN.js +0 -1
- package/dist/assets/DateTimeField-BkMuhOZJ.js +0 -1
- package/dist/assets/EditAppPage-B6HL4COW.js +0 -1
- package/dist/assets/EmailField-CP_O7tmo.js +0 -1
- package/dist/assets/FileField-CcczwlRk.js +0 -1
- package/dist/assets/ForgotPasswordPage-Slo6CHvD.js +0 -1
- package/dist/assets/FormulaField-DLdg1ImO.js +0 -1
- package/dist/assets/GeolocationField-DqeMjnyo.js +0 -1
- package/dist/assets/GridField-DaWMYyuc.js +0 -1
- package/dist/assets/ImageField-DAn05d1y.js +0 -1
- package/dist/assets/KanbanEnhanced-Dj7Qccu2.js +0 -1
- package/dist/assets/KanbanImpl-D9BbG_RT.js +0 -1
- package/dist/assets/LocationField-DYHVF_gq.js +0 -1
- package/dist/assets/LoginPage-D2CqpSi0.js +0 -1
- package/dist/assets/LookupField-BF9vCmht.js +0 -1
- package/dist/assets/MarkdownImpl-B0Iew7iJ.js +0 -29
- package/dist/assets/MasterDetailField-Dw4RRQ5W.js +0 -1
- package/dist/assets/NumberField-BKuVHBrN.js +0 -1
- package/dist/assets/ObjectField-z00gmFEc.js +0 -1
- package/dist/assets/OrgManagementPage-BqtqRi_6.js +0 -1
- package/dist/assets/PageDesignPage-BzIL8o0u.js +0 -1
- package/dist/assets/PageView-eCi7zkJr.js +0 -2
- package/dist/assets/PasswordField-B_rXL4g9.js +0 -1
- package/dist/assets/PercentField-Bn_SIbNe.js +0 -1
- package/dist/assets/PermissionManagementPage-BmI-0QXt.js +0 -1
- package/dist/assets/PhoneField-DuheMaUR.js +0 -1
- package/dist/assets/ProfilePage-CUo-xIgl.js +0 -1
- package/dist/assets/QRCodeField-IPS2Rpmi.js +0 -1
- package/dist/assets/RatingField-M6qZlpA4.js +0 -1
- package/dist/assets/RecordDetailView-CFVPmfrM.js +0 -1
- package/dist/assets/RegisterPage-D7PJIabW.js +0 -1
- package/dist/assets/ReportView-DNOPIpWM.js +0 -1
- package/dist/assets/RichTextField-CDGy9V9x.js +0 -1
- package/dist/assets/RoleManagementPage-DwtqyfDW.js +0 -1
- package/dist/assets/SearchResultsPage-BxzOkRnL.js +0 -1
- package/dist/assets/SelectField-F6UDlyvf.js +0 -1
- package/dist/assets/SignatureField-CHN7xBII.js +0 -1
- package/dist/assets/SliderField-BOfEMQyU.js +0 -1
- package/dist/assets/SummaryField-CZ8KzmBZ.js +0 -1
- package/dist/assets/SystemHubPage-RFiJSMgW.js +0 -1
- package/dist/assets/TextAreaField-1E39zZ_x.js +0 -1
- package/dist/assets/TextField-CwuU0Crc.js +0 -1
- package/dist/assets/TimeField-CEWXxhLE.js +0 -1
- package/dist/assets/UrlField-BtUImn9B.js +0 -1
- package/dist/assets/UserField-DSSEoy5L.js +0 -1
- package/dist/assets/UserManagementPage-BBS1vYGa.js +0 -1
- package/dist/assets/VectorField-BjfQeTZT.js +0 -1
- package/dist/assets/data-adapter-wZ81OFjZ.js +0 -39
- package/dist/assets/framework-DJlDX9E6.js +0 -1
- package/dist/assets/index-D9-L0QBO.css +0 -2
- package/dist/assets/index-DDpLaQOV.js +0 -8
- package/dist/assets/infrastructure-C6Ph6Ug0.js +0 -3
- package/dist/assets/maplibre-gl-DsUGuDud.js +0 -756
- package/dist/assets/plugins-core-Cfhp_BXE.css +0 -2
- package/dist/assets/plugins-core-PiAAytWV.js +0 -136
- package/dist/assets/plugins-views-CE0VP3vl.js +0 -62
- package/dist/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
- package/dist/assets/src-oeWLmiqa.js +0 -1
- package/dist/assets/systemObjects-5--4zaiX.js +0 -1
- package/dist/assets/ui-layout-DdDX0gzI.js +0 -3
- package/dist/assets/vendor-charts-Bl5l0H2K.js +0 -3
- package/dist/assets/vendor-objectstack-BtztJIHv.js +0 -1
- package/dist/mockServiceWorker.js +0 -349
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U as e}from"./framework-BW6KsEI0.js";import{Kt as t}from"./plugins-core-Ccvbi6db.js";var n=e();function r({cards:e=6}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-7 w-56`}),(0,n.jsx)(t,{className:`h-4 w-80`})]}),(0,n.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-20`}),(0,n.jsx)(t,{className:`h-8 w-24`}),(0,n.jsx)(t,{className:`h-3 w-16`})]},`stat-${r}`))}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(t,{className:`h-5 w-5 rounded-full`})]}),(0,n.jsx)(t,{className:`h-40 w-full`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-3 w-16`}),(0,n.jsx)(t,{className:`h-3 w-12`})]})]},`widget-${r}`))})]})}function i({fields:e=8,columns:r=2}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded`}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-6 w-48`}),(0,n.jsx)(t,{className:`h-4 w-32`})]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-9 w-20`}),(0,n.jsx)(t,{className:`h-9 w-20`})]})]}),(0,n.jsx)(t,{className:`h-5 w-24`}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 ${r===2?`md:grid-cols-2`:``} gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-24`}),(0,n.jsx)(t,{className:`h-9 w-full`})]},`field-${r}`))}),(0,n.jsxs)(`div`,{className:`space-y-3 pt-4 border-t`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,r)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded-full`}),(0,n.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,n.jsx)(t,{className:`h-4 w-40`}),(0,n.jsx)(t,{className:`h-3 w-24`})]})]},`related-${r}`))})]})]})}export{r as n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{F as n,H as r,U as i,W as a,a as o,k as s,m as c,n as l,p as u,t as d}from"./framework-BW6KsEI0.js";import{$i as f,Aa as p,Br as m,Ca as h,Ci as g,Da as _,Di as v,Ei as y,Fa as b,Fr as x,Gi as S,Gr as C,Hr as w,Ia as T,Ir as E,Ji as D,Jr as O,Ka as k,Ki as A,La as j,Li as M,Ma as N,Mi as P,Mr as ee,Na as F,Ni as te,Nr as ne,Oa as I,Oi as re,Pa as L,Qa as R,Qr as ie,Ri as z,Rr as B,Sa as ae,Ti as oe,Ui as se,Ur as V,Va as ce,Vi as H,Vr as le,Wi as ue,Xi as de,Xr as fe,Yi as pe,Yr as U,Za as W,_a as me,_i as he,aa as ge,ba as _e,bi as ve,c as ye,ca as be,d as xe,da as Se,eo as G,fa as Ce,fi as we,ga as Te,gi as Ee,ja as De,ji as Oe,ka as ke,ki as Ae,l as je,la as Me,li as Ne,ma as Pe,mi as Fe,na as Ie,oa as Le,pa as Re,ra as ze,ri as Be,sa as Ve,si as He,ua as Ue,va as We,xa as Ge,xi as Ke,ya as qe,zi as Je,zr as Ye}from"./plugins-core-Ccvbi6db.js";import{d as Xe,p as Ze}from"./ui-layout-CYz0tyDf.js";var K=t(a(),1);function Qe(e,t={}){let{maxHistory:n=50}=t,[r,i]=(0,K.useState)(e),a=(0,K.useRef)([]),o=(0,K.useRef)([]),s=(0,K.useCallback)(e=>{i(t=>(a.current=[...a.current.slice(-(n-1)),t],o.current=[],e))},[n]),c=(0,K.useCallback)(()=>{a.current.length!==0&&i(e=>{let t=[...a.current],n=t.pop();return a.current=t,o.current=[e,...o.current],n})},[]),l=(0,K.useCallback)(()=>{o.current.length!==0&&i(e=>{let t=[...o.current],n=t.shift();return o.current=t,a.current=[...a.current,e],n})},[]),u=(0,K.useCallback)(e=>{a.current=[],o.current=[],i(e)},[]);return{current:r,canUndo:a.current.length>0,canRedo:o.current.length>0,undoCount:a.current.length,redoCount:o.current.length,push:s,undo:c,redo:l,reset:u}}function $e(){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 et(){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 tt(){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 nt(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 rt(...e){return W(R(e))}function it({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)(le,{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:rt(`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 at(...e){return W(R(e))}function ot({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:at(`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)(I,{className:`h-3 w-3`}):(0,q.jsx)(p,{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)(st,{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 st({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 ct(...e){return W(R(e))}function lt({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:ct(`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 ut=(0,K.createContext)(null);ut.displayName=`CollaborationContext`;function dt(){return(0,K.useContext)(ut)}function J(...e){return W(R(e))}function ft({canvas:e={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:t=[],palette:n=pt,showComponentTree:r=!0,undoRedo:i=!0,propertyEditor:a=!0,readOnly:o=!1,showMinimap:s=!1,onChange:c,className:l}){let u=Qe(t),d=u.current,f=(0,K.useCallback)(e=>{u.push(e),c?.(e)},[u,c]),p=nt({initialZoom:e.zoom??1}),{zoom:m}=p,g=et(),_=(0,K.useMemo)(()=>{let e=Array.from(g.selectedIds);return e.length>0?e[0]:null},[g.selectedIds]),v=(0,K.useMemo)(()=>d.find(e=>e.id===_),[d,_]),b=tt(),x=$e(),S=dt(),C=(0,K.useCallback)(e=>{S&&S.sendOperation({...e,userId:S.currentUserId??``})},[S]),[w,T]=(0,K.useState)(!0),[E,D]=(0,K.useState)(!0),[O,k]=(0,K.useState)(s),A=(0,K.useRef)(null),j=(0,K.useRef)(null),N=(0,K.useCallback)(t=>!e.snapToGrid||!e.gridSize?t:Math.round(t/e.gridSize)*e.gridSize,[e.snapToGrid,e.gridSize]),P=(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]),g.selectOne(a.id),C({type:`insert`,elementId:a.id,data:{component:a}})},[d,o,n,f,g,C]),ee=(0,K.useCallback)(e=>{o||(f(d.filter(t=>t.id!==e)),g.isSelected(e)&&g.clearSelection(),C({type:`delete`,elementId:e,data:{}}))},[d,o,f,g,C]),F=(0,K.useCallback)(async()=>{if(o||g.count===0||!await x.confirm(`Delete components`,`Are you sure you want to delete ${g.count} component${g.count>1?`s`:``}?`))return;let e=g.selectedIds;f(d.filter(t=>!e.has(t.id))),g.clearSelection(),e.forEach(e=>{C({type:`delete`,elementId:e,data:{}})})},[o,g,x,d,f,C]),ne=(0,K.useCallback)((e,t)=>{o||!_||(f(d.map(n=>n.id===_?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)),C({type:`update`,elementId:_,data:{[e]:t}}))},[o,_,d,f,C]),I=(0,K.useCallback)(()=>{let e=g.selectedIds;if(e.size===0)return;let t=d.filter(t=>e.has(t.id));b.copy(t)},[g,d,b]),L=(0,K.useCallback)(()=>{if(o)return;let e=b.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`comp-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}}));f([...d,...n]),g.selectMany(n.map(e=>e.id)),n.forEach(e=>{C({type:`insert`,elementId:e.id,data:{component:e}})})},[o,b,d,f,g,C]),R=(0,K.useCallback)((e,t)=>{o||(A.current={id:t.id,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[o]),ie=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),B=(0,K.useCallback)(e=>{e.preventDefault();let t=A.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:N(e.position.x+n),y:N(e.position.y+r)}}:e)),C({type:`move`,elementId:t.id,data:{}}),A.current=null},[o,m,d,f,N,C]),ae=(0,K.useMemo)(()=>v?[{name:`label`,label:`Label`,type:`text`,value:v.label??``,group:`General`},{name:`x`,label:`X`,type:`number`,value:v.position.x,group:`Position`},{name:`y`,label:`Y`,type:`number`,value:v.position.y,group:`Position`},{name:`width`,label:`Width`,type:`number`,value:v.position.width,group:`Size`},{name:`height`,label:`Height`,type:`number`,value:v.position.height,group:`Size`}]:[],[v]),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:g.isSelected(e.id)})),[d,g]);return(0,K.useEffect)(()=>{let e=j.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&g.count>0&&!t){e.preventDefault(),F();return}if(e.key===`Escape`){g.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(),I();return}if(n&&e.key===`v`&&!o){e.preventDefault(),L();return}if(n&&e.key===`a`){e.preventDefault(),g.selectMany(d.map(e=>e.id));return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g,F,i,o,u,I,L,d]),(0,q.jsxs)(`div`,{ref:j,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`,w?`w-60`:`w-0 overflow-hidden`),role:`region`,"aria-label":`Component palette`,children:w&&(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:()=>P(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)(Ee,{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:w?`Collapse palette`:`Expand palette`,"aria-label":w?`Collapse palette`:`Expand palette`,onClick:()=>T(e=>!e),children:(0,q.jsx)(re,{className:J(`h-4 w-4`,!w&&`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)(Ye,{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)(Fe,{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`,g.count===0&&`opacity-40 pointer-events-none`),title:`Copy (Ctrl+C)`,"aria-label":`Copy`,disabled:g.count===0,onClick:I,children:(0,q.jsx)(qe,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,!b.hasContent&&`opacity-40 pointer-events-none`),title:`Paste (Ctrl+V)`,"aria-label":`Paste`,disabled:!b.hasContent,onClick:L,children:(0,q.jsx)(h,{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`,g.count===0&&`opacity-40 pointer-events-none`),title:`Delete selected`,"aria-label":`Delete selected`,disabled:g.count===0,onClick:F,children:(0,q.jsx)(V,{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)(Re,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:J(`p-1.5 rounded hover:bg-accent`,O&&`bg-accent`),title:`Toggle minimap`,"aria-label":`Toggle minimap`,onClick:()=>k(e=>!e),children:(0,q.jsx)(z,{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)(te,{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)(Ee,{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)(M,{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)(y,{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:ie,onDrop:B,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=g.isSelected(e.id);return(0,q.jsxs)(`div`,{draggable:!o,onDragStart:t=>R(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=>g.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)(ge,{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)(V,{className:`h-3 w-3 text-destructive`})})]}),(0,q.jsx)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:e.type})]},e.id)}),O&&(0,q.jsx)(lt,{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)(de,{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=>g.toggle(e.id,t.shiftKey),className:J(`w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left`,g.isSelected(e.id)?`bg-accent`:`hover:bg-accent/50`),children:(0,q.jsx)(`span`,{className:`truncate`,children:e.label??e.type})},e.id))}),a&&v?(0,q.jsx)(`div`,{className:`border-t`,children:(0,q.jsx)(ot,{title:`Properties – ${v.label??v.type}`,fields:ae,onChange:ne})}):v&&(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: `,v.type]}),(0,q.jsxs)(`div`,{children:[`ID: `,v.id]}),(0,q.jsxs)(`div`,{children:[`Position: `,v.position.x,`,`,` `,v.position.y]}),(0,q.jsxs)(`div`,{children:[`Size: `,v.position.width,` ×`,` `,v.position.height]})]})]})]})}),(0,q.jsx)(it,{isOpen:x.isOpen,title:x.title,message:x.message,onConfirm:x.onConfirm,onCancel:x.onCancel})]})}var pt=[{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 mt(e,t={}){return Qe(e,t)}function ht(...e){return W(R(e))}var gt=[`text`,`number`,`boolean`,`date`,`datetime`,`uuid`,`email`,`url`,`phone`,`json`,`integer`,`float`,`decimal`,`currency`,`percent`,`textarea`,`select`,`multiselect`,`lookup`,`attachment`,`formula`,`autonumber`];function _t(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 vt({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=mt({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]),m=$e(),g=et(),_=g.count>0?Array.from(g.selectedIds)[0]:null,v=tt(),y=nt({minZoom:.25,maxZoom:3,zoomStep:.1}),b=dt(),[x,C]=(0,K.useState)(!0),[w,T]=(0,K.useState)(!0),[D,O]=(0,K.useState)(null),[k,A]=(0,K.useState)(``),[j,M]=(0,K.useState)(null),[N,P]=(0,K.useState)(``),F=(0,K.useRef)(null),te=(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}),g.selectOne(t.id),b?.sendOperation({type:`insert`,userId:b?.currentUserId??``,elementId:t.id,data:{name:t.name,label:t.label}})},[i,l,f,g,b]),re=(0,K.useCallback)(async e=>{if(i)return;let t=u.find(t=>t.id===e);if(!await m.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)}),g.isSelected(e)&&g.clearSelection(),b?.sendOperation({type:`delete`,userId:b?.currentUserId??``,elementId:e,data:{}})},[i,u,m,l,f,g,b]),L=(0,K.useCallback)(async()=>{if(i||g.count===0)return;let e=Array.from(g.selectedIds);if(!await m.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))}),g.clearSelection()},[i,g,m,l,f]),R=(0,K.useCallback)(()=>{if(i)return;let e=l.current;f({entities:_t(e.entities),relationships:e.relationships})},[i,l,f]),ie=(0,K.useCallback)(()=>{let e=u.filter(e=>g.isSelected(e.id));e.length>0&&v.copy(e)},[u,g,v]),z=(0,K.useCallback)(()=>{if(i)return;let e=v.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}),g.selectMany(n.map(e=>e.id))},[i,v,l,f,g]),B=(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||(O({entityId:e,fieldIndex:t}),A(n))},[i]),oe=(0,K.useCallback)(()=>{if(!D)return;let e=k.trim();if(e===``){O(null);return}let t=l.current;f({entities:t.entities.map(t=>{if(t.id!==D.entityId)return t;let n=t.fields.map((t,n)=>n===D.fieldIndex?{...t,name:e}:t);return{...t,fields:n}}),relationships:t.relationships}),O(null)},[D,k,l,f]),se=(0,K.useCallback)(()=>{O(null)},[]),ce=(0,K.useCallback)((e,t)=>{i||(M(e),P(t))},[i]),H=(0,K.useCallback)(()=>{if(!j)return;let e=N.trim();if(e===``){M(null);return}let t=l.current;f({entities:t.entities.map(t=>t.id===j?{...t,label:e}:t),relationships:t.relationships}),M(null)},[j,N,l,f]),le=(0,K.useCallback)(()=>{M(null)},[]),ue=(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]),de=(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]),fe=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),pe=(0,K.useCallback)(e=>{if(e.preventDefault(),!F.current)return;let t=e.currentTarget.getBoundingClientRect(),n=y.zoom,r=(e.clientX-t.left-y.panOffset.x)/n-F.current.offsetX,i=(e.clientY-t.top-y.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},[y.zoom,y.panOffset,l,f]),U=_?u.find(e=>e.id===_):null,W=U?[{name:`name`,label:`Name`,type:`text`,value:U.name,group:`General`},{name:`label`,label:`Label`,type:`text`,value:U.label,group:`General`},{name:`description`,label:`Description`,type:`textarea`,value:U.description??``,group:`General`},{name:`color`,label:`Color`,type:`color`,value:U.color??`#3b82f6`,group:`Appearance`},{name:`position.x`,label:`X Position`,type:`number`,value:U.position.x,group:`Position`},{name:`position.y`,label:`Y Position`,type:`number`,value:U.position.y,group:`Position`}]:[],me=(0,K.useCallback)((e,t)=>{if(!_)return;let n=l.current;f({entities:n.entities.map(n=>n.id===_?e===`position.x`?{...n,position:{...n.position,x:Number(t)}}:e===`position.y`?{...n,position:{...n.position,y:Number(t)}}:{...n,[e]:t}:n),relationships:n.relationships})},[_,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(),ie()):n&&e.key===`v`?(e.preventDefault(),z()):(e.key===`Delete`||e.key===`Backspace`)&&g.count>0?(e.preventDefault(),L()):e.key===`Escape`&&(g.clearSelection(),O(null),M(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[l,ie,z,L,g]);let he=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:g.isSelected(e.id)}));return(0,q.jsxs)(`div`,{ref:c,tabIndex:0,className:ht(`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)(We,{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)(Ye,{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)(Fe,{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:y.zoomOut,"aria-label":`Zoom Out`,title:`Zoom Out`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums w-10 text-center`,children:[Math.round(y.zoom*100),`%`]}),(0,q.jsx)(`button`,{onClick:y.zoomIn,"aria-label":`Zoom In`,title:`Zoom In`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{onClick:y.resetZoom,"aria-label":`Reset Zoom`,title:`Reset Zoom`,className:`p-1 rounded hover:bg-accent`,children:(0,q.jsx)(we,{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:ie,disabled:g.count===0,"aria-label":`Copy`,title:`Copy (Ctrl+C)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(qe,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`button`,{onClick:z,disabled:!v.hasContent,"aria-label":`Paste`,title:`Paste (Ctrl+V)`,className:`p-1 rounded hover:bg-accent disabled:opacity-40`,children:(0,q.jsx)(h,{className:`h-3.5 w-3.5`})})]}),!i&&(0,q.jsxs)(`button`,{onClick:R,"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)(Le,{className:`h-3 w-3`}),` Auto Layout`]}),(0,q.jsx)(`div`,{className:`flex-1`}),b?.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:[b.users.length,` user`,b.users.length===1?``:`s`]})]}),g.count>1&&(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[g.count,` selected`]}),!i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{onClick:te,"aria-label":`Add Entity`,className:`flex items-center gap-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,q.jsx)(Ee,{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)(S,{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:y.handleWheel,onMouseDown:y.startPan,onDragOver:fe,onDrop:pe,children:[(0,q.jsxs)(`div`,{className:`relative`,style:{width:n.width,minHeight:n.height,...y.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=>de(t,e.id),className:ht(`absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing`,g.isSelected(e.id)?`border-primary ring-2 ring-primary/20`:`border-border hover:border-primary/50`),style:{left:e.position.x,top:e.position.y},onClick:t=>g.toggle(e.id,t.shiftKey),children:[(0,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)(We,{className:`h-3.5 w-3.5`}),j===e.id?(0,q.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),onBlur:H,onKeyDown:e=>{e.key===`Enter`&&H(),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(),re(e.id)},"aria-label":`Delete ${e.label}`,className:`ml-auto p-0.5 rounded hover:bg-destructive/20`,children:(0,q.jsx)(V,{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:[D&&D.entityId===e.id&&D.fieldIndex===n?(0,q.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(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:ht(`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(),ue(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:gt.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(),B(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)(Ee,{className:`h-3 w-3`}),` Add Field`]})})]},e.id))]}),w&&u.length>0&&(0,q.jsx)(lt,{items:he,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:()=>C(e=>!e),className:`flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 border-b`,"aria-expanded":x,"aria-controls":`property-editor-panel`,children:[x?(0,q.jsx)(p,{className:`h-3 w-3`}):(0,q.jsx)(I,{className:`h-3 w-3`}),`Properties`]}),x&&(0,q.jsx)(`div`,{id:`property-editor-panel`,className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(ot,{title:U?U.label:`Properties`,fields:W,onChange:me})})]}),(0,q.jsx)(`div`,{className:`border-t`,children:(0,q.jsxs)(`button`,{onClick:()=>T(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":w,children:[w?(0,q.jsx)(p,{className:`h-3 w-3`}):(0,q.jsx)(I,{className:`h-3 w-3`}),`Minimap`]})})]}),(0,q.jsx)(it,{isOpen:m.isOpen,title:m.title,message:m.message,onConfirm:m.onConfirm,onCancel:m.onCancel,destructive:!0})]})}function yt(...e){return W(R(e))}var bt=120,xt=50;function St(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 Ct({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=Qe({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]),_=$e(),v=et(),b=tt(),x=nt({initialZoom:1}),S=dt(),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(!1),[D,O]=(0,K.useState)(null),[k,A]=(0,K.useState)(null),[j,M]=(0,K.useState)(!0),[N,P]=(0,K.useState)(null),[F,te]=(0,K.useState)({x:0,y:0}),I=(0,K.useRef)(null),re=(0,K.useRef)(c),L=(0,K.useRef)(l);re.current=c,L.current=l,(0,K.useEffect)(()=>{re.current?.(f),L.current?.(p)},[d.current]);let R=(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),w(n.id),v.selectOne(n.id),S?.sendOperation({type:`insert`,elementId:n.id,data:{label:t},userId:S.currentUserId??``})},[f,p,s,m,v,S]),z=(0,K.useCallback)(async e=>{if(s)return;let t=f.find(t=>t.id===e);await _.confirm(`Delete Node`,`Are you sure you want to delete "${t?.label??e}"? This will also remove all connected edges.`)&&(m(f.filter(t=>t.id!==e),p.filter(t=>t.source!==e&&t.target!==e)),C===e&&w(null),v.clearSelection(),S?.sendOperation({type:`delete`,elementId:e,data:{},userId:S.currentUserId??``}))},[f,p,C,s,m,_,v,S]),B=(0,K.useCallback)(async()=>{if(s||v.count===0||!await _.confirm(`Delete Selected Nodes`,`Are you sure you want to delete ${v.count} selected node(s) and their connected edges?`))return;let e=v.selectedIds;m(f.filter(t=>!e.has(t.id)),p.filter(t=>!e.has(t.source)&&!e.has(t.target))),w(null),v.clearSelection()},[f,p,s,m,_,v]),ae=(0,K.useCallback)(()=>{let e=v.count>0?v.selectedIds:C?new Set([C]):new Set;if(e.size===0)return;let t=f.filter(t=>e.has(t.id));b.copy(t)},[f,C,v,b]),se=(0,K.useCallback)(()=>{if(s)return;let e=b.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),v.selectMany(t.map(e=>e.id)),w(t[0].id)},[s,f,p,b,m,v]),ce=(0,K.useCallback)(()=>{E(e=>e?(O(null),!1):!0)},[]),H=(0,K.useCallback)(e=>{if(!T)return!1;if(!D)return O(e),!0;if(D===e)return!0;let t={id:`edge-${Date.now()}`,source:D,target:e};return m(f,[...p,t]),O(null),E(!1),S?.sendOperation({type:`insert`,elementId:t.id,data:{source:D,target:e},userId:S.currentUserId??``}),!0},[T,D,f,p,m,S]),le=(0,K.useCallback)(()=>{s||f.length===0||m(St(f,p),p)},[f,p,s,m]),de=(0,K.useCallback)((e,t)=>{if(s||!f.find(e=>e.id===t))return;P(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]),fe=(0,K.useCallback)(e=>{if(e.preventDefault(),s||!N)return;let t=e.currentTarget.getBoundingClientRect(),n=x.zoom,r=(e.clientX-t.left-x.panOffset.x)/n-F.x,i=(e.clientY-t.top-x.panOffset.y)/n-F.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===N?{...e,position:{x:a,y:o}}:e),p),P(null)},[s,N,F,f,p,x.zoom,x.panOffset,m]),pe=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),U=(0,K.useMemo)(()=>f.find(e=>e.id===C)??null,[f,C]),W=(0,K.useMemo)(()=>U?[{name:`label`,label:`Name`,type:`text`,value:U.label,group:`General`},{name:`type`,label:`Type`,type:`select`,value:U.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:U.description??``,group:`General`}]:[],[U]),ge=(0,K.useCallback)((e,t)=>{s||!C||m(f.map(n=>n.id===C?{...n,[e]:t}:n),p)},[s,C,f,p,m]),_e=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`}},ve=(0,K.useMemo)(()=>f.map(e=>({id:e.id,x:e.position.x,y:e.position.y,width:bt,height:xt,selected:v.isSelected(e.id)||e.id===C})),[f,v,C]);(0,K.useEffect)(()=>{let e=I.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(),ae();return}if(n&&e.key===`v`){e.preventDefault(),se();return}if(e.key===`Delete`||e.key===`Backspace`){v.count>0?(e.preventDefault(),B()):C&&(e.preventDefault(),z(C));return}if(e.key===`Escape`){T?(E(!1),O(null)):(w(null),v.clearSelection());return}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[C,T,v,d,ae,se,z,B]);let ye=(0,K.useCallback)(e=>{e.target===e.currentTarget&&(w(null),v.clearSelection(),T&&(E(!1),O(null)))},[T,v]);return(0,q.jsxs)(`div`,{ref:I,tabIndex:0,className:yt(`flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background`,u),children:[(0,q.jsx)(it,{isOpen:_.isOpen,title:_.title,message:_.message,onConfirm:_.onConfirm,onCancel:_.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)(be,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`font-medium text-sm`,"aria-label":`Process name`,children:e}),S?.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`}),S.users.length,` user`,S.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)(Ye,{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)(Fe,{className:`h-3 w-3`})}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsx)(`button`,{onClick:ae,disabled:v.count===0&&!C,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)(qe,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:se,disabled:!b.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)(h,{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:yt(`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,T&&`bg-primary text-primary-foreground`),title:`Connect nodes`,"aria-label":`Connect nodes`,"aria-pressed":T,children:[(0,q.jsx)(ue,{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)(g,{className:`h-3 w-3`}),` Layout`]}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsx)(`button`,{onClick:x.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)(ne,{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(x.zoom*100),`%`]}),(0,q.jsx)(`button`,{onClick:x.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)(ee,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:x.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)(we,{className:`h-3 w-3`})}),(0,q.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,q.jsxs)(`button`,{onClick:()=>R(`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)(he,{className:`h-3 w-3 text-green-600`}),` Start`]}),(0,q.jsxs)(`button`,{onClick:()=>R(`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)(ie,{className:`h-3 w-3 text-blue-600`}),` Task`]}),(0,q.jsxs)(`button`,{onClick:()=>R(`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)(me,{className:`h-3 w-3 text-yellow-600`}),` Gateway`]}),(0,q.jsxs)(`button`,{onClick:()=>R(`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)(ie,{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:()=>M(e=>!e),className:`flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent`,title:j?`Hide properties`:`Show properties`,"aria-label":j?`Hide property panel`:`Show property panel`,"aria-expanded":j,children:j?(0,q.jsx)(y,{className:`h-3 w-3`}):(0,q.jsx)(oe,{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:x.handleWheel,onMouseDown:x.startPan,children:(0,q.jsxs)(`div`,{className:`relative`,style:{...x.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:ye,onDrop:fe,onDragOver:pe,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+bt/2;let r=t.position.y+xt/2;n.position.x+bt/2;let i=n.position.y+xt/2,a=t.position.x+bt,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=v.isSelected(e.id)||C===e.id,n=D===e.id,r=k===e.id,i=T||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&&!T,onDragStart:t=>de(t,e.id),onMouseEnter:()=>A(e.id),onMouseLeave:()=>A(null),onClick:t=>{H(e.id)||(t.shiftKey?v.toggle(e.id,!0):(w(e.id),v.selectOne(e.id)))},children:[(0,q.jsx)(`div`,{className:yt(`flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow`,_e(e.type),t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,T&&!n&&`cursor-crosshair`),children:(0,q.jsx)(`span`,{className:yt(`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:xt/2-6},title:`Input port`,onClick:t=>{t.stopPropagation(),H(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:xt/2-6},title:`Output port`,onClick:t=>{t.stopPropagation(),T?H(e.id):(E(!0),O(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:bt/2-6,top:-6},title:`Port`,onClick:t=>{t.stopPropagation(),H(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:bt/2-6,bottom:-6},title:`Port`,onClick:t=>{t.stopPropagation(),H(e.id)}})]}),!s&&t&&!T&&(0,q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),z(e.id)},className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,"aria-label":`Delete node`,children:(0,q.jsx)(V,{className:`h-3 w-3`})})]},e.id)}),a&&f.length>0&&(0,q.jsx)(lt,{items:ve,canvasWidth:i.width??1400,canvasHeight:i.height??800,position:`bottom-right`})]})}),j&&!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)(ot,{title:U?`Properties: ${U.label}`:`Properties`,fields:W,onChange:ge})})]})]})}function Y(...e){return W(R(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`},wt={A4:{width:595,height:842},A3:{width:842,height:1191},Letter:{width:612,height:792},Legal:{width:612,height:1008},Tabloid:{width:792,height:1224}},Tt=[{type:`header`,height:80,elements:[]},{type:`detail`,height:400,elements:[],repeat:!0},{type:`footer`,height:60,elements:[]}];function Et({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=Qe(a.length>0?a:Tt),f=d.current,p=(0,K.useCallback)(e=>{d.push(e),l?.(e)},[d,l]),g=et(),_=(0,K.useMemo)(()=>{let e=Array.from(g.selectedIds);return e.length>0?e[0]:null},[g.selectedIds]),v=tt(),x=$e(),S=dt(),C=(0,K.useCallback)(e=>{S&&S.sendOperation({...e,userId:S.currentUserId??``})},[S]),[w,T]=(0,K.useState)(!0),E=(0,K.useRef)(null),D=(0,K.useRef)(null),k=wt[n],A=r===`landscape`?k.height:k.width,j=r===`landscape`?k.width:k.height,M=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}},N=(0,K.useMemo)(()=>_?f.flatMap(e=>e.elements).find(e=>e.id===_):null,[_,f]),P=(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)),g.selectOne(n.id),C({type:`insert`,elementId:n.id,data:{element:n}})},[f,i.left,c,p,g,C]),ee=(0,K.useCallback)(e=>{c||(p(f.map(t=>({...t,elements:t.elements.filter(t=>t.id!==e)}))),g.isSelected(e)&&g.clearSelection(),C({type:`delete`,elementId:e,data:{}}))},[f,c,p,g,C]),F=(0,K.useCallback)(async()=>{if(c||g.count===0||!await x.confirm(X.deleteElementsTitle,X.deleteElementMessage(g.count)))return;let e=g.selectedIds;p(f.map(t=>({...t,elements:t.elements.filter(t=>!e.has(t.id))}))),g.clearSelection(),e.forEach(e=>{C({type:`delete`,elementId:e,data:{}})})},[c,g,x,f,p,C]),te=(0,K.useCallback)((e,t)=>{c||!_||(p(f.map(n=>({...n,elements:n.elements.map(n=>n.id===_?e===`x`?{...n,position:{...n.position,x:Number(t)}}:e===`y`?{...n,position:{...n.position,y:Number(t)}}:e===`width`?{...n,position:{...n.position,width:Number(t)}}:e===`height`?{...n,position:{...n.position,height:Number(t)}}:{...n,properties:{...n.properties,[e]:t}}:n)}))),C({type:`update`,elementId:_,data:{[e]:t}}))},[c,_,f,p,C]),ne=(0,K.useCallback)(()=>{let e=g.selectedIds;if(e.size===0)return;let t=f.flatMap(e=>e.elements).filter(t=>e.has(t.id));v.copy(t)},[g,f,v]),I=(0,K.useCallback)(()=>{if(c)return;let e=v.paste();if(!e||e.length===0)return;let t=0,n=e.map(e=>({...e,id:`elem-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...e.position,x:e.position.x+20,y:e.position.y+20}})),r=f.findIndex(e=>e.type===`detail`),i=r>=0?r:0;p(f.map((e,t)=>t===i?{...e,elements:[...e.elements,...n]}:e)),g.selectMany(n.map(e=>e.id)),n.forEach(e=>{C({type:`insert`,elementId:e.id,data:{element:e}})})},[c,v,f,p,g,C]),re=(0,K.useCallback)((e,t,n)=>{c||(E.current={id:t.id,sectionIndex:n,startX:e.clientX,startY:e.clientY},e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id))},[c]),L=(0,K.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),R=(0,K.useCallback)((e,t)=>{e.preventDefault();let n=E.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))}C({type:`move`,elementId:n.id,data:{}}),E.current=null},[c,f,p,C]),ie=(0,K.useMemo)(()=>{if(!N)return[];let e=[{name:`x`,label:X.propX,type:`number`,value:N.position.x,group:X.groupPosition},{name:`y`,label:X.propY,type:`number`,value:N.position.y,group:X.groupPosition},{name:`width`,label:X.propWidth,type:`number`,value:N.position.width,group:X.groupSize},{name:`height`,label:X.propHeight,type:`number`,value:N.position.height,group:X.groupSize}];return N.type===`text`&&e.push({name:`text`,label:X.propText,type:`text`,value:N.properties.text??``,group:X.groupContent}),N.type===`field`&&e.push({name:`field`,label:X.propField,type:`text`,value:N.properties.field??``,group:X.groupContent}),e},[N]);return(0,K.useEffect)(()=>{let e=D.current;if(!e)return;let t=e=>{let t=[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.target.tagName),n=e.ctrlKey||e.metaKey;if((e.key===`Delete`||e.key===`Backspace`)&&g.count>0&&!t){e.preventDefault(),F();return}if(e.key===`Escape`){g.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(),ne();return}if(n&&e.key===`v`&&!c){e.preventDefault(),I();return}if(n&&e.key===`a`){e.preventDefault();let t=f.flatMap(e=>e.elements).map(e=>e.id);g.selectMany(t);return}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g,F,c,d,ne,I,f]),(0,q.jsxs)(`div`,{ref:D,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)(Ce,{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)(Ye,{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)(Fe,{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`,g.count===0&&`opacity-40 pointer-events-none`),title:X.copyShortcut,"aria-label":X.copy,disabled:g.count===0,onClick:ne,children:(0,q.jsx)(qe,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{className:Y(`p-1.5 rounded hover:bg-accent`,!v.hasContent&&`opacity-40 pointer-events-none`),title:X.pasteShortcut,"aria-label":X.paste,disabled:!v.hasContent,onClick:I,children:(0,q.jsx)(h,{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`,g.count===0&&`opacity-40 pointer-events-none`),title:X.deleteSelected,"aria-label":X.deleteSelected,disabled:g.count===0,onClick:F,children:(0,q.jsx)(V,{className:`h-4 w-4`})}),(0,q.jsx)(`div`,{className:`flex-1`}),S?.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,S.users.length>1&&` (${S.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:w?X.collapsePanel:X.expandPanel,"aria-label":w?X.collapsePanel:X.expandPanel,onClick:()=>T(e=>!e),children:(0,q.jsx)(y,{className:Y(`h-4 w-4`,!w&&`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:A,minHeight:j},children:f.map((e,t)=>(0,q.jsxs)(`div`,{className:`relative border-b border-dashed border-gray-300`,style:{minHeight:e.height},onDragOver:L,onDrop:e=>R(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:[M(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:()=>P(t,`text`),className:`p-0.5 rounded hover:bg-accent`,title:X.addText,"aria-label":X.addText,children:(0,q.jsx)(m,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>P(t,`field`),className:`p-0.5 rounded hover:bg-accent`,title:X.addField,"aria-label":X.addField,children:(0,q.jsx)(Ee,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>P(t,`image`),className:`p-0.5 rounded hover:bg-accent`,title:X.addImage,"aria-label":X.addImage,children:(0,q.jsx)(Ie,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>P(t,`chart`),className:`p-0.5 rounded hover:bg-accent`,title:X.addChart,"aria-label":X.addChart,children:(0,q.jsx)(b,{className:`h-3 w-3`})}),(0,q.jsx)(`button`,{onClick:()=>P(t,`table`),className:`p-0.5 rounded hover:bg-accent`,title:X.addTable,"aria-label":X.addTable,children:(0,q.jsx)(O,{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=g.isSelected(e.id);return(0,q.jsxs)(`div`,{draggable:!c,onDragStart:n=>re(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=>g.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(),ee(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)(V,{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`,w?`w-56`:`w-0 overflow-hidden`),children:w&&(_&&N?(0,q.jsx)(ot,{title:`${X.properties} – ${N.type}`,fields:ie,onChange:te}):(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)(it,{isOpen:x.isOpen,title:x.title,message:x.message,onConfirm:x.onConfirm,onCancel:x.onCancel})]})}var Dt={"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 Ot(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=o();return e.t(`appDesigner.basicInfo`)===`appDesigner.basicInfo`?{t:Ot(Dt)}:{t:e.t}}catch{return{t:Ot(Dt)}}}function Q(...e){return W(R(e))}var kt={name:``,title:``,description:``,icon:``,template:``,layout:`sidebar`,objects:[],navigation:[],branding:{logo:``,primaryColor:`#3b82f6`,favicon:``}};function At(e){return e.filter(e=>e.selected).map(e=>({id:e.name,type:`object`,label:e.label,icon:e.icon,objectName:e.name}))}var jt=0;function Mt(e){return jt+=1,`${e}_${Date.now()}_${jt}`}function Nt({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)(De,{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 Pt({draft:e,templates:t,readOnly:n,onChange:r,t:i}){let a=e.name.length>0&&!d(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:v},{value:`header`,labelKey:`appDesigner.layoutHeader`,Icon:g},{value:`empty`,labelKey:`appDesigner.layoutEmpty`,Icon:A}].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 Ft({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)(Ne,{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)(De,{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 It={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 Lt({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)(Se,{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)(ue,{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)(te,{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`,It[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)(_,{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)(p,{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)(V,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function Rt({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)(Ie,{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)(Ae,{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)(Ve,{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 zt({availableObjects:e=[],templates:t=[],initialDraft:n,onComplete:r,onCancel:i,onSaveDraft:a,readOnly:o=!1,className:s}){let{t:c}=Z(),l=$e(),[u,f]=(0,K.useState)(0),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(()=>({...kt,objects:e.map(e=>({...e})),...n})),_=(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]),v=u===0,y=u===_.length-1,b=(0,K.useMemo)(()=>h.name.length>0&&d(h.name)&&h.title.trim().length>0,[h.name,h.title]),S=(0,K.useMemo)(()=>u===0?b:!0,[u,b]),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:Mt(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)(()=>{y||(u===1&&g(e=>({...e,navigation:At(e.objects)})),f(e=>e+1))},[u,y]),j=(0,K.useCallback)(()=>{v||f(e=>e-1)},[v]),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]),ee=(0,K.useCallback)(e=>{e<=u?f(e):e===u+1&&S&&(u===1&&e===2&&g(e=>({...e,navigation:At(e.objects)})),f(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)(x,{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)(Nt,{steps:_,currentIndex:u,onStepClick:ee})}),(0,q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[u===0&&(0,q.jsx)(Pt,{draft:h,templates:t,readOnly:o,onChange:C,t:c}),u===1&&(0,q.jsx)(Ft,{objects:h.objects,readOnly:o,onToggle:T,onToggleAll:E,search:p,onSearchChange:m,t:c}),u===2&&(0,q.jsx)(Lt,{items:h.navigation,readOnly:o,onAdd:D,onRemove:O,onReorder:k,t:c}),u===3&&(0,q.jsx)(Rt,{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:[!v&&(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)(ke,{className:`h-4 w-4`}),c(`common.back`)]}),y?(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)(De,{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)(I,{className:`h-4 w-4`})]})]})]})]})}function Bt(...e){return W(R(e))}var Vt=0;function Ht(e){return Vt+=1,`${e}_${Date.now()}_${Vt}`}var Ut={object:{labelKey:`appDesigner.navTypeObject`,color:`bg-green-100 text-green-700`,Icon:We},dashboard:{labelKey:`appDesigner.navTypeDashboard`,color:`bg-amber-100 text-amber-700`,Icon:pe},page:{labelKey:`appDesigner.navTypePage`,color:`bg-teal-100 text-teal-700`,Icon:Ce},report:{labelKey:`appDesigner.navTypeReport`,color:`bg-rose-100 text-rose-700`,Icon:b},url:{labelKey:`appDesigner.navTypeUrl`,color:`bg-sky-100 text-sky-700`,Icon:ue},group:{labelKey:`appDesigner.navTypeGroup`,color:`bg-purple-100 text-purple-700`,Icon:Se},separator:{labelKey:`appDesigner.navTypeSeparator`,color:`bg-gray-100 text-gray-600`,Icon:te},action:{labelKey:`appDesigner.navTypeAction`,color:`bg-orange-100 text-orange-700`,Icon:Oe}},Wt=[{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 Gt({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:m,expandedIds:h,t:g}){let[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(s(e.label)??``),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(e.icon||``),E=Ut[e.type];e.type===`group`&&e.children&&e.children.length;let D=h.has(e.id),O=e.visible===!1,k=()=>{b.trim()?u(e.id,b.trim()):x(s(e.label)??``),y(!1)},A=()=>{d(e.id,w.trim()),C(!1)};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`li`,{"data-testid":`nav-designer-item-${e.id}`,className:Bt(`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)(ge,{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":g(D?`appDesigner.navCollapseGroup`:`appDesigner.navExpandGroup`),children:D?(0,q.jsx)(p,{className:`h-3.5 w-3.5`}):(0,q.jsx)(I,{className:`h-3.5 w-3.5`})}):(0,q.jsx)(`span`,{className:`w-5`}),S&&!i?(0,q.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),onBlur:A,onKeyDown:t=>{t.key===`Enter`&&A(),t.key===`Escape`&&(T(e.icon||``),C(!1))},autoFocus:!0,placeholder:g(`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)(E.Icon,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}),!i&&e.type!==`separator`&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>{T(e.icon||``),C(!0)},className:`rounded p-0.5 text-gray-300 hover:text-blue-500`,"aria-label":g(`appDesigner.navEditIcon`),"data-testid":`nav-designer-edit-icon-${e.id}`,children:(0,q.jsx)(Ke,{className:`h-2.5 w-2.5`})})]}),e.type===`separator`?(0,q.jsx)(`span`,{className:`flex-1 text-xs italic text-gray-400`,children:g(`appDesigner.separatorLabel`)}):v&&!i?(0,q.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),onBlur:k,onKeyDown:t=>{t.key===`Enter`&&k(),t.key===`Escape`&&(x(s(e.label)??``),y(!1))},autoFocus:!0,className:`flex-1 rounded border border-blue-300 px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-blue-400`}):(0,q.jsx)(`span`,{className:Bt(`flex-1 truncate text-sm text-gray-800`,!i&&`cursor-text`),onDoubleClick:()=>{!i&&e.type!==`separator`&&(x(s(e.label)??``),y(!0))},children:s(e.label)}),(0,q.jsx)(`span`,{className:Bt(`rounded-full px-2 py-0.5 text-[10px] font-medium`,E.color),children:g(E.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:g(`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":g(`appDesigner.navToggleVisible`),"data-testid":`nav-designer-toggle-visible-${e.id}`,children:O?(0,q.jsx)(Pe,{className:`h-3.5 w-3.5`}):(0,q.jsx)(Re,{className:`h-3.5 w-3.5`})}),e.type===`group`&&!i&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>m(e.id,`page`),className:`rounded p-0.5 text-gray-400 hover:text-blue-500`,"aria-label":g(`appDesigner.navAddChild`),"data-testid":`nav-designer-add-child-${e.id}`,children:(0,q.jsx)(Ee,{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":g(`appDesigner.navMoveUp`),children:(0,q.jsx)(_,{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":g(`appDesigner.navMoveDown`),children:(0,q.jsx)(p,{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":g(`appDesigner.navRemove`),"data-testid":`nav-designer-remove-${e.id}`,children:(0,q.jsx)(V,{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)(Gt,{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:m,expandedIds:h,t:g},n.id))})]})}function Kt({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)(qt,{item:e,depth:0},e.id))})]})}function qt({item:e,depth:t}){let n=Ut[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)(qt,{item:e,depth:t+1},e.id))]})}function Jt({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:Ht(r),type:r,label:r===`separator`?``:`New ${s(Ut[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:Ht(n),type:n,label:n===`separator`?``:`New ${s(Ut[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:Bt(`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:[Wt.map(({type:e,labelKey:t})=>{let{Icon:r,color:i}=Ut[e];return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`nav-designer-add-${e}`,onClick:()=>_(e),disabled:n,className:Bt(`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)(Ee,{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)(Te,{className:`h-3 w-3`}),s(`appDesigner.navExportSchema`)]}),(0,q.jsxs)(`label`,{"data-testid":`nav-designer-import`,className:Bt(`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)(B,{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)(Gt,{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)(Kt,{items:e,t:s})]})}function Yt(...e){return W(R(e))}var Xt=[{type:`metric`,label:`KPI Metric`,Icon:w},{type:`bar`,label:`Bar Chart`,Icon:b},{type:`line`,label:`Line Chart`,Icon:L},{type:`pie`,label:`Pie Chart`,Icon:N},{type:`table`,label:`Table`,Icon:O},{type:`grid`,label:`Grid`,Icon:D}],Zt=0;function Qt(){return Zt+=1,`widget_${Date.now()}_${Zt}`}function $t({widget:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=e.type||`metric`,u=Xt.find(e=>e.type===l)||Xt[0];return(0,q.jsxs)(`div`,{"data-testid":`dashboard-widget-${e.id}`,onClick:a,className:Yt(`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)(ge,{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)(_,{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)(p,{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)(V,{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 en({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)(x,{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:Xt.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 tn({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=Xt.find(t=>t.type===(e.type||`metric`))||Xt[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 nn({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}=Qe(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=Qt(),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,_]),O=(0,K.useCallback)(e=>{w({...v,widgets:T.filter(t=>t.id!==e)}),g===e&&_(null)},[v,T,g,w,_]),k=(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]),A=(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(),O(g)}}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[n,S,C,g,O]);let j=(0,K.useCallback)(()=>{i&&i(v)},[v,i]),M=(0,K.useCallback)(()=>{m.current?.click()},[]),N=(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:Yt(`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:N}),E&&!d&&(0,q.jsx)(en,{widget:E,readOnly:n,onChange:A,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`),`:`]}),Xt.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)(Ye,{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)(Fe,{className:`h-4 w-4`})})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-export`,onClick:j,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navExportSchema`),children:(0,q.jsx)(Te,{className:`h-4 w-4`})}),!n&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-import`,onClick:M,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":c(`appDesigner.navImportSchema`),children:(0,q.jsx)(B,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`dashboard-preview-toggle`,onClick:()=>f(e=>!e),className:Yt(`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)(Pe,{className:`h-4 w-4`}):(0,q.jsx)(Re,{className:`h-4 w-4`})})]})]}),d?(0,q.jsx)(tn,{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)($t,{widget:e,index:t,total:T.length,selected:e.id===g,readOnly:n,onSelect:()=>_(e.id??null),onRemove:()=>O(e.id),onMoveUp:()=>k(e.id,`up`),onMoveDown:()=>k(e.id,`down`)},e.id))})]})]})}function rn(...e){return W(R(e))}var an=[{type:`grid`,label:`Data Grid`,Icon:O},{type:`kanban`,label:`Kanban Board`,Icon:f},{type:`calendar`,label:`Calendar`,Icon:j},{type:`gallery`,label:`Gallery`,Icon:Me},{type:`dashboard`,label:`Dashboard`,Icon:b},{type:`form`,label:`Form`,Icon:Ce},{type:`layout-grid`,label:`Grid Layout`,Icon:D}],on=[{value:`page`,labelKey:`appDesigner.modePage`},{value:`dashboard`,labelKey:`appDesigner.modeDashboard`}],sn=0;function cn(){return sn+=1,`component_${Date.now()}_${sn}`}function ln({component:e,index:t,total:n,selected:r,readOnly:i,onSelect:a,onRemove:o,onMoveUp:s,onMoveDown:c}){let l=an.find(t=>t.type===e.type)||an[0];return(0,q.jsxs)(`div`,{"data-testid":`canvas-component-${e.id}`,onClick:a,className:rn(`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)(ge,{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)(_,{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)(p,{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)(V,{className:`h-3.5 w-3.5`})})]})]})}function un({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)(x,{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:an.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 dn({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=an.find(t=>t.type===e.type)||an[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 fn({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}=Qe(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=cn(),n={id:t,type:e,label:an.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 O=(0,K.useCallback)(()=>{i&&i(e)},[e,i]),k=(0,K.useCallback)(()=>{c.current?.click()},[]),A=(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:rn(`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:A}),(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:on.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:rn(`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`),`:`]}),an.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)(Ye,{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)(Fe,{className:`h-4 w-4`})})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-export`,onClick:O,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navExportSchema`),children:(0,q.jsx)(Te,{className:`h-4 w-4`})}),!n&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-import`,onClick:k,className:`rounded p-1.5 text-gray-400 hover:text-gray-700`,"aria-label":o(`appDesigner.navImportSchema`),children:(0,q.jsx)(B,{className:`h-4 w-4`})}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`canvas-preview-toggle`,onClick:()=>m(e=>!e),className:rn(`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)(Pe,{className:`h-4 w-4`}):(0,q.jsx)(Re,{className:`h-4 w-4`})})]})]}),p?(0,q.jsx)(dn,{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)(ln,{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)(un,{component:_,readOnly:n,onChange:D,onClose:()=>f(null)})]})}function pn(...e){return W(R(e))}var mn={grid:{label:`Grid`,Icon:D},kanban:{label:`Kanban`,Icon:f},calendar:{label:`Calendar`,Icon:j},gallery:{label:`Gallery`,Icon:Me},timeline:{label:`Timeline`,Icon:ae},map:{label:`Map`,Icon:z},gantt:{label:`Gantt`,Icon:F}},hn=[{value:`compact`,label:`Compact`},{value:`medium`,label:`Medium`},{value:`tall`,label:`Tall`}];function gn({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)(_,{className:`h-3.5 w-3.5 text-gray-400`}):(0,q.jsx)(p,{className:`h-3.5 w-3.5 text-gray-400`})]}),i&&(0,q.jsx)(`div`,{className:`space-y-2`,children:r})]})}function _n({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:pn(`w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4`,i),children:[(0,q.jsx)(gn,{title:`View Type`,icon:(0,q.jsx)(D,{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}=mn[t];return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`view-type-${t}`,onClick:()=>a({viewType:t}),disabled:r,className:pn(`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)(gn,{title:`Fields (${c}/${e.columns.length})`,icon:(0,q.jsx)(_e,{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:pn(`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)(Re,{className:`h-3 w-3`}):(0,q.jsx)(Pe,{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)(_,{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)(p,{className:`h-3 w-3`})})]},t.name))})}),(0,q.jsx)(gn,{title:`Toolbar`,icon:(0,q.jsx)(Ue,{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)(gn,{title:`Appearance`,icon:(0,q.jsx)(He,{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:hn.map(({value:t,label:n})=>(0,q.jsx)(`button`,{type:`button`,"data-testid":`view-row-height-${t}`,onClick:()=>a({rowHeight:t}),disabled:r,className:pn(`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 W(R(e))}var vn=[{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`}],yn=[`Inter`,`Roboto`,`Open Sans`,`Lato`,`Montserrat`,`Poppins`,`Source Sans Pro`,`Noto Sans`,`system-ui`];function bn({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:h,redo:g}=Qe(e),_=(0,K.useRef)(!0);(0,K.useEffect)(()=>{if(_.current){_.current=!1;return}t(u)},[u]);let v=(0,K.useCallback)(e=>{let n={...u,...e};_.current=!0,d(n),t(n)},[u,d,t]),y=(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]),b=(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]),x=(0,K.useCallback)(e=>{r||((e.ctrlKey||e.metaKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?g():h()),(e.ctrlKey||e.metaKey)&&e.key===`y`&&(e.preventDefault(),g()))},[r,h,g]),S=u.primaryColor||`#3b82f6`,C=c===`dark`;return(0,q.jsxs)(`div`,{"data-testid":`branding-editor`,className:$(`flex flex-col gap-4 sm:gap-6`,i),onKeyDown:x,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:h,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)(Ye,{className:`h-3.5 w-3.5`}),s(`appDesigner.undo`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-redo`,type:`button`,onClick:g,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)(Fe,{className:`h-3.5 w-3.5`}),s(`appDesigner.redo`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-export`,type:`button`,onClick:y,className:`inline-flex items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50`,title:s(`appDesigner.brandingExport`),children:[(0,q.jsx)(Te,{className:`h-3.5 w-3.5`}),s(`appDesigner.brandingExport`)]}),(0,q.jsxs)(`button`,{"data-testid":`branding-import`,type:`button`,onClick:b,disabled:r,className:$(`inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors`,r?`border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed`:`border-gray-300 bg-white text-gray-700 hover:bg-gray-50`),title:s(`appDesigner.brandingImport`),children:[(0,q.jsx)(B,{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)(Ie,{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=>v({logo:e.target.value}),placeholder:`https://example.com/logo.svg`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,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)(Ae,{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=>v({primaryColor:e.target.value}),placeholder:`#3b82f6`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]}),(0,q.jsx)(`input`,{"data-testid":`branding-color-picker`,type:`color`,value:S,onChange:e=>v({primaryColor:e.target.value}),disabled:r,className:`h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed`})]}),(0,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:vn.map(e=>(0,q.jsx)(`button`,{"data-testid":`branding-swatch-${e.hex.slice(1)}`,type:`button`,onClick:()=>!r&&v({primaryColor:e.hex}),disabled:r,className:$(`h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed`,S===e.hex?`border-gray-800 ring-2 ring-offset-1 ring-gray-400`:`border-transparent`),style:{backgroundColor:e.hex},title:e.name},e.hex))})]})]}),(0,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)(Ve,{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=>v({favicon:e.target.value}),placeholder:`https://example.com/favicon.ico`,disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50`})]})]}),(0,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)(m,{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=>v({fontFamily:e.target.value||void 0}),disabled:r,className:`block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none`,children:[(0,q.jsx)(`option`,{value:``,children:s(`appDesigner.fontDefault`)}),yn.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)(U,{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)(P,{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`,C?`border-gray-700 bg-gray-900 text-gray-100`:`border-gray-200 bg-white text-gray-800`),style:{fontFamily:u.fontFamily||`inherit`},children:[(0,q.jsx)(`div`,{className:`rounded-md p-3 mb-3`,style:{backgroundColor:S},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:S}}),(0,q.jsx)(`span`,{className:$(`text-xs`,C?`text-gray-400`:`text-gray-500`),children:S})]}),(0,q.jsx)(`button`,{type:`button`,className:`rounded-md px-3 py-1.5 text-xs font-medium text-white transition-colors`,style:{backgroundColor:S},tabIndex:-1,children:s(`appDesigner.brandingSampleButton`)}),(0,q.jsx)(`p`,{className:$(`text-xs`,C?`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`,C?`text-gray-400`:`text-gray-500`),children:`Favicon`})]}),u.fontFamily&&(0,q.jsxs)(`div`,{className:$(`text-xs`,C?`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`,C?`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:S},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`,C?`bg-gray-700`:`bg-gray-200`)}),(0,q.jsx)(`div`,{className:$(`h-2 w-1/2 rounded`,C?`bg-gray-700`:`bg-gray-200`)}),(0,q.jsx)(`div`,{className:$(`h-2 w-2/3 rounded`,C?`bg-gray-700`:`bg-gray-200`)})]})]})]})]})]})}function xn(...e){return W(R(e))}var Sn=[`Custom Objects`,`System Objects`,`Integration`,`Analytics`],Cn=[`Box`,`Database`,`Users`,`FileText`,`Settings`,`ShoppingCart`,`Calendar`,`Mail`,`Briefcase`,`Building`,`Globe`,`Heart`,`Star`,`Tag`,`Bookmark`,`Folder`,`Archive`,`Package`,`Truck`,`CreditCard`];function wn({objects:e,onObjectsChange:t,onSelectObject:r,showSystemObjects:i=!0,readOnly:a=!1,className:o}){let{t:s}=Z(),c=$e(),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(null),p=(0,K.useMemo)(()=>i?e:e.filter(e=>!e.isSystem),[e,i]),m=(0,K.useMemo)(()=>new n({items:p}),[p]),h=(0,K.useMemo)(()=>[{field:`name`,label:s(`appDesigner.objectManager.objectName`),width:160},{field:`label`,label:s(`appDesigner.objectManager.objectLabel`),width:160},{field:`group`,label:s(`appDesigner.objectManager.group`),width:130},{field:`fieldCount`,label:`Fields`,width:80},{field:`enabled`,label:s(`appDesigner.objectManager.enabled`),width:80}],[s]),g=(0,K.useMemo)(()=>({type:`object-grid`,objectName:`object_definition`,columns:h,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:a?void 0:{create:!0,update:!0,delete:!0}}),[h,a]),_=(0,K.useCallback)(t=>{let n=e.find(e=>e.name===t.name);n&&r?.(n)},[e,r]),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 c.confirm(s(`appDesigner.objectManager.deleteConfirmTitle`),s(`appDesigner.objectManager.deleteConfirmMessage`))&&t?.(e.filter(e=>e.id!==r.id))},[e,t,c,s]),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?`${s(`common.edit`)} — ${d.label}`:s(`appDesigner.objectManager.addObject`),open:l,onOpenChange:S,modalSize:`lg`,customFields:[{name:`name`,label:s(`appDesigner.objectManager.objectName`),type:`text`,required:!0,placeholder:`api_name`,disabled:a||(d?.isSystem??!1)},{name:`label`,label:s(`appDesigner.objectManager.objectLabel`),type:`text`,required:!0,placeholder:`Display Name`,disabled:a},{name:`pluralLabel`,label:s(`appDesigner.objectManager.pluralLabel`),type:`text`,placeholder:`Display Names`,disabled:a},{name:`description`,label:s(`appDesigner.appDescription`),type:`textarea`,disabled:a},{name:`icon`,label:s(`appDesigner.objectManager.icon`),type:`select`,options:Cn.map(e=>({label:e,value:e})),disabled:a},{name:`group`,label:s(`appDesigner.objectManager.group`),type:`select`,options:Sn.map(e=>({label:e,value:e})),disabled:a},{name:`sortOrder`,label:s(`appDesigner.objectManager.sortOrder`),type:`number`,disabled:a},{name:`enabled`,label:s(`appDesigner.objectManager.enabled`),type:`boolean`,disabled:a}],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:a}),[d,l,S,x,a,s]);return(0,q.jsxs)(`div`,{"data-testid":`object-manager`,className:xn(`w-full space-y-3`,o),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)(We,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`h2`,{className:`text-sm font-semibold`,children:s(`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)(xe,{schema:g,dataSource:m,onRowClick:_,onEdit:a?void 0:v,onDelete:a?void 0:y,onAddRecord:a?void 0:b}),l&&(0,q.jsx)(ye,{schema:C}),(0,q.jsx)(it,{isOpen:c.isOpen,title:c.title,message:c.message,confirmLabel:s(`common.delete`),cancelLabel:s(`common.cancel`),onConfirm:c.onConfirm,onCancel:c.onCancel,destructive:!0})]})}function Tn(...e){return W(R(e))}var En={text:{label:`Text`,Icon:m},textarea:{label:`Text Area`,Icon:Ce},number:{label:`Number`,Icon:ze},boolean:{label:`Checkbox`,Icon:C},date:{label:`Date`,Icon:T},datetime:{label:`Date/Time`,Icon:T},time:{label:`Time`,Icon:T},select:{label:`Picklist`,Icon:se},email:{label:`Email`,Icon:ce},phone:{label:`Phone`,Icon:ve},url:{label:`URL`,Icon:Ve},password:{label:`Password`,Icon:H},currency:{label:`Currency`,Icon:ze},percent:{label:`Percent`,Icon:ze},lookup:{label:`Lookup`,Icon:S},formula:{label:`Formula`,Icon:Ge},autonumber:{label:`Auto Number`,Icon:ze},file:{label:`File`,Icon:Ce},image:{label:`Image`,Icon:Ie},markdown:{label:`Markdown`,Icon:Ce},html:{label:`Rich Text`,Icon:Ce},color:{label:`Color`,Icon:Ae},code:{label:`Code`,Icon:Ge},location:{label:`Location`,Icon:Je},address:{label:`Address`,Icon:Je},rating:{label:`Rating`,Icon:fe},slider:{label:`Slider`,Icon:Be}},Dn={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`]},On=[`text`,`number`,`date`,`choice`,`relation`,`advanced`];function kn({objectName:e,fields:t,onFieldsChange:r,readOnly:i=!1,className:a}){let{t:o}=Z(),s=$e(),[c,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 n({items:m}),[m]),g=(0,K.useMemo)(()=>[{field:`name`,label:o(`appDesigner.fieldDesigner.fieldName`),width:140},{field:`label`,label:o(`appDesigner.fieldDesigner.fieldLabel`),width:160},{field:`type`,label:o(`appDesigner.fieldDesigner.fieldType`),width:100},{field:`required`,label:o(`appDesigner.fieldDesigner.required`),width:80},{field:`unique`,label:o(`appDesigner.fieldDesigner.unique`),width:80},{field:`group`,label:o(`appDesigner.fieldDesigner.fieldGroup`),width:120}],[o]),_=(0,K.useMemo)(()=>({type:`object-grid`,objectName:`field_definition`,columns:g,searchableFields:[`name`,`label`,`description`],showSearch:!0,operations:i?void 0:{create:!0,update:!0,delete:!0}}),[g,i]),v=(0,K.useCallback)(e=>{let n=t.find(t=>t.name===e.name);n&&(d(n),l(!0))},[t]),y=(0,K.useCallback)(async e=>{let n=t.find(t=>t.name===e.name);!n||n.isSystem||await s.confirm(o(`appDesigner.fieldDesigner.deleteConfirmTitle`),o(`appDesigner.fieldDesigner.deleteConfirmMessage`))&&r?.(t.filter(e=>e.id!==n.id))},[t,r,s,o]),b=(0,K.useCallback)(()=>{d(null),l(!0)},[]),x=(0,K.useCallback)(e=>{if(u){let n={...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};r?.(t.map(e=>e.id===u.id?n:e))}else{let n={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};r?.([...t,n])}l(!1),d(null)},[u,t,r]),S=(0,K.useCallback)(e=>{e||(l(!1),d(null))},[]),C=(0,K.useMemo)(()=>On.map(e=>({category:e,label:o(`appDesigner.fieldDesigner.typeCategory.${e}`),options:Dn[e].map(e=>({label:En[e].label,value:e}))})),[o]),w=(0,K.useMemo)(()=>C.flatMap(e=>e.options),[C]),T=(0,K.useMemo)(()=>({type:`object-form`,formType:`drawer`,objectName:`field_definition`,mode:u?`edit`:`create`,title:u?`${o(`common.edit`)} — ${u.label}`:o(`appDesigner.fieldDesigner.addField`),open:c,onOpenChange:S,drawerSide:`right`,drawerWidth:`480px`,sections:[{name:`basic`,label:o(`appDesigner.fieldDesigner.basicSection`),fields:[{name:`name`,label:o(`appDesigner.fieldDesigner.fieldName`),type:`text`,required:!0,placeholder:`api_name`,disabled:i||(u?.isSystem??!1)},{name:`label`,label:o(`appDesigner.fieldDesigner.fieldLabel`),type:`text`,required:!0,placeholder:`Display Label`,disabled:i},{name:`type`,label:o(`appDesigner.fieldDesigner.fieldType`),type:`select`,required:!0,options:w,disabled:i||(u?.isSystem??!1)},{name:`required`,label:o(`appDesigner.fieldDesigner.required`),type:`boolean`,disabled:i},{name:`unique`,label:o(`appDesigner.fieldDesigner.unique`),type:`boolean`,disabled:i},{name:`description`,label:o(`appDesigner.fieldDesigner.description`),type:`textarea`,disabled:i}]},{name:`typeSpecific`,label:o(`appDesigner.fieldDesigner.typeSpecificSection`),fields:[{name:`referenceTo`,label:o(`appDesigner.fieldDesigner.referenceTo`),type:`text`,placeholder:`Referenced object`,disabled:i,condition:{field:`type`,equals:`lookup`}},{name:`formula`,label:o(`appDesigner.fieldDesigner.formula`),type:`textarea`,placeholder:`e.g. price * quantity`,disabled:i,condition:{field:`type`,equals:`formula`}},{name:`defaultValue`,label:o(`appDesigner.fieldDesigner.defaultValue`),type:`text`,placeholder:`Default value`,disabled:i},{name:`placeholder`,label:o(`appDesigner.fieldDesigner.placeholder`),type:`text`,placeholder:`Placeholder text`,disabled:i},{name:`group`,label:o(`appDesigner.fieldDesigner.fieldGroup`),type:`text`,placeholder:`Field Group`,disabled:i}]},{name:`advanced`,label:o(`appDesigner.fieldDesigner.advancedSection`),collapsible:!0,collapsed:!0,fields:[{name:`indexed`,label:o(`appDesigner.fieldDesigner.indexed`),type:`boolean`,disabled:i},{name:`externalId`,label:o(`appDesigner.fieldDesigner.externalId`),type:`boolean`,disabled:i},{name:`trackHistory`,label:o(`appDesigner.fieldDesigner.trackHistory`),type:`boolean`,disabled:i},{name:`readonly`,label:o(`appDesigner.fieldDesigner.readOnly`),type:`boolean`,disabled:i},{name:`hidden`,label:o(`appDesigner.fieldDesigner.hidden`),type:`boolean`,disabled:i}]}],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:x,onCancel:()=>S(!1),readOnly:i}),[u,c,S,x,w,i,o]);return(0,q.jsxs)(`div`,{"data-testid":`field-designer`,className:Tn(`w-full space-y-3`,a),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)(_e,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`h2`,{className:`text-sm font-semibold`,children:o(`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:o(`appDesigner.fieldDesigner.allTypes`)}),C.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)(xe,{schema:_,dataSource:h,onEdit:i?void 0:v,onDelete:i?void 0:y,onAddRecord:i?void 0:b}),c&&(0,q.jsx)(je,{schema:T}),(0,q.jsx)(it,{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})]})}var An=`objectui-app-wizard-draft`;function jn(){let e=Xe(),{appName:t}=Ze(),{objects:n,refresh:r}=c(),i=u(),a=(n||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:!1})),o=(0,K.useCallback)(()=>{try{let e=localStorage.getItem(An);if(e)return JSON.parse(e)}catch{}},[]),s=(0,K.useCallback)(async t=>{try{let n=l(t),a=i?.getClient();a&&await a.meta.saveItem(`app`,t.name,n),localStorage.removeItem(An),G.success(`Application "${t.title}" created successfully`),await r?.(),e(`/apps/${t.name}`)}catch(e){G.error(e?.message||`Failed to create application`)}},[e,r,i]),d=(0,K.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),f=(0,K.useCallback)(e=>{try{localStorage.setItem(An,JSON.stringify(e)),G.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)(zt,{availableObjects:a,initialDraft:o(),onComplete:s,onCancel:d,onSaveDraft:f})})}function Mn(){let e=Xe(),{appName:t,editAppName:n}=Ze(),{apps:r,objects:i,refresh:a}=c(),o=u(),s=n||t,d=r.find(e=>e.name===s),f=(i||[]).map(e=>({name:e.name,label:e.label||e.name,icon:e.icon,selected:d?.navigation?.some(t=>t.type===`object`&&t.objectName===e.name)??!1})),p=(0,K.useMemo)(()=>{if(d)return{name:d.name,title:d.title||d.label||``,description:d.description||``,icon:d.icon||``,layout:d.layout||`sidebar`,navigation:d.navigation||[],branding:{logo:d.branding?.logo||d.logo||``,primaryColor:d.branding?.primaryColor||`#3b82f6`,favicon:d.branding?.favicon||d.favicon||``}}},[d]),m=(0,K.useCallback)(async t=>{try{let n=l(t),r={...d,...n},i=o?.getClient();i&&await i.meta.saveItem(`app`,t.name,r),G.success(`Application "${t.title}" updated successfully`),await a?.(),e(`/apps/${t.name}`)}catch(e){G.error(e?.message||`Failed to update application`)}},[e,a,o,d]),h=(0,K.useCallback)(()=>{e(t?`/apps/${t}`:`/`)},[e,t]),g=(0,K.useCallback)(e=>{try{localStorage.setItem(`objectui-edit-draft-${s}`,JSON.stringify(e)),G.info(`Draft saved`)}catch{}},[s]);return d?(0,q.jsx)(`div`,{className:`mx-auto max-w-4xl py-8 px-4`,"data-testid":`edit-app-page`,children:(0,q.jsx)(zt,{availableObjects:f,initialDraft:p,onComplete:m,onCancel:h,onSaveDraft:g})}):(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 "`,s,`" not found.`]})})}function Nn(){let e=Xe(),{pageName:t}=Ze(),n=u(),{pages:r}=c(),i=r?.find(e=>e.name===t),[a,o]=(0,K.useState)(()=>i||{type:`page`,name:t??``,title:t??``,children:[]}),s=(0,K.useRef)(a);s.current=a;let l=(0,K.useCallback)(async e=>{try{if(n)return await n.update(`sys_page`,t,e),!0}catch{}return!1},[n,t]),d=(0,K.useCallback)(async e=>{o(e),await l(e)},[l]);(0,K.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),l(s.current).then(e=>{e&&G.success(`Page saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]);let f=(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),G.success(`Page schema exported`)},[t]),p=(0,K.useCallback)(e=>{G.success(`Page schema imported`),d(e)},[d]);return i?(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)(k,{className:`h-4 w-4`})}),(0,q.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Page: `,i.label||i.title||t]})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,q.jsx)(fn,{schema:a,onChange:d,onExport:f,onImport:p})})]}):(0,q.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Page "`,t,`" not found`]})}function Pn(){let e=Xe(),{dashboardName:t}=Ze(),n=u(),{dashboards:r,refresh:i}=c(),a=r?.find(e=>e.name===t),[o,s]=(0,K.useState)(()=>a||{type:`dashboard`,name:t??``,title:t??``,columns:2,widgets:[]}),l=(0,K.useRef)(o);l.current=o;let d=(0,K.useCallback)(async e=>{try{if(n)return await n.update(`sys_dashboard`,t,e),i().catch(()=>{}),!0}catch{}return!1},[n,t,i]),f=(0,K.useCallback)(async e=>{s(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&&G.success(`Dashboard saved`)}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d]);let p=(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),G.success(`Dashboard schema exported`)},[t]),m=(0,K.useCallback)(e=>{G.success(`Dashboard schema imported`),f(e)},[f]);return a?(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)(k,{className:`h-4 w-4`})}),(0,q.jsxs)(`h1`,{className:`text-lg font-semibold tracking-tight truncate`,children:[`Edit Dashboard: `,a.label||a.title||t]})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,q.jsx)(nn,{schema:o,onChange:f,onExport:p,onImport:m})})]}):(0,q.jsxs)(`div`,{className:`h-full flex items-center justify-center text-muted-foreground`,children:[`Dashboard "`,t,`" not found`]})}var Fn=e({AppCreationWizard:()=>zt,BrandingEditor:()=>bn,CreateAppPage:()=>jn,DashboardDesignPage:()=>Pn,DashboardEditor:()=>nn,DataModelDesigner:()=>vt,EditAppPage:()=>Mn,FieldDesigner:()=>kn,NavigationDesigner:()=>Jt,ObjectManager:()=>wn,ObjectViewConfigurator:()=>_n,PageCanvasEditor:()=>fn,PageDesignPage:()=>Nn,PageDesigner:()=>ft,ProcessDesigner:()=>Ct,ReportDesigner:()=>Et});r.register(`page-designer`,ft,{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}]}),r.register(`data-model-designer`,vt,{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}]}),r.register(`process-designer`,Ct,{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}]}),r.register(`report-designer`,Et,{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}]}),r.register(`app-creation-wizard`,zt,{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}]}),r.register(`navigation-designer`,Jt,{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}]}),r.register(`dashboard-editor`,nn,{label:`Dashboard Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Dashboard Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),r.register(`page-canvas-editor`,fn,{label:`Page Canvas Editor`,category:`Designer`,inputs:[{name:`schema`,type:`code`,label:`Page Schema`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),r.register(`object-view-configurator`,_n,{label:`Object View Configurator`,category:`Designer`,inputs:[{name:`config`,type:`code`,label:`View Config`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}]}),r.register(`branding-editor`,bn,{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}]}),r.register(`object-manager`,wn,{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}]}),r.register(`field-designer`,kn,{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{kn as n,wn as r,Fn as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n}from"./framework-BW6KsEI0.js";import{$ as r,$t as i,Ar as a,Ft as o,It as s,Lt as c,Mn as l,Mt as u,Nn as d,Nt as f,Oa as p,Pt as m,Q as h,Rt as g,Xr as _,Ya as v,Z as y,aa as b,ct as x,et as S,fa as C,it as w,jn as T,jt as E,lt as D,mr as O,ot as ee,rt as te,tt as k,ut as ne,vi as re,yi as A,zt as j}from"./plugins-core-Ccvbi6db.js";import{C as ie}from"./data-adapter-v22lWuhc.js";var M=e(n(),1),ae=`popstate`;function oe(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function se(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return ue(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:F(t)}return de(t,n,null,e)}function N(e,t){if(e===!1||e==null)throw Error(t)}function P(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function ce(){return Math.random().toString(36).substring(2,10)}function le(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ue(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?I(t):t,state:n,key:t&&t.key||r||ce(),unstable_mask:i}}function F({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function I(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function de(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=oe(e)?e:ue(h.location,e,t);n&&n(r,e),l=u()+1;let d=le(r,l),f=h.createHref(r.unstable_mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=oe(e)?e:ue(h.location,e,t);n&&n(r,e),l=u();let i=le(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return fe(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(ae,d),c=e,()=>{i.removeEventListener(ae,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function fe(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),N(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:F(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function pe(e,t,n=`/`){return me(e,t,n,!1)}function me(e,t,n,r){let i=R((typeof t==`string`?I(t):t).pathname||`/`,n);if(i==null)return null;let a=ge(e);ve(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Ae(i);o=Oe(a[e],t,r)}return o}function he(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function ge(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;N(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=B([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(N(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ge(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Ee(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of _e(e.path))a(e,t,!0,n)}),t}function _e(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=_e(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ve(e){e.sort((e,t)=>e.score===t.score?De(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ye=/^:[\w-]+$/,be=3,xe=2,Se=1,Ce=10,we=-2,Te=e=>e===`*`;function Ee(e,t){let n=e.split(`/`),r=n.length;return n.some(Te)&&(r+=we),t&&(r+=xe),n.filter(e=>!Te(e)).reduce((e,t)=>e+(ye.test(t)?be:t===``?Se:Ce),r)}function De(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Oe(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=L({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=L({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:B([a,u.pathname]),pathnameBase:ze(B([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=B([a,u.pathnameBase]))}return o}function L(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ke(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ke(e,t=!1,n=!0){P(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Ae(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return P(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function R(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var je=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Me(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?I(e):e,a;return n?(n=Le(n),a=n.startsWith(`/`)?Ne(n.substring(1),`/`):Ne(n,t)):a=t,{pathname:a,search:Be(r),hash:Ve(i)}}function Ne(e,t){let n=Re(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Pe(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Fe(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ie(e){let t=Fe(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function z(e,t,n,r=!1){let i;typeof e==`string`?i=I(e):(i={...e},N(!i.pathname||!i.pathname.includes(`?`),Pe(`?`,`pathname`,`search`,i)),N(!i.pathname||!i.pathname.includes(`#`),Pe(`#`,`pathname`,`hash`,i)),N(!i.search||!i.search.includes(`#`),Pe(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Me(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Le=e=>e.replace(/\/\/+/g,`/`),B=e=>Le(e.join(`/`)),Re=e=>e.replace(/\/+$/,``),ze=e=>Re(e).replace(/^\/*/,`/`),Be=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ve=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,He=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ue(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function We(e){return B(e.map(e=>e.route.path).filter(Boolean))||`/`}var Ge=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ke(e,t){let n=e;if(typeof n!=`string`||!je.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Ge)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=R(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{P(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var qe=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(qe);var Je=[`GET`,...qe];new Set(Je);var V=M.createContext(null);V.displayName=`DataRouter`;var H=M.createContext(null);H.displayName=`DataRouterState`;var Ye=M.createContext(!1);function Xe(){return M.useContext(Ye)}var Ze=M.createContext({isTransitioning:!1});Ze.displayName=`ViewTransition`;var Qe=M.createContext(new Map);Qe.displayName=`Fetchers`;var $e=M.createContext(null);$e.displayName=`Await`;var U=M.createContext(null);U.displayName=`Navigation`;var W=M.createContext(null);W.displayName=`Location`;var G=M.createContext({outlet:null,matches:[],isDataRoute:!1});G.displayName=`Route`;var et=M.createContext(null);et.displayName=`RouteError`;var tt=`REACT_ROUTER_ERROR`,nt=`REDIRECT`,rt=`ROUTE_ERROR_RESPONSE`;function it(e){if(e.startsWith(`${tt}:${nt}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function at(e){if(e.startsWith(`${tt}:${rt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new He(t.status,t.statusText,t.data)}catch{}}function ot(e,{relative:t}={}){N(K(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=M.useContext(U),{hash:i,pathname:a,search:o}=J(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:B([n,a])),r.createHref({pathname:s,search:o,hash:i})}function K(){return M.useContext(W)!=null}function q(){return N(K(),`useLocation() may be used only in the context of a <Router> component.`),M.useContext(W).location}var st=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function ct(e){M.useContext(U).static||M.useLayoutEffect(e)}function lt(){let{isDataRoute:e}=M.useContext(G);return e?Nt():ut()}function ut(){N(K(),`useNavigate() may be used only in the context of a <Router> component.`);let e=M.useContext(V),{basename:t,navigator:n}=M.useContext(U),{matches:r}=M.useContext(G),{pathname:i}=q(),a=JSON.stringify(Ie(r)),o=M.useRef(!1);return ct(()=>{o.current=!0}),M.useCallback((r,s={})=>{if(P(o.current,st),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=z(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:B([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var dt=M.createContext(null);function ft(){return M.useContext(dt)}function pt(e){let t=M.useContext(G).outlet;return M.useMemo(()=>t&&M.createElement(dt.Provider,{value:e},t),[t,e])}function mt(){let{matches:e}=M.useContext(G);return e[e.length-1]?.params??{}}function J(e,{relative:t}={}){let{matches:n}=M.useContext(G),{pathname:r}=q(),i=JSON.stringify(Ie(n));return M.useMemo(()=>z(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function ht(e,t){return gt(e,t)}function gt(e,t,n){N(K(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=M.useContext(U),{matches:i}=M.useContext(G),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Ft(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
2
|
+
|
|
3
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=q(),d;if(t){let e=typeof t==`string`?I(t):t;N(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=pe(e,{pathname:p});P(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),P(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=Ct(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:B([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:B([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?M.createElement(W.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...d},navigationType:`POP`}},h):h}function _t(){let e=Mt(),t=Ue(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=M.createElement(M.Fragment,null,M.createElement(`p`,null,`💿 Hey developer 👋`),M.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,M.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,M.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),M.createElement(M.Fragment,null,M.createElement(`h2`,null,`Unexpected Application Error!`),M.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?M.createElement(`pre`,{style:i},n):null,o)}var vt=M.createElement(_t,null),yt=class extends M.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=at(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:M.createElement(G.Provider,{value:this.props.routeContext},M.createElement(et.Provider,{value:e,children:this.props.component}));return this.context?M.createElement(xt,{error:e},t):t}};yt.contextType=Ye;var bt=new WeakMap;function xt({children:e,error:t}){let{basename:n}=M.useContext(U);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=it(t.digest);if(e){let r=bt.get(t);if(r)throw r;let i=Ke(e.location,n);if(Ge&&!bt.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw bt.set(t,n),n}return M.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function St({routeContext:e,match:t,children:n}){let r=M.useContext(V);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),M.createElement(G.Provider,{value:e},n)}function Ct(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);N(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:We(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||vt,o&&(s<0&&c===0?(Ft(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?M.createElement(n.route.Component,null):n.route.element?n.route.element:e,M.createElement(St,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?M.createElement(yt,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function wt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Tt(e){let t=M.useContext(V);return N(t,wt(e)),t}function Et(e){let t=M.useContext(H);return N(t,wt(e)),t}function Dt(e){let t=M.useContext(G);return N(t,wt(e)),t}function Ot(e){let t=Dt(e),n=t.matches[t.matches.length-1];return N(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function kt(){return Ot(`useRouteId`)}function At(){return Et(`useNavigation`).navigation}function jt(){let{matches:e,loaderData:t}=Et(`useMatches`);return M.useMemo(()=>e.map(e=>he(e,t)),[e,t])}function Mt(){let e=M.useContext(et),t=Et(`useRouteError`),n=Ot(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Nt(){let{router:e}=Tt(`useNavigate`),t=Ot(`useNavigate`),n=M.useRef(!1);return ct(()=>{n.current=!0}),M.useCallback(async(r,i={})=>{P(n.current,st),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Pt={};function Ft(e,t,n){!t&&!Pt[e]&&(Pt[e]=!0,P(!1,n))}M.memo(It);function It({routes:e,future:t,state:n,isStatic:r,onError:i}){return gt(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function Lt({to:e,replace:t,state:n,relative:r}){N(K(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=M.useContext(U);P(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=M.useContext(G),{pathname:o}=q(),s=lt(),c=z(e,Ie(a),o,r===`path`),l=JSON.stringify(c);return M.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Rt(e){return pt(e.context)}function zt(e){N(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Bt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){N(!K(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=M.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=I(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,unstable_mask:m}=n,h=M.useMemo(()=>{let e=R(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,unstable_mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return P(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:M.createElement(U.Provider,{value:c},M.createElement(W.Provider,{children:t,value:h}))}function Vt({children:e,location:t}){return ht(Ht(e),t)}M.Component;function Ht(e,t=[]){let n=[];return M.Children.forEach(e,(e,r)=>{if(!M.isValidElement(e))return;let i=[...t,r];if(e.type===M.Fragment){n.push.apply(n,Ht(e.props.children,i));return}N(e.type===zt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),N(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Ht(e.props.children,i)),n.push(a)}),n}var Ut=`get`,Wt=`application/x-www-form-urlencoded`;function Gt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Kt(e){return Gt(e)&&e.tagName.toLowerCase()===`button`}function qt(e){return Gt(e)&&e.tagName.toLowerCase()===`form`}function Jt(e){return Gt(e)&&e.tagName.toLowerCase()===`input`}function Yt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Xt(e,t){return e.button===0&&(!t||t===`_self`)&&!Yt(e)}function Zt(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Qt(e,t){let n=Zt(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var $t=null;function en(){if($t===null)try{new FormData(document.createElement(`form`),0),$t=!1}catch{$t=!0}return $t}var tn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function nn(e){return e!=null&&!tn.has(e)?(P(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Wt}"`),null):e}function rn(e,t){let n,r,i,a,o;if(qt(e)){let o=e.getAttribute(`action`);r=o?R(o,t):null,n=e.getAttribute(`method`)||Ut,i=nn(e.getAttribute(`enctype`))||Wt,a=new FormData(e)}else if(Kt(e)||Jt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?R(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Ut,i=nn(e.getAttribute(`formenctype`))||nn(o.getAttribute(`enctype`))||Wt,a=new FormData(o,e),!en()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Gt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Ut,r=null,i=Wt,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var an={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},on=/[&><\u2028\u2029]/g;function sn(e){return e.replace(on,e=>an[e])}function cn(e,t){if(e===!1||e==null)throw Error(t)}function ln(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&R(i.pathname,t)===`/`?i.pathname=`${Re(t)}/_root.${r}`:i.pathname=`${Re(i.pathname)}.${r}`,i}async function un(e,t){if(e.id in t)return t[e.id];try{let n=await ie(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function dn(e){return e!=null&&typeof e.page==`string`}function fn(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function pn(e,t,n){return vn((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await un(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(fn).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function mn(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function hn(e,t,{includeHydrateFallback:n}={}){return gn(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function gn(e){return[...new Set(e)]}function _n(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function vn(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!dn(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(_n(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function yn(){let e=M.useContext(V);return cn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function bn(){let e=M.useContext(H);return cn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var xn=M.createContext(void 0);xn.displayName=`FrameworkContext`;function Sn(){let e=M.useContext(xn);return cn(e,`You must render this element inside a <HydratedRouter> element`),e}function Cn(e,t){let n=M.useContext(xn),[r,i]=M.useState(!1),[a,o]=M.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=M.useRef(null);M.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),M.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Y(s,p),onBlur:Y(c,m),onMouseEnter:Y(l,p),onMouseLeave:Y(u,m),onTouchStart:Y(d,p)}]:[a,f,{}]:[!1,f,{}]}function Y(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function wn({page:e,...t}){let n=Xe(),{router:r}=yn(),i=M.useMemo(()=>pe(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?M.createElement(En,{page:e,matches:i,...t}):M.createElement(Dn,{page:e,matches:i,...t}):null}function Tn(e){let{manifest:t,routeModules:n}=Sn(),[r,i]=M.useState([]);return M.useEffect(()=>{let r=!1;return pn(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function En({page:e,matches:t,...n}){let r=q(),{future:i}=Sn(),{basename:a}=yn(),o=M.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=ln(e,a,i.unstable_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.unstable_trailingSlashAwareDataRequests,e,r,t]);return M.createElement(M.Fragment,null,o.map(e=>M.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Dn({page:e,matches:t,...n}){let r=q(),{future:i,manifest:a,routeModules:o}=Sn(),{basename:s}=yn(),{loaderData:c,matches:l}=bn(),u=M.useMemo(()=>mn(e,t,l,a,r,`data`),[e,t,l,a,r]),d=M.useMemo(()=>mn(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=M.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=ln(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=M.useMemo(()=>hn(d,a),[d,a]),m=Tn(d);return M.createElement(M.Fragment,null,f.map(e=>M.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>M.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>M.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function On(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}M.Component;var kn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{kn&&(window.__reactRouterVersion=`7.14.2`)}catch{}function An({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=M.useRef();i.current??=se({window:r,v5Compat:!0});let a=i.current,[o,s]=M.useState({action:a.action,location:a.location}),c=M.useCallback(e=>{n===!1?s(e):M.startTransition(()=>s(e))},[n]);return M.useLayoutEffect(()=>a.listen(c),[a,c]),M.createElement(Bt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function jn({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=M.useState({action:n.action,location:n.location}),o=M.useCallback(e=>{r===!1?a(e):M.startTransition(()=>a(e))},[r]);return M.useLayoutEffect(()=>n.listen(o),[n,o]),M.createElement(Bt,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}jn.displayName=`unstable_HistoryRouter`;var Mn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nn=M.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,unstable_mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,unstable_useTransitions:_}=M.useContext(U),v=typeof l==`string`&&Mn.test(l),y=Ke(l,h);l=y.to;let b=ot(l,{relative:r}),x=q(),S=null;if(o){let e=z(o,[],x.unstable_mask?x.unstable_mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:B([h,e.pathname])),S=g.createHref(e)}let[C,w,T]=Cn(n,p),E=Bn(l,{replace:a,unstable_mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:_});function D(t){e&&e(t),t.defaultPrevented||E(t)}let O=!(y.isExternal||i),ee=M.createElement(`a`,{...p,...T,href:(O?S:void 0)||y.absoluteURL||b,onClick:O?D:e,ref:On(m,w),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return C&&!v?M.createElement(M.Fragment,null,ee,M.createElement(wn,{page:b})):ee});Nn.displayName=`Link`;var Pn=M.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=J(a,{relative:c.relative}),d=q(),f=M.useContext(H),{navigator:p,basename:m}=M.useContext(U),h=f!=null&&Xn(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=R(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return M.createElement(Nn,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Pn.displayName=`NavLink`;var Fn=M.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Ut,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=M.useContext(U),g=Wn(),_=Gn(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Mn.test(s);return M.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?M.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Fn.displayName=`Form`;function In({getKey:e,storageKey:t,...n}){let r=M.useContext(xn),{basename:i}=M.useContext(U),a=q(),o=jt();Jn({getKey:e,storageKey:t});let s=M.useMemo(()=>{if(!r||!e)return null;let t=qn(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return M.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${sn(JSON.stringify(t||Kn))}, ${sn(JSON.stringify(s))})`}})}In.displayName=`ScrollRestoration`;function Ln(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Rn(e){let t=M.useContext(V);return N(t,Ln(e)),t}function zn(e){let t=M.useContext(H);return N(t,Ln(e)),t}function Bn(e,{target:t,replace:n,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=lt(),d=q(),f=J(e,{relative:o});return M.useCallback(p=>{if(Xt(p,t)){p.preventDefault();let t=n===void 0?F(d)===F(f):n,m=()=>u(e,{replace:t,unstable_mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?M.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function Vn(e){P(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=M.useRef(Zt(e)),n=M.useRef(!1),r=q(),i=M.useMemo(()=>Qt(r.search,n.current?null:t.current),[r.search]),a=lt();return[i,M.useCallback((e,t)=>{let r=Zt(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Hn=0,Un=()=>`__${String(++Hn)}__`;function Wn(){let{router:e}=Rn(`useSubmit`),{basename:t}=M.useContext(U),n=kt(),r=e.fetch,i=e.navigate;return M.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=rn(e,t);a.navigate===!1?await r(a.fetcherKey||Un(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Gn(e,{relative:t}={}){let{basename:n}=M.useContext(U),r=M.useContext(G);N(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...J(e||`.`,{relative:t})},o=q();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:B([n,a.pathname])),F(a)}var Kn=`react-router-scroll-positions`,X={};function qn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:R(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Jn({getKey:e,storageKey:t}={}){let{router:n}=Rn(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=zn(`useScrollRestoration`),{basename:a}=M.useContext(U),o=q(),s=jt(),c=At();M.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Yn(M.useCallback(()=>{if(c.state===`idle`){let t=qn(o,s,a,e);X[t]=window.scrollY}try{sessionStorage.setItem(t||Kn,JSON.stringify(X))}catch(e){P(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(M.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Kn);e&&(X=JSON.parse(e))}catch{}},[t]),M.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(X,()=>window.scrollY,e?(t,n)=>qn(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),M.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{P(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Yn(e,t){let{capture:n}=t||{};M.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Xn(e,{relative:t}={}){let n=M.useContext(Ze);N(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Rn(`useViewTransitionState`),i=J(e,{relative:t});if(!n.isTransitioning)return!1;let a=R(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=R(n.nextLocation.pathname,r)||n.nextLocation.pathname;return L(i.pathname,o)!=null||L(i.pathname,a)!=null}var Z=t();function Zn(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return`${Math.round(s*360)} ${Math.round(c*100)}% ${Math.round(l*100)}%`}function Qn(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function $n(e,t){(0,M.useEffect)(()=>{let n=document.documentElement;if(e?.primaryColor){let t=Zn(e.primaryColor);t&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t),n.style.setProperty(`--primary`,t),n.style.setProperty(`--primary-foreground`,Qn(e.primaryColor)),n.style.setProperty(`--ring`,t),n.style.setProperty(`--sidebar-primary`,t),n.style.setProperty(`--sidebar-ring`,t))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=Zn(e.accentColor);t&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t),n.style.setProperty(`--accent`,t),n.style.setProperty(`--accent-foreground`,Qn(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`);if(e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function er({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return $n(a,a?.title),(0,Z.jsxs)(j,{defaultOpen:i,className:`!flex-col`,children:[(0,Z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,Z.jsx)(m,{className:`min-w-0`,children:(0,Z.jsx)(`main`,{className:v(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6`,r),children:n})})]})]})}var tr=new Map;function nr(e){if(!e)return C;let t=tr.get(e);if(t)return t;if(a[e])return tr.set(e,a[e]),a[e];let n=e.split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return a[n]?(tr.set(e,a[n]),a[n]):C}function Q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function rr(e,t,n){let r=Q(e.label,n);return t&&e.type===`object`&&e.objectName&&typeof e.label==`string`?t(e.objectName,r):r}var ir=e=>!(e===!1||e===`false`),ar=()=>!0;function or(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};default:return{href:`#`,external:!1}}}function sr(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=sr(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return Q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var cr=5;function lr({item:e,basePath:t,evalVis:n,checkPerm:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,t:u}){let{attributes:d,listeners:f,setNodeRef:p,transform:m,transition:h,isDragging:g}=r({id:e.id,disabled:!c});return(0,Z.jsx)(`div`,{ref:p,style:{transform:ne.Transform.toString(m),transition:h,opacity:g?.5:void 0,zIndex:g?10:void 0},...d,children:(0,Z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?f:void 0,resolveObjectLabel:l,t:u})})}function $({item:e,basePath:t,evalVis:n,checkPerm:r,onAction:a,enablePinning:m,onPinToggle:h,dragListeners:_,resolveObjectLabel:v,t:y}){let x=q(),[S,C]=(0,M.useState)(e.defaultOpen!==!1);if(!n(e.visible)||e.requiredPermissions?.length&&!r(e.requiredPermissions))return null;if(e.type===`separator`)return(0,Z.jsx)(i,{className:`my-2`});if(e.type===`group`){let i=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,Z.jsx)(T,{open:S,onOpenChange:C,children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsxs)(d,{className:`flex w-full items-center justify-between`,children:[Q(e.label,y),(0,Z.jsx)(p,{className:`ml-auto h-4 w-4 transition-transform ${S?`rotate-90`:``}`})]})}),(0,Z.jsx)(l,{children:(0,Z.jsx)(u,{children:(0,Z.jsx)(o,{children:i.map(e=>(0,Z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,onAction:a,enablePinning:m,onPinToggle:h,resolveObjectLabel:v,t:y},e.id))})})})]})})}if(e.type===`action`){let t=nr(e.icon);return(0,Z.jsxs)(g,{children:[_&&(0,Z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":`Drag to reorder`,..._,children:(0,Z.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,Z.jsxs)(c,{tooltip:Q(e.label,y),onClick:()=>a?.(e),children:[(0,Z.jsx)(t,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:Q(e.label,y)}),e.badge!=null&&(0,Z.jsx)(O,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),m&&h&&(0,Z.jsx)(s,{showOnHover:!0,onClick:()=>h(e.id,!e.pinned),"aria-label":e.pinned?`Unpin ${Q(e.label,y)}`:`Pin ${Q(e.label,y)}`,children:e.pinned?(0,Z.jsx)(A,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(re,{className:`h-3.5 w-3.5`})})]})}let w=nr(e.icon),{href:D,external:ee}=or(e,t),te=D!==`#`&&x.pathname.startsWith(D),k=rr(e,v,y),ne=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:k}),e.badge!=null&&(0,Z.jsx)(O,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,Z.jsxs)(g,{children:[_&&(0,Z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":`Drag to reorder`,..._,children:(0,Z.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(c,{asChild:!0,isActive:te,tooltip:k,children:ee?(0,Z.jsx)(`a`,{href:D,target:`_blank`,rel:`noopener noreferrer`,children:ne}):(0,Z.jsx)(Nn,{to:D,children:ne})}),m&&h&&(0,Z.jsx)(s,{showOnHover:!0,onClick:()=>h(e.id,!e.pinned),"aria-label":e.pinned?`Unpin ${k}`:`Pin ${k}`,children:e.pinned?(0,Z.jsx)(A,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(re,{className:`h-3.5 w-3.5`})})]})}function ur({items:e,basePath:t=``,evaluateVisibility:n=ir,checkPermission:r=ar,onAction:i,searchQuery:a,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:d,resolveObjectLabel:p,t:m}){let g=(0,M.useMemo)(()=>a?sr(e,a):e,[e,a]),v=(0,M.useMemo)(()=>dr(g),[g]),b=g.slice().sort((e,t)=>(e.order??0)-(t.order??0)),C=D(x(w,{activationConstraint:{distance:cr}}),x(te)),T=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!d)return;let r=b.findIndex(e=>e.id===t.id),i=b.findIndex(e=>e.id===n.id);r===-1||i===-1||d(h(b,r,i).map((e,t)=>({...e,order:t})))},O={basePath:t,evalVis:n,checkPerm:r,onAction:i,enablePinning:s,onPinToggle:c,resolveObjectLabel:p,t:m},ne=b.some(e=>e.type===`group`),re=v.length>0&&s?(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(f,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(_,{className:`h-3.5 w-3.5`}),`Favorites`]}),(0,Z.jsx)(u,{children:(0,Z.jsx)(o,{children:v.map(e=>(0,Z.jsx)($,{item:e,...O},`fav-${e.id}`))})})]}):null;if(!ne){let e=b.filter(e=>e.type!==`group`).map(e=>e.id);return(0,Z.jsxs)(Z.Fragment,{children:[re,(0,Z.jsx)(E,{children:(0,Z.jsx)(u,{children:l?(0,Z.jsx)(k,{sensors:C,collisionDetection:ee,onDragEnd:T,children:(0,Z.jsx)(y,{items:e,strategy:S,children:(0,Z.jsx)(o,{children:b.map(e=>(0,Z.jsx)(lr,{item:e,enableReorder:l,...O},e.id))})})}):(0,Z.jsx)(o,{children:b.map(e=>(0,Z.jsx)($,{item:e,...O},e.id))})})})]})}let A=[],j=[],ie=e=>{if(j.length===0)return;let t=j;j=[],A.push((0,Z.jsx)(E,{children:(0,Z.jsx)(u,{children:(0,Z.jsx)(o,{children:t.map(e=>(0,Z.jsx)($,{item:e,...O},e.id))})})},e))};return b.forEach((e,t)=>{e.type===`group`?(ie(`leaf-${t}`),A.push((0,Z.jsx)($,{item:e,...O},e.id))):j.push(e)}),ie(`leaf-end`),(0,Z.jsxs)(Z.Fragment,{children:[re,A]})}function dr(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...dr(n.children));return t}export{Pn as a,zt as c,lt as d,ft as f,Nn as i,Vt as l,Vn as m,er as n,Lt as o,mt as p,An as r,Rt as s,ur as t,q as u};
|