@object-ui/layout 17.5.0 → 17.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/react"),require("react/jsx-runtime"),require("react-router-dom"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/types"),require("@objectstack/spec/ui")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`react/jsx-runtime`,`react-router-dom`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`,`@objectstack/spec/ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.lucide_react,e._object_ui_react,e.react_jsx_runtime,e.react_router_dom,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types,e._objectstack_spec_ui))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var b=e=>{let t=e?.name??e?.full_name??e?.display_name??e?.label??e?.title??e?.subject;return t!=null&&String(t).trim()?String(t):[e?.salutation,e?.first_name,e?.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e?.email==`string`&&e.email.trim()?e.email.trim():null)},x=(e,t)=>!e||typeof e!=`string`?e??``:e.includes(`{`)?e.replace(/\{([a-zA-Z0-9_.]+)\}/g,(e,n)=>{let r=n.split(`.`).reduce((e,t)=>e==null?e:e[t],t);return r==null?``:typeof r==`object`?b(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function S({title:e,subtitle:t,description:s,icon:c,action:l,actions:u,showBack:d,schema:f,className:p,children:m,...h}){let g=(0,a.useRecordContext)(),_=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),v=x(e,g?.data)||(_?``:e),y=t??s,b=typeof y==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(y),S=x(y,g?.data)||(b?``:y),C=!!g?.recordId,w=!!g?.embedded,T=d??(C&&!w),E=n.default.useCallback(()=>{if(typeof window>`u`)return;let e=window.location.pathname,t=e.replace(/\/record\/[^/]+\/?$/,``);t===e?window.history.length>1&&window.history.back():(window.history.pushState({},``,t+window.location.search),window.dispatchEvent(new PopStateEvent(`popstate`)))},[]),D=Array.isArray(f?.children)?f.children.filter(Boolean).map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,O=Array.isArray(u)&&u.length>0&&u||Array.isArray(f?.actions)&&f.actions.length>0&&f.actions||Array.isArray(f?.properties?.actions)&&f.properties.actions.length>0&&f.properties.actions||null,k=l||m||(O?(0,o.jsx)(a.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:O,location:`record_header`,align:`end`,inline:!0}}}):null)||D;return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,p),...h,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[T&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:E,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,o.jsx)(i.ArrowLeft,{className:`size-4`})}),c&&(v||S)&&(0,o.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof c==`string`?(0,o.jsx)(r.LazyIcon,{name:c,className:`size-5`}):c}),(0,o.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[v?(0,o.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:v}):null,S&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:S})]}),k&&(0,o.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:k})]})})}function C(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}}return{h:s*360,s:c*100,l:l*100}}function w(e){let t=C(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function T(e){let t=C(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function E(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 D(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=w(e.primaryColor),i=T(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:E(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}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=w(e.accentColor),i=T(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:E(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),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 O({sidebar:e,navbar:t,children:n,className:i,defaultOpen:a=!0,branding:s,rightRail:c}){return D(s,s?.title),(0,o.jsxs)(r.SidebarProvider,{defaultOpen:a,className:`!flex-col h-svh overflow-hidden`,children:[(0,o.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,o.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,o.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,o.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,i),children:n})}),c]})]})}function k({className:e,children:t,...n}){return(0,o.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,o.jsx)(`div`,{className:`p-6`,children:t})})}var A={xs:{1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,6:`grid-cols-6`,12:`grid-cols-12`},sm:{1:`sm:grid-cols-1`,2:`sm:grid-cols-2`,3:`sm:grid-cols-3`,4:`sm:grid-cols-4`,6:`sm:grid-cols-6`,12:`sm:grid-cols-12`},md:{1:`md:grid-cols-1`,2:`md:grid-cols-2`,3:`md:grid-cols-3`,4:`md:grid-cols-4`,6:`md:grid-cols-6`,12:`md:grid-cols-12`},lg:{1:`lg:grid-cols-1`,2:`lg:grid-cols-2`,3:`lg:grid-cols-3`,4:`lg:grid-cols-4`,6:`lg:grid-cols-6`,12:`lg:grid-cols-12`},xl:{1:`xl:grid-cols-1`,2:`xl:grid-cols-2`,3:`xl:grid-cols-3`,4:`xl:grid-cols-4`,6:`xl:grid-cols-6`,12:`xl:grid-cols-12`},"2xl":{1:`2xl:grid-cols-1`,2:`2xl:grid-cols-2`,3:`2xl:grid-cols-3`,4:`2xl:grid-cols-4`,6:`2xl:grid-cols-6`,12:`2xl:grid-cols-12`}};function j(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=A[n];if(e&&r){let n=Object.keys(e).map(Number).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e);t.push(e[n])}}return t.join(` `)||`grid-cols-1`}var M={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},N=({columns:e,gap:t=4,className:n,children:i})=>{let a=j(e),s=typeof t==`number`?M[t]||`gap-${t}`:``;return(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,a,s,n),children:i})};function P(e){return e?(0,r.getLazyIcon)(e):i.FileText}function F(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 I(e,t,n,r,i,a,o){let s=F(e.label,n);if(typeof e.label!=`string`)return s;let c=e=>!!e&&s.trim().toLowerCase()!==e.trim().toLowerCase();if(e.type===`object`&&e.objectName){if(e.viewName)return c(e.viewName)?s:a?a(e.objectName,e.viewName,s):s;if(c(e.objectName))return s;if(t)return t(e.objectName,s)}if(e.type===`dashboard`&&e.dashboardName){if(c(e.dashboardName))return s;if(r)return r(e.dashboardName,s)}if(e.type===`group`&&e.id){if(c(e.id))return s;if(i)return i(e.id,s)}return o&&e.id&&!c(e.id)?o(e.id,s):s}var L=e=>e!==!1&&e!==`false`,R=()=>!0,z=()=>!0;function B(e,t={}){let{evaluateVisibility:n=L,checkPermission:r=R,checkCapability:i=z,hasActionHandler:a=!1}=t;for(let o of e)if(n(o.visible)&&!(o.requiredPermissions?.length&&!r(o.requiredPermissions))&&!(o.requiresObject&&!i(`object`,o.requiresObject))&&!(o.requiresService&&!i(`service`,o.requiresService))&&o.type!==`separator`){if(o.type===`group`){if(B(o.children??[],t))return!0;continue}if(!(o.type===`action`&&!a))return!0}return!1}var ee=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function V(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(ee,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function H(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=V(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}let a=e.filters;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=new URLSearchParams;for(let[t,r]of Object.entries(a)){if(r==null||t===``)continue;let i=V(String(r),n);i!==null&&e.set(`filter[${t}]`,i)}let t=e.toString();return{href:t?`${r}/data?${t}`:`${r}/data`,external:!1}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null){if(typeof i==`string`){let r=V(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i))}let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(t!==`type`&&t!==`name`&&r!=null){if(typeof r==`string`){let i=V(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r))}let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}var te=50,ne=40,re=30,U=25,ie=10,ae=5;function oe(e){let t=new Map;return new URLSearchParams(e).forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.set(r[1],e)}),t}function W(e,t){return t.startsWith(`${e}.`)?t.slice(e.length+1):t}function se(e,t,n,r,i){let{href:a,external:o}=H(e,r,i);if(o||a===`#`)return 0;if(e.type===`object`&&e.objectName){let a=`${r}/${e.objectName}`;if(t!==a&&!t.startsWith(`${a}/`))return 0;let o=t===a?[]:t.slice(a.length+1).split(`/`),s=e.recordId;if(s){let e=V(s,i);if(e)return o[0]===`record`&&decodeURIComponent(o[1]??``)===e?te:0}let c=e.filters;if(c&&typeof c==`object`&&!Array.isArray(c)){if(o[0]!==`data`)return 0;let e=new Map;for(let[t,n]of Object.entries(c)){if(n==null||t===``)continue;let r=V(String(n),i);r!==null&&e.set(t,r)}if(e.size!==n.size)return 0;for(let[t,r]of e)if(n.get(t)!==r)return 0;return ne}return e.viewName?o[0]!==`view`||!o[1]?0:W(e.objectName,decodeURIComponent(o[1]))===W(e.objectName,e.viewName)?re:0:o.length===0?U:ie}let s=a.split(`?`)[0];if(t===s)return U;let c=e.componentRef;return c&&c.split(`:`)[1]===`directory`?0:t.startsWith(`${s}/`)?ae:0}function G(e,t,n,r,i){let a=oe(n),o=null,s=0,c=e=>{if(e)for(let n of e){if(n.type===`group`){c(n.children);continue}let e=se(n,t,a,r,i);e>s&&(o=n,s=e)}};return c(e),o}var K=n.default.createContext(null);function q(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=q(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return F(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ce=5;function le({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v}){let{attributes:y,listeners:b,setNodeRef:x,transform:S,transition:C,isDragging:w}=(0,l.useSortable)({id:e.id,disabled:!d}),T={transform:u.CSS.Transform.toString(S),transition:C,opacity:w?.5:void 0,zIndex:w?10:void 0};return(0,o.jsx)(`div`,{ref:x,style:T,...y,children:(0,o.jsx)(J,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?b:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v})})}function J({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y,templateContext:b}){let x=(0,r.useIsMobile)(),S=x?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,C=(0,r.cn)(`shrink-0`,x?`h-5 w-5`:`h-4 w-4`),w=(()=>{if(typeof e.expanded==`boolean`)return e.expanded;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),T=e.type===`group`?e.children?.length??0:0,E=n.default.useContext(K),D=n.default.useMemo(()=>{if(e.type!==`group`||!E)return!1;let t=e=>!!e?.some(e=>e.id===E||e.type===`group`&&t(e.children));return t(e.children)},[e,E])?!0:w??!(T>=8),[O,k]=(0,n.useState)(D);if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let A=e.requiresObject,j=e.requiresService;if(A&&!l(`object`,A)||j&&!l(`service`,j))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0)),s=I(e,m,y,h,g,_,v);return(0,o.jsx)(r.Collapsible,{open:O,onOpenChange:k,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,x&&`min-h-[44px] text-[15px] rounded-xl`),children:[s,(0,o.jsx)(i.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,x?`h-5 w-5`:`h-4 w-4`,O&&`rotate-90`)})]})}),(0,o.jsx)(r.CollapsibleContent,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:n.map(e=>(0,o.jsx)(J,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y,templateContext:b},e.id))})})})]})})}if(e.type===`action`){if(!u)return null;let n=P(e.icon),a=F(e.label,y);return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:a,onClick:()=>u?.(e),className:S,children:[(0,o.jsx)(n,{className:C}),(0,o.jsx)(`span`,{children:a}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${a}`:`Pin ${a}`,name:a}):e.pinned?`Unpin ${a}`:`Pin ${a}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let M=P(e.icon),{href:N,external:L}=H(e,t,b),R=E!==null&&e.id===E,z=I(e,m,y,h,g,_,v),B=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(M,{className:C}),(0,o.jsx)(`span`,{children:z}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:R,tooltip:z,className:S,children:L?(0,o.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,children:B}):(0,o.jsx)(s.Link,{to:N,children:B})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${z}`:`Pin ${z}`,name:z}):e.pinned?`Unpin ${z}`:`Pin ${z}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}function Y({items:e,basePath:t=``,evaluateVisibility:a=L,checkPermission:u=R,checkCapability:d=z,onAction:f,searchQuery:p,enablePinning:m,onPinToggle:h,enableReorder:g,onReorder:_,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w}){let T=(0,s.useLocation)(),E=(0,n.useMemo)(()=>G(e,T.pathname,T.search,t,w)?.id??null,[e,T.pathname,T.search,t,w]),D=(0,n.useMemo)(()=>p?q(e,p):e,[e,p]),O=(0,n.useMemo)(()=>X(D),[D]),k=D.slice().sort((e,t)=>(e.order??0)-(t.order??0)),A=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:ce}}),(0,c.useSensor)(c.KeyboardSensor)),j=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!_)return;let r=k.findIndex(e=>e.id===t.id),i=k.findIndex(e=>e.id===n.id);r!==-1&&i!==-1&&_((0,l.arrayMove)(k,r,i).map((e,t)=>({...e,order:t})))},M={basePath:t,evalVis:a,checkPerm:u,checkCap:d,onAction:f,enablePinning:m,onPinToggle:h,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w},N=k.some(e=>e.type===`group`),P=O.length>0&&m?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),C?C(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:O.map(e=>(0,o.jsx)(J,{item:e,...M},`fav-${e.id}`))})})]}):null;if(!N){let e=k.filter(e=>e.type!==`group`).map(e=>e.id),t=g?(0,o.jsx)(c.DndContext,{sensors:A,collisionDetection:c.closestCenter,onDragEnd:j,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(le,{item:e,enableReorder:g,...M},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(J,{item:e,...M},e.id))});return(0,o.jsxs)(K.Provider,{value:E,children:[P,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:t})})]})}let F=[],I=[],B=e=>{if(I.length===0)return;let t=I;I=[],F.push((0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:t.map(e=>(0,o.jsx)(J,{item:e,...M},e.id))})})},e))};return k.forEach((e,t)=>{e.type===`group`?(B(`leaf-${t}`),F.push((0,o.jsx)(J,{item:e,...M},e.id))):I.push(e)}),B(`leaf-end`),(0,o.jsxs)(K.Provider,{value:E,children:[P,F]})}function X(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...X(n.children));return t}function ue(e){return(0,f.resolveI18nLabel)(e,void 0)??``}function de({areas:e,activeAreaId:t,onAreaChange:n}){return e.length<=1?null:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:e.map(e=>{let i=P(e.icon),a=ue(e.label);return(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:a,onClick:()=>n(e.id),children:[(0,o.jsx)(i,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:a})]})},e.id)})})})]})}function fe({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=P(e.icon),i=`#`;if(e.type===`object`)i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`);else if(e.type===`dashboard`)i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`;else if(e.type===`page`)i=e.pageName?`${t}/page/${e.pageName}`:`#`;else if(e.type===`report`)i=e.reportName?`${t}/report/${e.reportName}`:`#`;else if(e.type===`url`)i=e.url??`#`;else if(e.type===`component`){let n=e.componentRef;if(n){i=`${t}/component/${n.split(`:`).filter(Boolean).join(`/`)}`;let r=e.params;if(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(i+=`?${t}`)}}}let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:F(e.label)})]},e.id)})})}function Z({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,visibleAreas:f,activeAreaId:p,setActiveAreaId:m,resolvedNavigation:h,enableSearch:g,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}){let x=P(e.logo),[S,C]=(0,n.useState)(``);return(0,o.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,o.jsxs)(r.SidebarHeader,{children:[l??(0,o.jsx)(r.SidebarMenu,{children:(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,o.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:e.logo&&e.logo.startsWith(`http`)?(0,o.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,o.jsx)(x,{className:`size-4`})}),(0,o.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,o.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,o.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),g&&(0,o.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,o.jsxs)(r.SidebarContent,{children:[f.length>1&&p&&(0,o.jsx)(de,{areas:f,activeAreaId:p,onAreaChange:m}),(0,o.jsx)(Y,{items:h,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function Q({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,navbar:l,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=i??(e=>e!==!1&&e!==`false`),C=a??(()=>!0),w=s??(()=>!0),T=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,d.menuItemToNavigationItem)(e,t)),[e.menu]),E=e.navigation??T,D=(e.areas??[]).filter(e=>B(e.navigation,{evaluateVisibility:S,checkPermission:C,checkCapability:w,hasActionHandler:!!c})),[k,A]=(0,n.useState)(()=>D.length>0?D[0].id:null),j=D.map(e=>e.id).join(`,`);(0,n.useEffect)(()=>{D.length>0?A(e=>D.some(t=>t.id===e)?e:D[0].id):A(null)},[e.name,j]);let M=D.find(e=>e.id===k)??D[0],N=M?.navigation??E,P={title:e.title,favicon:e.favicon,logo:e.logo},F=(0,o.jsx)(Z,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,visibleAreas:D,activeAreaId:M?.id??null,setActiveAreaId:A,resolvedNavigation:N,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(O,{sidebar:F,navbar:l,className:h,defaultOpen:g,branding:P,children:m}),r===`bottom_nav`&&(0,o.jsx)(fe,{items:N,basePath:t})]})}function pe(e){return`items`in e&&!(`href`in e)}function me({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,o.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,o.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,o.jsx)(r.SidebarMenuSubItem,{children:(0,o.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function he({items:e,title:t=`Application`,className:a,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search…`}){let d=(0,s.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:pe(e[0])?e.map(e=>({groupLabel:e.label,items:e.items})):[{items:e}],[e]),h=n.default.useMemo(()=>{if(!f)return m;let e=f.toLowerCase();return m.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e)||t.children?.some(t=>t.title.toLowerCase().includes(e)))})).filter(e=>e.items.length>0)},[m,f]);return(0,o.jsx)(r.Sidebar,{className:a,collapsible:c,children:(0,o.jsxs)(r.SidebarContent,{children:[l&&(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,o.jsx)(r.Input,{type:`search`,placeholder:u,value:f,onChange:e=>p(e.target.value),className:`pl-8 h-9`})]})}),h.map((e,n)=>(0,o.jsxs)(r.SidebarGroup,{children:[n>0&&(0,o.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,o.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,o.jsx)(me,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,S,{namespace:`layout`,label:`Page Header`,category:`Layout`,isContainer:!0,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`subtitle`,type:`string`,label:`Subtitle`},{name:`icon`,type:`string`,label:`Icon`,description:`Lucide icon name`},{name:`actions`,type:`array`,label:`Actions`,description:`ActionDef list (or action ids) rendered through record:quick_actions`}]}),t.ComponentRegistry.register(`page:card`,k,{namespace:`layout`,skipFallback:!0,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,O,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,N,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,Y,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`array`,required:!0},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,Q,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`string`}]})}try{$()}catch{}e.AppSchemaRenderer=Q,e.AppShell=O,e.NavigationRenderer=Y,e.PageCard=k,e.PageHeader=S,e.ResponsiveGrid=N,e.SidebarNav=he,e.filterNavigationItems=q,e.hasVisibleNavigationItems=B,e.registerLayout=$,e.resolveActiveNavItem=G,e.resolveHref=H,e.resolveIcon=P,e.resolveLabel=F,e.useAppShellBranding=D});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/components"),require("react/jsx-runtime"),require("react-router-dom"),require("lucide-react"),require("@object-ui/types"),require("@objectstack/spec/ui"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/react")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/components`,`react/jsx-runtime`,`react-router-dom`,`lucide-react`,`@object-ui/types`,`@objectstack/spec/ui`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e.react,e._object_ui_core,e._object_ui_components,e.react_jsx_runtime,e.react_router_dom,e.lucide_react,e._object_ui_types,e._objectstack_spec_ui,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_react))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function b({className:e,children:t,...n}){return(0,i.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,i.jsx)(`div`,{className:`p-6`,children:t})})}function x(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}}return{h:s*360,s:c*100,l:l*100}}function S(e){let t=x(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function C(e){let t=x(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function w(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 T(e,n){(0,t.useEffect)(()=>{let t=document.documentElement,r=()=>t.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let n=S(e.primaryColor),i=C(e.primaryColor),a=r()&&i||n;a&&(t.style.setProperty(`--brand-primary`,e.primaryColor),t.style.setProperty(`--brand-primary-hsl`,n||a),t.style.setProperty(`--primary`,a),t.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:w(e.primaryColor)),t.style.setProperty(`--ring`,a),t.style.setProperty(`--sidebar-primary`,a),t.style.setProperty(`--sidebar-ring`,a))}else t.style.removeProperty(`--brand-primary`),t.style.removeProperty(`--brand-primary-hsl`),t.style.removeProperty(`--primary`),t.style.removeProperty(`--primary-foreground`),t.style.removeProperty(`--ring`),t.style.removeProperty(`--sidebar-primary`),t.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let n=S(e.accentColor),i=C(e.accentColor),a=r()&&i||n;a&&(t.style.setProperty(`--brand-accent`,e.accentColor),t.style.setProperty(`--brand-accent-hsl`,n||a),t.style.setProperty(`--accent`,a),t.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:w(e.accentColor)))}else t.style.removeProperty(`--brand-accent`),t.style.removeProperty(`--brand-accent-hsl`),t.style.removeProperty(`--accent`),t.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});a.observe(t,{attributes:!0,attributeFilter:[`class`]});let o=null,s=null;if(e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(o=t,s=t.getAttribute(`href`),t.href=e.favicon)}let c=null;return n&&(c=document.title,document.title=n),()=>{a.disconnect(),c!==null&&(document.title=c),o&&(s===null?o.removeAttribute(`href`):o.setAttribute(`href`,s)),t.style.removeProperty(`--brand-primary`),t.style.removeProperty(`--brand-primary-hsl`),t.style.removeProperty(`--brand-accent`),t.style.removeProperty(`--brand-accent-hsl`),t.style.removeProperty(`--primary`),t.style.removeProperty(`--primary-foreground`),t.style.removeProperty(`--ring`),t.style.removeProperty(`--sidebar-primary`),t.style.removeProperty(`--sidebar-ring`),t.style.removeProperty(`--accent`),t.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,n])}function E({sidebar:e,navbar:t,children:n,className:a,defaultOpen:o=!0,branding:s,rightRail:c}){return T(s,s?.title),(0,i.jsxs)(r.SidebarProvider,{defaultOpen:o,className:`!flex-col h-svh overflow-hidden`,children:[(0,i.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,i.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,i.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,i.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,a),children:n})}),c]})]})}function D(e,t){return(e.order??0)-(t.order??0)}function O(e){return e?(0,r.getLazyIcon)(e):o.FileText}function k(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 A(e,t,n,r){return e.type===`separator`?``:e.label===void 0?N(e,n):j(e.label,t,r)}function j(e,t,n){return typeof e==`string`?e:M(e)?k(e,t):(0,c.resolveI18nLabel)(e,n)??``}function M(e){return typeof e==`object`&&!!e&&(`key`in e||`defaultValue`in e)}function N(e,t){let n=e=>{let n=t?.(e);return typeof n==`string`&&n.trim()!==``?n:void 0};switch(e.type){case`object`:if(!e.objectName)break;return e.viewName?n({kind:`view`,objectName:e.objectName,viewName:e.viewName})??n({kind:`object`,objectName:e.objectName})??e.viewName:n({kind:`object`,objectName:e.objectName})??e.objectName;case`dashboard`:if(!e.dashboardName)break;return n({kind:`dashboard`,dashboardName:e.dashboardName})??e.dashboardName;case`page`:if(e.pageName)return e.pageName;break;case`report`:if(e.reportName)return e.reportName;break;case`url`:if(e.url)return e.url;break;case`component`:if(e.componentRef)return e.componentRef;break;case`action`:if(e.actionDef?.actionName)return e.actionDef.actionName;break;case`doc`:if(e.doc)return e.doc;if(e.book)return e.book}return e.id}var P=e=>e!==!1&&e!==`false`,F=()=>!0,I=()=>!0;function L(e,t){let{evaluateVisibility:n=P,checkPermission:r=F,checkCapability:i=I,checkDocTarget:a}=t;if(!n(e.visible)||e.requiredPermissions?.length&&!r(e.requiredPermissions))return!1;let o=e.requiresObject,s=e.requiresService;return!(o&&!i(`object`,o)||s&&!i(`service`,s)||e.type===`doc`&&a&&!a({book:e.book,doc:e.doc}))}function R(e,t={}){let{hasActionHandler:n=!1}=t;for(let r of e)if(L(r,t)&&r.type!==`separator`){if(r.type===`group`){if(R(r.children??[],t))return!0;continue}if(r.type!==`action`||n)return!0}return!1}var z=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function B(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(z,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}var V=`runAction`;function H(e,t){let n=t.runAction;return typeof n!=`string`||n===``?e:`${e}${e.includes(`?`)?`&`:`?`}${V}=${encodeURIComponent(n)}`}function ee(e,t,n){let r=e=>encodeURIComponent(e);return e&&t?`${n}/docs/${r(e)}/${r(t)}`:t?`${n}/docs/${r(t)}`:e?`${n}/docs/${r(e)}`:`#`}function U(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=B(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}let a=e.filters;if(a&&typeof a==`object`&&!Array.isArray(a)){let t=new URLSearchParams;for(let[e,r]of Object.entries(a)){if(r==null||e===``)continue;let i=B(String(r),n);i!==null&&t.set(`filter[${e}]`,i)}let i=t.toString();return{href:H(i?`${r}/data?${i}`:`${r}/data`,e),external:!1}}return{href:H(e.viewName?`${r}/view/${e.viewName}`:r,e),external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null){if(typeof i==`string`){let r=B(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i))}let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(t!==`type`&&t!==`name`&&r!=null){if(typeof r==`string`){let i=B(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r))}let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}case`doc`:return{href:ee(e.book,e.doc,t),external:!1};default:return{href:`#`,external:!1}}}var te=50,ne=40,re=30,W=25,ie=10,ae=5;function oe(e){let t=new Map;return new URLSearchParams(e).forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.set(r[1],e)}),t}function G(e,t){return t.startsWith(`${e}.`)?t.slice(e.length+1):t}function se(e,t,n,r,i){let{href:a,external:o}=U(e,r,i);if(o||a===`#`)return 0;if(e.type===`object`&&e.objectName){let a=`${r}/${e.objectName}`;if(t!==a&&!t.startsWith(`${a}/`))return 0;let o=t===a?[]:t.slice(a.length+1).split(`/`),s=e.recordId;if(s){let e=B(s,i);if(e)return o[0]===`record`&&decodeURIComponent(o[1]??``)===e?te:0}let c=e.filters;if(c&&typeof c==`object`&&!Array.isArray(c)){if(o[0]!==`data`)return 0;let e=new Map;for(let[t,n]of Object.entries(c)){if(n==null||t===``)continue;let r=B(String(n),i);r!==null&&e.set(t,r)}if(e.size!==n.size)return 0;for(let[t,r]of e)if(n.get(t)!==r)return 0;return ne}return e.viewName?o[0]!==`view`||!o[1]?0:G(e.objectName,decodeURIComponent(o[1]))===G(e.objectName,e.viewName)?re:0:o.length===0?W:ie}let s=a.split(`?`)[0];if(t===s)return W;let c=e.componentRef;return c&&c.split(`:`)[1]===`directory`?0:t.startsWith(`${s}/`)?ae:0}function K(e,t,n,r,i){let a=oe(n),o=null,s=0,c=e=>{if(e)for(let n of e){if(n.type===`group`){c(n.children);continue}let e=se(n,t,a,r,i);e>s&&(o=n,s=e)}};return c(e),o}var q=t.default.createContext(null);function J(e,t,n=e=>A(e)){if(!t.trim())return e;let r=t.toLowerCase().trim();return e.reduce((e,i)=>{if(i.type===`separator`)return e;if(i.type===`group`&&i.children?.length){let r=J(i.children,t,n);return r.length>0&&e.push({...i,children:r}),e}return n(i).toLowerCase().includes(r)&&e.push(i),e},[])}var ce=5;function le({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,checkDocTarget:o,onAction:s,enablePinning:c,onPinToggle:l,enableReorder:f,resolveTargetLabel:p,locale:m,t:h,templateContext:g}){let{attributes:_,listeners:v,setNodeRef:y,transform:b,transition:x,isDragging:S}=(0,u.useSortable)({id:e.id,disabled:!f}),C={transform:d.CSS.Transform.toString(b),transition:x,opacity:S?.5:void 0,zIndex:S?10:void 0};return(0,i.jsx)(`div`,{ref:y,style:C,..._,children:(0,i.jsx)(Y,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,checkDocTarget:o,onAction:s,enablePinning:c,onPinToggle:l,dragListeners:f?v:void 0,resolveTargetLabel:p,locale:m,t:h,templateContext:g})})}function Y({item:e,basePath:n,evalVis:s,checkPerm:c,checkCap:l,checkDocTarget:u,onAction:d,enablePinning:f,onPinToggle:p,dragListeners:m,resolveTargetLabel:h,locale:g,t:_,templateContext:v}){let y=(0,r.useIsMobile)(),b=y?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,x=(0,r.cn)(`shrink-0`,y?`h-5 w-5`:`h-4 w-4`),S=(()=>{if(typeof e.expanded==`boolean`)return e.expanded;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),C=e.type===`group`?e.children?.length??0:0,w=t.default.useContext(q),T=t.default.useMemo(()=>{if(e.type!==`group`||!w)return!1;let t=e=>!!e?.some(e=>e.id===w||e.type===`group`&&t(e.children));return t(e.children)},[e,w])?!0:S??!(C>=8),[E,k]=(0,t.useState)(T),j={evaluateVisibility:s,checkPermission:c,checkCapability:l,checkDocTarget:u,hasActionHandler:!!d};if(!L(e,j))return null;if(e.type===`separator`)return(0,i.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let t=(e.children??[]).slice().sort(D);if(!R(t,j))return null;let a=A(e,_,h,g);return(0,i.jsx)(r.Collapsible,{open:E,onOpenChange:k,children:(0,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,i.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,y&&`min-h-[44px] text-[15px] rounded-xl`),children:[a,(0,i.jsx)(o.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,y?`h-5 w-5`:`h-4 w-4`,E&&`rotate-90`)})]})}),(0,i.jsx)(r.CollapsibleContent,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:t.map(e=>(0,i.jsx)(Y,{item:e,basePath:n,evalVis:s,checkPerm:c,checkCap:l,checkDocTarget:u,onAction:d,enablePinning:f,onPinToggle:p,resolveTargetLabel:h,locale:g,t:_,templateContext:v},e.id))})})})]})})}if(e.type===`action`){if(!d)return null;let t=O(e.icon),a=A(e,_,h,g);return(0,i.jsxs)(r.SidebarMenuItem,{children:[m&&(0,i.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":_?_(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...m,children:(0,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsxs)(r.SidebarMenuButton,{tooltip:a,onClick:()=>d?.(e),className:b,children:[(0,i.jsx)(t,{className:x}),(0,i.jsx)(`span`,{children:a}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),f&&p&&(0,i.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>p(e.id,!e.pinned,e,n),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${a}`:`Pin ${a}`,name:a}):e.pinned?`Unpin ${a}`:`Pin ${a}`,children:e.pinned?(0,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}let M=O(e.icon),{href:N,external:P}=U(e,n,v),F=w!==null&&e.id===w,I=A(e,_,h,g),z=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(M,{className:x}),(0,i.jsx)(`span`,{children:I}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,i.jsxs)(r.SidebarMenuItem,{children:[m&&(0,i.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":_?_(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...m,children:(0,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:F,tooltip:I,className:b,children:P?(0,i.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,children:z}):(0,i.jsx)(a.Link,{to:N,children:z})}),f&&p&&(0,i.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>p(e.id,!e.pinned,e,n),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${I}`:`Pin ${I}`,name:I}):e.pinned?`Unpin ${I}`:`Pin ${I}`,children:e.pinned?(0,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}function X({items:e,basePath:n=``,evaluateVisibility:s=P,checkPermission:c=F,checkCapability:d=I,checkDocTarget:f,onAction:p,searchQuery:m,enablePinning:h,onPinToggle:g,enableReorder:_,onReorder:v,resolveTargetLabel:y,locale:b,t:x,templateContext:S}){let C=(0,a.useLocation)(),w=(0,t.useMemo)(()=>K(e,C.pathname,C.search,n,S)?.id??null,[e,C.pathname,C.search,n,S]),T=(0,t.useMemo)(()=>m?J(e,m,e=>A(e,x,y,b)):e,[e,m,x,y,b]),E=(0,t.useMemo)(()=>Z(T,{evaluateVisibility:s,checkPermission:c,checkCapability:d,checkDocTarget:f}),[T,s,c,d,f]),O=T.slice().sort(D),k=(0,l.useSensors)((0,l.useSensor)(l.PointerSensor,{activationConstraint:{distance:ce}}),(0,l.useSensor)(l.KeyboardSensor)),j=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!v)return;let r=O.findIndex(e=>e.id===t.id),i=O.findIndex(e=>e.id===n.id);r!==-1&&i!==-1&&v((0,u.arrayMove)(O,r,i).map((e,t)=>({...e,order:t})))},M={basePath:n,evalVis:s,checkPerm:c,checkCap:d,checkDocTarget:f,onAction:p,enablePinning:h,onPinToggle:g,resolveTargetLabel:y,locale:b,t:x,templateContext:S},N=O.some(e=>e.type===`group`),L=E.length>0&&h?(0,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Star,{className:`h-3.5 w-3.5`}),x?x(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:E.map(e=>(0,i.jsx)(Y,{item:e,...M},`fav-${e.id}`))})})]}):null;if(!N){let e=O.filter(e=>e.type!==`group`).map(e=>e.id),t=_?(0,i.jsx)(l.DndContext,{sensors:k,collisionDetection:l.closestCenter,onDragEnd:j,children:(0,i.jsx)(u.SortableContext,{items:e,strategy:u.verticalListSortingStrategy,children:(0,i.jsx)(r.SidebarMenu,{children:O.map(e=>(0,i.jsx)(le,{item:e,enableReorder:_,...M},e.id))})})}):(0,i.jsx)(r.SidebarMenu,{children:O.map(e=>(0,i.jsx)(Y,{item:e,...M},e.id))});return(0,i.jsxs)(q.Provider,{value:w,children:[L,(0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:t})})]})}let R=[],z=[],B=e=>{if(z.length===0)return;let t=z;z=[],R.push((0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:t.map(e=>(0,i.jsx)(Y,{item:e,...M},e.id))})})},e))};return O.forEach((e,t)=>{e.type===`group`?(B(`leaf-${t}`),R.push((0,i.jsx)(Y,{item:e,...M},e.id))):z.push(e)}),B(`leaf-end`),(0,i.jsxs)(q.Provider,{value:w,children:[L,R]})}function Z(e,t){let n=[];for(let r of e)L(r,t)&&(r.type!==`group`&&r.type!==`separator`&&r.pinned&&n.push(r),r.children?.length&&n.push(...Z(r.children,t)));return n}function ue(e){return(0,c.resolveI18nLabel)(e,void 0)??``}function de({areas:e,activeAreaId:t,onAreaChange:n}){return e.length<=1?null:(0,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:e.map(e=>{let a=O(e.icon),o=ue(e.label);return(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:o,onClick:()=>n(e.id),children:[(0,i.jsx)(a,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:o})]})},e.id)})})})]})}function fe({items:e,basePath:t,guards:n,onAction:o}){let s=(0,a.useLocation)(),c=e=>{let t=[];for(let r of e.slice().sort(D))R([r],n)&&r.type!==`separator`&&(r.type===`group`?t.push(...c(r.children||[])):t.push(r));return t},l=c(e).slice(0,5);if(l.length===0)return null;let u=K(e,s.pathname,s.search,t)?.id??null;return(0,i.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:l.map(e=>{let n=O(e.icon),{href:s,external:c}=U(e,t),l=`relative flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${e.id===u?`text-primary`:`text-muted-foreground hover:text-foreground`}`,d=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n,{className:`h-5 w-5`}),(0,i.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:A(e)}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant,className:`absolute top-0.5 left-1/2 ml-1.5 px-1 py-0 text-[9px] leading-tight`,children:e.badge})]});return e.type===`action`?(0,i.jsx)(`button`,{type:`button`,onClick:()=>o?.(e),className:l,children:d},e.id):c?(0,i.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:l,children:d},e.id):(0,i.jsx)(a.Link,{to:s,className:l,children:d},e.id)})})}function pe({schema:e,basePath:n,evalVis:a,checkPerm:o,checkCap:s,checkDocTarget:c,onAction:l,sidebarHeader:u,sidebarFooter:d,sidebarExtra:f,visibleAreas:p,activeAreaId:m,setActiveAreaId:h,resolvedNavigation:g,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=e.branding?.logo,C=O(e.icon),[w,T]=(0,t.useState)(``);return(0,i.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,i.jsxs)(r.SidebarHeader,{children:[u??(0,i.jsx)(r.SidebarMenu,{children:(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,i.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:S?(0,i.jsx)(`img`,{src:S,alt:e.title??``,className:`size-6 object-contain`}):(0,i.jsx)(C,{className:`size-4`})}),(0,i.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,i.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,i.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),_&&(0,i.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:w,onChange:e=>T(e.target.value),"aria-label":`Search navigation`})]}),(0,i.jsxs)(r.SidebarContent,{children:[p.length>1&&m&&(0,i.jsx)(de,{areas:p,activeAreaId:m,onAreaChange:h}),(0,i.jsx)(X,{items:g,basePath:n,evaluateVisibility:a,checkPermission:o,checkCapability:s,checkDocTarget:c,onAction:l,searchQuery:w,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}),f]}),d&&(0,i.jsx)(r.SidebarFooter,{children:d})]})}function Q({schema:e,basePath:n=``,mobileNavMode:r=`drawer`,evaluateVisibility:a,checkPermission:o,checkCapability:c,checkDocTarget:l,onAction:u,navbar:d,sidebarHeader:f,sidebarFooter:p,sidebarExtra:m,children:h,className:g,defaultOpen:_=!0,enableSearch:v,enablePinning:y,onPinToggle:b,enableReorder:x,onReorder:S}){let C=a??(e=>e!==!1&&e!==`false`),w=o??(()=>!0),T=c??(()=>!0),D=(0,t.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,s.menuItemToNavigationItem)(e,t)),[e.menu]),O=e.navigation??D,k={evaluateVisibility:C,checkPermission:w,checkCapability:T,checkDocTarget:l,hasActionHandler:!!u},A=(e.areas??[]).filter(e=>R(e.navigation,k)),[j,M]=(0,t.useState)(()=>A.length>0?A[0].id:null),N=A.map(e=>e.id).join(`,`);(0,t.useEffect)(()=>{A.length>0?M(e=>A.some(t=>t.id===e)?e:A[0].id):M(null)},[e.name,N]);let P=A.find(e=>e.id===j)??A[0],F=P?.navigation??O,I={title:e.title,favicon:e.branding?.favicon},L=(0,i.jsx)(pe,{schema:e,basePath:n,evalVis:C,checkPerm:w,checkCap:T,checkDocTarget:l,onAction:u,sidebarHeader:f,sidebarFooter:p,sidebarExtra:m,visibleAreas:A,activeAreaId:P?.id??null,setActiveAreaId:M,resolvedNavigation:F,enableSearch:v,enablePinning:y,onPinToggle:b,enableReorder:x,onReorder:S});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(E,{sidebar:L,navbar:d,className:g,defaultOpen:_,branding:I,children:h}),r===`bottom_nav`&&(0,i.jsx)(fe,{items:F,basePath:n,guards:k,onAction:u})]})}var me=e=>{let t=e?.name??e?.full_name??e?.display_name??e?.label??e?.title??e?.subject;return t!=null&&String(t).trim()?String(t):[e?.salutation,e?.first_name,e?.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e?.email==`string`&&e.email.trim()?e.email.trim():null)},$=(e,t)=>!e||typeof e!=`string`?e??``:e.includes(`{`)?e.replace(/\{([a-zA-Z0-9_.]+)\}/g,(e,n)=>{let r=n.split(`.`).reduce((e,t)=>e==null?e:e[t],t);return r==null?``:typeof r==`object`?me(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function he({title:e,subtitle:n,icon:a,action:s,actions:c,showBack:l,schema:u,className:d,children:p,...m}){let h=(0,f.useRecordContext)(),g=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),_=$(e,h?.data)||(g?``:e),v=n,y=typeof v==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(v),b=$(v,h?.data)||(y?``:v),x=!!h?.recordId,S=!!h?.embedded,C=l??(x&&!S),w=t.default.useCallback(()=>{if(typeof window>`u`)return;let e=window.location.pathname,t=e.replace(/\/record\/[^/]+\/?$/,``);t===e?window.history.length>1&&window.history.back():(window.history.pushState({},``,t+window.location.search),window.dispatchEvent(new PopStateEvent(`popstate`)))},[]),T=Array.isArray(u?.children)?u.children.filter(Boolean).map((e,t)=>(0,i.jsx)(f.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,E=Array.isArray(c)&&c.length>0&&c||Array.isArray(u?.actions)&&u.actions.length>0&&u.actions||Array.isArray(u?.properties?.actions)&&u.properties.actions.length>0&&u.properties.actions||null,D=s||p||(E?(0,i.jsx)(f.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:E,location:`record_header`,align:`end`,inline:!0}}}):null)||T;return(0,i.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,d),...m,children:(0,i.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[C&&(0,i.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:w,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,i.jsx)(o.ArrowLeft,{className:`size-4`})}),a&&(_||b)&&(0,i.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof a==`string`?(0,i.jsx)(r.LazyIcon,{name:a,className:`size-5`}):a}),(0,i.jsxs)(`div`,{className:`flex flex-col min-w-48 flex-1`,children:[_?(0,i.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:_}):null,b&&(0,i.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:b})]}),D&&(0,i.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:D})]})})}function ge(e){return`items`in e&&!(`href`in e)}function _e({item:e,pathname:t}){return e.children&&e.children.length>0?(0,i.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,i.jsxs)(r.SidebarMenuItem,{children:[(0,i.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,i.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,i.jsx)(o.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,i.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,i.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,i.jsx)(r.SidebarMenuSubItem,{children:(0,i.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function ve({items:e,title:n=`Application`,className:s,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search…`}){let d=(0,a.useLocation)(),[f,p]=t.default.useState(``),m=t.default.useMemo(()=>e.length===0?[]:ge(e[0])?e.map(e=>({groupLabel:e.label,items:e.items})):[{items:e}],[e]),h=t.default.useMemo(()=>{if(!f)return m;let e=f.toLowerCase();return m.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e)||t.children?.some(t=>t.title.toLowerCase().includes(e)))})).filter(e=>e.items.length>0)},[m,f]);return(0,i.jsx)(r.Sidebar,{className:s,collapsible:c,children:(0,i.jsxs)(r.SidebarContent,{children:[l&&(0,i.jsx)(`div`,{className:`px-3 py-2`,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(o.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,i.jsx)(r.Input,{type:`search`,placeholder:u,value:f,onChange:e=>p(e.target.value),className:`pl-8 h-9`})]})}),h.map((e,t)=>(0,i.jsxs)(r.SidebarGroup,{children:[t>0&&(0,i.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,i.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||n}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,i.jsx)(_e,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||t))]})})}var ye={xs:{1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,6:`grid-cols-6`,12:`grid-cols-12`},sm:{1:`sm:grid-cols-1`,2:`sm:grid-cols-2`,3:`sm:grid-cols-3`,4:`sm:grid-cols-4`,6:`sm:grid-cols-6`,12:`sm:grid-cols-12`},md:{1:`md:grid-cols-1`,2:`md:grid-cols-2`,3:`md:grid-cols-3`,4:`md:grid-cols-4`,6:`md:grid-cols-6`,12:`md:grid-cols-12`},lg:{1:`lg:grid-cols-1`,2:`lg:grid-cols-2`,3:`lg:grid-cols-3`,4:`lg:grid-cols-4`,6:`lg:grid-cols-6`,12:`lg:grid-cols-12`},xl:{1:`xl:grid-cols-1`,2:`xl:grid-cols-2`,3:`xl:grid-cols-3`,4:`xl:grid-cols-4`,6:`xl:grid-cols-6`,12:`xl:grid-cols-12`},"2xl":{1:`2xl:grid-cols-1`,2:`2xl:grid-cols-2`,3:`2xl:grid-cols-3`,4:`2xl:grid-cols-4`,6:`2xl:grid-cols-6`,12:`2xl:grid-cols-12`}};function be(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=ye[n];if(e&&r){let n=Object.keys(e).map(Number).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e);t.push(e[n])}}return t.join(` `)||`grid-cols-1`}var xe={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},Se=({columns:e,gap:t=4,className:n,children:a})=>{let o=be(e),s=typeof t==`number`?xe[t]||`gap-${t}`:``;return(0,i.jsx)(`div`,{className:(0,r.cn)(`grid`,o,s,n),children:a})},Ce={type:`app`},we=({schema:e,children:n,...r})=>(0,t.createElement)(Q,{...r,schema:e?.schema??Ce,children:n});function Te(){n.ComponentRegistry.register(`page:card`,b,{namespace:`layout`,skipFallback:!0,label:`Page Card`,category:`Layout`,isContainer:!0}),n.ComponentRegistry.register(`app-schema-renderer`,we,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`enum`,enum:[`drawer`,`bottom_nav`],description:`Mobile navigation mode. "drawer" (default) puts the sidebar in the mobile sheet overlay; "bottom_nav" additionally renders a fixed bottom bar. These are the only two modes the renderer implements.`}]})}try{Te()}catch{}e.AppSchemaRenderer=Q,e.AppShell=E,e.NAV_RUN_ACTION_PARAM=V,e.NavigationRenderer=X,e.PageCard=b,e.PageHeader=he,e.ResponsiveGrid=Se,e.SidebarNav=ve,e.filterNavigationItems=J,e.hasVisibleNavigationItems=R,e.registerLayout=Te,e.resolveActiveNavItem=K,e.resolveHref=U,e.resolveIcon=O,e.resolveLabel=k,e.resolveNavItemLabel=A,e.useAppShellBranding=T});
@@ -0,0 +1,18 @@
1
+ import { NavigationItem } from '@object-ui/types';
2
+ /**
3
+ * Compare two navigation entries of the same level by `order` — the spec's
4
+ * "Sort order within the same level (lower = first)".
5
+ *
6
+ * The three sites that order a level import this one comparator, so the
7
+ * sidebar and the mobile tab bar cannot disagree about which entry comes first:
8
+ * `NavigationRenderer`'s top level, each group's children in
9
+ * `NavigationItemRenderer`, and the tab bar's flattening in
10
+ * `AppSchemaRenderer`, which sorts each level before it flattens. ⛔ Do not
11
+ * write the sort out again at a fourth site; import this.
12
+ *
13
+ * An entry with no `order` sorts as `0`, and entries that compare equal keep
14
+ * their authored order (`Array.prototype.sort` is stable). Both are the
15
+ * sidebar's behaviour from before this comparator was extracted, kept as they
16
+ * were.
17
+ */
18
+ export declare function byNavOrder(a: NavigationItem, b: NavigationItem): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/layout",
3
- "version": "17.5.0",
3
+ "version": "17.7.0",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./dist/index.js",
@@ -21,16 +21,12 @@
21
21
  "@dnd-kit/core": "^6.3.1",
22
22
  "@dnd-kit/sortable": "^10.0.0",
23
23
  "@dnd-kit/utilities": "^3.2.2",
24
- "@objectstack/spec": "^17.0.0-rc.6",
25
- "clsx": "^2.1.1",
26
- "lucide-react": "^1.29.0",
27
- "react": "19.2.8",
28
- "react-dom": "19.2.8",
29
- "tailwind-merge": "^3.6.0",
30
- "@object-ui/components": "17.5.0",
31
- "@object-ui/core": "17.5.0",
32
- "@object-ui/react": "17.5.0",
33
- "@object-ui/types": "17.5.0"
24
+ "@objectstack/spec": "^17.0.0",
25
+ "lucide-react": "^1.43.0",
26
+ "@object-ui/components": "17.7.0",
27
+ "@object-ui/core": "17.7.0",
28
+ "@object-ui/react": "17.7.0",
29
+ "@object-ui/types": "17.7.0"
34
30
  },
35
31
  "peerDependencies": {
36
32
  "react": "^18.0.0 || ^19.0.0",
@@ -39,10 +35,13 @@
39
35
  },
40
36
  "devDependencies": {
41
37
  "@vitejs/plugin-react": "^6.0.5",
38
+ "react": "19.2.8",
42
39
  "react-router-dom": "^7.18.2",
43
40
  "vite": "^8.2.1",
44
41
  "vite-plugin-dts": "^5.0.3",
45
- "vitest": "^4.1.10"
42
+ "vitest": "^4.1.10",
43
+ "@object-ui/sdui-parser": "17.7.0",
44
+ "@object-ui/test-support": "17.4.0"
46
45
  },
47
46
  "description": "Layout components for Object UI — AppShell, PageHeader, SidebarNav and responsive containers with React Router integration",
48
47
  "keywords": [
@@ -81,6 +80,7 @@
81
80
  ],
82
81
  "scripts": {
83
82
  "build": "vite build",
83
+ "test": "vitest run --root ../.. packages/layout/",
84
84
  "type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
85
85
  "lint": "eslint ."
86
86
  }