web-mojo 2.2.69 → 2.2.70

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.
Files changed (157) hide show
  1. package/dist/admin.cjs.js +1 -1
  2. package/dist/admin.cjs.js.map +1 -1
  3. package/dist/admin.es.js +1 -1
  4. package/dist/admin.es.js.map +1 -1
  5. package/dist/auth.cjs.js +1 -1
  6. package/dist/auth.es.js +1 -1
  7. package/dist/charts.cjs.js +1 -1
  8. package/dist/charts.cjs.js.map +1 -1
  9. package/dist/charts.es.js +1 -1
  10. package/dist/charts.es.js.map +1 -1
  11. package/dist/chunks/ChatView-DH42WXgV.js +2 -0
  12. package/dist/chunks/{ChatView-Dw-iVmht.js.map → ChatView-DH42WXgV.js.map} +1 -1
  13. package/dist/chunks/ChatView-_8eQTETQ.js +2 -0
  14. package/dist/chunks/{ChatView-CZ3Key2k.js.map → ChatView-_8eQTETQ.js.map} +1 -1
  15. package/dist/chunks/Collection-BUv4E9op.js +2 -0
  16. package/dist/chunks/Collection-BUv4E9op.js.map +1 -0
  17. package/dist/chunks/Collection-r1ACzUeh.js +2 -0
  18. package/dist/chunks/Collection-r1ACzUeh.js.map +1 -0
  19. package/dist/chunks/ContextMenu-BFxliZ03.js +2 -0
  20. package/dist/chunks/{ContextMenu-8vTiZZQV.js.map → ContextMenu-BFxliZ03.js.map} +1 -1
  21. package/dist/chunks/ContextMenu-BwJJ4QJE.js +2 -0
  22. package/dist/chunks/{ContextMenu-DBw0WMTO.js.map → ContextMenu-BwJJ4QJE.js.map} +1 -1
  23. package/dist/chunks/DataView-DMpNXerv.js +2 -0
  24. package/dist/chunks/{DataView-DyJKgOn3.js.map → DataView-DMpNXerv.js.map} +1 -1
  25. package/dist/chunks/DataView-_CACqzRt.js +2 -0
  26. package/dist/chunks/{DataView-BEovBggn.js.map → DataView-_CACqzRt.js.map} +1 -1
  27. package/dist/chunks/Dialog-BVCCpLPw.js +3 -0
  28. package/dist/chunks/Dialog-BVCCpLPw.js.map +1 -0
  29. package/dist/chunks/Dialog-BYiynSW-.js +3 -0
  30. package/dist/chunks/Dialog-BYiynSW-.js.map +1 -0
  31. package/dist/chunks/FormView-Dw7HDwzy.js +3 -0
  32. package/dist/chunks/{FormView-BRHAIawp.js.map → FormView-Dw7HDwzy.js.map} +1 -1
  33. package/dist/chunks/FormView-OgrZ7x0z.js +3 -0
  34. package/dist/chunks/{FormView-B1CXO2t8.js.map → FormView-OgrZ7x0z.js.map} +1 -1
  35. package/dist/chunks/ListView-2M4I8KHF.js +2 -0
  36. package/dist/chunks/{ListView-CMZpwyyC.js.map → ListView-2M4I8KHF.js.map} +1 -1
  37. package/dist/chunks/ListView-B0QbqSPv.js +2 -0
  38. package/dist/chunks/{ListView-BLFFK_Ir.js.map → ListView-B0QbqSPv.js.map} +1 -1
  39. package/dist/chunks/MetricsCountryMapView-DDdDJQFA.js +2 -0
  40. package/dist/chunks/{MetricsCountryMapView-B0kWK-Js.js.map → MetricsCountryMapView-DDdDJQFA.js.map} +1 -1
  41. package/dist/chunks/MetricsCountryMapView-DIlezla0.js +2 -0
  42. package/dist/chunks/{MetricsCountryMapView-DuBKO7gz.js.map → MetricsCountryMapView-DIlezla0.js.map} +1 -1
  43. package/dist/chunks/MetricsMiniChartWidget-Dt2V0eXP.js +2 -0
  44. package/dist/chunks/{MetricsMiniChartWidget-Dg1e6EQJ.js.map → MetricsMiniChartWidget-Dt2V0eXP.js.map} +1 -1
  45. package/dist/chunks/MetricsMiniChartWidget-_N4kzNY_.js +2 -0
  46. package/dist/chunks/{MetricsMiniChartWidget-D1w608Jy.js.map → MetricsMiniChartWidget-_N4kzNY_.js.map} +1 -1
  47. package/dist/chunks/PDFViewer-BruR1RFn.js +2 -0
  48. package/dist/chunks/{PDFViewer-D_3V8QJe.js.map → PDFViewer-BruR1RFn.js.map} +1 -1
  49. package/dist/chunks/PDFViewer-CyGFVcvX.js +2 -0
  50. package/dist/chunks/{PDFViewer-CDeV9OBs.js.map → PDFViewer-CyGFVcvX.js.map} +1 -1
  51. package/dist/chunks/TableView-CxYpxZvr.js +2 -0
  52. package/dist/chunks/{TableView-CI_7a-kD.js.map → TableView-CxYpxZvr.js.map} +1 -1
  53. package/dist/chunks/TableView-DemRVhnX.js +2 -0
  54. package/dist/chunks/{TableView-CWk5k4LQ.js.map → TableView-DemRVhnX.js.map} +1 -1
  55. package/dist/chunks/TokenManager-BFaxNsXO.js +2 -0
  56. package/dist/chunks/{TokenManager-sZgt--C9.js.map → TokenManager-BFaxNsXO.js.map} +1 -1
  57. package/dist/chunks/TokenManager-IlBEFXqZ.js +2 -0
  58. package/dist/chunks/{TokenManager-ien2XzwO.js.map → TokenManager-IlBEFXqZ.js.map} +1 -1
  59. package/dist/chunks/UserProfileView-9vkfCPsp.js +2 -0
  60. package/dist/chunks/{UserProfileView-kupeq2rN.js.map → UserProfileView-9vkfCPsp.js.map} +1 -1
  61. package/dist/chunks/UserProfileView-tcBT6XcE.js +2 -0
  62. package/dist/chunks/{UserProfileView-DnVMHcLH.js.map → UserProfileView-tcBT6XcE.js.map} +1 -1
  63. package/dist/chunks/WebApp-BFR1zozS.js +2 -0
  64. package/dist/chunks/{WebApp-CcVF73yg.js.map → WebApp-BFR1zozS.js.map} +1 -1
  65. package/dist/chunks/WebApp-C82womPC.js +2 -0
  66. package/dist/chunks/{WebApp-Bti0Gqqo.js.map → WebApp-C82womPC.js.map} +1 -1
  67. package/dist/chunks/WebSocketClient-Ibi7mLQu.js +2 -0
  68. package/dist/chunks/{WebSocketClient-Bh0Mmtje.js.map → WebSocketClient-Ibi7mLQu.js.map} +1 -1
  69. package/dist/chunks/WebSocketClient-QaCUN3EQ.js +2 -0
  70. package/dist/chunks/{WebSocketClient-CLgYPxWX.js.map → WebSocketClient-QaCUN3EQ.js.map} +1 -1
  71. package/dist/chunks/index-BaPQHxbL.js +2 -0
  72. package/dist/chunks/{index-Da9sT-tE.js.map → index-BaPQHxbL.js.map} +1 -1
  73. package/dist/chunks/index-BdfwxVMZ.js +2 -0
  74. package/dist/chunks/{index-Aq9ke4vg.js.map → index-BdfwxVMZ.js.map} +1 -1
  75. package/dist/chunks/{version-XmirKYWA.js → version-C2yYRyPn.js} +2 -2
  76. package/dist/chunks/{version-XmirKYWA.js.map → version-C2yYRyPn.js.map} +1 -1
  77. package/dist/chunks/{version-D8JjsPW0.js → version-CaiqhdME.js} +2 -2
  78. package/dist/chunks/{version-D8JjsPW0.js.map → version-CaiqhdME.js.map} +1 -1
  79. package/dist/docit.cjs.js +1 -1
  80. package/dist/docit.cjs.js.map +1 -1
  81. package/dist/docit.es.js +1 -1
  82. package/dist/docit.es.js.map +1 -1
  83. package/dist/index.cjs.js +1 -1
  84. package/dist/index.cjs.js.map +1 -1
  85. package/dist/index.es.js +1 -1
  86. package/dist/index.es.js.map +1 -1
  87. package/dist/lightbox.cjs.js +1 -1
  88. package/dist/lightbox.cjs.js.map +1 -1
  89. package/dist/lightbox.es.js +1 -1
  90. package/dist/lightbox.es.js.map +1 -1
  91. package/dist/map.cjs.js +1 -1
  92. package/dist/map.cjs.js.map +1 -1
  93. package/dist/map.es.js +1 -1
  94. package/dist/map.es.js.map +1 -1
  95. package/dist/timeline.cjs.js +1 -1
  96. package/dist/timeline.cjs.js.map +1 -1
  97. package/dist/timeline.es.js +1 -1
  98. package/dist/timeline.es.js.map +1 -1
  99. package/dist/user-profile.cjs.js +1 -1
  100. package/dist/user-profile.es.js +1 -1
  101. package/dist/web-mojo.lite.iife.js +5435 -5435
  102. package/dist/web-mojo.lite.iife.js.map +1 -1
  103. package/dist/web-mojo.lite.iife.min.js +68 -68
  104. package/dist/web-mojo.lite.iife.min.js.map +1 -1
  105. package/package.json +1 -1
  106. package/dist/chunks/ChatView-CZ3Key2k.js +0 -2
  107. package/dist/chunks/ChatView-Dw-iVmht.js +0 -2
  108. package/dist/chunks/Collection-BWKmydl5.js +0 -2
  109. package/dist/chunks/Collection-BWKmydl5.js.map +0 -1
  110. package/dist/chunks/Collection-CmjTsmrP.js +0 -2
  111. package/dist/chunks/Collection-CmjTsmrP.js.map +0 -1
  112. package/dist/chunks/ContextMenu-8vTiZZQV.js +0 -2
  113. package/dist/chunks/ContextMenu-DBw0WMTO.js +0 -2
  114. package/dist/chunks/DataView-BEovBggn.js +0 -2
  115. package/dist/chunks/DataView-DyJKgOn3.js +0 -2
  116. package/dist/chunks/Dialog-Dhqtd9Yz.js +0 -2
  117. package/dist/chunks/Dialog-Dhqtd9Yz.js.map +0 -1
  118. package/dist/chunks/Dialog-t_9l2Mou.js +0 -2
  119. package/dist/chunks/Dialog-t_9l2Mou.js.map +0 -1
  120. package/dist/chunks/Files-6eRT5k3r.js +0 -2
  121. package/dist/chunks/Files-6eRT5k3r.js.map +0 -1
  122. package/dist/chunks/Files-Dh_5PFBn.js +0 -2
  123. package/dist/chunks/Files-Dh_5PFBn.js.map +0 -1
  124. package/dist/chunks/FormView-B1CXO2t8.js +0 -3
  125. package/dist/chunks/FormView-BRHAIawp.js +0 -3
  126. package/dist/chunks/ListView-BLFFK_Ir.js +0 -2
  127. package/dist/chunks/ListView-CMZpwyyC.js +0 -2
  128. package/dist/chunks/MetricsCountryMapView-B0kWK-Js.js +0 -2
  129. package/dist/chunks/MetricsCountryMapView-DuBKO7gz.js +0 -2
  130. package/dist/chunks/MetricsMiniChartWidget-D1w608Jy.js +0 -2
  131. package/dist/chunks/MetricsMiniChartWidget-Dg1e6EQJ.js +0 -2
  132. package/dist/chunks/PDFViewer-CDeV9OBs.js +0 -2
  133. package/dist/chunks/PDFViewer-D_3V8QJe.js +0 -2
  134. package/dist/chunks/Rest-B1eUyLX5.js +0 -2
  135. package/dist/chunks/Rest-B1eUyLX5.js.map +0 -1
  136. package/dist/chunks/Rest-BJ3Mvx1L.js +0 -2
  137. package/dist/chunks/Rest-BJ3Mvx1L.js.map +0 -1
  138. package/dist/chunks/TableView-CI_7a-kD.js +0 -2
  139. package/dist/chunks/TableView-CWk5k4LQ.js +0 -2
  140. package/dist/chunks/ToastService-C2tTooFn.js +0 -3
  141. package/dist/chunks/ToastService-C2tTooFn.js.map +0 -1
  142. package/dist/chunks/ToastService-nUaGVpSl.js +0 -3
  143. package/dist/chunks/ToastService-nUaGVpSl.js.map +0 -1
  144. package/dist/chunks/TokenManager-ien2XzwO.js +0 -2
  145. package/dist/chunks/TokenManager-sZgt--C9.js +0 -2
  146. package/dist/chunks/User-BL9M_PWB.js +0 -2
  147. package/dist/chunks/User-BL9M_PWB.js.map +0 -1
  148. package/dist/chunks/User-DqHG5Gr1.js +0 -2
  149. package/dist/chunks/User-DqHG5Gr1.js.map +0 -1
  150. package/dist/chunks/UserProfileView-DnVMHcLH.js +0 -2
  151. package/dist/chunks/UserProfileView-kupeq2rN.js +0 -2
  152. package/dist/chunks/WebApp-Bti0Gqqo.js +0 -2
  153. package/dist/chunks/WebApp-CcVF73yg.js +0 -2
  154. package/dist/chunks/WebSocketClient-Bh0Mmtje.js +0 -2
  155. package/dist/chunks/WebSocketClient-CLgYPxWX.js +0 -2
  156. package/dist/chunks/index-Aq9ke4vg.js +0 -2
  157. package/dist/chunks/index-Da9sT-tE.js +0 -2
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{B as e,V as t,a as s,b as i,c as a,d as n}from"./chunks/version-D8JjsPW0.js";import{V as r,d as o,a as l}from"./chunks/Rest-BJ3Mvx1L.js";import{D as c,b as d,M as h,r as u}from"./chunks/Rest-BJ3Mvx1L.js";import{P as p}from"./chunks/ContextMenu-DBw0WMTO.js";import{C as g}from"./chunks/ContextMenu-DBw0WMTO.js";import{W as m}from"./chunks/WebApp-Bti0Gqqo.js";import{E as b,R as v}from"./chunks/WebApp-Bti0Gqqo.js";import{C as f,M as w}from"./chunks/Collection-BWKmydl5.js";import{B as y,C as S,a as A,b as P,c as M,d as C,e as L,E as k,f as I,g as T,h as D,i as x,j as G,F as E,G as _,k as F,I as N,l as R,m as V,n as O,o as H,p as U,q as j,r as B,s as K,t as $,u as z,v as q,w as J,J as W,x as Y,y as Q,z as X,A as Z,D as ee,H as te,K as se,L as ie,M as ae,N as ne,O as re,P as oe,Q as le,R as ce,S as de,T as he,U as ue,V as pe,W as ge,X as me,Y as be,Z as ve,_ as fe,$ as we,a0 as ye,a1 as Se,a2 as Ae,a3 as Pe,a4 as Me,a5 as Ce,a6 as Le,a7 as ke,a8 as Ie,a9 as Te,aa as De,ab as xe,ac as Ge,ad as Ee,ae as _e,af as Fe,ag as Ne,ah as Re,ai as Ve,aj as Oe,ak as He,al as Ue,am as je,an as Be}from"./chunks/ChatView-Dw-iVmht.js";import{F as Ke,a as $e,b as ze,c as qe,d as Je,e as We,f as Ye,P as Qe}from"./chunks/Files-6eRT5k3r.js";import{G as Xe,d as Ze,a as et}from"./chunks/User-BL9M_PWB.js";import{e as tt,f as st,g as it,c as at,h as nt,b as rt,i as ot,U as lt}from"./chunks/User-BL9M_PWB.js";import{b as ct}from"./chunks/TableView-CWk5k4LQ.js";import{D as dt,L as ht,c as ut,d as pt,e as gt,M as mt,a as bt,T as vt,f as ft,p as wt}from"./chunks/TableView-CWk5k4LQ.js";import{S as yt,T as St,a as At}from"./chunks/TokenManager-ien2XzwO.js";import Pt from"./chunks/Dialog-t_9l2Mou.js";import{T as Mt}from"./chunks/ToastService-nUaGVpSl.js";import{a as Ct,L as Lt}from"./chunks/ListView-BLFFK_Ir.js";import{default as kt}from"./chunks/DataView-BEovBggn.js";import{F as It}from"./chunks/FormView-BRHAIawp.js";import{a as Tt}from"./chunks/FormView-BRHAIawp.js";import{W as Dt}from"./chunks/WebSocketClient-Bh0Mmtje.js";import{P as xt,U as Gt}from"./chunks/UserProfileView-DnVMHcLH.js";const Et={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},_t=Object.freeze({silent:0,error:1,warn:2,info:3,log:3,debug:4,trace:5,all:5}),Ft=(()=>{try{if(void 0!==import.meta&&import.meta&&Et)return!1}catch{}if("undefined"!=typeof globalThis&&void 0!==globalThis.__DEV__)try{return!!globalThis.__DEV__}catch{}return!("undefined"==typeof process||!process||"object"!=typeof process.env||"string"!=typeof process.env.NODE_ENV)&&"production"!==process.env.NODE_ENV})(),Nt="undefined"!=typeof window&&"undefined"!=typeof document,Rt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:global,Vt=Rt.console||{},Ot={};let Ht=!1,Ut=null;function jt(e){if("number"==typeof e){const t=_t.silent,s=_t.trace;return Math.min(Math.max(e,t),s)}if("string"==typeof e){const t=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(_t,t))return _t[t]}return null}function Bt(e,t){const s=Ot[e]||Vt[e]||(()=>{});return function(...e){if(Ut>=t)return s.apply(Vt,e)}}const Kt={install(e={}){if(Ht)return e&&void 0!==e.level&&this.setLevel(e.level,{persist:!!e.persist}),this;if(!Rt||!Vt)return Ht=!0,this;Ut=function(e){const t=jt(e);if(null!==t)return t;const s=function(){if(!Nt||"undefined"==typeof location||!location.search)return null;try{const e=new URLSearchParams(location.search),t=["logLevel","loglevel","mojoLog"];for(const s of t){const t=e.get(s);if(null!=t){const e=jt(t);if(null!==e)return e}}}catch{}return null}();if(null!==s)return s;const i=function(){if(!Nt||!("localStorage"in Rt))return null;try{const e=Rt.localStorage.getItem("MOJO_LOG_LEVEL");if(null!=e){const t=jt(e);if(null!==t)return t}}catch{}return null}();return null!==i?i:jt(Ft?"debug":"warn")}(e.level);const t=function(){const e={...Vt},t={error:_t.error,warn:_t.warn,info:_t.info,log:_t.info,dir:_t.info,table:_t.info,debug:_t.debug,group:_t.debug,groupCollapsed:_t.debug,groupEnd:_t.debug,time:_t.debug,timeEnd:_t.debug,timeLog:_t.debug,trace:_t.trace};for(const s of Object.keys(t))Ot[s]=Vt[s]||(()=>{}),e[s]=Bt(s,t[s]);return Ot.assert=Vt.assert||(()=>{}),e.assert=function(){const e=Ot.assert||Vt.assert||(()=>{});return function(t,...s){if(!t)return Ut>=_t.error?e.apply(Vt,[t,...s]):void 0}}(),e}();return Rt.console=t,Ht=!0,Rt.MOJOConsoleSilencer=this,this},uninstall(){if(!Ht)return this;try{Rt.console=Vt}catch{}return Ht=!1,this},setLevel(e,{persist:t=!1}={}){const s=jt(e);return null===s||(Ut=s,t&&function(e){if(Nt&&"localStorage"in Rt)try{const t="string"==typeof e?e:null===e?null:Object.entries(_t).find(([,t])=>t===e)?.[0]??null;t?Rt.localStorage.setItem("MOJO_LOG_LEVEL",t):Rt.localStorage.removeItem("MOJO_LOG_LEVEL")}catch{}}(e)),this},getLevel:()=>Ut,getLevelName(){const e=Object.entries(_t).find(([,e])=>e===Ut);return e?e[0]:null},criticalOnly({persist:e=!1}={}){return this.setLevel("warn",{persist:e})},errorsOnly({persist:e=!1}={}){return this.setLevel("error",{persist:e})},silent({persist:e=!1}={}){return this.setLevel("silent",{persist:e})},verbose({persist:e=!1}={}){return this.setLevel(Ft?"debug":"info",{persist:e})},allowAll({persist:e=!1}={}){return this.setLevel("trace",{persist:e})},withTemporaryLevel(e,t){const s=Ut,i=jt(e);if(null===i||"function"!=typeof t)return t?.();Ut=i;try{return t()}finally{Ut=s}},LEVELS:_t},$t=e=>Kt.install(e);class GroupSearchView extends yt{constructor(e={}){super({...e,className:`group-search-view ${e.className||""}`.trim()}),this.showKind=void 0===e.showKind||e.showKind,this.parentField=e.parentField||"parent",this.kindField=e.kindField||"kind",this.treeData=[],this.flattenedItems=[],this.showLines=void 0===e.showLines||e.showLines}buildTreeHierarchy(e){if(!e||0===e.length)return[];const t=/* @__PURE__ */new Map;e.forEach(e=>{t.has(e.id)||t.set(e.id,{...e,children:[],level:0,hasChildren:!1});const s=e[this.parentField];s&&s.id&&!t.has(s.id)&&t.set(s.id,{...s,children:[],level:0,hasChildren:!1})});const s=[];t.forEach((i,a)=>{const n=e.find(e=>e.id===a)||i,r=n[this.parentField]?.id;if(r&&t.has(r)){const e=t.get(r);e.children.push(i),e.hasChildren=!0}else s.push(i)});const i=(e,t=0)=>{e.forEach(e=>{e.level=t,e.children.length>0&&(e.children.sort((e,t)=>(e.name||"").localeCompare(t.name||"")),i(e.children,t+1))})};return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"")),i(s),s}flattenTree(e,t=[],s=[]){return e.forEach((i,a)=>{i._isLastChild=a===e.length-1,i._ancestorLastFlags=[...s];const n=s.every(e=>e);if(i._isLastDescendant=n&&i._isLastChild&&(!i.children||0===i.children.length),t.push(i),i.children&&i.children.length>0){const e=[...s,i._isLastChild];this.flattenTree(i.children,t,e)}}),t}computeVerticalLines(e){for(let t=0;t<e.length;t++){const s=e[t];s._continueVertical=[];for(let i=0;i<s.level;i++){let a=!1;for(let s=t+1;s<e.length;s++){const t=e[s];if(t.level===i+1){a=!0;break}if(t.level<=i)break}s._continueVertical[i]=a}}}updateFilteredItems(){if(!this.collection)return this.filteredItems=[],this.treeData=[],void(this.flattenedItems=[]);const e=this.collection.toJSON();this.treeData=this.buildTreeHierarchy(e),this.flattenedItems=this.flattenTree(this.treeData),this.computeVerticalLines(this.flattenedItems),this.filteredItems=this.flattenedItems,this.updateResultsView()}getDefaultItemTemplate(){return'\n <div class="tree-item-content">\n <div class="tree-item-name">{{name}}</div>\n {{#showKind}}\n <div class="tree-item-kind">{{kind}}</div>\n {{/showKind}}\n </div>\n '}processItemTemplate(e){let t=this.itemTemplate;t=t.replace(/\{\{(\w+)\}\}/g,(t,s)=>"showKind"===s?this.showKind?"true":"":this.getNestedValue(e,s)||""),t=this.showKind?t.replace(/\{\{#showKind\}\}(.*?)\{\{\/showKind\}\}/gs,"$1"):t.replace(/\{\{#showKind\}\}.*?\{\{\/showKind\}\}/gs,"");let s="";if(this.showLines&&e.level>0)for(let i=0;i<e.level;i++)i===e.level-1?s+=`<span class="${e._isLastChild?"tree-seg tree-seg-last":"tree-seg tree-seg-mid"}"></span>`:s+=e._continueVertical&&e._continueVertical[i]?'<span class="tree-seg tree-seg-vert"></span>':'<span class="tree-seg"></span>';return`\n <div class="tree-item-wrapper${e.hasChildren?" has-children":""}${e._isLastChild?" is-last-child":""}" data-tree-level="${e.level}">\n <div class="tree-lines">\n ${s}\n </div>\n <div class="tree-item-body flex-grow-1">\n ${t}\n </div>\n </div>\n `}getRootItems(){return this.treeData}getNodeChildren(e){const t=(e,s)=>{for(const i of e){if(i.id===s)return i.children;if(i.children.length>0){const e=t(i.children,s);if(e)return e}}return null};return t(this.treeData,e)||[]}}class Sidebar extends r{constructor(e={}){super({tagName:"nav",className:"sidebar",id:"sidebar",...e}),this.menus=/* @__PURE__ */new Map,this.activeMenuName=null,this.currentRoute=null,this.showToggle=e.showToggle,this.isCollapsed=!1,this.sidebarTheme=e.theme||"sidebar-light",this.customView=null,this.options.groupHeader&&(this.groupHeader=this.options.groupHeader),this.groupSelectorMode=e.groupSelectorMode||"inline",this.groupSelectorDialog=null,this.sidebarTheme&&this.addClass(this.sidebarTheme),this.initializeMenus(e),this.setupRouteListeners(),!1!==e.autoCollapseMobile&&this.setupResponsiveBehavior()}groupHeader='\n {{#group.parent}}\n <div class="sidebar-parent-bar" data-action="select-group-parent">\n <div class="parent-info">\n <span class="parent-label">{{group.parent.kind}}:</span>\n <span class="parent-name collapsed-hidden">{{group.parent.name}}</span>\n </div>\n <i class="bi bi-chevron-down parent-expand collapsed-hidden"></i>\n </div>\n {{/group.parent}}\n <div class="sidebar-selected-group-row" data-action="show-group-search">\n <div class="selected-group-info">\n <div class=\'selected-group-name collapsed-hidden\'>{{group.name}}</div>\n <div class=\'selected-group-meta collapsed-hidden\'>\n <span class="selected-group-kind">{{group.kind}}</span>\n </div>\n </div>\n <i class="bi bi-chevron-down selected-group-chevron collapsed-hidden"></i>\n </div>\n ';async onInit(){await super.onInit();const e=this.getApp(),t=e?.router;if(t){const e=t.getCurrentPath();e&&this.autoSwitchToMenuForRoute(e)}this.initializeTooltips(),this.searchView=new GroupSearchView({noAppend:!0,showExitButton:!0,headerText:"Select Group",containerId:"sidebar-search-container",Collection:Xe,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n '}),this.addChild(this.searchView),this.searchView.on("item:selected",e=>{this.getApp().setActiveGroup(e.model)}),this.searchView.on("exit",e=>{this.hideGroupSearch()})}showGroupSearch(){"dialog"===this.groupSelectorMode?this.showGroupSearchDialog():(this.setClass("sidebar"),this.showSearch=!0,this.render())}hideGroupSearch(){"dialog"===this.groupSelectorMode?this.groupSelectorDialog&&this.groupSelectorDialog.hide():(this.setClass("sidebar"),this.showSearch=!1,this.render())}onActionShowGroupSearch(){this.showGroupSearch()}async onActionSelectGroupParent(){const e=this.getApp().activeGroup;if(await Pt.confirm(`Are you sure you want to navigate to the '${e.get("parent.name")}'?`)){this.getApp().showLoading();let t=new Ze({id:e.get("parent.id")});await t.fetch(),this.getApp().setActiveGroup(t),this.getApp().hideLoading()}}async showGroupSearchDialog(){const e=new Xe,t=new GroupSearchView({Collection:Xe,collection:e,searchFields:["name"],headerText:null,searchPlaceholder:"Search groups...",headerIcon:null,maxHeight:Math.min(600,window.innerHeight-200),showExitButton:!1,showKind:!0,parentField:"parent",kindField:"kind",autoExpandRoot:!0,autoExpandAll:!1,indentSize:20,showLines:!0});this.groupSelectorDialog=new Pt({body:t,size:"md",header:null,noBodyPadding:!0,scrollable:!1,buttons:[],closeButton:!0}),t.on("item:selected",e=>{this.getApp().setActiveGroup(e.model),this.groupSelectorDialog&&this.groupSelectorDialog.hide()}),this.groupSelectorDialog.on("hidden",()=>{this.groupSelectorDialog.destroy(),this.groupSelectorDialog=null}),await this.groupSelectorDialog.render(!0,document.body),this.groupSelectorDialog.show()}autoSwitchToMenuForRoute(e){for(const[t,s]of this.menus)if((!s.groupKind||this.getApp().activeGroup)&&this.menuContainsRoute(s,e))return this._setActiveMenu(t),this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),this.render(),this.emit("menu-auto-switched",{menuName:t,route:e,config:s,sidebar:this}),!0;return!1}clearAllActiveStates(){for(const[e,t]of this.menus)for(const s of t.items||[])if(s.active=!1,s.children)for(const e of s.children)e.active=!1}setActiveItemByRoute(e){const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e);for(const[i,a]of this.menus)if(!a.groupKind||this.getApp().activeGroup)for(const e of a.items||[]){if(e.route){const i=t(e.route);if(this.routesMatch(s,i))return e.active=!0,this.activeMenuItem=e,!0}if(e.children)for(const i of e.children)if(i.route){const a=t(i.route);if(this.routesMatch(s,a))return i.active=!0,e.active=!0,!0}}return!1}menuContainsRoute(e,t){const s=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},i=s(t);for(const a of e.items||[]){if(a.route){const e=s(a.route);if(this.routesMatch(i,e))return!0}if(a.children)for(const e of a.children)if(e.route){const t=s(e.route);if(this.routesMatch(i,t))return!0}}return!1}routesMatch(e,t){return this.getApp().router.doRoutesMatch(e,t)}getTemplate(){return this.customView?'<div class="sidebar-container" id="sidebar-custom-view-container"></div>':this.showSearch?this.getSearchTemplate():this.getMenuTemplate()}getSearchTemplate(){return'\n <div class="sidebar-container" id="sidebar-search-container">\n </div>\n '}getMenuTemplate(){return'\n <div class="sidebar-container">\n {{#data.currentMenu}}\n \x3c!-- Header --\x3e\n {{#header}}\n <div class="sidebar-header">\n {{{header}}}\n {{#showToggle}}\n <button class="sidebar-toggle" data-action="toggle-sidebar"\n aria-label="Toggle Sidebar">\n <i class="bi bi-chevron-left toggle-icon"></i>\n <i class="bi bi-chevron-right toggle-icon"></i>\n </button>\n {{/showToggle}}\n </div>\n {{/header}}\n\n \x3c!-- Navigation Items --\x3e\n <div class="sidebar-body">\n <ul class="nav nav-pills flex-column sidebar-nav" id="sidebar-nav-menu">\n {{#items}}\n {{>nav-item}}\n {{/items}}\n </ul>\n </div>\n\n \x3c!-- Footer --\x3e\n {{#footer}}\n <div class="sidebar-footer">\n {{{footer}}}\n </div>\n {{/footer}}\n {{/data.currentMenu}}\n\n {{^data.currentMenu}}\n <div class="sidebar-empty">\n <p class="text-danger text-center">No menu configured</p>\n </div>\n {{/data.currentMenu}}\n </div>\n '}getPartials(){return{"nav-item":'\n {{#isDivider}}\n {{>nav-divider}}\n {{/isDivider}}\n {{#isSpacer}}\n {{>nav-spacer}}\n {{/isSpacer}}\n {{#isLabel}}\n {{>nav-label}}\n {{/isLabel}}\n\n {{^isDivider}}\n {{^isSpacer}}\n {{^isLabel}}\n <li class="nav-item">\n {{#hasChildren}}\n \x3c!-- Item with submenu --\x3e\n <a class="nav-link {{#active}}active{{/active}} has-children collapsed"\n data-bs-toggle="collapse"\n href="#collapse-{{id}}"\n role="button"\n aria-expanded="{{#active}}true{{/active}}{{^active}}false{{/active}}"\n data-action="toggle-submenu">\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n <i class="bi bi-chevron-down nav-arrow ms-auto"></i>\n </a>\n <div class="collapse {{#active}}show{{/active}}" id="collapse-{{id}}" data-bs-parent="#sidebar-nav-menu">\n <ul class="nav flex-column nav-submenu">\n {{#children}}\n <li class="nav-item">\n <a class="nav-link {{#active}}active{{/active}}"\n {{#action}}data-action="{{action}}"{{/action}}\n {{#href}}href="{{href}}"{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n </li>\n {{/children}}\n </ul>\n </div>\n {{/hasChildren}}\n {{^hasChildren}}\n \x3c!-- Simple item --\x3e\n <a class="nav-link {{#active}}active{{/active}} {{#disabled}}disabled{{/disabled}}"\n {{#action}}{{^disabled}}data-action="{{action}}"{{/disabled}}{{/action}}\n {{#href}}{{^disabled}}href="{{href}}"{{/disabled}}{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n {{/hasChildren}}\n </li>\n {{/isLabel}}\n {{/isSpacer}}\n {{/isDivider}}\n ',"nav-divider":'\n <li class="nav-divider-item">\n <hr class="nav-divider-line">\n </li>\n ',"nav-spacer":'\n <li class="nav-spacer-item"></li>\n ',"nav-label":'\n <li class="nav-item {{className}}">\n <div class="nav-text px-3">{{text}}</div>\n </li>\n '}}getGroupHeader(){return this.groupHeader}addMenu(e,t){return t.groupKind&&!t.header&&(t.header=this.getGroupHeader()),this.menus.set(e,{name:e,groupKind:t.groupKind||null,header:t.header||null,footer:t.footer||null,items:t.items||[],data:t.data||{},className:t.className||"sidebar sidebar-dark"}),this.activeMenuName||this._setActiveMenu(e),this}_setActiveMenu(e){this.showSearch=!1,this.activeMenuName=e;const t=this.getCurrentMenuConfig();t.className?this.setClass(t.className):this.setClass("sidebar")}async setActiveMenu(e){if(!this.menus.has(e))return console.warn(`Menu '${e}' not found`),this;const t=this.menus.get(e);if(!t.groupKind||(this.lastGroupMenu=t,this.getApp().activeGroup))return this._setActiveMenu(e),await this.render(),this.emit("menu-changed",{menuName:e,config:t,sidebar:this}),this;this.showGroupSearch()}getGroupMenu(e){if(!e)return console.warn("No group provided"),null;let t=this.lastGroupMenu,s=null;if(e._.kind)for(const[i,a]of this.menus){if(this._groupKindMatches(a.groupKind,e._.kind)){t=a;break}"any"===a.groupKind&&(s=a)}return t||s}_groupKindMatches(e,t){return!(!e||!t)&&(Array.isArray(e)?e.includes(t):e===t)}showMenuForGroup(e){if(!e)return void console.warn("No group provided");let t=this.getGroupMenu(e);if(t)return this._setActiveMenu(t.name),this.render(),this.emit("menu-changed",{menuName:t.name,config:t,sidebar:this}),this;console.warn(`No menu found for group kind: ${e.kind}`)}getMenuConfig(e){return this.menus.get(e)||null}getCurrentMenuConfig(){return this.activeMenuName?this.menus.get(this.activeMenuName):null}updateMenu(e,t){const s=this.menus.get(e);return s?(Object.assign(s,t),this.activeMenuName===e&&this.render(),this):(console.warn(`Menu '${e}' not found`),this)}removeMenu(e){if(this.menus.delete(e),this.activeMenuName===e){const e=Array.from(this.menus.keys());this.activeMenuName=e.length>0?e[0]:null,this.render()}return this}async onBeforeRender(){const e=this.getCurrentMenuConfig();if(!e)return{currentMenu:null};let t={version:this.getApp().version||null,group:this.getApp().activeGroup||null,user:this.getApp.activeUser||null};this.data={currentMenu:{header:this.renderTemplateString(e.header||"",t),footer:this.renderTemplateString(e.footer||"",t),items:this.processNavItems(e.items,e.groupKind),data:e.data,showToggle:this.showToggle}}}async onAfterRender(){this.isCollapsedState()?setTimeout(()=>this.initializeTooltips(),50):this.destroyTooltips()}setCustomView(e){return this.customView&&this.removeChild(this.customView.id),this.customView=e,e&&(e.containerId="sidebar-custom-view-container",this.addChild(e)),this.render(),this}clearCustomView(){return this.customView&&(this.removeChild(this.customView.id),this.customView=null),this.render(),this}processNavItems(e,t){const s=this.getApp(),i=s?.activeUser,a=s?.activeGroup,n=e=>{let s=e;if(e.startsWith("/")&&!e.includes("?")&&(s=`?page=${e.substring(1)||"home"}`),t&&a&&a.id){const e=s.includes("?")?"&":"?";return`${s}${e}group=${a.id}`}return s};return e.map((e,t)=>{if(""===e||"object"==typeof e&&e.divider)return{isDivider:!0,id:`divider-${t}`};if("object"==typeof e&&e.spacer)return{isSpacer:!0,id:`spacer-${t}`};const s={...e};if(s.permissions&&(!i||!i.hasPermission(s.permissions)))return null;if(s.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(s.requiresGroupKind,e))return null}if("label"===s.kind)return s.isLabel=!0,s.id||(s.id=`nav-label-${t}`),s;if(s.id||(s.id=`nav-${t}`),s.route)s.href=n(s.route);else if(s.page){const e=s.page.startsWith("/")?s.page:`/${s.page}`;s.href=n(e),s.route=s.href}return s.children?(s.children=s.children.map(e=>{const t={...e};if(t.permissions&&i&&!i.hasPermission(t.permissions))return null;if(t.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(t.requiresGroupKind,e))return null}if(t.route)t.href=n(t.route);else if(t.page){const e=t.page.startsWith("/")?t.page:`/${t.page}`;t.href=n(e),t.route=t.href}return t}).filter(e=>null!==e),s.hasChildren=!!(s.children&&s.children.length>0)):s.hasChildren=!1,s}).filter(e=>null!==e)}isItemActive(e){if(!e.route||!this.currentRoute)return!1;const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e.route),i=t(this.currentRoute);return"/"===s&&"/"===i||"/"!==s&&"/"!==i&&(i.startsWith(s)||i===s)}async updateActiveItem(e){return this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),await this.render(),this}async handleActionToggleSubmenu(e,t){const s=t.querySelector(".nav-arrow");s&&s.classList.toggle("rotated")}async handleActionToggleSidebar(e,t){this.toggleSidebar()}onActionShowGroupMenu(e,t,s){return this.setActiveMenu("group_default"),!1}async onActionDefault(e,t,s){const i=this.getCurrentMenuConfig();if(!i)return;const a=i=>{for(const n of i){if(n.action==e&&n.handler)return n.handler(e,t,s,this.getApp()),!0;if(n.children&&n.children.length>0&&a(n.children))return!0}return!1};return a(i.items)}getMenuNames(){return Array.from(this.menus.keys())}hasMenu(e){return this.menus.has(e)}clearMenus(){return this.menus.clear(),this.activeMenuName=null,this.render(),this}setMenuData(e){const t=this.getCurrentMenuConfig();return t&&(t.data={...t.data,...e},this.render()),this}getMenuData(){const e=this.getCurrentMenuConfig();return e?e.data:{}}setupRouteListeners(){const e=this.getApp();e&&e.events&&(e.events.on(["page:showing"],e=>{this.onRouteChanged(e)}),e.events.on("group:changed",e=>{this.showMenuForGroup(e.group)}),e.events.on("portal:user-changed",e=>{this.render()}))}onRouteChanged(e){if(e.page&&e.page.route){const t=e.page.route;if(this.activeMenuItem&&this.routesMatch(t,this.activeMenuItem.route))return;if(this.autoSwitchToMenuForRoute(t))return;const s=e.page.sidebarMenu||e.page.options?.sidebarMenu||null;if(s&&this.menus.has(s))return this._setActiveMenu(s),this.clearAllActiveStates(),void this.render();let i=null;for(const[e,a]of this.menus)if(!a.groupKind){i=e;break}i&&this.activeMenuName!==i&&this._setActiveMenu(i),this.clearAllActiveStates(),this.updateActiveItem(t),this.render()}}toggleSidebar(){const e=document.querySelector(".portal-container");if(!e)return;this.hideAllTooltips();const t=e.classList.contains("collapse-sidebar");return e.classList.contains("hide-sidebar")?(e.classList.remove("hide-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):t?(e.classList.remove("collapse-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):(e.classList.add("collapse-sidebar"),this.isCollapsed=!0,setTimeout(()=>this.initializeTooltips(),150)),this}setSidebarState(e){const t=document.querySelector(".portal-container");if(!t)return this;switch(t.classList.remove("collapse-sidebar","hide-sidebar"),e){case"collapsed":t.classList.add("collapse-sidebar"),this.isCollapsed=!0;break;case"hidden":t.classList.add("hide-sidebar"),this.isCollapsed=!1;break;default:this.isCollapsed=!1}return this.isCollapsed?(this.hideAllTooltips(),setTimeout(()=>this.initializeTooltips(),100)):this.destroyTooltips(),this}initializeTooltips(){return this.destroyTooltips(),this.isCollapsedState()?(this.element.querySelectorAll(".sidebar-nav .nav-link").forEach(e=>{const t=e.querySelector(".nav-text");if(t&&t.textContent.trim()){const s=t.textContent.trim();if(e.setAttribute("data-bs-toggle","tooltip"),e.setAttribute("data-bs-placement","right"),e.setAttribute("data-bs-title",s),e.setAttribute("data-bs-container","body"),window.bootstrap&&window.bootstrap.Tooltip){const t=e.getAttribute("data-tooltip-theme"),s=e.getAttribute("data-tooltip-size");let i="";t&&(i+=`tooltip-${t} `),s&&(i+=`tooltip-${s}`);const a={placement:"right",container:"body",trigger:"hover",delay:{show:500,hide:100},fallbackPlacements:["top","bottom","left"]},n=i.trim();n&&(a.customClass=n);const r=new window.bootstrap.Tooltip(e,a);e._tooltipInstance=r,e.addEventListener("click",()=>{r.hide()}),e.addEventListener("blur",()=>{r.hide()})}}}),this.addTooltipHideListeners(),this):this}destroyTooltips(){return this.removeTooltipHideListeners(),this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&(t.hide(),t.dispose()),delete e._tooltipInstance,e.removeAttribute("data-bs-toggle"),e.removeAttribute("data-bs-placement"),e.removeAttribute("data-bs-title"),e.removeAttribute("data-bs-container")}),this}getSidebarState(){const e=document.querySelector(".portal-container");return e?e.classList.contains("hide-sidebar")?"hidden":e.classList.contains("collapse-sidebar")?"collapsed":"normal":"normal"}isCollapsedState(){return"collapsed"===this.getSidebarState()}setToggleEnabled(e){return this.showToggle=e,this.render(),this}initializeMenus(e){if(e.menus)for(const t of e.menus)this.addMenu(t.name,t);else e.menu&&(e.menu.name=e.menu.name||"default",this.addMenu(e.menu.name,e.menu))}addTooltipHideListeners(){this._tooltipScrollHandler=()=>this.hideAllTooltips(),this.element.addEventListener("scroll",this._tooltipScrollHandler,{passive:!0}),this._tooltipRouteHandler=()=>this.hideAllTooltips(),this.getApp(),this._tooltipBlurHandler=()=>this.hideAllTooltips(),window.addEventListener("blur",this._tooltipBlurHandler),this._tooltipEscapeHandler=e=>{"Escape"===e.key&&this.hideAllTooltips()},document.addEventListener("keydown",this._tooltipEscapeHandler)}removeTooltipHideListeners(){this._tooltipScrollHandler&&(this.element.removeEventListener("scroll",this._tooltipScrollHandler),delete this._tooltipScrollHandler),this._tooltipBlurHandler&&(window.removeEventListener("blur",this._tooltipBlurHandler),delete this._tooltipBlurHandler),this._tooltipEscapeHandler&&(document.removeEventListener("keydown",this._tooltipEscapeHandler),delete this._tooltipEscapeHandler)}hideAllTooltips(){this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&t.hide()}),document.querySelectorAll(".tooltip.show").forEach(e=>{e.remove()})}async onBeforeDestroy(){this.destroyTooltips(),await super.onBeforeDestroy()}setupResponsiveBehavior(){const e=()=>{const e=window.innerWidth<=768,t=document.querySelector(".portal-container");t&&(e?t.classList.add("sidebar-mobile"):t.classList.remove("sidebar-mobile","sidebar-open"))};e(),window.addEventListener("resize",e)}static createDefault(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!0,autoCollapseMobile:!0,...e})}static createMinimal(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!1,autoCollapseMobile:!1,...e})}setSidebarTheme(e){return this.removeClass("sidebar-light sidebar-dark sidebar-clean"),this.sidebarTheme=e,this.addClass(e),this}show(){return this.setSidebarState("normal")}hide(){return this.setSidebarState("hidden")}collapse(){return this.setSidebarState("collapsed")}expand(){return this.setSidebarState("normal")}pulseToggle(){const e=this.element.querySelector(".sidebar-toggle");if(e){e.classList.add("pulse");const t=()=>{e.classList.remove("pulse"),e.removeEventListener("click",t)};e.addEventListener("click",t,{once:!0}),setTimeout(t,3e3)}return this}addSimpleMenuItem(e,t,s,i="bi-circle"){const a=this.menus.get(e);return a&&(a.items=a.items||[],a.items.push({text:t,route:s,icon:i}),this.activeMenuName===e&&this.render()),this}setSimpleMenu(e,t,s){const i={name:e,header:t,items:s};return this.addMenu(e,i),this.setActiveMenu(e),this}}class PageHeader extends r{constructor(e={}){super({tagName:"div",className:"page-header",...e}),this.style=e.style||"default",this.size=e.size||"md",this.showIcon=!1!==e.showIcon,this.showDescription=!1!==e.showDescription,this.showBreadcrumbs=e.showBreadcrumbs||!1,this.currentPage=null}async getTemplate(){return"minimal"===this.style?this.getMinimalTemplate():"breadcrumb"===this.style?this.getBreadcrumbTemplate():this.getDefaultTemplate()}getDefaultTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-{{data.size}}">\n <div class="page-header-main">\n <div class="page-header-info">\n {{#data.showIcon}}\n {{#data.pageIcon}}\n <div class="page-icon">\n <i class="{{data.pageIcon}}"></i>\n </div>\n {{/data.pageIcon}}\n {{/data.showIcon}}\n \n <div class="page-title-group">\n <h1 class="page-title">{{data.pageTitle}}</h1>\n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n </div>\n\n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n </div>\n {{/data.hasPage}}\n '}getMinimalTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-minimal">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n </div>\n {{/data.hasPage}}\n '}getBreadcrumbTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-breadcrumb">\n {{#data.showBreadcrumbs}}\n <nav aria-label="breadcrumb">\n <ol class="breadcrumb mb-2">\n {{#data.breadcrumbs}}\n <li class="breadcrumb-item {{#active}}active{{/active}}">\n {{#href}}<a href="{{href}}">{{label}}</a>{{/href}}\n {{^href}}{{label}}{{/href}}\n </li>\n {{/data.breadcrumbs}}\n </ol>\n </nav>\n {{/data.showBreadcrumbs}}\n \n <div class="d-flex justify-content-between align-items-start">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n \n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n \n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted mt-2">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n {{/data.hasPage}}\n '}async onBeforeRender(){await super.onBeforeRender();const e=this.currentPage,t=!!e;e&&(e.title,e.displayName,e.name,e.pageName,e.icon,e.pageIcon,e.pageDescription,e.description);const s=e?.options?.headerActions||e?.headerActions||e?.constructor?.prototype?.headerActions||[];this.data={hasPage:t,pageTitle:e?.title||e?.displayName||e?.name||e?.pageName||"",pageIcon:e?.icon||e?.pageIcon||"",pageDescription:e?.pageDescription||e?.description||"",showIcon:this.showIcon,showDescription:this.showDescription,showBreadcrumbs:this.showBreadcrumbs,breadcrumbs:e?.options?.breadcrumbs||e?.breadcrumbs||[],actions:s,hasActions:s.length>0,size:this.size},this.data}async setPage(e){this.currentPage=e,e&&await this.render()}getPage(){return this.currentPage}async onActionDefault(e,t,s){return this.currentPage&&"function"==typeof this.currentPage.onHeaderAction?(await this.currentPage.onHeaderAction(e,t,s),!0):(this.emit("action",{action:e,event:t,element:s,page:this.currentPage}),!1)}}class DeniedPage extends p{constructor(e={}){super({pageName:"Access Denied",route:"/denied",title:"Access Denied",pageIcon:"bi bi-shield-x",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-shield-x text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Access Denied</h2>\n <p class="text-muted">You don\'t have permission to access this page.</p>\n </div>\n\n {{#deniedPage}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body">\n <h6 class="card-subtitle mb-2 text-muted">Requested Page</h6>\n <h5 class="card-title">\n <i class="{{pageIcon}} me-2"></i>\n {{displayName}}\n </h5>\n {{#route}}\n <p class="card-text text-muted small">{{route}}</p>\n {{/route}}\n {{#description}}\n <p class="card-text">{{description}}</p>\n {{/description}}\n\n {{#requiredPermissions}}\n <div class="mt-3">\n <h6 class="mb-2">Required Permissions:</h6>\n {{#permissions}}\n <span class="badge bg-light text-dark me-1 mb-1">{{.}}</span>\n {{/permissions}}\n {{^permissions}}\n <span class="text-muted small">Authentication required</span>\n {{/permissions}}\n </div>\n {{/requiredPermissions}}\n </div>\n </div>\n {{/deniedPage}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n {{#showLogin}}\n <button type="button" class="btn btn-outline-primary" data-action="login">\n <i class="bi bi-box-arrow-in-right me-1"></i>\n Login\n </button>\n {{/showLogin}}\n </div>\n\n {{#currentUser}}\n <div class="text-center mt-4">\n <small class="text-muted">\n Logged in as <strong>{{username}}</strong>\n </small>\n </div>\n {{/currentUser}}\n </div>\n </div>\n </div>\n ',...e}),this.deniedPage=null,this.deniedPageOptions=null}async onParams(e={},t={}){await super.onParams(e,t),e.page?(this.deniedPage=e.page,this.deniedPageOptions=e.page.options||e.page.pageOptions||{}):t.page&&(this.deniedPageName=t.page)}setDeniedPage(e){return this.deniedPage=e,this.deniedPageOptions=e?.options||e?.pageOptions||{},this}async getViewData(){const e=this.getApp(),t=e?.activeUser||e?.getCurrentUser?.()||null;let s=null;if(this.deniedPage){const e=this.deniedPageOptions?.permissions||this.deniedPage.options?.permissions||this.deniedPage.pageOptions?.permissions;s={displayName:this.deniedPage.displayName||this.deniedPage.pageName||this.deniedPage.title||"Unknown Page",pageName:this.deniedPage.pageName,route:this.deniedPage.route,description:this.deniedPage.pageDescription||this.deniedPage.description,pageIcon:this.deniedPage.pageIcon||"bi bi-file-text",requiredPermissions:e?{permissions:Array.isArray(e)?e:[e]}:null}}else this.deniedPageName&&(s={displayName:this.deniedPageName,pageName:this.deniedPageName,pageIcon:"bi bi-file-text"});return{deniedPage:s,currentUser:t?{username:t.username||t.name||t.email||"Unknown User",name:t.name,email:t.email}:null,showLogin:!t}}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async handleActionLogin(e,t){e.preventDefault();const s=this.getApp();if(s)try{await s.showPage("login")}catch(i){try{await s.navigate("/login")}catch(a){this.emit("login-required",{returnUrl:this.deniedPage?.route||window.location.pathname}),setTimeout(()=>{s?.showInfo?.("Please contact your administrator for access.")},100)}}}async onEnter(){await super.onEnter();const e=this.deniedPage?.pageName||this.deniedPageName;e&&this.setMeta({title:`Access Denied - ${e}`}),console.warn("Access denied to page:",{page:this.deniedPage?.pageName||this.deniedPageName,route:this.deniedPage?.route,permissions:this.deniedPageOptions?.permissions,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPage(e,t){const s=new DeniedPage;return s.setDeniedPage(t),e.showPage(s)}}class NotFoundPage extends p{constructor(e={}){super({pageName:"404",route:"/404",title:"404 - Page Not Found",pageIcon:"bi bi-search",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-search text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Page Not Found</h2>\n <p class="text-muted">The page you\'re looking for doesn\'t exist.</p>\n </div>\n\n {{#path}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body text-center">\n <h6 class="card-subtitle mb-2 text-muted">Requested Path</h6>\n <code class="text-primary">{{path}}</code>\n </div>\n </div>\n {{/path}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n </div>\n </div>\n </div>\n </div>\n ',...e}),this.path=null}async onParams(e={},t={}){await super.onParams(e,t),e.path&&(this.path=e.path),t.path&&(this.path=t.path)}setInfo(e){return this.path=e||null,this}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async onEnter(){await super.onEnter(),this.path&&this.setMeta({title:`404 - ${this.path} Not Found`}),console.warn("404 Not Found:",{path:this.path,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPath(e,t){const s=new NotFoundPage;return s.setInfo(t),s.render()}}class PortalApp extends m{constructor(e={}){super(e),this.sidebarConfig=e.sidebar,this.topbarConfig=e.topbar||{},e.topnav&&!e.topbar&&(this.topbarConfig=e.topnav),this.showPageHeader=e.showPageHeader||!1,this.pageHeaderConfig=e.pageHeader||{},this.sidebar=null,this.topbar=null,this.topnav=null,this.pageHeader=null,this.tokenManager=new St,this.activeGroup=null,this.isMobile()?this.sidebarCollapsed=this.sidebarConfig.defaultCollapsed||!1:this.sidebarCollapsed=this.loadSidebarState()??(this.sidebarConfig.defaultCollapsed||!1),this.setupPageContainer(),this.toast=new Mt,this.Dialog=Pt,this.registerPage("denied",DeniedPage),this.registerPage("404",NotFoundPage)}async start(){await this.checkAuthStatus(),this.events.on("auth:unauthorized",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("auth:logout",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("browser:focus",()=>{this.activeUser&&this.tokenManager.checkAndRefreshTokens(this)}),this.events.on("portal:action",this.onPortalAction.bind(this)),this.activeUser&&await this.checkActiveGroup(),await this.setupRouter(),this.isStarted=!0,this.events.emit("app:ready",{app:this}),this.activeUser&&!this.activeUser.get("has_passkey")&&this.showPasskeySetup()}async checkAuthStatus(){const e=this.tokenManager.checkTokenStatus();if("logout"===e.action)return this.events.emit("auth:unauthorized",{app:this}),!1;if("refresh"===e.action&&!(await this.tokenManager.checkAndRefreshTokens(this)))return!1;const t=this.tokenManager.getTokenInstance();if(this.activeUser)return this.tokenManager.startAutoRefresh(this),!0;this.rest.setAuthToken(t.token);const s=new et({id:t.getUserId()}),i=await s.fetch();return i.success?(this.setActiveUser(s),this.tokenManager.startAutoRefresh(this),!0):(this.tokenManager.clearTokens(),this.events.emit("auth:unauthorized",{app:this,error:i.error}),!1)}async checkActiveGroup(){const e=new URLSearchParams(window.location.search).get("group"),t=e||this.loadActiveGroupId();if(t)try{const s=new Ze({id:t}),i=await s.fetch();if(!i.success||!i.data.status)return this.clearActiveGroup(),void console.warn("Failed to load active group:",i.statusText);this.activeGroup=s,e&&this.saveActiveGroupId(t),this.activeUser&&(this.activeUser.member=new ct,await this.activeUser.member.fetchForGroup(s.id)),this.events.emit("group:loaded",{group:this.activeGroup})}catch(s){if(console.warn("Failed to load active group:",s),e&&!this.loadActiveGroupId())this.clearActiveGroupId();else if(e){const t=this.loadActiveGroupId();if(t&&t!==e)try{const e=new Ze({id:t});await e.fetch(),this.activeGroup=e,this.events.emit("group:loaded",{group:this.activeGroup})}catch(i){console.warn("Fallback to stored group also failed:",i),this.clearActiveGroupId()}}}}async setActiveGroup(e){const t=this.activeGroup;this.activeGroup=e,e&&e.get("id")?this.saveActiveGroupId(e.get("id")):this.clearActiveGroupId(),this.activeUser&&(this.activeUser.member=new ct,await this.activeUser.member.fetchForGroup(e.id)),this.events.emit("group:changed",{group:e,previousGroup:t,app:this});const s=this.getCurrentPage();return s&&s.onGroupChange(e),this.router.updateUrl({group:e.id},{replace:!0}),this}getActiveGroup(){return this.activeGroup}async clearActiveGroup(){const e=this.activeGroup;return this.activeGroup=null,this.clearActiveGroupId(),this.events.emit("group:cleared",{previousGroup:e,app:this}),this}saveActiveGroupId(e){try{const t=this.getActiveGroupStorageKey();localStorage.setItem(t,e.toString())}catch(t){console.warn("Failed to save active group ID:",t)}}loadActiveGroupId(){try{const e=this.getActiveGroupStorageKey();return localStorage.getItem(e)}catch(e){return console.warn("Failed to load active group ID:",e),null}}clearActiveGroupId(){try{const e=this.getActiveGroupStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear active group ID:",e)}}getActiveGroupStorageKey(){return"active_group_id"}setPortalProfile(e){try{localStorage.setItem("portal_profile",e)}catch(t){console.warn("Failed to save portal profile:",t)}}needsGroupSelection(){return!this.activeGroup}setupPageContainer(){const e="string"==typeof this.container?document.querySelector(this.container):this.container;if(!e)throw new Error(`Portal container not found: ${this.container}`);const t=this.sidebarConfig&&Object.keys(this.sidebarConfig).length>0,s=this.topbarConfig&&Object.keys(this.topbarConfig).length>0,i=this.showPageHeader?'\n <div class="portal-content" id="portal-content">\n <div id="page-header"></div>\n <div id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n </div>\n ':'\n <div class="portal-content" id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n ';e.innerHTML=`\n <div class="portal-layout hide-sidebar">\n ${t?'<div id="portal-sidebar"></div>':""}\n <div class="portal-body">\n ${s?'<div id="portal-topnav"></div>':""}\n ${i}\n </div>\n </div>\n `,this.pageContainer="#page-container",e.classList.add("portal-container"),this.setupPortalComponents(),this.applySidebarState(e)}async setupPortalComponents(){await this.setupSidebar(),await this.setupTopbar(),await this.setupPageHeader(),this.setupPortalEvents()}async setupSidebar(){this.sidebarConfig&&0!==Object.keys(this.sidebarConfig).length&&(this.sidebar=new Sidebar({containerId:"portal-sidebar",...this.sidebarConfig}),await this.sidebar.render())}async setupTopbar(){this.topbarConfig&&0!==Object.keys(this.topbarConfig).length&&(this.topbar=new At({containerId:"portal-topnav",brandText:this.topbarConfig.brand||this.brand||this.title,brandRoute:this.topbarConfig.brandRoute||"/",brandIcon:this.topbarConfig.brandIcon||this.brandIcon,navItems:this.topbarConfig.leftItems||[],rightItems:this.topbarConfig.rightItems||[],displayMode:this.topbarConfig.displayMode||"both",showSidebarToggle:this.topbarConfig.showSidebarToggle||!1,...this.topbarConfig}),await this.topbar.render(),this.topnav=this.topbar)}async setupPageHeader(){if(!this.showPageHeader)return;this.pageHeader=new PageHeader({containerId:"page-header",style:this.pageHeaderConfig.style||"default",showIcon:!1!==this.pageHeaderConfig.showIcon,showDescription:!1!==this.pageHeaderConfig.showDescription,showBreadcrumbs:this.pageHeaderConfig.showBreadcrumbs||!1,...this.pageHeaderConfig});const e=document.getElementById("page-header");e&&await this.pageHeader.render(!0,e)}setupPortalEvents(){if(document.addEventListener("click",e=>{e.target.closest('[data-action="toggle-sidebar"]')&&(e.preventDefault(),this.toggleSidebar())}),window.ResizeObserver){const e=new ResizeObserver(()=>{this.handleResponsive()});e.observe(document.body),this._resizeObserver=e}else this._resizeHandler=()=>this.handleResponsive(),window.addEventListener("resize",this._resizeHandler);this.handleResponsive()}toggleSidebar(){if(!this.sidebar)return;const e=document.querySelector(".portal-container"),t=this.isMobile();t?e.classList.toggle("hide-sidebar"):(e.classList.toggle("collapse-sidebar"),this.sidebarCollapsed=!this.sidebarCollapsed,this.saveSidebarState(this.sidebarCollapsed)),this.events.emit("sidebar:toggled",{collapsed:this.sidebarCollapsed,mobile:t})}handleResponsive(){const e=document.querySelector(".portal-container");if(!e)return;const t=this.isMobile();t?(e.classList.add("mobile-layout"),e.classList.contains("hide-sidebar")||e.classList.add("hide-sidebar")):e.classList.remove("mobile-layout","hide-sidebar"),this.events.emit("responsive:changed",{mobile:t})}getPortalContainer(){return document.querySelector(".portal-container")}isMobile(){return window.innerWidth<768}hasMobileLayout(){return this.getPortalContainer().classList.contains("mobile-layout")}async showPage(e,t={},s={},i={}){const a=await super.showPage(e,t,s,i);return this.hasMobileLayout()&&this.getPortalContainer().classList.add("hide-sidebar"),this.currentPage&&this.updateNavigation(this.currentPage),a}updateNavigation(e){this.sidebar&&this.sidebar.setActivePage&&this.sidebar.setActivePage(e.route),this.topbar&&this.topbar.setActivePage&&this.topbar.setActivePage(e.route),this.pageHeader&&this.pageHeader.setPage(e),this.events.emit("portal:page-changed",{page:e})}setActiveUser(e){this.activeUser=e,this.topbar&&this.topbar.setUser(e),this.events.emit("portal:user-changed",{user:e})}getActiveUser(){return this.activeUser}saveSidebarState(e){try{const t=this.getSidebarStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.warn("Failed to save sidebar state:",t)}}loadSidebarState(){try{const e=this.getSidebarStorageKey(),t=localStorage.getItem(e);return null!==t?JSON.parse(t):null}catch(e){return console.warn("Failed to load sidebar state:",e),null}}getSidebarStorageKey(){return`${this.title?this.title.replace(/\s+/g,"_").toLowerCase():"portal_app"}_sidebar_collapsed`}applySidebarState(e=null){e||(e=document.querySelector(".portal-container")),e&&(this.sidebarCollapsed?e.classList.add("collapse-sidebar"):e.classList.remove("collapse-sidebar"))}clearSidebarState(){try{const e=this.getSidebarStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear sidebar state:",e)}}async changePassword(){const e=await this.showForm({title:"Change Password",fields:[{name:"current_password",type:"password",label:"Current Password",required:!0,showToggle:!0,strengthMeter:!0,capsLockWarning:!0},{name:"new_password",type:"password",label:"New Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{autocomplete:"new-password"}},{name:"confirm_password",type:"password",label:"Confirm Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{}}],submitLabel:"Change Password"});e&&(e.new_password===e.confirm_password?200===(await this.activeUser.save(e)).status?this.toast.success("Password changed successfully"):this.toast.error("Failed to change password"):this.toast.error("Passwords do not match"))}onPortalAction(e){switch(e.action){case"logout":this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null);break;case"profile":this.showProfile();break;case"change-password":this.changePassword();break;default:console.warn(`Unknown portal action: ${e}`)}}async showProfile(){if(this.activeUser)try{const{UserProfileView:e}=await import("./chunks/index-Aq9ke4vg.js"),t=new e({model:this.activeUser});await Pt.showDialog({body:t,header:null,size:"lg",noBodyPadding:!0,centered:!1})}catch(e){console.error("Error showing profile:",e),this.showError("Failed to load profile")}else this.showError("No user is currently logged in")}async showPasskeySetup(){if(!localStorage.getItem("passkey_setup_dismissed"))try{const{PasskeySetupView:e}=await import("./chunks/index-Aq9ke4vg.js"),t=new e;t.on("dismiss",()=>{const e=t.element?.closest(".modal");if(e){const t=bootstrap.Modal.getInstance(e);t&&t.hide()}}),await Pt.showDialog({header:null,body:t,size:"sm",centered:!0,buttons:[]})}catch(e){console.error("Error showing passkey setup:",e)}}async destroy(){this.activeGroup=null,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.topbar&&(await this.topbar.destroy(),this.topbar=null,this.topnav=null),this.sidebar&&(await this.sidebar.destroy(),this.sidebar=null),await super.destroy()}static create(e={}){return new PortalApp(e)}}class FormPage extends p{constructor(e={}){super({title:"Form Page",description:"A page for submitting forms",icon:"form",fields:[],template:'<div data-container="form-view-container"></div>',className:"form-page container-sm",...e})}async onInit(){await super.onInit(),await this.recreateFormView()}async onEnter(){await super.onEnter(),this.formView&&await this.recreateFormView()}async onGroupChange(e){this.formView&&await this.recreateFormView()}async getModel(){return this.model?this.model:this.getApp().activeGroup?this.getApp().activeGroup:null}async recreateFormView(){this.formView&&(await this.formView.destroy(),this.removeChild(this.formView)),this.formView=new It({containerId:"form-view-container",fields:this.options.fields,autosaveModelField:!0}),this.addChild(this.formView);const e=await this.getModel();e&&this.formView.setModel(e)}}const zt=new class{constructor(){this.formatter=o,this.compiledTemplates=/* @__PURE__ */new Map}render(e,t,s={}){return l.render(e,t,s)}compile(e){const t=l.parse(e);return this.compiledTemplates.set(e,t),t}renderCompiled(e,t,s={}){return l.render(e,t,s)}clearCache(){this.compiledTemplates.clear(),l.clearCache()}cache(e,t){return{key:e,template:t,compiled:this.compile(t)}}getCached(e){for(const[t,s]of this.compiledTemplates)if(t===e||s===e)return{key:e,template:t,compiled:s};return null}registerFormatter(e,t){return this.formatter.register(e,t),this}hasPipes(e){return/\{\{[{]?[^}|]+\|[^}]+\}[}]?\}/.test(e)}processData(e,t){const s={...e};for(const[i,a]of Object.entries(t))if(e&&"function"==typeof e.get)s[i]=e.get(`${i}|${a}`);else{const t=this.getValueFromPath(e,i);s[i]=this.formatter.pipe(t,a)}return s}getValueFromPath(e,t){if(!e||!t)return;if(e&&"function"==typeof e.get)return e.get(t);const s=t.split(".");let i=e;for(const a of s){if(null==i)return;i=!isNaN(a)&&Array.isArray(i)?i[parseInt(a)]:i[a]}return i}processTemplate(e,t){return{template:e,data:t}}};Kt.install({level:"warn"});const qt="MOJO",Jt="web-mojo",Wt={FRAMEWORK_NAME:qt,PACKAGE_NAME:Jt};export{e as BUILD_TIME,y as BundleByOptions,S as ChatInputView,A as ChatMessageView,P as ChatView,f as Collection,M as CommonEventFields,C as CommonScopeOptions,L as ComparatorOptions,Kt as ConsoleSilencer,g as ContextMenu,kt as DataView,c as DataWrapper,Pt as Dialog,dt as DjangoLookups,k as EmailDomain,I as EmailDomainForms,T as EmailDomainList,D as EmailTemplate,x as EmailTemplateForms,G as EmailTemplateList,b as EventBus,d as EventDelegate,qt as FRAMEWORK_NAME,Ke as File,$e as FileForms,ze as FileList,qe as FileManager,Je as FileManagerForms,We as FileManagerList,E as FilePreviewView,Ye as FileUpload,FormPage,It as FormView,_ as GeoLocatedIP,F as GeoLocatedIPList,Ze as Group,tt as GroupForms,Xe as GroupList,N as Incident,R as IncidentEvent,V as IncidentEventForms,O as IncidentEventList,H as IncidentForms,U as IncidentHistory,j as IncidentHistoryList,B as IncidentList,K as IncidentRule,$ as IncidentRuleList,z as IncidentRuleSet,q as IncidentRuleSetList,J as IncidentStats,W as Job,Y as JobEvent,Q as JobEventList,X as JobForms,Z as JobList,ee as JobLog,te as JobLogList,se as JobRunner,ie as JobRunnerForms,ae as JobRunnerList,ne as JobsEngineStats,ht as LOOKUPS,Ct as ListView,Lt as ListViewItem,ut as Log,pt as LogList,h as MOJOUtils,re as Mailbox,oe as MailboxForms,le as MailboxList,ce as MatchByOptions,ct as Member,gt as MemberForms,mt as MemberList,de as MetricsForms,he as MetricsPermission,ue as MetricsPermissionList,w as Model,zt as MustacheFormatter,Jt as PACKAGE_NAME,p as Page,xt as PasskeySetupView,PortalApp,Qe as ProgressView,pe as PushConfig,ge as PushConfigForms,me as PushConfigList,be as PushDelivery,ve as PushDeliveryList,fe as PushDevice,we as PushDeviceList,ye as PushTemplate,Se as PushTemplateForms,Ae as PushTemplateList,u as Rest,v as Router,Pe as Rule,Me as RuleForms,Ce as RuleList,Le as RuleSet,ke as RuleSetForms,Ie as RuleSetList,Te as S3Bucket,De as S3BucketForms,xe as S3BucketList,Ge as SentMessage,Ee as SentMessageForms,_e as SentMessageList,Sidebar,yt as SimpleSearchView,Fe as TabView,Ne as TablePage,bt as TableRow,vt as TableView,Re as Ticket,Ve as TicketCategories,Oe as TicketForms,He as TicketList,Ue as TicketNote,je as TicketNoteList,Mt as ToastService,St as TokenManager,At as TopNav,et as User,st as UserDataView,it as UserDevice,at as UserDeviceList,nt as UserDeviceLocation,rt as UserDeviceLocationList,ot as UserForms,lt as UserList,Gt as UserProfileView,t as VERSION,s as VERSION_INFO,i as VERSION_MAJOR,a as VERSION_MINOR,n as VERSION_REVISION,Be as ValueTypeOptions,r as View,m as WebApp,Dt as WebSocketClient,Tt as applyFileDropMixin,o as dataFormatter,Wt as default,ft as formatFilterDisplay,$t as installConsoleSilencer,wt as parseFilterKey};
1
+ import{B as e,V as t,a as s,b as i,c as a,d as n}from"./chunks/version-CaiqhdME.js";import{V as r,d as o,a as l}from"./chunks/Collection-r1ACzUeh.js";import{C as c,D as d,c as h,b as u,M as p,r as g}from"./chunks/Collection-r1ACzUeh.js";import{P as m}from"./chunks/ContextMenu-BwJJ4QJE.js";import{C as b}from"./chunks/ContextMenu-BwJJ4QJE.js";import{W as v}from"./chunks/WebApp-C82womPC.js";import{E as f,R as w}from"./chunks/WebApp-C82womPC.js";import{B as y,C as S,a as A,b as P,c as M,d as C,e as L,E as I,f as k,g as T,h as D,i as x,j as G,F as E,G as _,k as F,I as N,l as V,m as R,n as O,o as H,p as U,q as B,r as j,s as K,t as $,u as z,v as q,w as J,J as W,x as Y,y as Q,z as X,A as Z,D as ee,H as te,K as se,L as ie,M as ae,N as ne,O as re,P as oe,Q as le,R as ce,S as de,T as he,U as ue,V as pe,W as ge,X as me,Y as be,Z as ve,_ as fe,$ as we,a0 as ye,a1 as Se,a2 as Ae,a3 as Pe,a4 as Me,a5 as Ce,a6 as Le,a7 as Ie,a8 as ke,a9 as Te,aa as De,ab as xe,ac as Ge,ad as Ee,ae as _e,af as Fe,ag as Ne,ah as Ve,ai as Re,aj as Oe,ak as He,al as Ue,am as Be,an as je}from"./chunks/ChatView-DH42WXgV.js";import{G as Ke,D as $e,c as ze,T as qe,U as Je}from"./chunks/Dialog-BVCCpLPw.js";import{F as We,d as Ye,e as Qe,f as Xe,g as Ze,h as et,i as tt,j as st,P as it,k as at,l as nt,b as rt,m as ot,a as lt,n as ct,o as dt}from"./chunks/Dialog-BVCCpLPw.js";import{b as ht}from"./chunks/TableView-DemRVhnX.js";import{D as ut,L as pt,c as gt,d as mt,e as bt,M as vt,a as ft,T as wt,f as yt,p as St}from"./chunks/TableView-DemRVhnX.js";import{S as At,T as Pt,a as Mt}from"./chunks/TokenManager-IlBEFXqZ.js";import{a as Ct,L as Lt}from"./chunks/ListView-B0QbqSPv.js";import{default as It}from"./chunks/DataView-_CACqzRt.js";import{F as kt}from"./chunks/FormView-Dw7HDwzy.js";import{a as Tt}from"./chunks/FormView-Dw7HDwzy.js";import{W as Dt}from"./chunks/WebSocketClient-QaCUN3EQ.js";import{P as xt,U as Gt}from"./chunks/UserProfileView-tcBT6XcE.js";const Et={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},_t=Object.freeze({silent:0,error:1,warn:2,info:3,log:3,debug:4,trace:5,all:5}),Ft=(()=>{try{if(void 0!==import.meta&&import.meta&&Et)return!1}catch{}if("undefined"!=typeof globalThis&&void 0!==globalThis.__DEV__)try{return!!globalThis.__DEV__}catch{}return!("undefined"==typeof process||!process||"object"!=typeof process.env||"string"!=typeof process.env.NODE_ENV)&&"production"!==process.env.NODE_ENV})(),Nt="undefined"!=typeof window&&"undefined"!=typeof document,Vt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:global,Rt=Vt.console||{},Ot={};let Ht=!1,Ut=null;function Bt(e){if("number"==typeof e){const t=_t.silent,s=_t.trace;return Math.min(Math.max(e,t),s)}if("string"==typeof e){const t=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(_t,t))return _t[t]}return null}function jt(e,t){const s=Ot[e]||Rt[e]||(()=>{});return function(...e){if(Ut>=t)return s.apply(Rt,e)}}const Kt={install(e={}){if(Ht)return e&&void 0!==e.level&&this.setLevel(e.level,{persist:!!e.persist}),this;if(!Vt||!Rt)return Ht=!0,this;Ut=function(e){const t=Bt(e);if(null!==t)return t;const s=function(){if(!Nt||"undefined"==typeof location||!location.search)return null;try{const e=new URLSearchParams(location.search),t=["logLevel","loglevel","mojoLog"];for(const s of t){const t=e.get(s);if(null!=t){const e=Bt(t);if(null!==e)return e}}}catch{}return null}();if(null!==s)return s;const i=function(){if(!Nt||!("localStorage"in Vt))return null;try{const e=Vt.localStorage.getItem("MOJO_LOG_LEVEL");if(null!=e){const t=Bt(e);if(null!==t)return t}}catch{}return null}();return null!==i?i:Bt(Ft?"debug":"warn")}(e.level);const t=function(){const e={...Rt},t={error:_t.error,warn:_t.warn,info:_t.info,log:_t.info,dir:_t.info,table:_t.info,debug:_t.debug,group:_t.debug,groupCollapsed:_t.debug,groupEnd:_t.debug,time:_t.debug,timeEnd:_t.debug,timeLog:_t.debug,trace:_t.trace};for(const s of Object.keys(t))Ot[s]=Rt[s]||(()=>{}),e[s]=jt(s,t[s]);return Ot.assert=Rt.assert||(()=>{}),e.assert=function(){const e=Ot.assert||Rt.assert||(()=>{});return function(t,...s){if(!t)return Ut>=_t.error?e.apply(Rt,[t,...s]):void 0}}(),e}();return Vt.console=t,Ht=!0,Vt.MOJOConsoleSilencer=this,this},uninstall(){if(!Ht)return this;try{Vt.console=Rt}catch{}return Ht=!1,this},setLevel(e,{persist:t=!1}={}){const s=Bt(e);return null===s||(Ut=s,t&&function(e){if(Nt&&"localStorage"in Vt)try{const t="string"==typeof e?e:null===e?null:Object.entries(_t).find(([,t])=>t===e)?.[0]??null;t?Vt.localStorage.setItem("MOJO_LOG_LEVEL",t):Vt.localStorage.removeItem("MOJO_LOG_LEVEL")}catch{}}(e)),this},getLevel:()=>Ut,getLevelName(){const e=Object.entries(_t).find(([,e])=>e===Ut);return e?e[0]:null},criticalOnly({persist:e=!1}={}){return this.setLevel("warn",{persist:e})},errorsOnly({persist:e=!1}={}){return this.setLevel("error",{persist:e})},silent({persist:e=!1}={}){return this.setLevel("silent",{persist:e})},verbose({persist:e=!1}={}){return this.setLevel(Ft?"debug":"info",{persist:e})},allowAll({persist:e=!1}={}){return this.setLevel("trace",{persist:e})},withTemporaryLevel(e,t){const s=Ut,i=Bt(e);if(null===i||"function"!=typeof t)return t?.();Ut=i;try{return t()}finally{Ut=s}},LEVELS:_t},$t=e=>Kt.install(e);class GroupSearchView extends At{constructor(e={}){super({...e,className:`group-search-view ${e.className||""}`.trim()}),this.showKind=void 0===e.showKind||e.showKind,this.parentField=e.parentField||"parent",this.kindField=e.kindField||"kind",this.treeData=[],this.flattenedItems=[],this.showLines=void 0===e.showLines||e.showLines}buildTreeHierarchy(e){if(!e||0===e.length)return[];const t=/* @__PURE__ */new Map;e.forEach(e=>{t.has(e.id)||t.set(e.id,{...e,children:[],level:0,hasChildren:!1});const s=e[this.parentField];s&&s.id&&!t.has(s.id)&&t.set(s.id,{...s,children:[],level:0,hasChildren:!1})});const s=[];t.forEach((i,a)=>{const n=e.find(e=>e.id===a)||i,r=n[this.parentField]?.id;if(r&&t.has(r)){const e=t.get(r);e.children.push(i),e.hasChildren=!0}else s.push(i)});const i=(e,t=0)=>{e.forEach(e=>{e.level=t,e.children.length>0&&(e.children.sort((e,t)=>(e.name||"").localeCompare(t.name||"")),i(e.children,t+1))})};return s.sort((e,t)=>(e.name||"").localeCompare(t.name||"")),i(s),s}flattenTree(e,t=[],s=[]){return e.forEach((i,a)=>{i._isLastChild=a===e.length-1,i._ancestorLastFlags=[...s];const n=s.every(e=>e);if(i._isLastDescendant=n&&i._isLastChild&&(!i.children||0===i.children.length),t.push(i),i.children&&i.children.length>0){const e=[...s,i._isLastChild];this.flattenTree(i.children,t,e)}}),t}computeVerticalLines(e){for(let t=0;t<e.length;t++){const s=e[t];s._continueVertical=[];for(let i=0;i<s.level;i++){let a=!1;for(let s=t+1;s<e.length;s++){const t=e[s];if(t.level===i+1){a=!0;break}if(t.level<=i)break}s._continueVertical[i]=a}}}updateFilteredItems(){if(!this.collection)return this.filteredItems=[],this.treeData=[],void(this.flattenedItems=[]);const e=this.collection.toJSON();this.treeData=this.buildTreeHierarchy(e),this.flattenedItems=this.flattenTree(this.treeData),this.computeVerticalLines(this.flattenedItems),this.filteredItems=this.flattenedItems,this.updateResultsView()}getDefaultItemTemplate(){return'\n <div class="tree-item-content">\n <div class="tree-item-name">{{name}}</div>\n {{#showKind}}\n <div class="tree-item-kind">{{kind}}</div>\n {{/showKind}}\n </div>\n '}processItemTemplate(e){let t=this.itemTemplate;t=t.replace(/\{\{(\w+)\}\}/g,(t,s)=>"showKind"===s?this.showKind?"true":"":this.getNestedValue(e,s)||""),t=this.showKind?t.replace(/\{\{#showKind\}\}(.*?)\{\{\/showKind\}\}/gs,"$1"):t.replace(/\{\{#showKind\}\}.*?\{\{\/showKind\}\}/gs,"");let s="";if(this.showLines&&e.level>0)for(let i=0;i<e.level;i++)i===e.level-1?s+=`<span class="${e._isLastChild?"tree-seg tree-seg-last":"tree-seg tree-seg-mid"}"></span>`:s+=e._continueVertical&&e._continueVertical[i]?'<span class="tree-seg tree-seg-vert"></span>':'<span class="tree-seg"></span>';return`\n <div class="tree-item-wrapper${e.hasChildren?" has-children":""}${e._isLastChild?" is-last-child":""}" data-tree-level="${e.level}">\n <div class="tree-lines">\n ${s}\n </div>\n <div class="tree-item-body flex-grow-1">\n ${t}\n </div>\n </div>\n `}getRootItems(){return this.treeData}getNodeChildren(e){const t=(e,s)=>{for(const i of e){if(i.id===s)return i.children;if(i.children.length>0){const e=t(i.children,s);if(e)return e}}return null};return t(this.treeData,e)||[]}}class Sidebar extends r{constructor(e={}){super({tagName:"nav",className:"sidebar",id:"sidebar",...e}),this.menus=/* @__PURE__ */new Map,this.activeMenuName=null,this.currentRoute=null,this.showToggle=e.showToggle,this.isCollapsed=!1,this.sidebarTheme=e.theme||"sidebar-light",this.customView=null,this.options.groupHeader&&(this.groupHeader=this.options.groupHeader),this.groupSelectorMode=e.groupSelectorMode||"inline",this.groupSelectorDialog=null,this.sidebarTheme&&this.addClass(this.sidebarTheme),this.initializeMenus(e),this.setupRouteListeners(),!1!==e.autoCollapseMobile&&this.setupResponsiveBehavior()}groupHeader='\n {{#group.parent}}\n <div class="sidebar-parent-bar" data-action="select-group-parent">\n <div class="parent-info">\n <span class="parent-label">{{group.parent.kind}}:</span>\n <span class="parent-name collapsed-hidden">{{group.parent.name}}</span>\n </div>\n <i class="bi bi-chevron-down parent-expand collapsed-hidden"></i>\n </div>\n {{/group.parent}}\n <div class="sidebar-selected-group-row" data-action="show-group-search">\n <div class="selected-group-info">\n <div class=\'selected-group-name collapsed-hidden\'>{{group.name}}</div>\n <div class=\'selected-group-meta collapsed-hidden\'>\n <span class="selected-group-kind">{{group.kind}}</span>\n </div>\n </div>\n <i class="bi bi-chevron-down selected-group-chevron collapsed-hidden"></i>\n </div>\n ';async onInit(){await super.onInit();const e=this.getApp(),t=e?.router;if(t){const e=t.getCurrentPath();e&&this.autoSwitchToMenuForRoute(e)}this.initializeTooltips(),this.searchView=new GroupSearchView({noAppend:!0,showExitButton:!0,headerText:"Select Group",containerId:"sidebar-search-container",Collection:Ke,itemTemplate:'\n <div class="p-3 border-bottom">\n <div class="fw-semibold text-dark">{{name}}</div>\n <small class="text-muted">#{{id}} {{kind}}</small>\n </div>\n '}),this.addChild(this.searchView),this.searchView.on("item:selected",e=>{this.getApp().setActiveGroup(e.model)}),this.searchView.on("exit",e=>{this.hideGroupSearch()})}showGroupSearch(){"dialog"===this.groupSelectorMode?this.showGroupSearchDialog():(this.setClass("sidebar"),this.showSearch=!0,this.render())}hideGroupSearch(){"dialog"===this.groupSelectorMode?this.groupSelectorDialog&&this.groupSelectorDialog.hide():(this.setClass("sidebar"),this.showSearch=!1,this.render())}onActionShowGroupSearch(){this.showGroupSearch()}async onActionSelectGroupParent(){const e=this.getApp().activeGroup;if(await $e.confirm(`Are you sure you want to navigate to the '${e.get("parent.name")}'?`)){this.getApp().showLoading();let t=new ze({id:e.get("parent.id")});await t.fetch(),this.getApp().setActiveGroup(t),this.getApp().hideLoading()}}async showGroupSearchDialog(){const e=new Ke,t=new GroupSearchView({Collection:Ke,collection:e,searchFields:["name"],headerText:null,searchPlaceholder:"Search groups...",headerIcon:null,maxHeight:Math.min(600,window.innerHeight-200),showExitButton:!1,showKind:!0,parentField:"parent",kindField:"kind",autoExpandRoot:!0,autoExpandAll:!1,indentSize:20,showLines:!0});this.groupSelectorDialog=new $e({body:t,size:"md",header:null,noBodyPadding:!0,scrollable:!1,buttons:[],closeButton:!0}),t.on("item:selected",e=>{this.getApp().setActiveGroup(e.model),this.groupSelectorDialog&&this.groupSelectorDialog.hide()}),this.groupSelectorDialog.on("hidden",()=>{this.groupSelectorDialog.destroy(),this.groupSelectorDialog=null}),await this.groupSelectorDialog.render(!0,document.body),this.groupSelectorDialog.show()}autoSwitchToMenuForRoute(e){for(const[t,s]of this.menus)if((!s.groupKind||this.getApp().activeGroup)&&this.menuContainsRoute(s,e))return this._setActiveMenu(t),this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),this.render(),this.emit("menu-auto-switched",{menuName:t,route:e,config:s,sidebar:this}),!0;return!1}clearAllActiveStates(){for(const[e,t]of this.menus)for(const s of t.items||[])if(s.active=!1,s.children)for(const e of s.children)e.active=!1}setActiveItemByRoute(e){const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e);for(const[i,a]of this.menus)if(!a.groupKind||this.getApp().activeGroup)for(const e of a.items||[]){if(e.route){const i=t(e.route);if(this.routesMatch(s,i))return e.active=!0,this.activeMenuItem=e,!0}if(e.children)for(const i of e.children)if(i.route){const a=t(i.route);if(this.routesMatch(s,a))return i.active=!0,e.active=!0,!0}}return!1}menuContainsRoute(e,t){const s=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},i=s(t);for(const a of e.items||[]){if(a.route){const e=s(a.route);if(this.routesMatch(i,e))return!0}if(a.children)for(const e of a.children)if(e.route){const t=s(e.route);if(this.routesMatch(i,t))return!0}}return!1}routesMatch(e,t){return this.getApp().router.doRoutesMatch(e,t)}getTemplate(){return this.customView?'<div class="sidebar-container" id="sidebar-custom-view-container"></div>':this.showSearch?this.getSearchTemplate():this.getMenuTemplate()}getSearchTemplate(){return'\n <div class="sidebar-container" id="sidebar-search-container">\n </div>\n '}getMenuTemplate(){return'\n <div class="sidebar-container">\n {{#data.currentMenu}}\n \x3c!-- Header --\x3e\n {{#header}}\n <div class="sidebar-header">\n {{{header}}}\n {{#showToggle}}\n <button class="sidebar-toggle" data-action="toggle-sidebar"\n aria-label="Toggle Sidebar">\n <i class="bi bi-chevron-left toggle-icon"></i>\n <i class="bi bi-chevron-right toggle-icon"></i>\n </button>\n {{/showToggle}}\n </div>\n {{/header}}\n\n \x3c!-- Navigation Items --\x3e\n <div class="sidebar-body">\n <ul class="nav nav-pills flex-column sidebar-nav" id="sidebar-nav-menu">\n {{#items}}\n {{>nav-item}}\n {{/items}}\n </ul>\n </div>\n\n \x3c!-- Footer --\x3e\n {{#footer}}\n <div class="sidebar-footer">\n {{{footer}}}\n </div>\n {{/footer}}\n {{/data.currentMenu}}\n\n {{^data.currentMenu}}\n <div class="sidebar-empty">\n <p class="text-danger text-center">No menu configured</p>\n </div>\n {{/data.currentMenu}}\n </div>\n '}getPartials(){return{"nav-item":'\n {{#isDivider}}\n {{>nav-divider}}\n {{/isDivider}}\n {{#isSpacer}}\n {{>nav-spacer}}\n {{/isSpacer}}\n {{#isLabel}}\n {{>nav-label}}\n {{/isLabel}}\n\n {{^isDivider}}\n {{^isSpacer}}\n {{^isLabel}}\n <li class="nav-item">\n {{#hasChildren}}\n \x3c!-- Item with submenu --\x3e\n <a class="nav-link {{#active}}active{{/active}} has-children collapsed"\n data-bs-toggle="collapse"\n href="#collapse-{{id}}"\n role="button"\n aria-expanded="{{#active}}true{{/active}}{{^active}}false{{/active}}"\n data-action="toggle-submenu">\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n <i class="bi bi-chevron-down nav-arrow ms-auto"></i>\n </a>\n <div class="collapse {{#active}}show{{/active}}" id="collapse-{{id}}" data-bs-parent="#sidebar-nav-menu">\n <ul class="nav flex-column nav-submenu">\n {{#children}}\n <li class="nav-item">\n <a class="nav-link {{#active}}active{{/active}}"\n {{#action}}data-action="{{action}}"{{/action}}\n {{#href}}href="{{href}}"{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n </li>\n {{/children}}\n </ul>\n </div>\n {{/hasChildren}}\n {{^hasChildren}}\n \x3c!-- Simple item --\x3e\n <a class="nav-link {{#active}}active{{/active}} {{#disabled}}disabled{{/disabled}}"\n {{#action}}{{^disabled}}data-action="{{action}}"{{/disabled}}{{/action}}\n {{#href}}{{^disabled}}href="{{href}}"{{/disabled}}{{/href}}>\n {{#icon}}<i class="{{icon}} me-2"></i>{{/icon}}\n <span class="nav-text">{{text}}</span>\n {{#badge}}\n <span class="{{badge.class}} ms-auto">{{badge.text}}</span>\n {{/badge}}\n </a>\n {{/hasChildren}}\n </li>\n {{/isLabel}}\n {{/isSpacer}}\n {{/isDivider}}\n ',"nav-divider":'\n <li class="nav-divider-item">\n <hr class="nav-divider-line">\n </li>\n ',"nav-spacer":'\n <li class="nav-spacer-item"></li>\n ',"nav-label":'\n <li class="nav-item {{className}}">\n <div class="nav-text px-3">{{text}}</div>\n </li>\n '}}getGroupHeader(){return this.groupHeader}addMenu(e,t){return t.groupKind&&!t.header&&(t.header=this.getGroupHeader()),this.menus.set(e,{name:e,groupKind:t.groupKind||null,header:t.header||null,footer:t.footer||null,items:t.items||[],data:t.data||{},className:t.className||"sidebar sidebar-dark"}),this.activeMenuName||this._setActiveMenu(e),this}_setActiveMenu(e){this.showSearch=!1,this.activeMenuName=e;const t=this.getCurrentMenuConfig();t.className?this.setClass(t.className):this.setClass("sidebar")}async setActiveMenu(e){if(!this.menus.has(e))return console.warn(`Menu '${e}' not found`),this;const t=this.menus.get(e);if(!t.groupKind||(this.lastGroupMenu=t,this.getApp().activeGroup))return this._setActiveMenu(e),await this.render(),this.emit("menu-changed",{menuName:e,config:t,sidebar:this}),this;this.showGroupSearch()}getGroupMenu(e){if(!e)return console.warn("No group provided"),null;let t=this.lastGroupMenu,s=null;if(e._.kind)for(const[i,a]of this.menus){if(this._groupKindMatches(a.groupKind,e._.kind)){t=a;break}"any"===a.groupKind&&(s=a)}return t||s}_groupKindMatches(e,t){return!(!e||!t)&&(Array.isArray(e)?e.includes(t):e===t)}showMenuForGroup(e){if(!e)return void console.warn("No group provided");let t=this.getGroupMenu(e);if(t)return this._setActiveMenu(t.name),this.render(),this.emit("menu-changed",{menuName:t.name,config:t,sidebar:this}),this;console.warn(`No menu found for group kind: ${e.kind}`)}getMenuConfig(e){return this.menus.get(e)||null}getCurrentMenuConfig(){return this.activeMenuName?this.menus.get(this.activeMenuName):null}updateMenu(e,t){const s=this.menus.get(e);return s?(Object.assign(s,t),this.activeMenuName===e&&this.render(),this):(console.warn(`Menu '${e}' not found`),this)}removeMenu(e){if(this.menus.delete(e),this.activeMenuName===e){const e=Array.from(this.menus.keys());this.activeMenuName=e.length>0?e[0]:null,this.render()}return this}async onBeforeRender(){const e=this.getCurrentMenuConfig();if(!e)return{currentMenu:null};let t={version:this.getApp().version||null,group:this.getApp().activeGroup||null,user:this.getApp.activeUser||null};this.data={currentMenu:{header:this.renderTemplateString(e.header||"",t),footer:this.renderTemplateString(e.footer||"",t),items:this.processNavItems(e.items,e.groupKind),data:e.data,showToggle:this.showToggle}}}async onAfterRender(){this.isCollapsedState()?setTimeout(()=>this.initializeTooltips(),50):this.destroyTooltips()}setCustomView(e){return this.customView&&this.removeChild(this.customView.id),this.customView=e,e&&(e.containerId="sidebar-custom-view-container",this.addChild(e)),this.render(),this}clearCustomView(){return this.customView&&(this.removeChild(this.customView.id),this.customView=null),this.render(),this}processNavItems(e,t){const s=this.getApp(),i=s?.activeUser,a=s?.activeGroup,n=e=>{let s=e;if(e.startsWith("/")&&!e.includes("?")&&(s=`?page=${e.substring(1)||"home"}`),t&&a&&a.id){const e=s.includes("?")?"&":"?";return`${s}${e}group=${a.id}`}return s};return e.map((e,t)=>{if(""===e||"object"==typeof e&&e.divider)return{isDivider:!0,id:`divider-${t}`};if("object"==typeof e&&e.spacer)return{isSpacer:!0,id:`spacer-${t}`};const s={...e};if(s.permissions&&(!i||!i.hasPermission(s.permissions)))return null;if(s.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(s.requiresGroupKind,e))return null}if("label"===s.kind)return s.isLabel=!0,s.id||(s.id=`nav-label-${t}`),s;if(s.id||(s.id=`nav-${t}`),s.route)s.href=n(s.route);else if(s.page){const e=s.page.startsWith("/")?s.page:`/${s.page}`;s.href=n(e),s.route=s.href}return s.children?(s.children=s.children.map(e=>{const t={...e};if(t.permissions&&i&&!i.hasPermission(t.permissions))return null;if(t.requiresGroupKind){const e=a?._.kind||a?.kind;if(!e||!this._groupKindMatches(t.requiresGroupKind,e))return null}if(t.route)t.href=n(t.route);else if(t.page){const e=t.page.startsWith("/")?t.page:`/${t.page}`;t.href=n(e),t.route=t.href}return t}).filter(e=>null!==e),s.hasChildren=!!(s.children&&s.children.length>0)):s.hasChildren=!1,s}).filter(e=>null!==e)}isItemActive(e){if(!e.route||!this.currentRoute)return!1;const t=e=>{if(!e)return"/";const t=decodeURIComponent(e);return t.startsWith("/")?t:`/${t}`},s=t(e.route),i=t(this.currentRoute);return"/"===s&&"/"===i||"/"!==s&&"/"!==i&&(i.startsWith(s)||i===s)}async updateActiveItem(e){return this.currentRoute=e,this.clearAllActiveStates(),this.setActiveItemByRoute(e),await this.render(),this}async handleActionToggleSubmenu(e,t){const s=t.querySelector(".nav-arrow");s&&s.classList.toggle("rotated")}async handleActionToggleSidebar(e,t){this.toggleSidebar()}onActionShowGroupMenu(e,t,s){return this.setActiveMenu("group_default"),!1}async onActionDefault(e,t,s){const i=this.getCurrentMenuConfig();if(!i)return;const a=i=>{for(const n of i){if(n.action==e&&n.handler)return n.handler(e,t,s,this.getApp()),!0;if(n.children&&n.children.length>0&&a(n.children))return!0}return!1};return a(i.items)}getMenuNames(){return Array.from(this.menus.keys())}hasMenu(e){return this.menus.has(e)}clearMenus(){return this.menus.clear(),this.activeMenuName=null,this.render(),this}setMenuData(e){const t=this.getCurrentMenuConfig();return t&&(t.data={...t.data,...e},this.render()),this}getMenuData(){const e=this.getCurrentMenuConfig();return e?e.data:{}}setupRouteListeners(){const e=this.getApp();e&&e.events&&(e.events.on(["page:showing"],e=>{this.onRouteChanged(e)}),e.events.on("group:changed",e=>{this.showMenuForGroup(e.group)}),e.events.on("portal:user-changed",e=>{this.render()}))}onRouteChanged(e){if(e.page&&e.page.route){const t=e.page.route;if(this.activeMenuItem&&this.routesMatch(t,this.activeMenuItem.route))return;if(this.autoSwitchToMenuForRoute(t))return;const s=e.page.sidebarMenu||e.page.options?.sidebarMenu||null;if(s&&this.menus.has(s))return this._setActiveMenu(s),this.clearAllActiveStates(),void this.render();let i=null;for(const[e,a]of this.menus)if(!a.groupKind){i=e;break}i&&this.activeMenuName!==i&&this._setActiveMenu(i),this.clearAllActiveStates(),this.updateActiveItem(t),this.render()}}toggleSidebar(){const e=document.querySelector(".portal-container");if(!e)return;this.hideAllTooltips();const t=e.classList.contains("collapse-sidebar");return e.classList.contains("hide-sidebar")?(e.classList.remove("hide-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):t?(e.classList.remove("collapse-sidebar"),this.isCollapsed=!1,this.destroyTooltips()):(e.classList.add("collapse-sidebar"),this.isCollapsed=!0,setTimeout(()=>this.initializeTooltips(),150)),this}setSidebarState(e){const t=document.querySelector(".portal-container");if(!t)return this;switch(t.classList.remove("collapse-sidebar","hide-sidebar"),e){case"collapsed":t.classList.add("collapse-sidebar"),this.isCollapsed=!0;break;case"hidden":t.classList.add("hide-sidebar"),this.isCollapsed=!1;break;default:this.isCollapsed=!1}return this.isCollapsed?(this.hideAllTooltips(),setTimeout(()=>this.initializeTooltips(),100)):this.destroyTooltips(),this}initializeTooltips(){return this.destroyTooltips(),this.isCollapsedState()?(this.element.querySelectorAll(".sidebar-nav .nav-link").forEach(e=>{const t=e.querySelector(".nav-text");if(t&&t.textContent.trim()){const s=t.textContent.trim();if(e.setAttribute("data-bs-toggle","tooltip"),e.setAttribute("data-bs-placement","right"),e.setAttribute("data-bs-title",s),e.setAttribute("data-bs-container","body"),window.bootstrap&&window.bootstrap.Tooltip){const t=e.getAttribute("data-tooltip-theme"),s=e.getAttribute("data-tooltip-size");let i="";t&&(i+=`tooltip-${t} `),s&&(i+=`tooltip-${s}`);const a={placement:"right",container:"body",trigger:"hover",delay:{show:500,hide:100},fallbackPlacements:["top","bottom","left"]},n=i.trim();n&&(a.customClass=n);const r=new window.bootstrap.Tooltip(e,a);e._tooltipInstance=r,e.addEventListener("click",()=>{r.hide()}),e.addEventListener("blur",()=>{r.hide()})}}}),this.addTooltipHideListeners(),this):this}destroyTooltips(){return this.removeTooltipHideListeners(),this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&(t.hide(),t.dispose()),delete e._tooltipInstance,e.removeAttribute("data-bs-toggle"),e.removeAttribute("data-bs-placement"),e.removeAttribute("data-bs-title"),e.removeAttribute("data-bs-container")}),this}getSidebarState(){const e=document.querySelector(".portal-container");return e?e.classList.contains("hide-sidebar")?"hidden":e.classList.contains("collapse-sidebar")?"collapsed":"normal":"normal"}isCollapsedState(){return"collapsed"===this.getSidebarState()}setToggleEnabled(e){return this.showToggle=e,this.render(),this}initializeMenus(e){if(e.menus)for(const t of e.menus)this.addMenu(t.name,t);else e.menu&&(e.menu.name=e.menu.name||"default",this.addMenu(e.menu.name,e.menu))}addTooltipHideListeners(){this._tooltipScrollHandler=()=>this.hideAllTooltips(),this.element.addEventListener("scroll",this._tooltipScrollHandler,{passive:!0}),this._tooltipRouteHandler=()=>this.hideAllTooltips(),this.getApp(),this._tooltipBlurHandler=()=>this.hideAllTooltips(),window.addEventListener("blur",this._tooltipBlurHandler),this._tooltipEscapeHandler=e=>{"Escape"===e.key&&this.hideAllTooltips()},document.addEventListener("keydown",this._tooltipEscapeHandler)}removeTooltipHideListeners(){this._tooltipScrollHandler&&(this.element.removeEventListener("scroll",this._tooltipScrollHandler),delete this._tooltipScrollHandler),this._tooltipBlurHandler&&(window.removeEventListener("blur",this._tooltipBlurHandler),delete this._tooltipBlurHandler),this._tooltipEscapeHandler&&(document.removeEventListener("keydown",this._tooltipEscapeHandler),delete this._tooltipEscapeHandler)}hideAllTooltips(){this.element.querySelectorAll('.sidebar-nav .nav-link[data-bs-toggle="tooltip"]').forEach(e=>{const t=e._tooltipInstance||window.bootstrap?.Tooltip?.getInstance(e);t&&t.hide()}),document.querySelectorAll(".tooltip.show").forEach(e=>{e.remove()})}async onBeforeDestroy(){this.destroyTooltips(),await super.onBeforeDestroy()}setupResponsiveBehavior(){const e=()=>{const e=window.innerWidth<=768,t=document.querySelector(".portal-container");t&&(e?t.classList.add("sidebar-mobile"):t.classList.remove("sidebar-mobile","sidebar-open"))};e(),window.addEventListener("resize",e)}static createDefault(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!0,autoCollapseMobile:!0,...e})}static createMinimal(e={}){return new Sidebar({theme:"sidebar-clean",showToggle:!1,autoCollapseMobile:!1,...e})}setSidebarTheme(e){return this.removeClass("sidebar-light sidebar-dark sidebar-clean"),this.sidebarTheme=e,this.addClass(e),this}show(){return this.setSidebarState("normal")}hide(){return this.setSidebarState("hidden")}collapse(){return this.setSidebarState("collapsed")}expand(){return this.setSidebarState("normal")}pulseToggle(){const e=this.element.querySelector(".sidebar-toggle");if(e){e.classList.add("pulse");const t=()=>{e.classList.remove("pulse"),e.removeEventListener("click",t)};e.addEventListener("click",t,{once:!0}),setTimeout(t,3e3)}return this}addSimpleMenuItem(e,t,s,i="bi-circle"){const a=this.menus.get(e);return a&&(a.items=a.items||[],a.items.push({text:t,route:s,icon:i}),this.activeMenuName===e&&this.render()),this}setSimpleMenu(e,t,s){const i={name:e,header:t,items:s};return this.addMenu(e,i),this.setActiveMenu(e),this}}class PageHeader extends r{constructor(e={}){super({tagName:"div",className:"page-header",...e}),this.style=e.style||"default",this.size=e.size||"md",this.showIcon=!1!==e.showIcon,this.showDescription=!1!==e.showDescription,this.showBreadcrumbs=e.showBreadcrumbs||!1,this.currentPage=null}async getTemplate(){return"minimal"===this.style?this.getMinimalTemplate():"breadcrumb"===this.style?this.getBreadcrumbTemplate():this.getDefaultTemplate()}getDefaultTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-{{data.size}}">\n <div class="page-header-main">\n <div class="page-header-info">\n {{#data.showIcon}}\n {{#data.pageIcon}}\n <div class="page-icon">\n <i class="{{data.pageIcon}}"></i>\n </div>\n {{/data.pageIcon}}\n {{/data.showIcon}}\n \n <div class="page-title-group">\n <h1 class="page-title">{{data.pageTitle}}</h1>\n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n </div>\n\n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n </div>\n {{/data.hasPage}}\n '}getMinimalTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-minimal">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n </div>\n {{/data.hasPage}}\n '}getBreadcrumbTemplate(){return'\n {{#data.hasPage}}\n <div class="page-header-content page-header-breadcrumb">\n {{#data.showBreadcrumbs}}\n <nav aria-label="breadcrumb">\n <ol class="breadcrumb mb-2">\n {{#data.breadcrumbs}}\n <li class="breadcrumb-item {{#active}}active{{/active}}">\n {{#href}}<a href="{{href}}">{{label}}</a>{{/href}}\n {{^href}}{{label}}{{/href}}\n </li>\n {{/data.breadcrumbs}}\n </ol>\n </nav>\n {{/data.showBreadcrumbs}}\n \n <div class="d-flex justify-content-between align-items-start">\n <h1 class="page-title">\n {{#data.showIcon}}\n {{#data.pageIcon}}<i class="{{data.pageIcon}} me-2"></i>{{/data.pageIcon}}\n {{/data.showIcon}}\n {{data.pageTitle}}\n </h1>\n \n {{#data.hasActions}}\n <div class="page-actions">\n {{#data.actions}}\n <button class="btn {{buttonClass}}" \n data-action="{{action}}"\n type="button">\n {{#icon}}<i class="{{icon}} me-1"></i>{{/icon}}\n {{label}}\n </button>\n {{/data.actions}}\n </div>\n {{/data.hasActions}}\n </div>\n \n {{#data.showDescription}}\n {{#data.pageDescription}}\n <p class="page-description text-muted mt-2">{{data.pageDescription}}</p>\n {{/data.pageDescription}}\n {{/data.showDescription}}\n </div>\n {{/data.hasPage}}\n '}async onBeforeRender(){await super.onBeforeRender();const e=this.currentPage,t=!!e;e&&(e.title,e.displayName,e.name,e.pageName,e.icon,e.pageIcon,e.pageDescription,e.description);const s=e?.options?.headerActions||e?.headerActions||e?.constructor?.prototype?.headerActions||[];this.data={hasPage:t,pageTitle:e?.title||e?.displayName||e?.name||e?.pageName||"",pageIcon:e?.icon||e?.pageIcon||"",pageDescription:e?.pageDescription||e?.description||"",showIcon:this.showIcon,showDescription:this.showDescription,showBreadcrumbs:this.showBreadcrumbs,breadcrumbs:e?.options?.breadcrumbs||e?.breadcrumbs||[],actions:s,hasActions:s.length>0,size:this.size},this.data}async setPage(e){this.currentPage=e,e&&await this.render()}getPage(){return this.currentPage}async onActionDefault(e,t,s){return this.currentPage&&"function"==typeof this.currentPage.onHeaderAction?(await this.currentPage.onHeaderAction(e,t,s),!0):(this.emit("action",{action:e,event:t,element:s,page:this.currentPage}),!1)}}class DeniedPage extends m{constructor(e={}){super({pageName:"Access Denied",route:"/denied",title:"Access Denied",pageIcon:"bi bi-shield-x",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-shield-x text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Access Denied</h2>\n <p class="text-muted">You don\'t have permission to access this page.</p>\n </div>\n\n {{#deniedPage}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body">\n <h6 class="card-subtitle mb-2 text-muted">Requested Page</h6>\n <h5 class="card-title">\n <i class="{{pageIcon}} me-2"></i>\n {{displayName}}\n </h5>\n {{#route}}\n <p class="card-text text-muted small">{{route}}</p>\n {{/route}}\n {{#description}}\n <p class="card-text">{{description}}</p>\n {{/description}}\n\n {{#requiredPermissions}}\n <div class="mt-3">\n <h6 class="mb-2">Required Permissions:</h6>\n {{#permissions}}\n <span class="badge bg-light text-dark me-1 mb-1">{{.}}</span>\n {{/permissions}}\n {{^permissions}}\n <span class="text-muted small">Authentication required</span>\n {{/permissions}}\n </div>\n {{/requiredPermissions}}\n </div>\n </div>\n {{/deniedPage}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n {{#showLogin}}\n <button type="button" class="btn btn-outline-primary" data-action="login">\n <i class="bi bi-box-arrow-in-right me-1"></i>\n Login\n </button>\n {{/showLogin}}\n </div>\n\n {{#currentUser}}\n <div class="text-center mt-4">\n <small class="text-muted">\n Logged in as <strong>{{username}}</strong>\n </small>\n </div>\n {{/currentUser}}\n </div>\n </div>\n </div>\n ',...e}),this.deniedPage=null,this.deniedPageOptions=null}async onParams(e={},t={}){await super.onParams(e,t),e.page?(this.deniedPage=e.page,this.deniedPageOptions=e.page.options||e.page.pageOptions||{}):t.page&&(this.deniedPageName=t.page)}setDeniedPage(e){return this.deniedPage=e,this.deniedPageOptions=e?.options||e?.pageOptions||{},this}async getViewData(){const e=this.getApp(),t=e?.activeUser||e?.getCurrentUser?.()||null;let s=null;if(this.deniedPage){const e=this.deniedPageOptions?.permissions||this.deniedPage.options?.permissions||this.deniedPage.pageOptions?.permissions;s={displayName:this.deniedPage.displayName||this.deniedPage.pageName||this.deniedPage.title||"Unknown Page",pageName:this.deniedPage.pageName,route:this.deniedPage.route,description:this.deniedPage.pageDescription||this.deniedPage.description,pageIcon:this.deniedPage.pageIcon||"bi bi-file-text",requiredPermissions:e?{permissions:Array.isArray(e)?e:[e]}:null}}else this.deniedPageName&&(s={displayName:this.deniedPageName,pageName:this.deniedPageName,pageIcon:"bi bi-file-text"});return{deniedPage:s,currentUser:t?{username:t.username||t.name||t.email||"Unknown User",name:t.name,email:t.email}:null,showLogin:!t}}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async handleActionLogin(e,t){e.preventDefault();const s=this.getApp();if(s)try{await s.showPage("login")}catch(i){try{await s.navigate("/login")}catch(a){this.emit("login-required",{returnUrl:this.deniedPage?.route||window.location.pathname}),setTimeout(()=>{s?.showInfo?.("Please contact your administrator for access.")},100)}}}async onEnter(){await super.onEnter();const e=this.deniedPage?.pageName||this.deniedPageName;e&&this.setMeta({title:`Access Denied - ${e}`}),console.warn("Access denied to page:",{page:this.deniedPage?.pageName||this.deniedPageName,route:this.deniedPage?.route,permissions:this.deniedPageOptions?.permissions,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPage(e,t){const s=new DeniedPage;return s.setDeniedPage(t),e.showPage(s)}}class NotFoundPage extends m{constructor(e={}){super({pageName:"404",route:"/404",title:"404 - Page Not Found",pageIcon:"bi bi-search",template:'\n <div class="container mt-5">\n <div class="row justify-content-center">\n <div class="col-md-8 col-lg-6">\n <div class="text-center mb-4">\n <i class="bi bi-search text-muted" style="font-size: 3rem;"></i>\n <h2 class="mt-3 mb-2">Page Not Found</h2>\n <p class="text-muted">The page you\'re looking for doesn\'t exist.</p>\n </div>\n\n {{#path}}\n <div class="card border-0 shadow-sm mb-4">\n <div class="card-body text-center">\n <h6 class="card-subtitle mb-2 text-muted">Requested Path</h6>\n <code class="text-primary">{{path}}</code>\n </div>\n </div>\n {{/path}}\n\n <div class="d-grid gap-2 d-md-flex justify-content-md-center">\n <button type="button" class="btn btn-primary" data-action="go-back">\n <i class="bi bi-arrow-left me-1"></i>\n Go Back\n </button>\n <button type="button" class="btn btn-outline-secondary" data-action="go-home">\n <i class="bi bi-house me-1"></i>\n Home\n </button>\n </div>\n </div>\n </div>\n </div>\n ',...e}),this.path=null}async onParams(e={},t={}){await super.onParams(e,t),e.path&&(this.path=e.path),t.path&&(this.path=t.path)}setInfo(e){return this.path=e||null,this}async handleActionGoBack(e,t){e.preventDefault(),window.history.length>1?window.history.back():await this.handleActionGoHome(e,t)}async handleActionGoHome(e,t){e.preventDefault();const s=this.getApp();s?await s.navigateToDefault():window.location.href="/"}async onEnter(){await super.onEnter(),this.path&&this.setMeta({title:`404 - ${this.path} Not Found`}),console.warn("404 Not Found:",{path:this.path,timestamp:/* @__PURE__ */(new Date).toISOString()})}static showForPath(e,t){const s=new NotFoundPage;return s.setInfo(t),s.render()}}class PortalApp extends v{constructor(e={}){super(e),this.sidebarConfig=e.sidebar,this.topbarConfig=e.topbar||{},e.topnav&&!e.topbar&&(this.topbarConfig=e.topnav),this.showPageHeader=e.showPageHeader||!1,this.pageHeaderConfig=e.pageHeader||{},this.sidebar=null,this.topbar=null,this.topnav=null,this.pageHeader=null,this.tokenManager=new Pt,this.activeGroup=null,this.isMobile()?this.sidebarCollapsed=this.sidebarConfig.defaultCollapsed||!1:this.sidebarCollapsed=this.loadSidebarState()??(this.sidebarConfig.defaultCollapsed||!1),this.setupPageContainer(),this.toast=new qe,this.Dialog=$e,this.registerPage("denied",DeniedPage),this.registerPage("404",NotFoundPage)}async start(){await this.checkAuthStatus(),this.events.on("auth:unauthorized",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("auth:logout",()=>{this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null)}),this.events.on("browser:focus",()=>{this.activeUser&&this.tokenManager.checkAndRefreshTokens(this)}),this.events.on("portal:action",this.onPortalAction.bind(this)),this.activeUser&&await this.checkActiveGroup(),await this.setupRouter(),this.isStarted=!0,this.events.emit("app:ready",{app:this}),this.activeUser&&!this.activeUser.get("has_passkey")&&this.showPasskeySetup()}async checkAuthStatus(){const e=this.tokenManager.checkTokenStatus();if("logout"===e.action)return this.events.emit("auth:unauthorized",{app:this}),!1;if("refresh"===e.action&&!(await this.tokenManager.checkAndRefreshTokens(this)))return!1;const t=this.tokenManager.getTokenInstance();if(this.activeUser)return this.tokenManager.startAutoRefresh(this),!0;this.rest.setAuthToken(t.token);const s=new Je({id:t.getUserId()}),i=await s.fetch();return i.success?(this.setActiveUser(s),this.tokenManager.startAutoRefresh(this),!0):(this.tokenManager.clearTokens(),this.events.emit("auth:unauthorized",{app:this,error:i.error}),!1)}async checkActiveGroup(){const e=new URLSearchParams(window.location.search).get("group"),t=e||this.loadActiveGroupId();if(t)try{const s=new ze({id:t}),i=await s.fetch();if(!i.success||!i.data.status)return this.clearActiveGroup(),void console.warn("Failed to load active group:",i.statusText);this.activeGroup=s,e&&this.saveActiveGroupId(t),this.activeUser&&(this.activeUser.member=new ht,await this.activeUser.member.fetchForGroup(s.id)),this.events.emit("group:loaded",{group:this.activeGroup})}catch(s){if(console.warn("Failed to load active group:",s),e&&!this.loadActiveGroupId())this.clearActiveGroupId();else if(e){const t=this.loadActiveGroupId();if(t&&t!==e)try{const e=new ze({id:t});await e.fetch(),this.activeGroup=e,this.events.emit("group:loaded",{group:this.activeGroup})}catch(i){console.warn("Fallback to stored group also failed:",i),this.clearActiveGroupId()}}}}async setActiveGroup(e){const t=this.activeGroup;this.activeGroup=e,e&&e.get("id")?this.saveActiveGroupId(e.get("id")):this.clearActiveGroupId(),this.activeUser&&(this.activeUser.member=new ht,await this.activeUser.member.fetchForGroup(e.id)),this.events.emit("group:changed",{group:e,previousGroup:t,app:this});const s=this.getCurrentPage();return s&&s.onGroupChange(e),this.router.updateUrl({group:e.id},{replace:!0}),this}getActiveGroup(){return this.activeGroup}async clearActiveGroup(){const e=this.activeGroup;return this.activeGroup=null,this.clearActiveGroupId(),this.events.emit("group:cleared",{previousGroup:e,app:this}),this}saveActiveGroupId(e){try{const t=this.getActiveGroupStorageKey();localStorage.setItem(t,e.toString())}catch(t){console.warn("Failed to save active group ID:",t)}}loadActiveGroupId(){try{const e=this.getActiveGroupStorageKey();return localStorage.getItem(e)}catch(e){return console.warn("Failed to load active group ID:",e),null}}clearActiveGroupId(){try{const e=this.getActiveGroupStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear active group ID:",e)}}getActiveGroupStorageKey(){return"active_group_id"}setPortalProfile(e){try{localStorage.setItem("portal_profile",e)}catch(t){console.warn("Failed to save portal profile:",t)}}needsGroupSelection(){return!this.activeGroup}setupPageContainer(){const e="string"==typeof this.container?document.querySelector(this.container):this.container;if(!e)throw new Error(`Portal container not found: ${this.container}`);const t=this.sidebarConfig&&Object.keys(this.sidebarConfig).length>0,s=this.topbarConfig&&Object.keys(this.topbarConfig).length>0,i=this.showPageHeader?'\n <div class="portal-content" id="portal-content">\n <div id="page-header"></div>\n <div id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n </div>\n ':'\n <div class="portal-content" id="page-container">\n \x3c!-- Pages render here --\x3e\n </div>\n ';e.innerHTML=`\n <div class="portal-layout hide-sidebar">\n ${t?'<div id="portal-sidebar"></div>':""}\n <div class="portal-body">\n ${s?'<div id="portal-topnav"></div>':""}\n ${i}\n </div>\n </div>\n `,this.pageContainer="#page-container",e.classList.add("portal-container"),this.setupPortalComponents(),this.applySidebarState(e)}async setupPortalComponents(){await this.setupSidebar(),await this.setupTopbar(),await this.setupPageHeader(),this.setupPortalEvents()}async setupSidebar(){this.sidebarConfig&&0!==Object.keys(this.sidebarConfig).length&&(this.sidebar=new Sidebar({containerId:"portal-sidebar",...this.sidebarConfig}),await this.sidebar.render())}async setupTopbar(){this.topbarConfig&&0!==Object.keys(this.topbarConfig).length&&(this.topbar=new Mt({containerId:"portal-topnav",brandText:this.topbarConfig.brand||this.brand||this.title,brandRoute:this.topbarConfig.brandRoute||"/",brandIcon:this.topbarConfig.brandIcon||this.brandIcon,navItems:this.topbarConfig.leftItems||[],rightItems:this.topbarConfig.rightItems||[],displayMode:this.topbarConfig.displayMode||"both",showSidebarToggle:this.topbarConfig.showSidebarToggle||!1,...this.topbarConfig}),await this.topbar.render(),this.topnav=this.topbar)}async setupPageHeader(){if(!this.showPageHeader)return;this.pageHeader=new PageHeader({containerId:"page-header",style:this.pageHeaderConfig.style||"default",showIcon:!1!==this.pageHeaderConfig.showIcon,showDescription:!1!==this.pageHeaderConfig.showDescription,showBreadcrumbs:this.pageHeaderConfig.showBreadcrumbs||!1,...this.pageHeaderConfig});const e=document.getElementById("page-header");e&&await this.pageHeader.render(!0,e)}setupPortalEvents(){if(document.addEventListener("click",e=>{e.target.closest('[data-action="toggle-sidebar"]')&&(e.preventDefault(),this.toggleSidebar())}),window.ResizeObserver){const e=new ResizeObserver(()=>{this.handleResponsive()});e.observe(document.body),this._resizeObserver=e}else this._resizeHandler=()=>this.handleResponsive(),window.addEventListener("resize",this._resizeHandler);this.handleResponsive()}toggleSidebar(){if(!this.sidebar)return;const e=document.querySelector(".portal-container"),t=this.isMobile();t?e.classList.toggle("hide-sidebar"):(e.classList.toggle("collapse-sidebar"),this.sidebarCollapsed=!this.sidebarCollapsed,this.saveSidebarState(this.sidebarCollapsed)),this.events.emit("sidebar:toggled",{collapsed:this.sidebarCollapsed,mobile:t})}handleResponsive(){const e=document.querySelector(".portal-container");if(!e)return;const t=this.isMobile();t?(e.classList.add("mobile-layout"),e.classList.contains("hide-sidebar")||e.classList.add("hide-sidebar")):e.classList.remove("mobile-layout","hide-sidebar"),this.events.emit("responsive:changed",{mobile:t})}getPortalContainer(){return document.querySelector(".portal-container")}isMobile(){return window.innerWidth<768}hasMobileLayout(){return this.getPortalContainer().classList.contains("mobile-layout")}async showPage(e,t={},s={},i={}){const a=await super.showPage(e,t,s,i);return this.hasMobileLayout()&&this.getPortalContainer().classList.add("hide-sidebar"),this.currentPage&&this.updateNavigation(this.currentPage),a}updateNavigation(e){this.sidebar&&this.sidebar.setActivePage&&this.sidebar.setActivePage(e.route),this.topbar&&this.topbar.setActivePage&&this.topbar.setActivePage(e.route),this.pageHeader&&this.pageHeader.setPage(e),this.events.emit("portal:page-changed",{page:e})}setActiveUser(e){this.activeUser=e,this.topbar&&this.topbar.setUser(e),this.events.emit("portal:user-changed",{user:e})}getActiveUser(){return this.activeUser}saveSidebarState(e){try{const t=this.getSidebarStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.warn("Failed to save sidebar state:",t)}}loadSidebarState(){try{const e=this.getSidebarStorageKey(),t=localStorage.getItem(e);return null!==t?JSON.parse(t):null}catch(e){return console.warn("Failed to load sidebar state:",e),null}}getSidebarStorageKey(){return`${this.title?this.title.replace(/\s+/g,"_").toLowerCase():"portal_app"}_sidebar_collapsed`}applySidebarState(e=null){e||(e=document.querySelector(".portal-container")),e&&(this.sidebarCollapsed?e.classList.add("collapse-sidebar"):e.classList.remove("collapse-sidebar"))}clearSidebarState(){try{const e=this.getSidebarStorageKey();localStorage.removeItem(e)}catch(e){console.warn("Failed to clear sidebar state:",e)}}async changePassword(){const e=await this.showForm({title:"Change Password",fields:[{name:"current_password",type:"password",label:"Current Password",required:!0,showToggle:!0,strengthMeter:!0,capsLockWarning:!0},{name:"new_password",type:"password",label:"New Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{autocomplete:"new-password"}},{name:"confirm_password",type:"password",label:"Confirm Password",required:!0,showToggle:!0,passwordUsage:"new",strengthMeter:!0,capsLockWarning:!0,attributes:{}}],submitLabel:"Change Password"});e&&(e.new_password===e.confirm_password?200===(await this.activeUser.save(e)).status?this.toast.success("Password changed successfully"):this.toast.error("Failed to change password"):this.toast.error("Passwords do not match"))}onPortalAction(e){switch(e.action){case"logout":this.tokenManager.clearTokens(),this.rest.clearAuth(),this.setActiveUser(null);break;case"profile":this.showProfile();break;case"change-password":this.changePassword();break;default:console.warn(`Unknown portal action: ${e}`)}}async showProfile(){if(this.activeUser)try{const{UserProfileView:e}=await import("./chunks/index-BdfwxVMZ.js"),t=new e({model:this.activeUser});await $e.showDialog({body:t,header:null,size:"lg",noBodyPadding:!0,centered:!1})}catch(e){console.error("Error showing profile:",e),this.showError("Failed to load profile")}else this.showError("No user is currently logged in")}async showPasskeySetup(){if(!localStorage.getItem("passkey_setup_dismissed"))try{const{PasskeySetupView:e}=await import("./chunks/index-BdfwxVMZ.js"),t=new e;t.on("dismiss",()=>{const e=t.element?.closest(".modal");if(e){const t=bootstrap.Modal.getInstance(e);t&&t.hide()}}),await $e.showDialog({header:null,body:t,size:"sm",centered:!0,buttons:[]})}catch(e){console.error("Error showing passkey setup:",e)}}async destroy(){this.activeGroup=null,this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.topbar&&(await this.topbar.destroy(),this.topbar=null,this.topnav=null),this.sidebar&&(await this.sidebar.destroy(),this.sidebar=null),await super.destroy()}static create(e={}){return new PortalApp(e)}}class FormPage extends m{constructor(e={}){super({title:"Form Page",description:"A page for submitting forms",icon:"form",fields:[],template:'<div data-container="form-view-container"></div>',className:"form-page container-sm",...e})}async onInit(){await super.onInit(),await this.recreateFormView()}async onEnter(){await super.onEnter(),this.formView&&await this.recreateFormView()}async onGroupChange(e){this.formView&&await this.recreateFormView()}async getModel(){return this.model?this.model:this.getApp().activeGroup?this.getApp().activeGroup:null}async recreateFormView(){this.formView&&(await this.formView.destroy(),this.removeChild(this.formView)),this.formView=new kt({containerId:"form-view-container",fields:this.options.fields,autosaveModelField:!0}),this.addChild(this.formView);const e=await this.getModel();e&&this.formView.setModel(e)}}const zt=new class{constructor(){this.formatter=o,this.compiledTemplates=/* @__PURE__ */new Map}render(e,t,s={}){return l.render(e,t,s)}compile(e){const t=l.parse(e);return this.compiledTemplates.set(e,t),t}renderCompiled(e,t,s={}){return l.render(e,t,s)}clearCache(){this.compiledTemplates.clear(),l.clearCache()}cache(e,t){return{key:e,template:t,compiled:this.compile(t)}}getCached(e){for(const[t,s]of this.compiledTemplates)if(t===e||s===e)return{key:e,template:t,compiled:s};return null}registerFormatter(e,t){return this.formatter.register(e,t),this}hasPipes(e){return/\{\{[{]?[^}|]+\|[^}]+\}[}]?\}/.test(e)}processData(e,t){const s={...e};for(const[i,a]of Object.entries(t))if(e&&"function"==typeof e.get)s[i]=e.get(`${i}|${a}`);else{const t=this.getValueFromPath(e,i);s[i]=this.formatter.pipe(t,a)}return s}getValueFromPath(e,t){if(!e||!t)return;if(e&&"function"==typeof e.get)return e.get(t);const s=t.split(".");let i=e;for(const a of s){if(null==i)return;i=!isNaN(a)&&Array.isArray(i)?i[parseInt(a)]:i[a]}return i}processTemplate(e,t){return{template:e,data:t}}};Kt.install({level:"warn"});const qt="MOJO",Jt="web-mojo",Wt={FRAMEWORK_NAME:qt,PACKAGE_NAME:Jt};export{e as BUILD_TIME,y as BundleByOptions,S as ChatInputView,A as ChatMessageView,P as ChatView,c as Collection,M as CommonEventFields,C as CommonScopeOptions,L as ComparatorOptions,Kt as ConsoleSilencer,b as ContextMenu,It as DataView,d as DataWrapper,$e as Dialog,ut as DjangoLookups,I as EmailDomain,k as EmailDomainForms,T as EmailDomainList,D as EmailTemplate,x as EmailTemplateForms,G as EmailTemplateList,f as EventBus,h as EventDelegate,qt as FRAMEWORK_NAME,We as File,Ye as FileForms,Qe as FileList,Xe as FileManager,Ze as FileManagerForms,et as FileManagerList,E as FilePreviewView,tt as FileUpload,FormPage,kt as FormView,_ as GeoLocatedIP,F as GeoLocatedIPList,ze as Group,st as GroupForms,Ke as GroupList,N as Incident,V as IncidentEvent,R as IncidentEventForms,O as IncidentEventList,H as IncidentForms,U as IncidentHistory,B as IncidentHistoryList,j as IncidentList,K as IncidentRule,$ as IncidentRuleList,z as IncidentRuleSet,q as IncidentRuleSetList,J as IncidentStats,W as Job,Y as JobEvent,Q as JobEventList,X as JobForms,Z as JobList,ee as JobLog,te as JobLogList,se as JobRunner,ie as JobRunnerForms,ae as JobRunnerList,ne as JobsEngineStats,pt as LOOKUPS,Ct as ListView,Lt as ListViewItem,gt as Log,mt as LogList,u as MOJOUtils,re as Mailbox,oe as MailboxForms,le as MailboxList,ce as MatchByOptions,ht as Member,bt as MemberForms,vt as MemberList,de as MetricsForms,he as MetricsPermission,ue as MetricsPermissionList,p as Model,zt as MustacheFormatter,Jt as PACKAGE_NAME,m as Page,xt as PasskeySetupView,PortalApp,it as ProgressView,pe as PushConfig,ge as PushConfigForms,me as PushConfigList,be as PushDelivery,ve as PushDeliveryList,fe as PushDevice,we as PushDeviceList,ye as PushTemplate,Se as PushTemplateForms,Ae as PushTemplateList,g as Rest,w as Router,Pe as Rule,Me as RuleForms,Ce as RuleList,Le as RuleSet,Ie as RuleSetForms,ke as RuleSetList,Te as S3Bucket,De as S3BucketForms,xe as S3BucketList,Ge as SentMessage,Ee as SentMessageForms,_e as SentMessageList,Sidebar,At as SimpleSearchView,Fe as TabView,Ne as TablePage,ft as TableRow,wt as TableView,Ve as Ticket,Re as TicketCategories,Oe as TicketForms,He as TicketList,Ue as TicketNote,Be as TicketNoteList,qe as ToastService,Pt as TokenManager,Mt as TopNav,Je as User,at as UserDataView,nt as UserDevice,rt as UserDeviceList,ot as UserDeviceLocation,lt as UserDeviceLocationList,ct as UserForms,dt as UserList,Gt as UserProfileView,t as VERSION,s as VERSION_INFO,i as VERSION_MAJOR,a as VERSION_MINOR,n as VERSION_REVISION,je as ValueTypeOptions,r as View,v as WebApp,Dt as WebSocketClient,Tt as applyFileDropMixin,o as dataFormatter,Wt as default,yt as formatFilterDisplay,$t as installConsoleSilencer,St as parseFilterKey};
2
2
  //# sourceMappingURL=index.es.js.map