@revisium/admin 2.6.0-alpha.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -379,7 +379,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
379
379
  `?(KR(e),e.i++):n===`\r`&&e.i+1<t.length&&t[e.i+1]===`
380
380
  `?(KR(e),e.i+=2):(e.currentField+=n,e.i++)}function JR(e){if(e.length===0)return[];let t={rows:[],currentRow:[],currentField:``,inQuotes:!1,i:0};for(;t.i<e.length;)t.inQuotes?GR(t,e):qR(t,e);return t.currentRow.push(t.currentField),WR(t.currentRow)&&t.rows.push(t.currentRow),t.rows}function YR(e){return e.includes(` `)||e.includes(`
381
381
  `)||e.includes(`"`)?`"${e.replaceAll(`"`,`""`)}"`:e}function XR(e,t,n){let r=[];for(let i=e.startRow;i<=e.endRow;i++){let a=[];for(let r=e.startCol;r<=e.endCol;r++){let e=t[i],o=n[r];e&&o&&a.push(YR(e.getCellVM(o).displayValue))}r.push(a.join(` `))}try{return navigator.clipboard.writeText(r.join(`
382
- `))}catch{return Promise.resolve()}}async function ZR(e,t,n,r){let i;try{i=await navigator.clipboard.readText()}catch{return}let a=JR(i);for(let[i,o]of a.entries()){let a=n[e+i];if(!a)break;for(let[e,n]of o.entries()){let i=r[t+e];if(!i)break;let o=a.getCellVM(i);o.isEditable&&o.applyPastedText(n)}}}function QR(e,t,n){let r=e.focusedCell;if(!r)return null;let i=t.findIndex(e=>e.field===r.field),a=n.findIndex(e=>e.rowId===r.rowId);return i===-1||a===-1?null:{colIndex:i,rowIndex:a}}function $R(e,t,n){for(let r=e.startRow;r<=e.endRow;r++)for(let i=e.startCol;i<=e.endCol;i++){let e=t[r],a=n[i];e&&a&&e.getCellVM(a).clearToDefault()}}var ez=`#ededed`,tz=`inset 0 -1px 0 0 ${ez}`;function nz(){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,left:`-8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:`var(--shadow-right-opacity, 0)`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}function rz(e,t){return t<=0?e:e===`0px`?`${t}px`:`calc(${e} + ${t}px)`}var iz=40,az=g(({field:e,columnsModel:t})=>{let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(0),a=(0,L.useRef)(0),o=(0,L.useRef)(0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>()=>{s.current&&s.current()},[]),(0,I.jsx)(A,{role:`separator`,position:`absolute`,right:`-4px`,top:0,bottom:0,width:`8px`,cursor:`col-resize`,zIndex:10,onMouseDown:(0,L.useCallback)(n=>{n.preventDefault(),n.stopPropagation();let c=t.resolveColumnWidth(e);i.current=n.clientX,a.current=c,r(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let l=n=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let r=n.clientX-i.current,o=Math.max(iz,a.current+r);t.setColumnWidth(e,o)})},u=()=>{cancelAnimationFrame(o.current),t.commitColumnWidth(),r(!1),document.body.style.cursor=``,document.body.style.userSelect=``,document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,d),s.current=null},d=()=>{u()};s.current=u,document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,d)},[e,t]),"data-testid":`resize-${e}`,children:(0,I.jsx)(A,{position:`absolute`,left:`3px`,top:0,bottom:0,width:`2px`,bg:n?`blue.500`:`transparent`,_groupHover:{bg:`blue.500`},transition:`background 0.1s`})})}),oz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.getSortIndex(e),i=t.sortCount>1;return n?(0,I.jsxs)(j,{alignItems:`center`,gap:`1px`,color:`blue.500`,fontSize:`xs`,flexShrink:0,"data-testid":`sort-indicator-${e}`,children:[n===`asc`?(0,I.jsx)(uk,{size:12}):(0,I.jsx)(ak,{size:12}),i&&r!==null&&(0,I.jsx)(A,{as:`span`,fontSize:`10px`,fontWeight:`medium`,lineHeight:1,children:r})]}):null}),sz=g(({field:e,columnsModel:t})=>t.isPinned(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`pin-indicator-${e}`,children:(0,I.jsx)(Ck,{size:12})}):null),cz=g(({field:e,filterModel:t})=>t.hasFilterForField(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`filter-indicator-${e}`,children:(0,I.jsx)(yk,{size:12})}):null),lz=({column:e})=>e.hasFormula?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`formula-indicator-${e.field}`,children:(0,I.jsx)(Yf,{size:12})}):null,uz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.isSorted(e);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Sort`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[(0,I.jsxs)(gt,{value:`sort-asc`,onClick:()=>{t.setSingleSort(e,`asc`)},color:n===`asc`?`blue.600`:void 0,children:[(0,I.jsx)(ck,{}),(0,I.jsx)(k,{children:`Sort A → Z`})]}),(0,I.jsxs)(gt,{value:`sort-desc`,onClick:()=>{t.setSingleSort(e,`desc`)},color:n===`desc`?`blue.600`:void 0,children:[(0,I.jsx)(ik,{}),(0,I.jsx)(k,{children:`Sort Z → A`})]}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`remove-sort`,onClick:()=>{t.removeSort(e)},children:[(0,I.jsx)(Dk,{}),(0,I.jsx)(k,{children:`Remove sort`})]})]})]})})})]})}),dz=g(({field:e,columnsModel:t})=>{let n=t.canMoveLeft(e),r=t.canMoveRight(e),i=t.canMoveToStart(e),a=t.canMoveToEnd(e);return!n&&!r?null:(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Move column`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[n&&(0,I.jsxs)(gt,{value:`move-left`,onClick:()=>t.moveColumnLeft(e),children:[(0,I.jsx)(pk,{}),(0,I.jsx)(k,{children:`Move left`})]}),i&&(0,I.jsxs)(gt,{value:`move-to-start`,onClick:()=>t.moveColumnToStart(e),children:[(0,I.jsx)(ok,{}),(0,I.jsx)(k,{children:`Move to start`})]}),r&&(0,I.jsxs)(gt,{value:`move-right`,onClick:()=>t.moveColumnRight(e),children:[(0,I.jsx)(mk,{}),(0,I.jsx)(k,{children:`Move right`})]}),a&&(0,I.jsxs)(gt,{value:`move-to-end`,onClick:()=>t.moveColumnToEnd(e),children:[(0,I.jsx)(sk,{}),(0,I.jsx)(k,{children:`Move to end`})]})]})})})]})}),fz=(0,L.memo)(({field:e,name:t,fieldType:n,valuePrefix:r,onClick:i})=>(0,I.jsx)(gt,{value:r?`${r}-${e}`:e,onClick:()=>i(e),children:(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,width:`100%`,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(n)}),(0,I.jsx)(k,{truncate:!0,children:t||`(unnamed)`})]})})),pz=({group:e,parentVisible:t,valuePrefix:n,onClick:r})=>e.children.length===0&&!t?(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}):(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{"data-testid":`file-group-${e.parent.field}`,children:[(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,flex:1,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(e.parent.fieldType)}),(0,I.jsx)(k,{truncate:!0,children:e.parent.label})]}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:[!t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}),(0,I.jsx)(dt,{})]}),e.children.map(e=>(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:n,onClick:r},e.field))]})})})]}),mz=({label:e,valuePrefix:t,availableFields:n,allColumns:r,onSelect:i})=>{if(n.length===0)return null;let a=EI(n,r);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:e}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:a.map(e=>TI(e)?(0,I.jsx)(pz,{group:e,parentVisible:e.parentVisible,valuePrefix:t,onClick:i},e.parent.field):(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:t,onClick:i},e.field))})})})]})},hz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:a})=>{let o=t.canRemoveColumn,s=t.availableFieldsToInsert,c=s.length>0,l=t.canMoveLeft(e.field)||t.canMoveRight(e.field),u=t.isPinned(e.field),d=t.canPinLeft(e.field),f=t.canPinRight(e.field);return(0,I.jsxs)(v,{minW:`180px`,children:[n&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(uz,{field:e.field,sortModel:n}),(0,I.jsx)(dt,{})]}),r&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`add-filter`,onClick:()=>{r&&(r.addConditionForField(e.field),r.setOpen(!0))},children:[(0,I.jsx)(yk,{}),(0,I.jsx)(k,{children:`Add filter`})]}),(0,I.jsx)(dt,{})]}),u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`unpin`,onClick:()=>{t.unpin(e.field)},children:[(0,I.jsx)(Sk,{}),(0,I.jsx)(k,{children:`Unpin column`})]}),(0,I.jsx)(dt,{})]}):(0,I.jsxs)(I.Fragment,{children:[d&&(0,I.jsxs)(gt,{value:`pin-left`,onClick:()=>{t.pinLeft(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to left`})]}),f&&(0,I.jsxs)(gt,{value:`pin-right`,onClick:()=>{t.pinRight(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to right`})]}),(d||f)&&(0,I.jsx)(dt,{})]}),l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dz,{field:e.field,columnsModel:t}),(0,I.jsx)(dt,{})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mz,{label:`Insert before`,valuePrefix:`before`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnBefore(e.field,n),a?.()}}),(0,I.jsx)(mz,{label:`Insert after`,valuePrefix:`after`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnAfter(e.field,n),a?.()}}),(0,I.jsx)(dt,{})]}),(0,I.jsxs)(gt,{value:`hide`,disabled:!o,onClick:()=>{t.hideColumn(e.field)},children:[(0,I.jsx)(dne,{}),(0,I.jsx)(k,{children:`Hide column`})]}),(0,I.jsxs)(gt,{value:`hide-all`,disabled:!o,onClick:t.hideAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Hide all columns`})]}),(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`copy-path`,onClick:()=>{i?i(e.field):navigator.clipboard.writeText(e.field).catch(()=>{})},children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Copy path`})]})]})});function gz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e.side===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e.side===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function _z(e){return e?`${tz}, ${e.side===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var vz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,stickyPosition:a})=>{let[o,s]=(0,L.useState)(!1),c=t.columnWidthCssVar(e.field),l=!!a;return(0,I.jsxs)(A,{as:`th`,position:l?`sticky`:`relative`,left:a?.side===`left`?a.offsetCss:void 0,right:a?.side===`right`?a.offsetCss:void 0,zIndex:l?2:void 0,width:c,minWidth:c,maxWidth:c,height:`inherit`,bg:`white`,boxShadow:_z(a),textAlign:`left`,fontWeight:`normal`,p:0,css:a?.isBoundary?gz(a):void 0,children:[(0,I.jsxs)(en,{positioning:{placement:`bottom-end`},lazyMount:!0,unmountOnExit:!0,open:o,onOpenChange:e=>s(e.open),children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(j,{alignItems:`center`,height:`100%`,pl:`8px`,pr:`16px`,gap:`4px`,cursor:`pointer`,transition:`background 0.15s`,overflow:`hidden`,_hover:{bg:`gray.100`},"data-testid":`header-${e.field}`,children:[(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flexShrink:0,fontSize:`xs`,color:`gray.400`,width:`16px`,children:sL(e.fieldType)}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.400`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,overflow:`hidden`,flex:1,minWidth:0,textDecoration:e.isDeprecated?`line-through`:void 0,children:e.label}),(0,I.jsx)(lz,{column:e}),(0,I.jsx)(sz,{field:e.field,columnsModel:t}),r&&e.isSortable&&(0,I.jsx)(cz,{field:e.field,filterModel:r}),n&&e.isSortable&&(0,I.jsx)(oz,{field:e.field,sortModel:n})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(hz,{column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:()=>s(!1)})})})]}),(0,I.jsx)(az,{field:e.field,columnsModel:t})]})}),yz=g(({columnsModel:e})=>{let t=e.availableFieldsToAdd,n=e.availableSystemFieldsToAdd;if(!e.hasHiddenColumns)return null;let r=EI(t,e.allColumns);return(0,I.jsx)(j,{alignItems:`center`,px:`4px`,height:`100%`,children:(0,I.jsxs)(en,{positioning:{placement:`bottom-start`},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(Ze,{"aria-label":`Add column`,size:`xs`,variant:`ghost`,color:`gray.400`,_hover:{bg:`gray.100`,color:`gray.600`},focusRing:`none`,"data-testid":`add-column-button`,children:(0,I.jsx)(ep,{})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`200px`,maxH:`340px`,overflowY:`auto`,children:[(0,I.jsxs)(gt,{value:`add-all`,onClick:e.addAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Add all columns`})]}),r.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`Data fields`}),r.map(t=>TI(t)?(0,I.jsx)(pz,{group:t,parentVisible:t.parentVisible,onClick:e.showColumn},t.parent.field):(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`System fields`}),n.map(t=>(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]})]})})})]})})}),bz=40,xz=40,Sz=g(({columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,showSelection:i})=>{let a=i?bz:0,o=e.hasHiddenColumns;return(0,I.jsxs)(A,{as:`tr`,height:`40px`,children:[i&&(0,I.jsx)(A,{as:`th`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,bg:`white`,p:0,position:`sticky`,left:0,zIndex:2,boxShadow:tz}),e.visibleColumns.map(i=>(0,I.jsx)(vz,{column:i,columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,stickyPosition:Cz(i.field,e,a,o)},i.field)),o?(0,I.jsx)(A,{as:`th`,width:`100%`,minWidth:`${xz}px`,bg:`white`,p:0,position:`sticky`,right:0,zIndex:2,boxShadow:tz,css:e.pinnedRightCount===0?nz():void 0,children:(0,I.jsx)(yz,{columnsModel:e})}):(0,I.jsx)(A,{as:`th`,width:`100%`,bg:`white`,p:0,boxShadow:tz})]})});function Cz(e,t,n,r){let i=t.getColumnStickyLeftCss(e,n);if(i!==void 0)return{side:`left`,offsetCss:i,isBoundary:t.isStickyLeftBoundary(e)};let a=t.getColumnStickyRightCss(e);if(a!==void 0)return{side:`right`,offsetCss:rz(a,r?xz:0),isBoundary:t.isStickyRightBoundary(e)}}var wz=({rowId:e,testIdPrefix:t,onSelect:n,onDuplicate:r,onDelete:i})=>(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(gt,{value:`select`,onClick:()=>n(e),"data-testid":`${t}-select-${e}`,children:[(0,I.jsx)(Kf,{}),(0,I.jsx)(k,{children:`Select`})]}),r&&(0,I.jsxs)(gt,{value:`duplicate`,onClick:()=>r(e),"data-testid":`${t}-duplicate-${e}`,children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Duplicate`})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`delete`,onClick:()=>i(e),"data-testid":`${t}-delete-${e}`,children:[(0,I.jsx)(Ek,{}),(0,I.jsx)(k,{color:`red.600`,children:`Delete`})]})]})]}),Tz=({rowId:e,onOpen:t,onPick:n,onSelect:r,onDuplicate:i,onDelete:a})=>{let[o,s]=(0,L.useState)(!1),c=n??t,l=n?Kf:df,u=n?`row-action-pick-${e}`:`row-action-open-${e}`,d=!!(t||r||i||a);return(0,I.jsx)(j,{position:`absolute`,right:`8px`,top:`50%`,transform:`translateY(-50%)`,alignItems:`center`,className:`row-action-buttons`,"data-menu-open":o||void 0,"data-testid":`row-action-buttons-${e}`,children:(0,I.jsxs)(j,{alignItems:`center`,height:`24px`,borderRadius:`6px`,bg:`white`,boxShadow:`0px 2px 8px rgba(0,0,0,0.16)`,overflow:`hidden`,"data-testid":`row-action-split-${e}`,children:[c&&(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`28px`,minWidth:`28px`,cursor:`pointer`,_hover:{bg:`gray.100`},onClick:t=>{t.stopPropagation(),c(e)},"data-testid":u,children:(0,I.jsx)(Ve,{boxSize:`20px`,color:`gray.400`,as:l})}),d&&(0,I.jsxs)(en,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:e})=>s(e),positioning:{placement:`bottom-start`},children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`18px`,minWidth:`18px`,cursor:`pointer`,borderLeft:c?`1px solid`:void 0,borderColor:`gray.100`,_hover:{bg:`gray.100`},onClick:e=>e.stopPropagation(),"data-testid":`row-action-trigger-${e}`,children:(0,I.jsx)(Ve,{as:nf,boxSize:`16px`,color:`gray.300`})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`180px`,"data-testid":`row-action-menu-${e}`,children:[t&&(0,I.jsxs)(gt,{value:`open`,onClick:()=>t(e),"data-testid":`row-action-menu-open-${e}`,children:[(0,I.jsx)(df,{}),(0,I.jsx)(k,{children:`Open`})]}),t&&(r||i||a)&&(0,I.jsx)(dt,{}),(0,I.jsx)(wz,{rowId:e,testIdPrefix:`row-action`,onSelect:r,onDuplicate:i,onDelete:a})]})})})]})]})})},Ez=({rowId:e,isSelected:t,onToggleSelection:n})=>(0,I.jsx)(A,{as:`td`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,p:0,position:`sticky`,left:0,zIndex:1,bg:`white`,boxShadow:`inset 0 -1px 0 0 ${ez}, inset -1px 0 0 0 ${ez}`,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,children:(0,I.jsxs)(Ne,{checked:t,onCheckedChange:()=>n(),size:`sm`,"data-testid":`select-${e}`,children:[(0,I.jsx)($e,{}),(0,I.jsx)(Ye,{})]})})}),Dz=40,Oz=40;function kz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function Az(e,t,n,r){let i=r&&n,a=i?{"& .row-action-buttons":{opacity:0},"&:hover .row-action-buttons, & .row-action-buttons[data-menu-open]":{opacity:1,transition:`opacity 0.15s ease`}}:{};if(e)return{...a,...kz(t)};if(i)return a}function jz(e,t,n,r){let i=t.getColumnStickyLeftCss(e.field,n),a=t.getColumnStickyRightCss(e.field),o=i!==void 0,s=a!==void 0,c=o||s,l=t.isStickyLeftBoundary(e.field),u=t.isStickyRightBoundary(e.field),d=s&&a!==void 0?rz(a,r):a;return{isSticky:c,isBoundary:l||u,boundarySide:o?`left`:`right`,leftCss:o?i:void 0,rightCss:s?d:void 0,colWidth:c?t.columnWidthCssVar(e.field):void 0}}function Mz(e,t){return e?`${tz}, ${t===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var Nz=g(({row:e,columnsModel:t,showSelection:n,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a,onOpenRow:o,onPickRow:s,onSelectRow:c,onDuplicateRow:l,onDeleteRow:u})=>{let d=!!(o||s||c||l||u),f=n?Dz:0,p=t.hasHiddenColumns,m=p?Oz:0;return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsx)(Ez,{rowId:e.rowId,isSelected:e.isSelected,onToggleSelection:()=>e.toggleSelection()}),t.visibleColumns.map((n,p)=>{let h=e.getCellVM(n),g=p===0,_=g&&d&&!h.isEditing,v=jz(n,t,f,m);return(0,I.jsxs)(A,{as:`td`,width:v.colWidth,minWidth:v.colWidth,maxWidth:v.isSticky?v.colWidth:`0`,overflow:v.isBoundary?`visible`:`hidden`,borderRight:v.isSticky?void 0:`1px solid`,borderColor:v.isSticky?void 0:ez,p:0,position:v.isSticky?`sticky`:`relative`,left:v.leftCss,right:v.rightCss,zIndex:v.isSticky?1:void 0,bg:v.isSticky?`white`:void 0,boxShadow:Mz(v.isSticky,v.boundarySide),css:Az(v.isBoundary,v.boundarySide,d,g),children:[v.isBoundary?(0,I.jsx)(A,{overflow:`hidden`,children:(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a})}):(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a}),_&&(0,I.jsx)(Tz,{rowId:e.rowId,onOpen:o,onPick:s,onSelect:c,onDuplicate:l,onDelete:u})]},n.field)}),p?(0,I.jsx)(A,{as:`td`,width:`100%`,minWidth:`${Oz}px`,p:0,position:`sticky`,right:0,zIndex:1,bg:`white`,boxShadow:tz,css:t.pinnedRightCount===0?nz():void 0}):(0,I.jsx)(A,{as:`td`,width:`100%`,p:0,boxShadow:tz})]})}),Pz=g(({selection:e,allRowIds:t,onDuplicate:n,onDelete:r})=>{let i=e.isAllSelected(t);return(0,I.jsx)(tee,{open:e.isSelectionMode,children:(0,I.jsx)(R,{children:(0,I.jsx)(vt,{zIndex:5,children:(0,I.jsxs)(pt,{"data-testid":`selection-toolbar`,children:[(0,I.jsxs)(zt,{children:[e.selectedCount,` selected`]}),(0,I.jsx)(wt,{}),!i&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>e.selectAll(t),"data-testid":`select-all`,children:[(0,I.jsx)(Kf,{}),`Select all`]}),n&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>n(e.selectedIds),"data-testid":`duplicate-selected`,children:[(0,I.jsx)(vk,{}),`Duplicate`]}),r&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>r(e.selectedIds),"data-testid":`delete-selected`,children:[(0,I.jsx)(Ek,{}),`Delete`]}),(0,I.jsx)(iee,{asChild:!0,children:(0,I.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Exit selection`,onClick:()=>e.exitSelectionMode(),"data-testid":`exit-selection`,children:(0,I.jsx)(ip,{})})})]})})})})}),Fz=({isOpen:e,onClose:t,onConfirm:n,count:r})=>{let i=(0,L.useRef)(null),a=r&&r>1?`Are you sure you want to delete ${r} rows?`:`Are you sure you want to delete this row?`;return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>{e||t()},initialFocusEl:()=>i.current,role:`alertdialog`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`400px`,"data-testid":`delete-confirm-dialog`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete confirmation`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:a})}),(0,I.jsx)(w,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(N,{ref:i,variant:`outline`,size:`sm`,onClick:t,"data-testid":`delete-cancel`,children:`Cancel`}),(0,I.jsx)(N,{colorPalette:`red`,size:`sm`,onClick:n,"data-testid":`delete-confirm`,children:`Delete`})]})})]})})]})})},Iz=({style:e,children:t,...n})=>(0,I.jsx)(`table`,{...n,style:{...e,width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:t}),Lz=({"data-index":e,context:t,style:n,children:r,...i})=>{let a=t?.rows[e];return(0,I.jsx)(`tr`,{...i,className:`group`,"data-testid":a?`row-${a.rowId}`:void 0,style:{...n,height:`40px`},children:r})},Rz={left:!1,right:!1},zz=class{_left=!1;_right=!1;_paused=!1;_dirty=!1;_onChange=null;get showLeftShadow(){return this._left}get showRightShadow(){return this._right}setOnChange(e){this._onChange=e}pause(){this._paused=!0,this._dirty=!1}resume(){this._paused=!1,this._dirty&&(this._dirty=!1,this._notify())}update(e,t){if(!(this._left===e&&this._right===t)){if(this._left=e,this._right=t,this._paused){this._dirty=!0;return}this._notify()}}reset(){if(!(!this._left&&!this._right)){if(this._left=!1,this._right=!1,this._paused){this._dirty=!0;return}this._notify()}}_notify(){this._onChange&&this._onChange({left:this._left,right:this._right})}};function Bz(e){return e instanceof HTMLElement?e:document.scrollingElement}function Vz(){let e=(0,L.useRef)(null);e.current||=new zz;let t=e.current,[n,r]=(0,L.useState)(Rz);t.setOnChange(r),(0,L.useEffect)(()=>()=>{t.setOnChange(null)},[t]);let i={"--shadow-left-opacity":n.left?`1`:`0`,"--shadow-right-opacity":n.right?`1`:`0`},a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(null),c=(0,L.useCallback)(()=>{let e=a.current;if(!e)return;let n=Bz(e);if(!n)return;let r=n.scrollLeft,i=n.scrollWidth-n.clientWidth;t.update(r>0,i>1&&r<i-1)},[t]),l=(0,L.useCallback)(()=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c)},[c]),u=(0,L.useCallback)(e=>{let n=a.current;if(n&&n.removeEventListener(`scroll`,l),s.current&&=(s.current.disconnect(),null),e){a.current=e,e.addEventListener(`scroll`,l,{passive:!0}),o.current=requestAnimationFrame(c);let t=Bz(e);if(t){let e=new ResizeObserver(l),n=t.querySelector(`table`);n&&e.observe(n),s.current=e}}else a.current=null,t.reset()},[l,c,t]);return(0,L.useEffect)(()=>()=>{let e=a.current;e&&e.removeEventListener(`scroll`,l),s.current&&s.current.disconnect(),o.current&&cancelAnimationFrame(o.current)},[l]),{shadowCssVars:i,shadowModel:t,setScrollerRef:u}}var Hz={Table:Iz,TableRow:Lz},Uz=g(({rows:e,columnsModel:t,cellFSM:n,selection:r,sortModel:i,filterModel:a,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onDeleteSelected:d,onDuplicateSelected:f,onDeleteRow:p,onDuplicateRow:m,onCopyPath:h,onEndReached:g,isLoadingMore:_,useWindowScroll:v})=>{let y=r.isSelectionMode,b=e.map(e=>e.rowId),[x,S]=(0,L.useState)(null),{shadowCssVars:C,shadowModel:w,setScrollerRef:T}=Vz(),E=t.isResizing;(0,L.useEffect)(()=>{E?w.pause():w.resume()},[E,w]);let[D,ee]=(0,L.useState)(null),te=(0,L.useCallback)(e=>{ee(e),t.setWrapperElement(e)},[t]);(0,L.useEffect)(()=>{if(!(!v||!D))return T(D),()=>{T(null)}},[v,D,T]);let ne=(0,L.useCallback)(e=>{r.enterSelectionMode(e)},[r]),O=(0,L.useCallback)(e=>{S({rowId:e})},[]),re=(0,L.useCallback)(e=>{S({batchIds:e})},[]),ie=(0,L.useCallback)(()=>{x?.rowId?(r.deselect(x.rowId),p?p(x.rowId):d&&d([x.rowId])):x?.batchIds&&(d?.(x.batchIds),r.exitSelectionMode()),S(null)},[x,p,d,r]),ae=(0,L.useCallback)(()=>{S(null)},[]),oe=x?.batchIds?.length,se=!!(p||d),ce=!!m,le=se||ce||!!f,ue=(0,L.useMemo)(()=>({copyRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&XR(r,e,i)},pasteRange:()=>{if(!n)return;let r=t.visibleColumns,i=n.getSelectedRange(),a=QR(n,r,e);i?ZR(i.startRow,i.startCol,e,r):a&&ZR(a.rowIndex,a.colIndex,e,r)},clearRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&$R(r,e,i)}}),[n,e,t]),de=(0,L.useCallback)(r=>{if(!n)return;let i=r.ctrlKey||r.metaKey,a=t.visibleColumns;if(i&&r.key===`v`&&n.focusedCell){let t=n.getSelectedRange(),i=QR(n,a,e);t?(r.preventDefault(),ZR(t.startRow,t.startCol,e,a)):i&&(r.preventDefault(),ZR(i.rowIndex,i.colIndex,e,a));return}if(n.hasSelection){if(i&&r.key===`c`){let t=n.getSelectedRange();t&&(r.preventDefault(),XR(t,e,a));return}if(r.key===`Delete`||r.key===`Backspace`){let t=n.getSelectedRange();t&&(r.preventDefault(),$R(t,e,a))}}},[n,e,t]),fe=(0,L.useCallback)((e,n)=>(0,I.jsx)(Nz,{row:n,columnsModel:t,showSelection:y,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onSelectRow:le?ne:void 0,onDuplicateRow:ce?m:void 0,onDeleteRow:se?O:void 0}),[t,y,o,s,c,l,u,le,se,ce,ne,m,O]),pe=(0,L.useCallback)(()=>(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y}),[t,i,a,h,y]),me=(0,L.useMemo)(()=>({rows:e}),[e]),he=t.visibleColumns.length+(y?2:1),ge=(0,L.useCallback)(()=>_?(0,I.jsx)(`tfoot`,{children:(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:he,style:{textAlign:`center`,padding:`16px 0`},children:(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`})})})}):null,[_,he]),_e=(0,L.useMemo)(()=>({...Hz,Footer:ge}),[ge]);return t.visibleColumns.length===0?(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No columns to display.`})}):(0,I.jsxs)(nR.Provider,{value:n?ue:null,children:[(0,I.jsxs)(A,{ref:te,position:`relative`,height:v?void 0:`100%`,overflowX:`auto`,overflowY:v?`clip`:void 0,"data-testid":`table-widget`,onKeyDown:de,style:{...t.columnWidthCssVars,...C},children:[e.length===0?(0,I.jsxs)(A,{children:[(0,I.jsx)(`table`,{style:{width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:(0,I.jsx)(`thead`,{children:(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y})})}),(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No rows to display.`})})]}):(0,I.jsx)(Foe,{useWindowScroll:v,style:v?void 0:{height:`100%`},data:e,context:me,defaultItemHeight:40,initialItemCount:Math.min(e.length,20),increaseViewportBy:2e3,endReached:g,fixedHeaderContent:pe,itemContent:fe,components:_e,scrollerRef:v?void 0:T}),(0,I.jsx)(Pz,{selection:r,allRowIds:b,onDuplicate:f,onDelete:d?re:void 0})]}),(0,I.jsx)(Fz,{isOpen:x!==null,onClose:ae,onConfirm:ie,count:oe})]})}),Wz=class{_cellFSM;_columnsModel;constructor(e,t){this._cellFSM=e,this._columnsModel=t,f(this,{},{autoBind:!0})}get _focusedColumn(){let e=this._cellFSM.focusedCell;return e?this._columnsModel.allColumns.find(t=>t.field===e.field)??null:null}get isVisible(){return this._focusedColumn!==null&&!this._cellFSM.hasSelection}get fieldLabel(){return this._focusedColumn?.label??``}get formulaExpression(){return this._focusedColumn?.formulaExpression}get foreignKeyTableId(){return this._focusedColumn?.foreignKeyTableId}},Gz=class{_totalCount=0;_baseTotalCount=0;_isFiltering=!1;_isRefetching=!1;constructor(){f(this,{},{autoBind:!0})}get totalCount(){return this._totalCount}get baseTotalCount(){return this._baseTotalCount}get isFiltering(){return this._isFiltering}get isRefetching(){return this._isRefetching}get text(){return this._isFiltering?`${this._totalCount} of ${this._baseTotalCount} ${this._baseTotalCount===1?`row`:`rows`}`:`${this._totalCount} ${this._totalCount===1?`row`:`rows`}`}setTotalCount(e){this._totalCount=e}setBaseTotalCount(e){this._baseTotalCount=e}setIsFiltering(e){this._isFiltering=e}setRefetching(e){this._isRefetching=e}decrementBaseTotalCount(e=1){this._baseTotalCount=Math.max(0,this._baseTotalCount-e),this._totalCount=Math.max(0,this._totalCount-e)}},Kz=class{_snapshot=null;_currentSnapshot=null;_canSave=!1;_isPopoverOpen=!1;_onSave=null;_onRevert=null;constructor(){f(this,{},{autoBind:!0})}get hasChanges(){return this._snapshot!==this._currentSnapshot}get isVisible(){return this.hasChanges}get canSave(){return this._canSave}get isPopoverOpen(){return this._isPopoverOpen}saveSnapshot(e){let t=JSON.stringify(e);this._snapshot=t,this._currentSnapshot=t}checkForChanges(e){this._currentSnapshot=JSON.stringify(e)}async save(){this._onSave&&await this._onSave()}revert(){this._onRevert&&this._onRevert(),this._currentSnapshot=this._snapshot}setCanSave(e){this._canSave=e}setPopoverOpen(e){this._isPopoverOpen=e}setOnSave(e){this._onSave=e}setOnRevert(e){this._onRevert=e}dispose(){this._onSave=null,this._onRevert=null}},qz=50,Jz=class{columns;filters;sorts;search;viewBadge;cellFSM;selection;rowCount;cellInfo;_dataSource;_pageSize;_breadcrumbs;_callbacks;_tableId;_schemaContext=new oI;_readonly=!1;_rows=[];_isBootstrapping=!0;_isLoadingMore=!1;_hasNextPage=!1;_endCursor=null;_savedViewState=null;constructor(e,t){this._dataSource=e,this._tableId=t.tableId,this._pageSize=t.pageSize??qz,this._readonly=t.readonly??!1,this._breadcrumbs=t.breadcrumbs??[],this._callbacks=t.callbacks??{},this.columns=new wI,this.filters=new oL,this.sorts=new TL,this.search=new xL(e=>this._handleSearch(e)),this.viewBadge=new Kz,this.cellFSM=new GL,this.selection=new jL,this.rowCount=new Gz,this.cellInfo=new Wz(this.cellFSM,this.columns),this.columns.setOnChange(()=>this._handleColumnsChange()),this.filters.setOnChange(()=>this._handleFilterChange()),this.filters.setOnApply(e=>this._handleFilterApply()),this.sorts.setOnChange(()=>this._handleSortChange()),this.sorts.setOnApply(e=>this._handleSortApply()),this.viewBadge.setOnSave(()=>this._handleViewSave()),this.viewBadge.setOnRevert(()=>this._handleViewRevert()),this.cellFSM.setOnReadonlyEditAttempt(this._callbacks.onReadonlyEditAttempt??null),f(this,{},{autoBind:!0}),queueMicrotask(()=>void this._bootstrap())}get rows(){return this._rows}get isBootstrapping(){return this._isBootstrapping}get isLoadingMore(){return this._isLoadingMore}get readonly(){return this._readonly}get tableId(){return this._tableId}get breadcrumbs(){return this._breadcrumbs}get callbacks(){return this._callbacks}getViewState(){return{columns:this.columns.serializeToViewColumns(),filters:null,sorts:this.sorts.serializeToViewSorts(),search:``}}applyViewState(e){this.columns.applyViewColumns(e.columns),this.sorts.applyViewSorts(e.sorts)}async loadMore(){if(!(!this._hasNextPage||this._isLoadingMore)){this._isLoadingMore=!0;try{let e=this._buildQuery(this._endCursor),t=await this._dataSource.fetchRows(e);c(()=>{this._appendRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage,this._isLoadingMore=!1})}catch{c(()=>{this._isLoadingMore=!1})}}}async deleteRows(e){(await this._dataSource.deleteRows(e)).ok&&c(()=>{let t=new Set(e);this._rows=this._rows.filter(e=>!t.has(e.rowId)),this.rowCount.decrementBaseTotalCount(e.length),this.selection.exitSelectionMode(),this._updateNavigationContext()})}dispose(){this.columns.dispose(),this.filters.dispose(),this.sorts.dispose(),this.search.dispose(),this.viewBadge.dispose(),this.selection.exitSelectionMode(),this.cellFSM.blur();for(let e of this._rows)e.dispose()}async _bootstrap(){try{let e=await this._dataSource.fetchMetadata();c(()=>{this._schemaContext.init(e.dataSchema,e.refSchemas),this._readonly=this._readonly||e.readonly,this.viewBadge.setCanSave(!this._readonly)}),this.columns.init(this._schemaContext.allColumns),this.sorts.init(this._schemaContext.sortableFields),this.filters.init(this._schemaContext.filterableFields),e.viewState&&this.applyViewState(e.viewState),this._saveViewSnapshot(),await this._loadRows(),c(()=>{this._isBootstrapping=!1})}catch{c(()=>{this._isBootstrapping=!1})}}_buildQuery(e=null){return{where:this.filters.hasActiveFilters?this.filters.buildCurrentWhereClause():null,orderBy:this.sorts.serializeToQuerySorts(),search:this.search.debouncedQuery,first:this._pageSize,after:e}}async _loadRows(){let e=this._buildQuery(),t=await this._dataSource.fetchRows(e);c(()=>{this._replaceRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage;let e=this.filters.hasActiveFilters||this.search.hasActiveSearch;this.rowCount.setTotalCount(t.totalCount),e||this.rowCount.setBaseTotalCount(t.totalCount),this.rowCount.setIsFiltering(e),this._updateNavigationContext()})}async _reloadRows(){this._isBootstrapping||(this.selection.exitSelectionMode(),this.cellFSM.blur(),await this._loadRows())}_replaceRowVMs(e){for(let e of this._rows)e.dispose();this._rows=this._createRowVMs(e)}_appendRowVMs(e){let t=this._createRowVMs(e);this._rows=[...this._rows,...t],this._updateNavigationContext()}_createRowVMs(e){let t=this._schemaContext.wrappedDataSchema;if(!t)return[];let n=kc({tableId:this._tableId,schema:t,rows:e.map(e=>({rowId:e.rowId,data:{data:e.data}})),refSchemas:this._schemaContext.fullRefSchemas}),r=new Map;for(let t of e)r.set(t.rowId,this._buildSystemValues(t));return n.rows.map(e=>new qL(e,e.rowId,this.cellFSM,this.selection,(e,t,n,r)=>this._commitCell(e,t,n,r),r.get(e.rowId),this._readonly))}_buildSystemValues(e){return{...e.systemFields,id:e.rowId}}_toPatchField(e){return nI(e)}async _commitCell(e,t,n,r){let i=this._toPatchField(t),a=(await this._dataSource.patchCells([{rowId:e,field:i,value:n}]))[0];a&&!a.ok&&c(()=>{let n=this._rows.find(t=>t.rowId===e);if(n&&r!==void 0){let e=n.rowModel.get(t);e?.isPrimitive()?e.setValue(r):e?.isObject()&&e.setValue(r,{internal:!0})}})}_updateNavigationContext(){this.cellFSM.setNavigationContext(this.columns.visibleColumns.map(e=>e.field),this._rows.map(e=>e.rowId))}_handleColumnsChange(){this.cellFSM.updateNavigationContext(this.columns.visibleColumns.map(e=>e.field),this.cellFSM.rowIds),this._checkViewChanges()}_handleFilterChange(){}_handleFilterApply(){this._reloadRows()}_handleSortChange(){this._checkViewChanges()}_handleSortApply(){this._reloadRows(),this._checkViewChanges()}_handleSearch(e){this._reloadRows()}async _handleViewSave(){try{let e=this.getViewState();(await this._dataSource.saveView(e)).ok&&this._saveViewSnapshot()}catch{}}_handleViewRevert(){this._savedViewState&&(this.applyViewState(this._savedViewState),this._reloadRows())}_saveViewSnapshot(){let e=this.getViewState();this._savedViewState=e,this.viewBadge.saveSnapshot(e)}_checkViewChanges(){this.viewBadge.checkForChanges(this.getViewState())}};function Yz(e,{delayMs:t=150,minShowMs:n=300}={}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(e){let e=setTimeout(()=>{a.current=Date.now(),i(!0)},t);return()=>clearTimeout(e)}if(a.current!==null){let e=n-(Date.now()-a.current);if(e>0){let t=setTimeout(()=>{a.current=null,i(!1)},e);return()=>clearTimeout(t)}a.current=null}i(!1)},[e,t,n]),r}var Xz=g(({model:e})=>e.isVisible?(0,I.jsxs)(j,{alignItems:`center`,gap:2,overflow:`hidden`,flexShrink:1,minW:0,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-field`,children:e.fieldLabel}),e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`purple.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-formula`,children:[`= `,e.formulaExpression]}),e.foreignKeyTableId&&!e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-fk`,children:[`→ `,e.foreignKeyTableId]})]}):null),Zz=g(({model:e})=>(0,I.jsxs)(j,{alignItems:`center`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,"data-testid":`row-count-text`,children:e.text}),e.isRefetching&&(0,I.jsx)(Ht,{size:`xs`,color:`gray.400`,"data-testid":`row-count-spinner`})]})),Qz=g(({model:e})=>{if(!e.isVisible)return null;let t=e.canSave?`orange`:`gray`,n=e.canSave?`orange.500`:`gray.400`,r=e.canSave?`unsaved`:`local`,i=e.canSave?`Unsaved view settings`:`Local view changes`,a=e.canSave?`Column order, widths, and sort settings will be saved to the Default view and shared with everyone.`:`View settings can only be saved in draft revisions. These changes are temporary and will be lost when you leave.`,o=e.canSave?`Revert`:`Reset`;return(0,I.jsxs)(ge,{open:e.isPopoverOpen,onOpenChange:t=>e.setPopoverOpen(t.open),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsxs)(It,{variant:`subtle`,size:`sm`,colorPalette:t,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:1,_hover:{opacity:.8},"data-testid":`view-settings-badge`,children:[(0,I.jsx)(A,{width:`6px`,height:`6px`,borderRadius:`full`,bg:n}),r]})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{p:3,maxW:`300px`,children:[(0,I.jsxs)(P,{mb:2,children:[(0,I.jsx)(A,{color:`gray.400`,children:(0,I.jsx)(bk,{size:16})}),(0,I.jsx)(k,{fontWeight:`semibold`,fontSize:`sm`,children:i})]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,mb:3,children:a}),(0,I.jsxs)(P,{children:[(0,I.jsx)(N,{variant:`ghost`,size:`xs`,onClick:()=>{e.revert(),e.setPopoverOpen(!1)},"data-testid":`view-settings-revert`,children:o}),e.canSave&&(0,I.jsx)(N,{colorPalette:`blue`,size:`xs`,onClick:()=>{e.save(),e.setPopoverOpen(!1)},"data-testid":`view-settings-save`,children:`Save`})]})]})})})]})}),$z=40,eB=40,tB=8,nB=[120,150,120,100,130],rB=[[80,110,70,60,90],[100,90,100,80,110],[60,130,80,70,80],[90,100,60,90,100],[75,120,90,55,70],[110,80,75,80,120],[85,140,95,65,95],[95,70,110,85,80]],iB=({breadcrumbs:e,onBreadcrumbClick:t,showCreateButton:n,useWindowScroll:r})=>(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:r?void 0:`100%`,flex:r?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...r&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[e.length>0?(0,I.jsx)(JN,{segments:e,highlightLast:!1,onSegmentClick:t,action:n?(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}):void 0}):(0,I.jsx)(A,{}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(j,{height:`${$z}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((e,t)=>(0,I.jsx)(A,{width:`${e}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`12px`,width:`60px`,borderRadius:`4px`})},`h-${t}`))}),rB.slice(0,tB).map((e,t)=>(0,I.jsx)(j,{height:`${eB}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((n,r)=>(0,I.jsx)(A,{width:`${n}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`14px`,width:`${e[r]}px`,borderRadius:`4px`})},`r-${t}-c-${r}`))},`r-${t}`))]})]}),aB=()=>{};function oB(e,t,n){return{onDeleteRow:e?void 0:e=>t.deleteRows([e]),onDuplicateRow:e?void 0:n.onDuplicateRow,onDeleteSelected:e?void 0:e=>t.deleteRows(e),onUploadFile:e?void 0:n.onUploadFile}}var sB=g(({viewModel:e,useWindowScroll:t})=>{let n=Yz(e.isBootstrapping);if(e.isBootstrapping)return n?(0,I.jsx)(iB,{breadcrumbs:e.breadcrumbs,onBreadcrumbClick:e.callbacks.onBreadcrumbClick,showCreateButton:!e.readonly&&!!e.callbacks.onCreateRow,useWindowScroll:t}):null;let r=e.readonly,{breadcrumbs:i,callbacks:a}=e;return(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:t?void 0:`100%`,flex:t?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...t&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[i.length>0&&(0,I.jsx)(JN,{segments:i,highlightLast:!1,onSegmentClick:a.onBreadcrumbClick,action:a.onCreateRow?(0,I.jsx)(XN,{tooltip:`New row`,onClick:a.onCreateRow,dataTestId:`create-row-button`}):void 0}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(CL,{model:e.search}),(0,I.jsx)(bL,{model:e.filters,availableFields:e.columns.filterableFields}),(0,I.jsx)(AL,{model:e.sorts,availableFields:e.columns.sortableFields,onChange:aB})]})]}),(0,I.jsx)(A,{flex:1,minHeight:0,children:(0,I.jsx)(Uz,{rows:e.rows,columnsModel:e.columns,cellFSM:e.cellFSM,selection:e.selection,sortModel:e.sorts,filterModel:e.filters,isLoadingMore:e.isLoadingMore,onEndReached:e.loadMore,onOpenRow:a.onOpenRow,onPickRow:a.onPickRow,...oB(r,e,a),onSearchForeignKey:a.onSearchForeignKey,onOpenFile:a.onOpenFile,onCopyPath:a.onCopyPath,useWindowScroll:t})}),(0,I.jsxs)(j,{px:3,py:2,alignItems:`center`,overflow:`hidden`,...t&&{position:`sticky`,bottom:0,bg:`white`,zIndex:3},children:[(0,I.jsx)(Zz,{model:e.rowCount}),(0,I.jsxs)(j,{alignItems:`center`,gap:3,overflow:`hidden`,flexShrink:1,minW:0,flex:1,justifyContent:`flex-end`,children:[(0,I.jsx)(Xz,{model:e.cellInfo}),(0,I.jsx)(Qz,{model:e.viewBadge})]})]})]})}),cB=Sn(),lB=e=>{let t={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`69fec82`,MODE:`production`,PACKAGE_VERSION:`2.6.0-alpha.1`,PROD:!0,REACT_APP_ENDPOINT_HOST:``,REACT_APP_ENDPOINT_PORT:``,REACT_APP_ENDPOINT_SERVER_URL:`/endpoint`,REACT_APP_GRAPHQL_SERVER_URL:`/graphql`,REACT_APP_SWAGGER_SERVER_URL:`/api`,SSR:!1}[e];return globalThis.__env__?.[e]||t},uB=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},dB=[`light`,`dark`],fB=`(prefers-color-scheme: dark)`,pB=typeof window>`u`,mB=L.createContext(void 0),hB=e=>L.useContext(mB)?L.createElement(L.Fragment,null,e.children):L.createElement(_B,{...e}),gB=[`light`,`dark`],_B=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i=`theme`,themes:a=gB,defaultTheme:o=n?`system`:`light`,attribute:s=`data-theme`,value:c,children:l,nonce:u,scriptProps:d})=>{let[f,p]=L.useState(()=>yB(i,o)),[m,h]=L.useState(()=>f===`system`?xB():f),g=c?Object.values(c):a,_=L.useCallback(e=>{let i=e;if(!i)return;e===`system`&&n&&(i=xB());let a=c?c[i]:i,l=t?bB(u):null,d=document.documentElement,f=e=>{e===`class`?(d.classList.remove(...g),a&&d.classList.add(a)):e.startsWith(`data-`)&&(a?d.setAttribute(e,a):d.removeAttribute(e))};if(Array.isArray(s)?s.forEach(f):f(s),r){let e=dB.includes(o)?o:null,t=dB.includes(i)?i:e;d.style.colorScheme=t}l?.()},[u]),v=L.useCallback(e=>{let t=typeof e==`function`?e(f):e;p(t);try{localStorage.setItem(i,t)}catch{}},[f]),y=L.useCallback(t=>{h(xB(t)),f===`system`&&n&&!e&&_(`system`)},[f,e]);L.useEffect(()=>{let e=window.matchMedia(fB);return e.addListener(y),y(e),()=>e.removeListener(y)},[y]),L.useEffect(()=>{let e=e=>{e.key===i&&(e.newValue?p(e.newValue):v(o))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[v]),L.useEffect(()=>{_(e??f)},[e,f]);let b=L.useMemo(()=>({theme:f,setTheme:v,forcedTheme:e,resolvedTheme:f===`system`?m:f,themes:n?[...a,`system`]:a,systemTheme:n?m:void 0}),[f,v,e,m,n,a]);return L.createElement(mB.Provider,{value:b},L.createElement(vB,{forcedTheme:e,storageKey:i,attribute:s,enableSystem:n,enableColorScheme:r,defaultTheme:o,value:c,themes:a,nonce:u,scriptProps:d}),l)},vB=L.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return L.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${uB.toString()})(${u})`}})}),yB=(e,t)=>{if(pB)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},bB=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},xB=e=>(e||=window.matchMedia(fB),e.matches?`dark`:`light`),SB=()=>(0,L.useCallback)(e=>{e&&e.focus()},[]),CB=(e,...t)=>{let n=(0,L.useRef)(null),[r,i]=(0,L.useState)(t),a=(0,L.useMemo)(()=>r.length!==t.length||r.some((e,n)=>e!==t[n])?(i(t),t):r,[t,r]);return n.current||=Y.get(e),(0,L.useEffect)(()=>{let e=n.current;return e?.init?.(...a),()=>{e?.dispose?.()}},[a]),n.current};function wB(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e==`object`&&t===`[object Date]`?new e.constructor(+e):typeof e==`number`||t===`[object Number]`||typeof e==`string`||t===`[object String]`?new Date(e):new Date(NaN)}function TB(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}var EB=365.2425,DB=6048e5,OB=864e5,kB=43200,AB=1440,jB=3600*24;jB*7,jB*EB/12*3;var MB={};function NB(){return MB}function PB(e,t){let n=NB(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wB(e),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function FB(e){return PB(e,{weekStartsOn:1})}function IB(e){let t=wB(e),n=t.getFullYear(),r=TB(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let i=FB(r),a=TB(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let o=FB(a);return t.getTime()>=i.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function LB(e){let t=wB(e);return t.setHours(0,0,0,0),t}function RB(e){let t=wB(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function zB(e,t){let n=LB(e),r=LB(t),i=+n-RB(n),a=+r-RB(r);return Math.round((i-a)/OB)}function BB(e){let t=IB(e),n=TB(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),FB(n)}function VB(e,t){let n=wB(e),r=wB(t),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function HB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function UB(e){if(!HB(e)&&typeof e!=`number`)return!1;let t=wB(e);return!isNaN(Number(t))}function WB(e,t){let n=wB(e),r=wB(t),i=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return i*12+a}function GB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function KB(e,t){return wB(e)-+wB(t)}function qB(e){let t=wB(e);return t.setHours(23,59,59,999),t}function JB(e){let t=wB(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function YB(e){let t=wB(e);return+qB(t)==+JB(t)}function XB(e,t){let n=wB(e),r=wB(t),i=VB(n,r),a=Math.abs(WB(n,r)),o;if(a<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*a);let t=VB(n,r)===-i;YB(wB(e))&&a===1&&VB(e,r)===1&&(t=!1),o=i*(a-Number(t))}return o===0?0:o}function ZB(e,t,n){let r=KB(e,t)/1e3;return GB(n?.roundingMethod)(r)}function QB(e){let t=wB(e),n=TB(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}var $B={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},eV=(e,t,n)=>{let r,i=$B[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function tV(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var nV={date:tV({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:tV({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:tV({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},rV={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},iV=(e,t,n,r)=>rV[e];function aV(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var oV={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:aV({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:aV({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:aV({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:aV({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:aV({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function sV(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?lV(s,e=>e.test(o)):cV(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function cV(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function lV(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function uV(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var dV={code:`en-US`,formatDistance:eV,formatLong:nV,formatRelative:iV,localize:oV,match:{ordinalNumber:uV({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:sV({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:sV({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:sV({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:sV({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:sV({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function fV(e){let t=wB(e);return zB(t,QB(t))+1}function pV(e){let t=wB(e),n=FB(t)-+BB(t);return Math.round(n/DB)+1}function mV(e,t){let n=wB(e),r=n.getFullYear(),i=NB(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=TB(e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=PB(o,t),c=TB(e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=PB(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function hV(e,t){let n=NB(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=mV(e,t),a=TB(e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),PB(a,t)}function gV(e,t){let n=wB(e),r=PB(n,t)-+hV(n,t);return Math.round(r/DB)+1}function _V(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var vV={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return _V(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):_V(n+1,2)},d(e,t){return _V(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return _V(e.getHours()%12||12,t.length)},H(e,t){return _V(e.getHours(),t.length)},m(e,t){return _V(e.getMinutes(),t.length)},s(e,t){return _V(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return _V(Math.trunc(r*10**(n-3)),t.length)}},yV={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},bV={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return vV.y(e,t)},Y:function(e,t,n,r){let i=mV(e,r),a=i>0?i:1-i;return t===`YY`?_V(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):_V(a,t.length)},R:function(e,t){return _V(IB(e),t.length)},u:function(e,t){return _V(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return _V(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return _V(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return vV.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return _V(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=gV(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):_V(i,t.length)},I:function(e,t,n){let r=pV(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):_V(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):vV.d(e,t)},D:function(e,t,n){let r=fV(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):_V(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return _V(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return _V(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return _V(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?yV.noon:r===0?yV.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?yV.evening:r>=12?yV.afternoon:r>=4?yV.morning:yV.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return vV.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):vV.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):vV.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):vV.s(e,t)},S:function(e,t){return vV.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return SV(r);case`XXXX`:case`XX`:return CV(r);default:return CV(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return SV(r);case`xxxx`:case`xx`:return CV(r);default:return CV(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},t:function(e,t,n){return _V(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,n){return _V(e.getTime(),t.length)}};function xV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+_V(a,2)}function SV(e,t){return e%60==0?(e>0?`-`:`+`)+_V(Math.abs(e)/60,2):CV(e,t)}function CV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=_V(Math.trunc(r/60),2),a=_V(r%60,2);return n+i+t+a}var wV=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},TV=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},EV={p:TV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return wV(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,wV(r,t)).replace(`{{time}}`,TV(i,t))}},DV=/^D+$/,OV=/^Y+$/,kV=[`D`,`DD`,`YY`,`YYYY`];function AV(e){return DV.test(e)}function jV(e){return OV.test(e)}function MV(e,t,n){let r=NV(e,t,n);if(console.warn(r),kV.includes(e))throw RangeError(r)}function NV(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var PV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,FV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IV=/^'([^]*?)'?$/,LV=/''/g,RV=/[a-zA-Z]/;function zV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=wB(e);if(!UB(s))throw RangeError(`Invalid time value`);let c=t.match(FV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=EV[t];return n(e,i.formatLong)}return e}).join(``).match(PV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:BV(e)};if(bV[t])return{isToken:!0,value:e};if(t.match(RV))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&jV(a)||!n?.useAdditionalDayOfYearTokens&&AV(a))&&MV(a,t,String(e));let o=bV[a[0]];return o(s,a,i.localize,l)}).join(``)}function BV(e){let t=e.match(IV);return t?t[1].replace(LV,`'`):e}function VV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=VB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),s,c;a>0?(s=wB(t),c=wB(e)):(s=wB(e),c=wB(t));let l=ZB(c,s),u=(RB(c)-RB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/AB);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/kB),i.formatDistance(`aboutXMonths`,f,o);if(f=XB(c,s),f<12){let e=Math.round(d/kB);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function HV(e,t){return VV(e,Date.now(),t)}function UV(e,t=`dd.MM.yyyy, HH:mm`,n){if(!e)return``;let r=new Date(e);return Number.isNaN(r.getTime())?(console.warn(`Invalid date:`,e),``):zV(r,t,{locale:n})}var WV=()=>globalThis.location.origin,GV=e=>navigator.clipboard.writeText(e),Y=new class{registrations=new Map;register(e,t,n){this.registrations.set(e,{factory:t,scope:n.scope})}get(e){let t=this.registrations.get(e);if(!t)throw Error(`No provider found for ${e.name}`);return t.scope===`singleton`?(t.instance??=t.factory(),t.instance):t.factory()}},KV=class extends Error{constructor(){super(`Aborted`),this.name=`AbortError`}},X=class e{_data=null;_error=null;_isLoading=!1;_isLoaded=!1;_abortController=null;static of(t,n){return new e(t,n)}constructor(e,t){this.fetchFunction=e,this.options=t,f(this)}get data(){return this._data}get isLoading(){return this._isLoading}get isLoaded(){return this._isLoaded}get error(){return this._error}get errorMessage(){return this._error?.response.errors?.[0].message}abort(){this._abortController?.abort(),this._abortController=null}setDataDirectly(e){this._data=e,this._isLoaded=!0}async fetch(...e){this.abort(),this._abortController=new AbortController;let t=this._abortController.signal;this.options?.skipResetting||this.reset();try{this.setIsLoading(!0);let n=await this.fetchFunction(...e);return t.aborted?{isRight:!1,error:new KV}:(this.setData(n),{isRight:!0,data:n})}catch(e){return t.aborted?{isRight:!1,error:new KV}:(console.error(e),this.setError(e),{isRight:!1,error:e})}finally{this.setIsLoading(!1),this.setIsLoaded(!0)}}reset(){this.setIsLoading(!1),this.setData(null),this.setError(null)}setData(e){this._data=e}setIsLoading(e){this._isLoading=e}setIsLoaded(e){this._isLoaded=e}setError(e){this._error=e}};function qV(e){return!e.isRight&&e.error instanceof KV}var JV=class{values;constructor(e){this.values=e,f(this,{},{autoBind:!0})}setValue(e,t){this.values[e]=t}get isValid(){return Object.values(this.values).every(Boolean)}},YV=e=>{if(e&&e.startsWith(`/`)&&!e.startsWith(`//`))return e},XV=e=>{if(!e)return null;try{let t=JSON.parse(e)?.redirect;return typeof t==`string`?t:null}catch{return null}},ZV=e=>{if(e)return JSON.stringify({redirect:e})},QV=()=>YV(new URLSearchParams(globalThis.location.search).get(`redirect`)),$V=e=>{let t=YV(e);return!t||t===`/`?``:`?redirect=${encodeURIComponent(t)}`},eH=function(e){return e.Loading=`loading`,e.Empty=`empty`,e.List=`list`,e.NotFound=`notFound`,e.Error=`error`,e}({}),tH=class{_state=eH.Loading;_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=0;_isInitialLoad=!0;constructor(){f(this,{},{autoBind:!0})}get state(){return this._state}get items(){return this._items}get hasNextPage(){return this._hasNextPage}get endCursor(){return this._endCursor}get totalCount(){return this._totalCount}get isInitialLoad(){return this._isInitialLoad}get showLoading(){return this._state===eH.Loading&&this._isInitialLoad}get showEmpty(){return this._state===eH.Empty}get showNotFound(){return this._state===eH.NotFound}get showList(){return this._state===eH.List}get showError(){return this._state===eH.Error}setLoading(){this._state=eH.Loading}setError(){this._isInitialLoad=!1,this._state=eH.Error}setItems(e,t){this._isInitialLoad=!1,this._items=e,this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor,this._totalCount=t.totalCount,e.length>0?this._state=eH.List:t.isSearching?this._state=eH.NotFound:this._state=eH.Empty}appendItems(e,t){this._items=[...this._items,...e],this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor}removeItem(e){let t=this._items.length;this._items=this._items.filter(t=>!e(t));let n=t-this._items.length;this._totalCount=Math.max(0,this._totalCount-n)}updateStateAfterRemove(e){this._items.length===0&&(this._state=e?eH.NotFound:eH.Empty)}reset(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this._state=eH.Loading}resetToLoading(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._totalCount=0,this._isInitialLoad=!0,this._state=eH.Loading}},nH=class{cachedItemViewModels=u.map();constructor(e){this.dataSource=e,h(this,{cachedItemViewModels:u,showLoading:a,showEmpty:a,showList:a,showError:a,items:a,totalCount:a,hasNextPage:a,init:m,dispose:m,tryToFetchNextPage:m,getOrCreateItemViewModel:!1})}get showLoading(){return this.dataSource.state===eH.Loading&&this.dataSource.isInitialLoad}get showEmpty(){return this.dataSource.state===eH.Empty}get showList(){return this.dataSource.state===eH.List}get showError(){return this.dataSource.state===eH.Error}get items(){return this.dataSource.items.map(e=>this.getOrCreateItemViewModel(e))}get totalCount(){return this.dataSource.totalCount}get hasNextPage(){return this.dataSource.hasNextPage}init(){this.dataSource.load()}dispose(){this.dataSource.dispose(),this.cachedItemViewModels.clear()}async tryToFetchNextPage(){await this.dataSource.loadNextPage()}getOrCreateItemViewModel(e){let t=this.getItemKey(e),n=this.cachedItemViewModels.get(t);return n||(n=this.createItemViewModel(e),this.cachedItemViewModels.set(t,n)),n}},rH=class{listState=new tH;request;config;constructor(e,t={}){this.request=X.of(e,{skipResetting:!0}),this.config={pageSize:t.pageSize??50},h(this,{items:a,hasNextPage:a,totalCount:a,isLoading:a,isInitialLoad:a,state:a,load:m,loadNextPage:m,reset:m,dispose:m},{autoBind:!0})}get items(){return this.listState.items}get hasNextPage(){return this.listState.hasNextPage}get totalCount(){return this.listState.totalCount}get isLoading(){return this.request.isLoading}get isInitialLoad(){return this.listState.isInitialLoad}get state(){return this.listState.state}async load(e){this.listState.setLoading();let t=await this.request.fetch(this.buildFetchArgs(e));if(!t.isRight){if(qV(t))return;c(()=>{this.listState.setError()});return}c(()=>{let e=this.extractItems(t.data),n=this.extractPageInfo(t.data);this.listState.setItems(e,n)})}async loadNextPage(){if(!this.hasNextPage||this.isLoading)return!1;let e=await this.request.fetch(this.buildFetchArgs(void 0,this.listState.endCursor||void 0));return e.isRight?(c(()=>{let t=this.extractItems(e.data),n=this.extractPageInfo(e.data);this.listState.appendItems(t,{hasNextPage:n.hasNextPage,endCursor:n.endCursor})}),!0):!1}reset(){this.listState.reset(),this.request.abort()}dispose(){this.request.abort()}},iH=class{id=ds();pendingRequestInternal=null;resolverInternal=null;constructor(){h(this,{pendingRequestInternal:u,hasPendingRequest:a,pendingRequest:a,setPendingRequest:m,clearPendingRequest:m})}setResolver(e){this.resolverInternal=e}resolve(e){this.resolverInternal?.(e)}get hasPendingRequest(){return this.pendingRequestInternal!==null}get pendingRequest(){return this.pendingRequestInternal}setPendingRequest(e){this.pendingRequestInternal=e}clearPendingRequest(){this.pendingRequestInternal=null}init(){}dispose(){}};function aH(e,t,n){return{payload:e,resolve:t,reject:n}}var oH=class{stack=[];constructor(){h(this,{stack:u,initStack:m.bound,pushRequest:m.bound,resolveToParent:m.bound,rejectRequest:m.bound,cancelFromItem:m.bound,dispose:m.bound})}initStack(e){this.stack=[e],this.setupItemResolver(e)}pushRequest(e,t,n,r){let i=aH(t,n,r);e.setPendingRequest(i);let a=this.createItemForRequest(i);this.addItem(a)}resolveToParent(e,t){let n=this.stack.indexOf(e);if(n===-1)return;let r=this.stack[n-1];r?.pendingRequest&&(r.pendingRequest.resolve(t),r.clearPendingRequest()),this.stack.splice(n).forEach(e=>e.dispose())}rejectRequest(e){let t=this.stack.indexOf(e);t!==-1&&this.stack.splice(t+1).forEach(e=>e.dispose());let n=t-1;if(n>=0){let e=this.stack[n];e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest())}}cancelFromItem(e){let t=this.stack.indexOf(e);t!==-1&&(this.stack.splice(t+1).forEach(e=>e.dispose()),e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest()))}dispose(){this.stack.forEach(e=>e.dispose()),this.stack=[]}addItem(e){this.setupItemResolver(e),this.stack.push(e)}setupItemResolver(e){e.setResolver(t=>this.handleItemResult(e,t))}},sH=class{_isFullscreen=!1;_isInitialized=!1;_containerRef=null;constructor(){h(this,{_isFullscreen:u,_containerRef:u,setContainerRef:m.bound,toggleFullscreen:m.bound,init:m.bound,dispose:m.bound,handleFullscreenChange:m.bound})}get isFullscreen(){return this._isFullscreen}setContainerRef(e){this._containerRef=e}toggleFullscreen(){this._isFullscreen?this.exitFullscreen():this.enterFullscreen()}init(){this._isInitialized||(this._isInitialized=!0,document.addEventListener(`fullscreenchange`,this.handleFullscreenChange))}dispose(){this._isInitialized&&(this._isInitialized=!1,document.removeEventListener(`fullscreenchange`,this.handleFullscreenChange),this._containerRef=null,this._isFullscreen=!1)}async enterFullscreen(){if(this._containerRef)try{await this._containerRef.requestFullscreen()}catch(e){console.error(e)}}async exitFullscreen(){try{await document.exitFullscreen()}catch(e){console.error(e)}}handleFullscreenChange(){this._isFullscreen=document.fullscreenElement===this._containerRef}},cH=class{_timer=null;constructor(e){this.delayMs=e}schedule(e){this.cancel(),this._timer=setTimeout(e,this.delayMs)}cancel(){this._timer&&=(clearTimeout(this._timer),null)}dispose(){this.cancel()}},lH=class{constructor(e,t){this.operator=e,this.value=t,Object.defineProperty(this,`t`,{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},uH=class extends lH{},dH=class extends uH{constructor(e,t){if(!Array.isArray(t))throw Error(`"${e}" operator expects to receive an array of conditions`);super(e,t)}},fH=`__itself__`,pH=class extends lH{constructor(e,t,n){super(e,n),this.field=t}},mH=new uH(`__null__`,null),hH=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function gH(e,t){return t instanceof dH&&t.operator===e}function _H(e,t){return t.length===1?t[0]:new dH(e,function e(t,n,r){let i=r||[];for(let r=0,a=n.length;r<a;r++){let a=n[r];gH(t,a)?e(t,a.value,i):i.push(a)}return i}(e,t))}var vH=e=>e,yH=()=>Object.create(null),bH=Object.defineProperty(yH(),`__@type@__`,{value:`ignore value`});function xH(e,t,n=!1){if(!e||e&&e.constructor!==Object)return!1;for(let r in e)if(hH(e,r)&&hH(t,r)&&(!n||e[r]!==bH))return!0;return!1}function SH(e){let t=[];for(let n in e)hH(e,n)&&e[n]!==bH&&t.push(n);return t}function CH(e,t){t!==mH&&e.push(t)}var wH=e=>_H(`and`,e),TH={compound(e,t,n){let r=(Array.isArray(t)?t:[t]).map(e=>n.parse(e));return new dH(e.name,r)},field:(e,t,n)=>new pH(e.name,n.field,t),document:(e,t)=>new uH(e.name,t)},EH=class{constructor(e,t=yH()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:t.operatorToConditionName||vH,defaultOperatorName:t.defaultOperatorName||`eq`,mergeFinalConditions:t.mergeFinalConditions||wH},this.o=Object.keys(e).reduce((t,n)=>(t[n]=Object.assign({name:this.u.operatorToConditionName(n)},e[n]),t),{}),this.s=Object.assign({},t.fieldContext,{field:``,query:{},parse:this.parse,hasOperators:e=>xH(e,this.o,t.useIgnoreValue)}),this.i=Object.assign({},t.documentContext,{parse:this.parse,query:{}}),this.h=t.useIgnoreValue?SH:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,t,n,r){let i=this.o[t];if(!i)throw Error(`Unsupported operator "${t}"`);if(i.type!==`field`)throw Error(`Unexpected ${i.type} operator "${t}" at field level`);return this.s.field=e,this.s.query=r,this.parseInstruction(i,n,this.s)}parseInstruction(e,t,n){return typeof e.validate==`function`&&e.validate(e,t),(e.parse||TH[e.type])(e,t,n)}parseFieldOperators(e,t){let n=[],r=this.h(t);for(let i=0,a=r.length;i<a;i++){let a=r[i];if(!this.o[a])throw Error(`Field query for "${e}" may contain only operators or a plain object as a value`);CH(n,this.parseField(e,a,t[a],t))}return n}parse(e){let t=[],n=this.h(e);this.i.query=e;for(let r=0,i=n.length;r<i;r++){let i=n[r],a=e[i],o=this.o[i];if(o){if(o.type!==`document`&&o.type!==`compound`)throw Error(`Cannot use parsing instruction for operator "${i}" in "document" context as it is supposed to be used in "${o.type}" context`);CH(t,this.parseInstruction(o,a,this.i))}else this.s.hasOperators(a)?t.push(...this.parseFieldOperators(i,a)):CH(t,this.parseField(i,this.u.defaultOperatorName,a,e))}return this.u.mergeFinalConditions(t)}};function DH(e,t){let n=e[t];if(typeof n!=`function`)throw Error(`Unable to interpret "${t}" condition. Did you forget to register interpreter for it?`);return n}function OH(e){return e.operator}function kH(e,t){let n=t,r=n&&n.getInterpreterName||OH,i;switch(n?n.numberOfArguments:0){case 1:i=t=>DH(e,r(t,n))(t,a);break;case 3:i=(t,i,o)=>DH(e,r(t,n))(t,i,o,a);break;default:i=(t,i)=>DH(e,r(t,n))(t,i,a)}let a=Object.assign({},n,{interpret:i});return a.interpret}function AH(e,t){return(n,...r)=>{let i=e(n,...r),a=t.bind(null,i);return a.ast=i,a}}EH.prototype.parseInstruction;function jH(e,t){if(!Array.isArray(t))throw Error(`"${e.name}" expects value to be an array`)}function MH(e,t){if(jH(e,t),!t.length)throw Error(`"${e.name}" expects to have at least one element in array`)}var NH=e=>(t,n)=>{if(typeof n!==e)throw Error(`"${t.name}" expects value to be a "${e}"`)},PH={type:`compound`,validate:MH,parse(e,t,{parse:n}){let r=t.map(e=>n(e));return _H(e.name,r)}},FH=PH,IH={type:`compound`,validate:MH},LH={type:`field`,validate(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw Error(`"${e.name}" expects to receive either regular expression or object of field operators`)},parse(e,t,n){let r=t instanceof RegExp?new pH(`regex`,n.field,t):n.parse(t,n);return new dH(e.name,[r])}},RH={type:`field`,validate(e,t){if(!t||t.constructor!==Object)throw Error(`"${e.name}" expects to receive an object with nested query or field level operators`)},parse(e,t,{parse:n,field:r,hasOperators:i}){let a=i(t)?n(t,{field:fH}):n(t);return new pH(e.name,r,a)}},zH={type:`field`,validate:NH(`number`)},BH={type:`field`,validate:jH},VH=BH,HH=BH,UH={type:`field`,validate(e,t){if(!Array.isArray(t)||t.length!==2)throw Error(`"${e.name}" expects an array with 2 numeric elements`)}},WH={type:`field`,validate:NH(`boolean`)},GH={type:`field`,validate:function(e,t){if(!(typeof t==`string`||typeof t==`number`||t instanceof Date))throw Error(`"${e.name}" expects value to be comparable (i.e., string, number or date)`)}},KH=GH,qH=KH,JH=KH,YH={type:`field`},XH=YH,ZH={type:`field`,validate(e,t){if(!(t instanceof RegExp)&&typeof t!=`string`)throw Error(`"${e.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(e,t,n){let r=typeof t==`string`?new RegExp(t,n.query.$options||``):t;return new pH(e.name,n.field,r)}},QH={type:`field`,parse:()=>mH},$H={type:`document`,validate:NH(`function`)},eU=Object.freeze({__proto__:null,$and:PH,$or:FH,$nor:IH,$not:LH,$elemMatch:RH,$size:zH,$in:BH,$nin:VH,$all:HH,$mod:UH,$exists:WH,$gte:GH,$gt:KH,$lt:qH,$lte:JH,$eq:YH,$ne:XH,$regex:ZH,$options:QH,$where:$H}),tU=class extends EH{constructor(e){super(e,{defaultOperatorName:`$eq`,operatorToConditionName:e=>e.slice(1)})}parse(e,t){return t&&t.field?wH(this.parseFieldOperators(t.field,e)):super.parse(e)}},nU=eU;function rU(e,t,n){for(let r=0,i=e.length;r<i;r++)if(n(e[r],t)===0)return!0;return!1}function iU(e,t){return Array.isArray(e)&&Number.isNaN(Number(t))}function aU(e,t,n){if(!iU(e,t))return n(e,t);let r=[];for(let i=0;i<e.length;i++){let a=n(e[i],t);a!==void 0&&(r=r.concat(a))}return r}function oU(e){return(t,n,r)=>{let i=r.get(n,t.field);return Array.isArray(i)?i.some(n=>e(t,n,r)):e(t,i,r)}}var sU=(e,t)=>e[t];function cU(e,t,n){let r=t.lastIndexOf(`.`);return r===-1?[e,t]:[n(e,t.slice(0,r)),t.slice(r+1)]}function lU(e,t,n=sU){if(t===`__itself__`)return e;if(!e)throw Error(`Unable to get field "${t}" out of ${String(e)}.`);return function(e,t,n){if(t.indexOf(`.`)===-1)return aU(e,t,n);let r=t.split(`.`),i=e;for(let e=0,t=r.length;e<t;e++)if(i=aU(i,r[e],n),!i||typeof i!=`object`)return i;return i}(e,t,n)}function uU(e,t){return e===t?0:e>t?1:-1}function dU(e,t={}){return kH(e,Object.assign({get:lU,compare:uU},t))}var fU=(e,t,{interpret:n})=>e.value.some(e=>n(e,t)),pU=(e,t,n)=>!fU(e,t,n),mU=(e,t,{interpret:n})=>e.value.every(e=>n(e,t)),hU=(e,t,{interpret:n})=>!n(e.value[0],t),gU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&!Array.isArray(e.value)?rU(i,e.value,n):n(i,e.value)===0},_U=(e,t,n)=>!gU(e,t,n),vU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===-1}),yU=oU((e,t,n)=>n.compare(t,e.value)===-1),bU=oU((e,t,n)=>n.compare(t,e.value)===1),xU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===1}),SU=(e,t,{get:n})=>{if(e.field===`__itself__`)return t!==void 0;let[r,i]=cU(t,e.field,n),a=t=>t==null?!!t===e.value:t.hasOwnProperty(i)===e.value;return iU(r,i)?r.some(a):a(r)},CU=oU((e,t)=>typeof t==`number`&&t%e.value[0]===e.value[1]),wU=(e,t,{get:n})=>{let[r,i]=cU(t,e.field,n),a=t=>{let r=n(t,i);return Array.isArray(r)&&r.length===e.value};return e.field!==`__itself__`&&iU(r,i)?r.some(a):a(r)},TU=oU((e,t)=>typeof t==`string`&&e.value.test(t)),EU=oU((e,t,{compare:n})=>rU(e.value,t,n)),DU=(e,t,n)=>!EU(e,t,n),OU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&e.value.every(e=>rU(i,e,n))},kU=(e,t,{interpret:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&i.some(t=>n(e.value,t))},AU=Object.freeze({__proto__:null,or:fU,nor:pU,and:mU,not:hU,eq:gU,ne:_U,lte:vU,lt:yU,gt:bU,gte:xU,exists:SU,mod:CU,size:wU,regex:TU,within:EU,nin:DU,all:OU,elemMatch:kU,where:(e,t)=>e.value.call(t)}),jU=Object.assign({},AU,{in:EU});dU(jU);function MU(e){return typeof e!=`object`||!e?e:e instanceof Date?e.getTime():e&&typeof e.toJSON==`function`?e.toJSON():e}var NU=(e,t)=>uU(MU(e),MU(t));function PU(e,t,n){let r=new tU(e),i=dU(t,Object.assign({compare:NU},n));if(n&&n.forPrimitives){let e={field:fH},t=r.parse;r.setParse(n=>t(n,e))}return AH(r.parse,i)}PU(nU,jU),PU([`$and`,`$or`].reduce((e,t)=>(e[t]=Object.assign({},e[t],{type:`field`}),e),Object.assign({},nU,{$nor:Object.assign({},nU.$nor,{type:`field`,parse:TH.compound})})),jU,{forPrimitives:!0});var FU=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t));function IU(e){return Array.isArray(e)?e:[e]}var LU=`__caslSubjectType__`;function RU(e,t){if(t){if(!FU(t,LU))Object.defineProperty(t,LU,{value:e});else if(e!==t[LU])throw Error(`Trying to cast object to subject type ${e} but previously it was casted to ${t[LU]}`)}return t}var zU=e=>{let t=typeof e;return t===`string`||t===`function`},BU=e=>e.modelName||e.name;function VU(e){return typeof e==`string`?e:BU(e)}function HU(e){return FU(e,LU)?e[LU]:BU(e.constructor)}var UU={function:e=>e.constructor,string:HU};function WU(e,t,n){for(let r=n;r<t.length;r++)e.push(t[r])}function GU(e,t){if(!e||!e.length)return t||[];if(!t||!t.length)return e||[];let n=0,r=0,i=[];for(;n<e.length&&r<t.length;)e[n].priority<t[r].priority?(i.push(e[n]),n++):(i.push(t[r]),r++);return WU(i,e,n),WU(i,t,r),i}function KU(e,t,n){let r=e.get(t);return r||(r=n(),e.set(t,r)),r}var qU=e=>e;function JU(e,t){if(Array.isArray(e.fields)&&!e.fields.length)throw Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(e.fields&&!t.fieldMatcher)throw Error(`You need to pass "fieldMatcher" option in order to restrict access by fields`);if(e.conditions&&!t.conditionsMatcher)throw Error(`You need to pass "conditionsMatcher" option in order to restrict access by conditions`)}var YU=class{constructor(e,t,n=0){JU(e,t),this.action=t.resolveAction(e.action),this.subject=e.subject,this.inverted=!!e.inverted,this.conditions=e.conditions,this.reason=e.reason,this.origin=e,this.fields=e.fields?IU(e.fields):void 0,this.priority=n,this.t=t}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){let e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||zU(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||=this.t.fieldMatcher(this.fields),this.u(e)):!this.inverted:!0}};function XU(e,t){let n={value:e,prev:t,next:null};return t&&(t.next=n),n}function ZU(e){e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next),e.next=e.prev=null}var QU=e=>({value:e.value,prev:e.prev,next:e.next}),$U=()=>({rules:[],merged:!1}),eW=()=>new Map,tW=class{constructor(e=[],t={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:t.conditionsMatcher,fieldMatcher:t.fieldMatcher,resolveAction:t.resolveAction||qU},this.$=t.anyAction||`manage`,this.A=t.anySubjectType||`all`,this.m=e,this.M=!!t.detectSubjectType,this.j=t.detectSubjectType||HU,this.v(e)}get rules(){return this.m}detectSubjectType(e){return zU(e)?e:e?this.j(e):this.A}update(e){let t={rules:e,ability:this,target:this};return this._(`update`,t),this.m=e,this.v(e),this._(`updated`,t),this}v(e){let t=new Map,n;for(let r=e.length-1;r>=0;r--){let i=e.length-r-1,a=new YU(e[r],this.p,i),o=IU(a.action),s=IU(a.subject||this.A);!this.h&&a.fields&&(this.h=!0);for(let e=0;e<s.length;e++){let r=KU(t,s[e],eW);n===void 0&&(n=typeof s[e]),typeof s[e]!==n&&n!==`mixed`&&(n=`mixed`);for(let e=0;e<o.length;e++)KU(r,o[e],$U).rules.push(a)}}this.l=t,n!==`mixed`&&!this.M&&(this.j=UU[n]||UU.string)}possibleRulesFor(e,t=this.A){if(!zU(t))throw Error(`"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter`);let n=KU(this.l,t,eW),r=KU(n,e,$U);if(r.merged)return r.rules;let i=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0,a=GU(r.rules,i);return t!==this.A&&(a=GU(a,this.possibleRulesFor(e,this.A))),r.rules=a,r.merged=!0,a}rulesFor(e,t,n){let r=this.possibleRulesFor(e,t);if(n&&typeof n!=`string`)throw Error("The 3rd, `field` parameter is expected to be a string. See https://stalniy.github.io/casl/en/api/casl-ability#can-of-pure-ability for details");return this.h?r.filter(e=>e.matchesField(n)):r}actionsFor(e){if(!zU(e))throw Error(`"actionsFor" accepts only subject types (i.e., string or class) as a parameter`);let t=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(e=>t.add(e));let r=e===this.A?void 0:this.l.get(this.A);return r&&Array.from(r.keys()).forEach(e=>t.add(e)),Array.from(t)}on(e,t){this.F=this.F||new Map;let n=this.F,r=XU(t,n.get(e)||null);return n.set(e,r),()=>{let t=n.get(e);!r.next&&!r.prev&&t===r?n.delete(e):r===t&&n.set(e,r.prev),ZU(r)}}_(e,t){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){let e=n.prev?QU(n.prev):null;n.value(t),n=e}}},nW=class extends tW{can(e,t,n){let r=this.relevantRuleFor(e,t,n);return!!r&&!r.inverted}relevantRuleFor(e,t,n){let r=this.detectSubjectType(t),i=this.rulesFor(e,r,n);for(let e=0,n=i.length;e<n;e++)if(i[e].matchesConditions(t))return i[e];return null}cannot(e,t,n){return!this.can(e,t,n)}},rW=PU({$eq:YH,$ne:XH,$lt:qH,$lte:JH,$gt:KH,$gte:GH,$in:BH,$nin:VH,$all:HH,$size:zH,$regex:ZH,$options:QH,$elemMatch:RH,$exists:WH},{eq:gU,ne:_U,lt:yU,lte:vU,gt:bU,gte:xU,in:EU,nin:DU,all:OU,size:wU,regex:TU,elemMatch:kU,exists:SU,and:mU}),iW=/[-/\\^$+?.()|[\]{}]/g,aW=/\.?\*+\.?/g,oW=/\*+/,sW=/\./g;function cW(e,t,n){let r=n[0]===`*`||e[0]===`.`&&e[e.length-1]===`.`?`+`:`*`,i=e.indexOf(`**`)===-1?`[^.]`:`.`,a=e.replace(sW,`\\$&`).replace(oW,i+r);return t+e.length===n.length?`(?:${a})?`:a}function lW(e,t,n){return e===`.`&&(n[t-1]===`*`||n[t+1]===`*`)?e:`\\${e}`}function uW(e){let t=e.map(e=>e.replace(iW,lW).replace(aW,cW)),n=t.length>1?`(?:${t.join(`|`)})`:t[0];return RegExp(`^${n}$`)}var dW=e=>{let t;return n=>(t===void 0&&(t=e.every(e=>e.indexOf(`*`)===-1)?null:uW(e)),t===null?e.indexOf(n)!==-1:t.test(n))};function fW(e=[],t={}){return new nW(e,Object.assign({conditionsMatcher:rW,fieldMatcher:dW},t))}var pW=e=>`Cannot execute "${e.action}" on "${e.subjectType}"`,mW=function(e){this.message=e};mW.prototype=Object.create(Error.prototype);var hW=class extends mW{static setDefaultMessage(e){this.P=typeof e==`string`?()=>e:e}static from(e){return new this(e)}constructor(e){super(``),this.ability=e,typeof Error.captureStackTrace==`function`&&(this.name=`ForbiddenError`,Error.captureStackTrace(this,this.constructor))}setMessage(e){return this.message=e,this}throwUnlessCan(e,t,n){let r=this.unlessCan(e,t,n);if(r)throw r}unlessCan(e,t,n){let r=this.ability.relevantRuleFor(e,t,n);if(r&&!r.inverted)return;this.action=e,this.subject=t,this.subjectType=VU(this.ability.detectSubjectType(t)),this.field=n;let i=r?r.reason:``;return this.message=this.message||i||this.constructor.P(this),this}};hW.P=pW,Object.freeze({__proto__:null});var gW=new Set([`read-project-private`,`read-project-public`]),_W=[`Table`,`Row`,`Branch`,`Revision`,`Endpoint`],vW=class{ability=fW();loadedScopes=new Set;addSystemPermissions(e){let t=this.scopeToKey({type:`system`});if(this.loadedScopes.has(t))return;let n=this.permissionsToRules(e,null),r=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...r]),this.loadedScopes.add(t)}addOrganizationPermissions(e,t){let n=this.scopeToKey({type:`organization`,organizationId:e});if(this.loadedScopes.has(n))return;let r={organizationId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addProjectPermissions(e,t){let n=this.scopeToKey({type:`project`,projectId:e});if(this.loadedScopes.has(n))return;let r={projectId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addPublicReadPermissions(e){let t=`public:${e}`;if(this.loadedScopes.has(t))return;let n={projectId:e},r={action:`read`,subject:`Project`,conditions:{...n,isPublic:!0}},i=_W.map(e=>({action:`read`,subject:e,conditions:{...n}}));this.ability.update([...this.ability.rules,r,...i]),this.loadedScopes.add(t)}can(e,t,n){let r=RU(t,n?{...n}:{});return this.ability.can(e,r)}cannot(e,t,n){return!this.can(e,t,n)}hasScope(e){return this.loadedScopes.has(this.scopeToKey(e))}clearAll(){this.ability.update([]),this.loadedScopes.clear()}scopeToKey(e){switch(e.type){case`system`:return`system`;case`organization`:return`organization:${e.organizationId}`;case`project`:return`project:${e.projectId}`}}permissionsToRules(e,t){return e.map(e=>this.permissionToRule(e,t))}permissionToRule(e,t){let n={action:e.action,subject:e.subject},r=this.mergeConditions(e.condition,t);return r&&(n.conditions=r),n}mergeConditions(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(!(!n&&!r))return n&&r?{...e,...t}:n?{...e}:{...t}}expandPermissions(e,t){let n=[];for(let r of e)if(gW.has(r.id))for(let e of _W){let r={action:`read`,subject:e};t&&Object.keys(t).length>0&&(r.conditions={...t}),n.push(r)}return n}};Y.register(vW,()=>new vW,{scope:`singleton`});var yW=class{constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){let t=e.permissions.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addSystemPermissions(t)}}clearAll(){this.permissionService.clearAll()}get canCreateProject(){return this.permissionService.can(`create`,`Project`)}get canReadUser(){return this.permissionService.can(`read`,`User`)}get canCreateUser(){return this.permissionService.can(`create`,`User`)}get canAddUser(){return this.permissionService.can(`add`,`User`)}get canUpdateUser(){return this.permissionService.can(`update`,`User`)}get canDeleteUser(){return this.permissionService.can(`delete`,`User`)}get canManageUsers(){return this.canAddUser||this.canReadUser}get canReadOrganization(){return this.permissionService.can(`read`,`Organization`)}get canUpdateOrganization(){return this.permissionService.can(`update`,`Organization`)}get canDeleteOrganization(){return this.permissionService.can(`delete`,`Organization`)}};Y.register(yW,()=>new yW(Y.get(vW)),{scope:`singleton`});var bW=class{_contextProvider=null;constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setContextProvider(e){this._contextProvider=e}get context(){return this._contextProvider?.()??{projectId:null,organizationId:null,isPublic:!1,projectRoleName:null}}get projectId(){return this.context.projectId}get organizationId(){return this.context.organizationId}get isPublic(){return this.context.isPublic}get projectRoleName(){return this.context.projectRoleName}getProjectContext(){let e=this.context,t={};return e.projectId&&(t.projectId=e.projectId),e.organizationId&&(t.organizationId=e.organizationId),t}can(e,t,n){let r=n??this.getProjectContext();return this.permissionService.can(e,t,Object.keys(r).length>0?r:void 0)}get canReadProject(){return this.can(`read`,`Project`,{...this.getProjectContext(),isPublic:this.context.isPublic})}get canUpdateProject(){return this.can(`update`,`Project`)}get canDeleteProject(){return this.can(`delete`,`Project`)}get canReadBranch(){return this.can(`read`,`Branch`)}get canCreateBranch(){return this.can(`create`,`Branch`)}get canDeleteBranch(){return this.can(`delete`,`Branch`)}get canReadRevision(){return this.can(`read`,`Revision`)}get canCreateRevision(){return this.can(`create`,`Revision`)}get canRevertRevision(){return this.can(`revert`,`Revision`)}get canReadTable(){return this.can(`read`,`Table`)}get canCreateTable(){return this.can(`create`,`Table`)}get canUpdateTable(){return this.can(`update`,`Table`)}get canDeleteTable(){return this.can(`delete`,`Table`)}get canReadRow(){return this.can(`read`,`Row`)}get canCreateRow(){return this.can(`create`,`Row`)}get canUpdateRow(){return this.can(`update`,`Row`)}get canDeleteRow(){return this.can(`delete`,`Row`)}get canReadEndpoint(){return this.can(`read`,`Endpoint`)}get canCreateEndpoint(){return this.can(`create`,`Endpoint`)}get canDeleteEndpoint(){return this.can(`delete`,`Endpoint`)}get canAddUser(){return this.can(`add`,`User`)}get canUpdateUser(){return this.can(`update`,`User`)}get canDeleteUser(){return this.can(`delete`,`User`)}get canReadUser(){return this.can(`read`,`User`)}get canManageApiKeys(){return this.can(`manage`,`ApiKey`)}get canManageUsers(){return this.canAddUser||this.canReadUser}get canAccessSettings(){return this.canUpdateProject||this.canDeleteProject}get canWrite(){return this.canCreateTable||this.canUpdateTable||this.canDeleteTable||this.canCreateRow||this.canUpdateRow||this.canDeleteRow}get isReadOnly(){return!this.canWrite}};Y.register(bW,()=>new bW(Y.get(vW)),{scope:`singleton`});var xW;n((()=>{xW=function(){return xW=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xW.apply(this,arguments)}}))();var SW=new Map,CW=new Map,wW=!0,TW=!1;function EW(e){return e.replace(/[\s,]+/g,` `).trim()}function DW(e){return EW(e.source.body.substring(e.start,e.end))}function OW(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if(e.kind===`FragmentDefinition`){var r=e.name.value,i=DW(e.loc),a=CW.get(r);a&&!a.has(i)?wW&&console.warn(`Warning: fragment with name `+r+` already exists.
382
+ `))}catch{return Promise.resolve()}}async function ZR(e,t,n,r){let i;try{i=await navigator.clipboard.readText()}catch{return}let a=JR(i);for(let[i,o]of a.entries()){let a=n[e+i];if(!a)break;for(let[e,n]of o.entries()){let i=r[t+e];if(!i)break;let o=a.getCellVM(i);o.isEditable&&o.applyPastedText(n)}}}function QR(e,t,n){let r=e.focusedCell;if(!r)return null;let i=t.findIndex(e=>e.field===r.field),a=n.findIndex(e=>e.rowId===r.rowId);return i===-1||a===-1?null:{colIndex:i,rowIndex:a}}function $R(e,t,n){for(let r=e.startRow;r<=e.endRow;r++)for(let i=e.startCol;i<=e.endCol;i++){let e=t[r],a=n[i];e&&a&&e.getCellVM(a).clearToDefault()}}var ez=`#ededed`,tz=`inset 0 -1px 0 0 ${ez}`;function nz(){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,left:`-8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:`var(--shadow-right-opacity, 0)`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}function rz(e,t){return t<=0?e:e===`0px`?`${t}px`:`calc(${e} + ${t}px)`}var iz=40,az=g(({field:e,columnsModel:t})=>{let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(0),a=(0,L.useRef)(0),o=(0,L.useRef)(0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>()=>{s.current&&s.current()},[]),(0,I.jsx)(A,{role:`separator`,position:`absolute`,right:`-4px`,top:0,bottom:0,width:`8px`,cursor:`col-resize`,zIndex:10,onMouseDown:(0,L.useCallback)(n=>{n.preventDefault(),n.stopPropagation();let c=t.resolveColumnWidth(e);i.current=n.clientX,a.current=c,r(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let l=n=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let r=n.clientX-i.current,o=Math.max(iz,a.current+r);t.setColumnWidth(e,o)})},u=()=>{cancelAnimationFrame(o.current),t.commitColumnWidth(),r(!1),document.body.style.cursor=``,document.body.style.userSelect=``,document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,d),s.current=null},d=()=>{u()};s.current=u,document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,d)},[e,t]),"data-testid":`resize-${e}`,children:(0,I.jsx)(A,{position:`absolute`,left:`3px`,top:0,bottom:0,width:`2px`,bg:n?`blue.500`:`transparent`,_groupHover:{bg:`blue.500`},transition:`background 0.1s`})})}),oz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.getSortIndex(e),i=t.sortCount>1;return n?(0,I.jsxs)(j,{alignItems:`center`,gap:`1px`,color:`blue.500`,fontSize:`xs`,flexShrink:0,"data-testid":`sort-indicator-${e}`,children:[n===`asc`?(0,I.jsx)(uk,{size:12}):(0,I.jsx)(ak,{size:12}),i&&r!==null&&(0,I.jsx)(A,{as:`span`,fontSize:`10px`,fontWeight:`medium`,lineHeight:1,children:r})]}):null}),sz=g(({field:e,columnsModel:t})=>t.isPinned(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`pin-indicator-${e}`,children:(0,I.jsx)(Ck,{size:12})}):null),cz=g(({field:e,filterModel:t})=>t.hasFilterForField(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`filter-indicator-${e}`,children:(0,I.jsx)(yk,{size:12})}):null),lz=({column:e})=>e.hasFormula?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`formula-indicator-${e.field}`,children:(0,I.jsx)(Yf,{size:12})}):null,uz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.isSorted(e);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Sort`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[(0,I.jsxs)(gt,{value:`sort-asc`,onClick:()=>{t.setSingleSort(e,`asc`)},color:n===`asc`?`blue.600`:void 0,children:[(0,I.jsx)(ck,{}),(0,I.jsx)(k,{children:`Sort A → Z`})]}),(0,I.jsxs)(gt,{value:`sort-desc`,onClick:()=>{t.setSingleSort(e,`desc`)},color:n===`desc`?`blue.600`:void 0,children:[(0,I.jsx)(ik,{}),(0,I.jsx)(k,{children:`Sort Z → A`})]}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`remove-sort`,onClick:()=>{t.removeSort(e)},children:[(0,I.jsx)(Dk,{}),(0,I.jsx)(k,{children:`Remove sort`})]})]})]})})})]})}),dz=g(({field:e,columnsModel:t})=>{let n=t.canMoveLeft(e),r=t.canMoveRight(e),i=t.canMoveToStart(e),a=t.canMoveToEnd(e);return!n&&!r?null:(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Move column`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[n&&(0,I.jsxs)(gt,{value:`move-left`,onClick:()=>t.moveColumnLeft(e),children:[(0,I.jsx)(pk,{}),(0,I.jsx)(k,{children:`Move left`})]}),i&&(0,I.jsxs)(gt,{value:`move-to-start`,onClick:()=>t.moveColumnToStart(e),children:[(0,I.jsx)(ok,{}),(0,I.jsx)(k,{children:`Move to start`})]}),r&&(0,I.jsxs)(gt,{value:`move-right`,onClick:()=>t.moveColumnRight(e),children:[(0,I.jsx)(mk,{}),(0,I.jsx)(k,{children:`Move right`})]}),a&&(0,I.jsxs)(gt,{value:`move-to-end`,onClick:()=>t.moveColumnToEnd(e),children:[(0,I.jsx)(sk,{}),(0,I.jsx)(k,{children:`Move to end`})]})]})})})]})}),fz=(0,L.memo)(({field:e,name:t,fieldType:n,valuePrefix:r,onClick:i})=>(0,I.jsx)(gt,{value:r?`${r}-${e}`:e,onClick:()=>i(e),children:(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,width:`100%`,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(n)}),(0,I.jsx)(k,{truncate:!0,children:t||`(unnamed)`})]})})),pz=({group:e,parentVisible:t,valuePrefix:n,onClick:r})=>e.children.length===0&&!t?(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}):(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{"data-testid":`file-group-${e.parent.field}`,children:[(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,flex:1,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(e.parent.fieldType)}),(0,I.jsx)(k,{truncate:!0,children:e.parent.label})]}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:[!t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}),(0,I.jsx)(dt,{})]}),e.children.map(e=>(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:n,onClick:r},e.field))]})})})]}),mz=({label:e,valuePrefix:t,availableFields:n,allColumns:r,onSelect:i})=>{if(n.length===0)return null;let a=EI(n,r);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:e}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:a.map(e=>TI(e)?(0,I.jsx)(pz,{group:e,parentVisible:e.parentVisible,valuePrefix:t,onClick:i},e.parent.field):(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:t,onClick:i},e.field))})})})]})},hz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:a})=>{let o=t.canRemoveColumn,s=t.availableFieldsToInsert,c=s.length>0,l=t.canMoveLeft(e.field)||t.canMoveRight(e.field),u=t.isPinned(e.field),d=t.canPinLeft(e.field),f=t.canPinRight(e.field);return(0,I.jsxs)(v,{minW:`180px`,children:[n&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(uz,{field:e.field,sortModel:n}),(0,I.jsx)(dt,{})]}),r&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`add-filter`,onClick:()=>{r&&(r.addConditionForField(e.field),r.setOpen(!0))},children:[(0,I.jsx)(yk,{}),(0,I.jsx)(k,{children:`Add filter`})]}),(0,I.jsx)(dt,{})]}),u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`unpin`,onClick:()=>{t.unpin(e.field)},children:[(0,I.jsx)(Sk,{}),(0,I.jsx)(k,{children:`Unpin column`})]}),(0,I.jsx)(dt,{})]}):(0,I.jsxs)(I.Fragment,{children:[d&&(0,I.jsxs)(gt,{value:`pin-left`,onClick:()=>{t.pinLeft(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to left`})]}),f&&(0,I.jsxs)(gt,{value:`pin-right`,onClick:()=>{t.pinRight(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to right`})]}),(d||f)&&(0,I.jsx)(dt,{})]}),l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dz,{field:e.field,columnsModel:t}),(0,I.jsx)(dt,{})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mz,{label:`Insert before`,valuePrefix:`before`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnBefore(e.field,n),a?.()}}),(0,I.jsx)(mz,{label:`Insert after`,valuePrefix:`after`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnAfter(e.field,n),a?.()}}),(0,I.jsx)(dt,{})]}),(0,I.jsxs)(gt,{value:`hide`,disabled:!o,onClick:()=>{t.hideColumn(e.field)},children:[(0,I.jsx)(dne,{}),(0,I.jsx)(k,{children:`Hide column`})]}),(0,I.jsxs)(gt,{value:`hide-all`,disabled:!o,onClick:t.hideAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Hide all columns`})]}),(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`copy-path`,onClick:()=>{i?i(e.field):navigator.clipboard.writeText(e.field).catch(()=>{})},children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Copy path`})]})]})});function gz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e.side===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e.side===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function _z(e){return e?`${tz}, ${e.side===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var vz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,stickyPosition:a})=>{let[o,s]=(0,L.useState)(!1),c=t.columnWidthCssVar(e.field),l=!!a;return(0,I.jsxs)(A,{as:`th`,position:l?`sticky`:`relative`,left:a?.side===`left`?a.offsetCss:void 0,right:a?.side===`right`?a.offsetCss:void 0,zIndex:l?2:void 0,width:c,minWidth:c,maxWidth:c,height:`inherit`,bg:`white`,boxShadow:_z(a),textAlign:`left`,fontWeight:`normal`,p:0,css:a?.isBoundary?gz(a):void 0,children:[(0,I.jsxs)(en,{positioning:{placement:`bottom-end`},lazyMount:!0,unmountOnExit:!0,open:o,onOpenChange:e=>s(e.open),children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(j,{alignItems:`center`,height:`100%`,pl:`8px`,pr:`16px`,gap:`4px`,cursor:`pointer`,transition:`background 0.15s`,overflow:`hidden`,_hover:{bg:`gray.100`},"data-testid":`header-${e.field}`,children:[(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flexShrink:0,fontSize:`xs`,color:`gray.400`,width:`16px`,children:sL(e.fieldType)}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.400`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,overflow:`hidden`,flex:1,minWidth:0,textDecoration:e.isDeprecated?`line-through`:void 0,children:e.label}),(0,I.jsx)(lz,{column:e}),(0,I.jsx)(sz,{field:e.field,columnsModel:t}),r&&e.isSortable&&(0,I.jsx)(cz,{field:e.field,filterModel:r}),n&&e.isSortable&&(0,I.jsx)(oz,{field:e.field,sortModel:n})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(hz,{column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:()=>s(!1)})})})]}),(0,I.jsx)(az,{field:e.field,columnsModel:t})]})}),yz=g(({columnsModel:e})=>{let t=e.availableFieldsToAdd,n=e.availableSystemFieldsToAdd;if(!e.hasHiddenColumns)return null;let r=EI(t,e.allColumns);return(0,I.jsx)(j,{alignItems:`center`,px:`4px`,height:`100%`,children:(0,I.jsxs)(en,{positioning:{placement:`bottom-start`},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(Ze,{"aria-label":`Add column`,size:`xs`,variant:`ghost`,color:`gray.400`,_hover:{bg:`gray.100`,color:`gray.600`},focusRing:`none`,"data-testid":`add-column-button`,children:(0,I.jsx)(ep,{})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`200px`,maxH:`340px`,overflowY:`auto`,children:[(0,I.jsxs)(gt,{value:`add-all`,onClick:e.addAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Add all columns`})]}),r.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`Data fields`}),r.map(t=>TI(t)?(0,I.jsx)(pz,{group:t,parentVisible:t.parentVisible,onClick:e.showColumn},t.parent.field):(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`System fields`}),n.map(t=>(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]})]})})})]})})}),bz=40,xz=40,Sz=g(({columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,showSelection:i})=>{let a=i?bz:0,o=e.hasHiddenColumns;return(0,I.jsxs)(A,{as:`tr`,height:`40px`,children:[i&&(0,I.jsx)(A,{as:`th`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,bg:`white`,p:0,position:`sticky`,left:0,zIndex:2,boxShadow:tz}),e.visibleColumns.map(i=>(0,I.jsx)(vz,{column:i,columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,stickyPosition:Cz(i.field,e,a,o)},i.field)),o?(0,I.jsx)(A,{as:`th`,width:`100%`,minWidth:`${xz}px`,bg:`white`,p:0,position:`sticky`,right:0,zIndex:2,boxShadow:tz,css:e.pinnedRightCount===0?nz():void 0,children:(0,I.jsx)(yz,{columnsModel:e})}):(0,I.jsx)(A,{as:`th`,width:`100%`,bg:`white`,p:0,boxShadow:tz})]})});function Cz(e,t,n,r){let i=t.getColumnStickyLeftCss(e,n);if(i!==void 0)return{side:`left`,offsetCss:i,isBoundary:t.isStickyLeftBoundary(e)};let a=t.getColumnStickyRightCss(e);if(a!==void 0)return{side:`right`,offsetCss:rz(a,r?xz:0),isBoundary:t.isStickyRightBoundary(e)}}var wz=({rowId:e,testIdPrefix:t,onSelect:n,onDuplicate:r,onDelete:i})=>(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(gt,{value:`select`,onClick:()=>n(e),"data-testid":`${t}-select-${e}`,children:[(0,I.jsx)(Kf,{}),(0,I.jsx)(k,{children:`Select`})]}),r&&(0,I.jsxs)(gt,{value:`duplicate`,onClick:()=>r(e),"data-testid":`${t}-duplicate-${e}`,children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Duplicate`})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`delete`,onClick:()=>i(e),"data-testid":`${t}-delete-${e}`,children:[(0,I.jsx)(Ek,{}),(0,I.jsx)(k,{color:`red.600`,children:`Delete`})]})]})]}),Tz=({rowId:e,onOpen:t,onPick:n,onSelect:r,onDuplicate:i,onDelete:a})=>{let[o,s]=(0,L.useState)(!1),c=n??t,l=n?Kf:df,u=n?`row-action-pick-${e}`:`row-action-open-${e}`,d=!!(t||r||i||a);return(0,I.jsx)(j,{position:`absolute`,right:`8px`,top:`50%`,transform:`translateY(-50%)`,alignItems:`center`,className:`row-action-buttons`,"data-menu-open":o||void 0,"data-testid":`row-action-buttons-${e}`,children:(0,I.jsxs)(j,{alignItems:`center`,height:`24px`,borderRadius:`6px`,bg:`white`,boxShadow:`0px 2px 8px rgba(0,0,0,0.16)`,overflow:`hidden`,"data-testid":`row-action-split-${e}`,children:[c&&(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`28px`,minWidth:`28px`,cursor:`pointer`,_hover:{bg:`gray.100`},onClick:t=>{t.stopPropagation(),c(e)},"data-testid":u,children:(0,I.jsx)(Ve,{boxSize:`20px`,color:`gray.400`,as:l})}),d&&(0,I.jsxs)(en,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:e})=>s(e),positioning:{placement:`bottom-start`},children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`18px`,minWidth:`18px`,cursor:`pointer`,borderLeft:c?`1px solid`:void 0,borderColor:`gray.100`,_hover:{bg:`gray.100`},onClick:e=>e.stopPropagation(),"data-testid":`row-action-trigger-${e}`,children:(0,I.jsx)(Ve,{as:nf,boxSize:`16px`,color:`gray.300`})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`180px`,"data-testid":`row-action-menu-${e}`,children:[t&&(0,I.jsxs)(gt,{value:`open`,onClick:()=>t(e),"data-testid":`row-action-menu-open-${e}`,children:[(0,I.jsx)(df,{}),(0,I.jsx)(k,{children:`Open`})]}),t&&(r||i||a)&&(0,I.jsx)(dt,{}),(0,I.jsx)(wz,{rowId:e,testIdPrefix:`row-action`,onSelect:r,onDuplicate:i,onDelete:a})]})})})]})]})})},Ez=({rowId:e,isSelected:t,onToggleSelection:n})=>(0,I.jsx)(A,{as:`td`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,p:0,position:`sticky`,left:0,zIndex:1,bg:`white`,boxShadow:`inset 0 -1px 0 0 ${ez}, inset -1px 0 0 0 ${ez}`,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,children:(0,I.jsxs)(Ne,{checked:t,onCheckedChange:()=>n(),size:`sm`,"data-testid":`select-${e}`,children:[(0,I.jsx)($e,{}),(0,I.jsx)(Ye,{})]})})}),Dz=40,Oz=40;function kz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function Az(e,t,n,r){let i=r&&n,a=i?{"& .row-action-buttons":{opacity:0},"&:hover .row-action-buttons, & .row-action-buttons[data-menu-open]":{opacity:1,transition:`opacity 0.15s ease`}}:{};if(e)return{...a,...kz(t)};if(i)return a}function jz(e,t,n,r){let i=t.getColumnStickyLeftCss(e.field,n),a=t.getColumnStickyRightCss(e.field),o=i!==void 0,s=a!==void 0,c=o||s,l=t.isStickyLeftBoundary(e.field),u=t.isStickyRightBoundary(e.field),d=s&&a!==void 0?rz(a,r):a;return{isSticky:c,isBoundary:l||u,boundarySide:o?`left`:`right`,leftCss:o?i:void 0,rightCss:s?d:void 0,colWidth:c?t.columnWidthCssVar(e.field):void 0}}function Mz(e,t){return e?`${tz}, ${t===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var Nz=g(({row:e,columnsModel:t,showSelection:n,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a,onOpenRow:o,onPickRow:s,onSelectRow:c,onDuplicateRow:l,onDeleteRow:u})=>{let d=!!(o||s||c||l||u),f=n?Dz:0,p=t.hasHiddenColumns,m=p?Oz:0;return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsx)(Ez,{rowId:e.rowId,isSelected:e.isSelected,onToggleSelection:()=>e.toggleSelection()}),t.visibleColumns.map((n,p)=>{let h=e.getCellVM(n),g=p===0,_=g&&d&&!h.isEditing,v=jz(n,t,f,m);return(0,I.jsxs)(A,{as:`td`,width:v.colWidth,minWidth:v.colWidth,maxWidth:v.isSticky?v.colWidth:`0`,overflow:v.isBoundary?`visible`:`hidden`,borderRight:v.isSticky?void 0:`1px solid`,borderColor:v.isSticky?void 0:ez,p:0,position:v.isSticky?`sticky`:`relative`,left:v.leftCss,right:v.rightCss,zIndex:v.isSticky?1:void 0,bg:v.isSticky?`white`:void 0,boxShadow:Mz(v.isSticky,v.boundarySide),css:Az(v.isBoundary,v.boundarySide,d,g),children:[v.isBoundary?(0,I.jsx)(A,{overflow:`hidden`,children:(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a})}):(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a}),_&&(0,I.jsx)(Tz,{rowId:e.rowId,onOpen:o,onPick:s,onSelect:c,onDuplicate:l,onDelete:u})]},n.field)}),p?(0,I.jsx)(A,{as:`td`,width:`100%`,minWidth:`${Oz}px`,p:0,position:`sticky`,right:0,zIndex:1,bg:`white`,boxShadow:tz,css:t.pinnedRightCount===0?nz():void 0}):(0,I.jsx)(A,{as:`td`,width:`100%`,p:0,boxShadow:tz})]})}),Pz=g(({selection:e,allRowIds:t,onDuplicate:n,onDelete:r})=>{let i=e.isAllSelected(t);return(0,I.jsx)(tee,{open:e.isSelectionMode,children:(0,I.jsx)(R,{children:(0,I.jsx)(vt,{zIndex:5,children:(0,I.jsxs)(pt,{"data-testid":`selection-toolbar`,children:[(0,I.jsxs)(zt,{children:[e.selectedCount,` selected`]}),(0,I.jsx)(wt,{}),!i&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>e.selectAll(t),"data-testid":`select-all`,children:[(0,I.jsx)(Kf,{}),`Select all`]}),n&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>n(e.selectedIds),"data-testid":`duplicate-selected`,children:[(0,I.jsx)(vk,{}),`Duplicate`]}),r&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>r(e.selectedIds),"data-testid":`delete-selected`,children:[(0,I.jsx)(Ek,{}),`Delete`]}),(0,I.jsx)(iee,{asChild:!0,children:(0,I.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Exit selection`,onClick:()=>e.exitSelectionMode(),"data-testid":`exit-selection`,children:(0,I.jsx)(ip,{})})})]})})})})}),Fz=({isOpen:e,onClose:t,onConfirm:n,count:r})=>{let i=(0,L.useRef)(null),a=r&&r>1?`Are you sure you want to delete ${r} rows?`:`Are you sure you want to delete this row?`;return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>{e||t()},initialFocusEl:()=>i.current,role:`alertdialog`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`400px`,"data-testid":`delete-confirm-dialog`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete confirmation`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:a})}),(0,I.jsx)(w,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(N,{ref:i,variant:`outline`,size:`sm`,onClick:t,"data-testid":`delete-cancel`,children:`Cancel`}),(0,I.jsx)(N,{colorPalette:`red`,size:`sm`,onClick:n,"data-testid":`delete-confirm`,children:`Delete`})]})})]})})]})})},Iz=({style:e,children:t,...n})=>(0,I.jsx)(`table`,{...n,style:{...e,width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:t}),Lz=({"data-index":e,context:t,style:n,children:r,...i})=>{let a=t?.rows[e];return(0,I.jsx)(`tr`,{...i,className:`group`,"data-testid":a?`row-${a.rowId}`:void 0,style:{...n,height:`40px`},children:r})},Rz={left:!1,right:!1},zz=class{_left=!1;_right=!1;_paused=!1;_dirty=!1;_onChange=null;get showLeftShadow(){return this._left}get showRightShadow(){return this._right}setOnChange(e){this._onChange=e}pause(){this._paused=!0,this._dirty=!1}resume(){this._paused=!1,this._dirty&&(this._dirty=!1,this._notify())}update(e,t){if(!(this._left===e&&this._right===t)){if(this._left=e,this._right=t,this._paused){this._dirty=!0;return}this._notify()}}reset(){if(!(!this._left&&!this._right)){if(this._left=!1,this._right=!1,this._paused){this._dirty=!0;return}this._notify()}}_notify(){this._onChange&&this._onChange({left:this._left,right:this._right})}};function Bz(e){return e instanceof HTMLElement?e:document.scrollingElement}function Vz(){let e=(0,L.useRef)(null);e.current||=new zz;let t=e.current,[n,r]=(0,L.useState)(Rz);t.setOnChange(r),(0,L.useEffect)(()=>()=>{t.setOnChange(null)},[t]);let i={"--shadow-left-opacity":n.left?`1`:`0`,"--shadow-right-opacity":n.right?`1`:`0`},a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(null),c=(0,L.useCallback)(()=>{let e=a.current;if(!e)return;let n=Bz(e);if(!n)return;let r=n.scrollLeft,i=n.scrollWidth-n.clientWidth;t.update(r>0,i>1&&r<i-1)},[t]),l=(0,L.useCallback)(()=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c)},[c]),u=(0,L.useCallback)(e=>{let n=a.current;if(n&&n.removeEventListener(`scroll`,l),s.current&&=(s.current.disconnect(),null),e){a.current=e,e.addEventListener(`scroll`,l,{passive:!0}),o.current=requestAnimationFrame(c);let t=Bz(e);if(t){let e=new ResizeObserver(l),n=t.querySelector(`table`);n&&e.observe(n),s.current=e}}else a.current=null,t.reset()},[l,c,t]);return(0,L.useEffect)(()=>()=>{let e=a.current;e&&e.removeEventListener(`scroll`,l),s.current&&s.current.disconnect(),o.current&&cancelAnimationFrame(o.current)},[l]),{shadowCssVars:i,shadowModel:t,setScrollerRef:u}}var Hz={Table:Iz,TableRow:Lz},Uz=g(({rows:e,columnsModel:t,cellFSM:n,selection:r,sortModel:i,filterModel:a,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onDeleteSelected:d,onDuplicateSelected:f,onDeleteRow:p,onDuplicateRow:m,onCopyPath:h,onEndReached:g,isLoadingMore:_,useWindowScroll:v})=>{let y=r.isSelectionMode,b=e.map(e=>e.rowId),[x,S]=(0,L.useState)(null),{shadowCssVars:C,shadowModel:w,setScrollerRef:T}=Vz(),E=t.isResizing;(0,L.useEffect)(()=>{E?w.pause():w.resume()},[E,w]);let[D,ee]=(0,L.useState)(null),te=(0,L.useCallback)(e=>{ee(e),t.setWrapperElement(e)},[t]);(0,L.useEffect)(()=>{if(!(!v||!D))return T(D),()=>{T(null)}},[v,D,T]);let ne=(0,L.useCallback)(e=>{r.enterSelectionMode(e)},[r]),O=(0,L.useCallback)(e=>{S({rowId:e})},[]),re=(0,L.useCallback)(e=>{S({batchIds:e})},[]),ie=(0,L.useCallback)(()=>{x?.rowId?(r.deselect(x.rowId),p?p(x.rowId):d&&d([x.rowId])):x?.batchIds&&(d?.(x.batchIds),r.exitSelectionMode()),S(null)},[x,p,d,r]),ae=(0,L.useCallback)(()=>{S(null)},[]),oe=x?.batchIds?.length,se=!!(p||d),ce=!!m,le=se||ce||!!f,ue=(0,L.useMemo)(()=>({copyRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&XR(r,e,i)},pasteRange:()=>{if(!n)return;let r=t.visibleColumns,i=n.getSelectedRange(),a=QR(n,r,e);i?ZR(i.startRow,i.startCol,e,r):a&&ZR(a.rowIndex,a.colIndex,e,r)},clearRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&$R(r,e,i)}}),[n,e,t]),de=(0,L.useCallback)(r=>{if(!n)return;let i=r.ctrlKey||r.metaKey,a=t.visibleColumns;if(i&&r.key===`v`&&n.focusedCell){let t=n.getSelectedRange(),i=QR(n,a,e);t?(r.preventDefault(),ZR(t.startRow,t.startCol,e,a)):i&&(r.preventDefault(),ZR(i.rowIndex,i.colIndex,e,a));return}if(n.hasSelection){if(i&&r.key===`c`){let t=n.getSelectedRange();t&&(r.preventDefault(),XR(t,e,a));return}if(r.key===`Delete`||r.key===`Backspace`){let t=n.getSelectedRange();t&&(r.preventDefault(),$R(t,e,a))}}},[n,e,t]),fe=(0,L.useCallback)((e,n)=>(0,I.jsx)(Nz,{row:n,columnsModel:t,showSelection:y,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onSelectRow:le?ne:void 0,onDuplicateRow:ce?m:void 0,onDeleteRow:se?O:void 0}),[t,y,o,s,c,l,u,le,se,ce,ne,m,O]),pe=(0,L.useCallback)(()=>(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y}),[t,i,a,h,y]),me=(0,L.useMemo)(()=>({rows:e}),[e]),he=t.visibleColumns.length+(y?2:1),ge=(0,L.useCallback)(()=>_?(0,I.jsx)(`tfoot`,{children:(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:he,style:{textAlign:`center`,padding:`16px 0`},children:(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`})})})}):null,[_,he]),_e=(0,L.useMemo)(()=>({...Hz,Footer:ge}),[ge]);return t.visibleColumns.length===0?(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No columns to display.`})}):(0,I.jsxs)(nR.Provider,{value:n?ue:null,children:[(0,I.jsxs)(A,{ref:te,position:`relative`,height:v?void 0:`100%`,overflowX:`auto`,overflowY:v?`clip`:void 0,"data-testid":`table-widget`,onKeyDown:de,style:{...t.columnWidthCssVars,...C},children:[e.length===0?(0,I.jsxs)(A,{children:[(0,I.jsx)(`table`,{style:{width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:(0,I.jsx)(`thead`,{children:(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y})})}),(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No rows to display.`})})]}):(0,I.jsx)(Foe,{useWindowScroll:v,style:v?void 0:{height:`100%`},data:e,context:me,defaultItemHeight:40,initialItemCount:Math.min(e.length,20),increaseViewportBy:2e3,endReached:g,fixedHeaderContent:pe,itemContent:fe,components:_e,scrollerRef:v?void 0:T}),(0,I.jsx)(Pz,{selection:r,allRowIds:b,onDuplicate:f,onDelete:d?re:void 0})]}),(0,I.jsx)(Fz,{isOpen:x!==null,onClose:ae,onConfirm:ie,count:oe})]})}),Wz=class{_cellFSM;_columnsModel;constructor(e,t){this._cellFSM=e,this._columnsModel=t,f(this,{},{autoBind:!0})}get _focusedColumn(){let e=this._cellFSM.focusedCell;return e?this._columnsModel.allColumns.find(t=>t.field===e.field)??null:null}get isVisible(){return this._focusedColumn!==null&&!this._cellFSM.hasSelection}get fieldLabel(){return this._focusedColumn?.label??``}get formulaExpression(){return this._focusedColumn?.formulaExpression}get foreignKeyTableId(){return this._focusedColumn?.foreignKeyTableId}},Gz=class{_totalCount=0;_baseTotalCount=0;_isFiltering=!1;_isRefetching=!1;constructor(){f(this,{},{autoBind:!0})}get totalCount(){return this._totalCount}get baseTotalCount(){return this._baseTotalCount}get isFiltering(){return this._isFiltering}get isRefetching(){return this._isRefetching}get text(){return this._isFiltering?`${this._totalCount} of ${this._baseTotalCount} ${this._baseTotalCount===1?`row`:`rows`}`:`${this._totalCount} ${this._totalCount===1?`row`:`rows`}`}setTotalCount(e){this._totalCount=e}setBaseTotalCount(e){this._baseTotalCount=e}setIsFiltering(e){this._isFiltering=e}setRefetching(e){this._isRefetching=e}decrementBaseTotalCount(e=1){this._baseTotalCount=Math.max(0,this._baseTotalCount-e),this._totalCount=Math.max(0,this._totalCount-e)}},Kz=class{_snapshot=null;_currentSnapshot=null;_canSave=!1;_isPopoverOpen=!1;_onSave=null;_onRevert=null;constructor(){f(this,{},{autoBind:!0})}get hasChanges(){return this._snapshot!==this._currentSnapshot}get isVisible(){return this.hasChanges}get canSave(){return this._canSave}get isPopoverOpen(){return this._isPopoverOpen}saveSnapshot(e){let t=JSON.stringify(e);this._snapshot=t,this._currentSnapshot=t}checkForChanges(e){this._currentSnapshot=JSON.stringify(e)}async save(){this._onSave&&await this._onSave()}revert(){this._onRevert&&this._onRevert(),this._currentSnapshot=this._snapshot}setCanSave(e){this._canSave=e}setPopoverOpen(e){this._isPopoverOpen=e}setOnSave(e){this._onSave=e}setOnRevert(e){this._onRevert=e}dispose(){this._onSave=null,this._onRevert=null}},qz=50,Jz=class{columns;filters;sorts;search;viewBadge;cellFSM;selection;rowCount;cellInfo;_dataSource;_pageSize;_breadcrumbs;_callbacks;_tableId;_schemaContext=new oI;_readonly=!1;_rows=[];_isBootstrapping=!0;_isLoadingMore=!1;_hasNextPage=!1;_endCursor=null;_savedViewState=null;constructor(e,t){this._dataSource=e,this._tableId=t.tableId,this._pageSize=t.pageSize??qz,this._readonly=t.readonly??!1,this._breadcrumbs=t.breadcrumbs??[],this._callbacks=t.callbacks??{},this.columns=new wI,this.filters=new oL,this.sorts=new TL,this.search=new xL(e=>this._handleSearch(e)),this.viewBadge=new Kz,this.cellFSM=new GL,this.selection=new jL,this.rowCount=new Gz,this.cellInfo=new Wz(this.cellFSM,this.columns),this.columns.setOnChange(()=>this._handleColumnsChange()),this.filters.setOnChange(()=>this._handleFilterChange()),this.filters.setOnApply(e=>this._handleFilterApply()),this.sorts.setOnChange(()=>this._handleSortChange()),this.sorts.setOnApply(e=>this._handleSortApply()),this.viewBadge.setOnSave(()=>this._handleViewSave()),this.viewBadge.setOnRevert(()=>this._handleViewRevert()),this.cellFSM.setOnReadonlyEditAttempt(this._callbacks.onReadonlyEditAttempt??null),f(this,{},{autoBind:!0}),queueMicrotask(()=>void this._bootstrap())}get rows(){return this._rows}get isBootstrapping(){return this._isBootstrapping}get isLoadingMore(){return this._isLoadingMore}get readonly(){return this._readonly}get tableId(){return this._tableId}get breadcrumbs(){return this._breadcrumbs}get callbacks(){return this._callbacks}getViewState(){return{columns:this.columns.serializeToViewColumns(),filters:null,sorts:this.sorts.serializeToViewSorts(),search:``}}applyViewState(e){this.columns.applyViewColumns(e.columns),this.sorts.applyViewSorts(e.sorts)}async loadMore(){if(!(!this._hasNextPage||this._isLoadingMore)){this._isLoadingMore=!0;try{let e=this._buildQuery(this._endCursor),t=await this._dataSource.fetchRows(e);c(()=>{this._appendRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage,this._isLoadingMore=!1})}catch{c(()=>{this._isLoadingMore=!1})}}}async deleteRows(e){(await this._dataSource.deleteRows(e)).ok&&c(()=>{let t=new Set(e);this._rows=this._rows.filter(e=>!t.has(e.rowId)),this.rowCount.decrementBaseTotalCount(e.length),this.selection.exitSelectionMode(),this._updateNavigationContext()})}dispose(){this.columns.dispose(),this.filters.dispose(),this.sorts.dispose(),this.search.dispose(),this.viewBadge.dispose(),this.selection.exitSelectionMode(),this.cellFSM.blur();for(let e of this._rows)e.dispose()}async _bootstrap(){try{let e=await this._dataSource.fetchMetadata();c(()=>{this._schemaContext.init(e.dataSchema,e.refSchemas),this._readonly=this._readonly||e.readonly,this.viewBadge.setCanSave(!this._readonly)}),this.columns.init(this._schemaContext.allColumns),this.sorts.init(this._schemaContext.sortableFields),this.filters.init(this._schemaContext.filterableFields),e.viewState&&this.applyViewState(e.viewState),this._saveViewSnapshot(),await this._loadRows(),c(()=>{this._isBootstrapping=!1})}catch{c(()=>{this._isBootstrapping=!1})}}_buildQuery(e=null){return{where:this.filters.hasActiveFilters?this.filters.buildCurrentWhereClause():null,orderBy:this.sorts.serializeToQuerySorts(),search:this.search.debouncedQuery,first:this._pageSize,after:e}}async _loadRows(){let e=this._buildQuery(),t=await this._dataSource.fetchRows(e);c(()=>{this._replaceRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage;let e=this.filters.hasActiveFilters||this.search.hasActiveSearch;this.rowCount.setTotalCount(t.totalCount),e||this.rowCount.setBaseTotalCount(t.totalCount),this.rowCount.setIsFiltering(e),this._updateNavigationContext()})}async _reloadRows(){this._isBootstrapping||(this.selection.exitSelectionMode(),this.cellFSM.blur(),await this._loadRows())}_replaceRowVMs(e){for(let e of this._rows)e.dispose();this._rows=this._createRowVMs(e)}_appendRowVMs(e){let t=this._createRowVMs(e);this._rows=[...this._rows,...t],this._updateNavigationContext()}_createRowVMs(e){let t=this._schemaContext.wrappedDataSchema;if(!t)return[];let n=kc({tableId:this._tableId,schema:t,rows:e.map(e=>({rowId:e.rowId,data:{data:e.data}})),refSchemas:this._schemaContext.fullRefSchemas}),r=new Map;for(let t of e)r.set(t.rowId,this._buildSystemValues(t));return n.rows.map(e=>new qL(e,e.rowId,this.cellFSM,this.selection,(e,t,n,r)=>this._commitCell(e,t,n,r),r.get(e.rowId),this._readonly))}_buildSystemValues(e){return{...e.systemFields,id:e.rowId}}_toPatchField(e){return nI(e)}async _commitCell(e,t,n,r){let i=this._toPatchField(t),a=(await this._dataSource.patchCells([{rowId:e,field:i,value:n}]))[0];a&&!a.ok&&c(()=>{let n=this._rows.find(t=>t.rowId===e);if(n&&r!==void 0){let e=n.rowModel.get(t);e?.isPrimitive()?e.setValue(r):e?.isObject()&&e.setValue(r,{internal:!0})}})}_updateNavigationContext(){this.cellFSM.setNavigationContext(this.columns.visibleColumns.map(e=>e.field),this._rows.map(e=>e.rowId))}_handleColumnsChange(){this.cellFSM.updateNavigationContext(this.columns.visibleColumns.map(e=>e.field),this.cellFSM.rowIds),this._checkViewChanges()}_handleFilterChange(){}_handleFilterApply(){this._reloadRows()}_handleSortChange(){this._checkViewChanges()}_handleSortApply(){this._reloadRows(),this._checkViewChanges()}_handleSearch(e){this._reloadRows()}async _handleViewSave(){try{let e=this.getViewState();(await this._dataSource.saveView(e)).ok&&this._saveViewSnapshot()}catch{}}_handleViewRevert(){this._savedViewState&&(this.applyViewState(this._savedViewState),this._reloadRows())}_saveViewSnapshot(){let e=this.getViewState();this._savedViewState=e,this.viewBadge.saveSnapshot(e)}_checkViewChanges(){this.viewBadge.checkForChanges(this.getViewState())}};function Yz(e,{delayMs:t=150,minShowMs:n=300}={}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(e){let e=setTimeout(()=>{a.current=Date.now(),i(!0)},t);return()=>clearTimeout(e)}if(a.current!==null){let e=n-(Date.now()-a.current);if(e>0){let t=setTimeout(()=>{a.current=null,i(!1)},e);return()=>clearTimeout(t)}a.current=null}i(!1)},[e,t,n]),r}var Xz=g(({model:e})=>e.isVisible?(0,I.jsxs)(j,{alignItems:`center`,gap:2,overflow:`hidden`,flexShrink:1,minW:0,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-field`,children:e.fieldLabel}),e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`purple.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-formula`,children:[`= `,e.formulaExpression]}),e.foreignKeyTableId&&!e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-fk`,children:[`→ `,e.foreignKeyTableId]})]}):null),Zz=g(({model:e})=>(0,I.jsxs)(j,{alignItems:`center`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,"data-testid":`row-count-text`,children:e.text}),e.isRefetching&&(0,I.jsx)(Ht,{size:`xs`,color:`gray.400`,"data-testid":`row-count-spinner`})]})),Qz=g(({model:e})=>{if(!e.isVisible)return null;let t=e.canSave?`orange`:`gray`,n=e.canSave?`orange.500`:`gray.400`,r=e.canSave?`unsaved`:`local`,i=e.canSave?`Unsaved view settings`:`Local view changes`,a=e.canSave?`Column order, widths, and sort settings will be saved to the Default view and shared with everyone.`:`View settings can only be saved in draft revisions. These changes are temporary and will be lost when you leave.`,o=e.canSave?`Revert`:`Reset`;return(0,I.jsxs)(ge,{open:e.isPopoverOpen,onOpenChange:t=>e.setPopoverOpen(t.open),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsxs)(It,{variant:`subtle`,size:`sm`,colorPalette:t,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:1,_hover:{opacity:.8},"data-testid":`view-settings-badge`,children:[(0,I.jsx)(A,{width:`6px`,height:`6px`,borderRadius:`full`,bg:n}),r]})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{p:3,maxW:`300px`,children:[(0,I.jsxs)(P,{mb:2,children:[(0,I.jsx)(A,{color:`gray.400`,children:(0,I.jsx)(bk,{size:16})}),(0,I.jsx)(k,{fontWeight:`semibold`,fontSize:`sm`,children:i})]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,mb:3,children:a}),(0,I.jsxs)(P,{children:[(0,I.jsx)(N,{variant:`ghost`,size:`xs`,onClick:()=>{e.revert(),e.setPopoverOpen(!1)},"data-testid":`view-settings-revert`,children:o}),e.canSave&&(0,I.jsx)(N,{colorPalette:`blue`,size:`xs`,onClick:()=>{e.save(),e.setPopoverOpen(!1)},"data-testid":`view-settings-save`,children:`Save`})]})]})})})]})}),$z=40,eB=40,tB=8,nB=[120,150,120,100,130],rB=[[80,110,70,60,90],[100,90,100,80,110],[60,130,80,70,80],[90,100,60,90,100],[75,120,90,55,70],[110,80,75,80,120],[85,140,95,65,95],[95,70,110,85,80]],iB=({breadcrumbs:e,onBreadcrumbClick:t,showCreateButton:n,useWindowScroll:r})=>(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:r?void 0:`100%`,flex:r?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...r&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[e.length>0?(0,I.jsx)(JN,{segments:e,highlightLast:!1,onSegmentClick:t,action:n?(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}):void 0}):(0,I.jsx)(A,{}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(j,{height:`${$z}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((e,t)=>(0,I.jsx)(A,{width:`${e}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`12px`,width:`60px`,borderRadius:`4px`})},`h-${t}`))}),rB.slice(0,tB).map((e,t)=>(0,I.jsx)(j,{height:`${eB}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((n,r)=>(0,I.jsx)(A,{width:`${n}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`14px`,width:`${e[r]}px`,borderRadius:`4px`})},`r-${t}-c-${r}`))},`r-${t}`))]})]}),aB=()=>{};function oB(e,t,n){return{onDeleteRow:e?void 0:e=>t.deleteRows([e]),onDuplicateRow:e?void 0:n.onDuplicateRow,onDeleteSelected:e?void 0:e=>t.deleteRows(e),onUploadFile:e?void 0:n.onUploadFile}}var sB=g(({viewModel:e,useWindowScroll:t})=>{let n=Yz(e.isBootstrapping);if(e.isBootstrapping)return n?(0,I.jsx)(iB,{breadcrumbs:e.breadcrumbs,onBreadcrumbClick:e.callbacks.onBreadcrumbClick,showCreateButton:!e.readonly&&!!e.callbacks.onCreateRow,useWindowScroll:t}):null;let r=e.readonly,{breadcrumbs:i,callbacks:a}=e;return(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:t?void 0:`100%`,flex:t?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...t&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[i.length>0&&(0,I.jsx)(JN,{segments:i,highlightLast:!1,onSegmentClick:a.onBreadcrumbClick,action:a.onCreateRow?(0,I.jsx)(XN,{tooltip:`New row`,onClick:a.onCreateRow,dataTestId:`create-row-button`}):void 0}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(CL,{model:e.search}),(0,I.jsx)(bL,{model:e.filters,availableFields:e.columns.filterableFields}),(0,I.jsx)(AL,{model:e.sorts,availableFields:e.columns.sortableFields,onChange:aB})]})]}),(0,I.jsx)(A,{flex:1,minHeight:0,children:(0,I.jsx)(Uz,{rows:e.rows,columnsModel:e.columns,cellFSM:e.cellFSM,selection:e.selection,sortModel:e.sorts,filterModel:e.filters,isLoadingMore:e.isLoadingMore,onEndReached:e.loadMore,onOpenRow:a.onOpenRow,onPickRow:a.onPickRow,...oB(r,e,a),onSearchForeignKey:a.onSearchForeignKey,onOpenFile:a.onOpenFile,onCopyPath:a.onCopyPath,useWindowScroll:t})}),(0,I.jsxs)(j,{px:3,py:2,alignItems:`center`,overflow:`hidden`,...t&&{position:`sticky`,bottom:0,bg:`white`,zIndex:3},children:[(0,I.jsx)(Zz,{model:e.rowCount}),(0,I.jsxs)(j,{alignItems:`center`,gap:3,overflow:`hidden`,flexShrink:1,minW:0,flex:1,justifyContent:`flex-end`,children:[(0,I.jsx)(Xz,{model:e.cellInfo}),(0,I.jsx)(Qz,{model:e.viewBadge})]})]})]})}),cB=Sn(),lB=e=>{let t={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`4c22f33`,MODE:`production`,PACKAGE_VERSION:`2.6.0`,PROD:!0,REACT_APP_ENDPOINT_HOST:``,REACT_APP_ENDPOINT_PORT:``,REACT_APP_ENDPOINT_SERVER_URL:`/endpoint`,REACT_APP_GRAPHQL_SERVER_URL:`/graphql`,REACT_APP_SWAGGER_SERVER_URL:`/api`,SSR:!1}[e];return globalThis.__env__?.[e]||t},uB=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},dB=[`light`,`dark`],fB=`(prefers-color-scheme: dark)`,pB=typeof window>`u`,mB=L.createContext(void 0),hB=e=>L.useContext(mB)?L.createElement(L.Fragment,null,e.children):L.createElement(_B,{...e}),gB=[`light`,`dark`],_B=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i=`theme`,themes:a=gB,defaultTheme:o=n?`system`:`light`,attribute:s=`data-theme`,value:c,children:l,nonce:u,scriptProps:d})=>{let[f,p]=L.useState(()=>yB(i,o)),[m,h]=L.useState(()=>f===`system`?xB():f),g=c?Object.values(c):a,_=L.useCallback(e=>{let i=e;if(!i)return;e===`system`&&n&&(i=xB());let a=c?c[i]:i,l=t?bB(u):null,d=document.documentElement,f=e=>{e===`class`?(d.classList.remove(...g),a&&d.classList.add(a)):e.startsWith(`data-`)&&(a?d.setAttribute(e,a):d.removeAttribute(e))};if(Array.isArray(s)?s.forEach(f):f(s),r){let e=dB.includes(o)?o:null,t=dB.includes(i)?i:e;d.style.colorScheme=t}l?.()},[u]),v=L.useCallback(e=>{let t=typeof e==`function`?e(f):e;p(t);try{localStorage.setItem(i,t)}catch{}},[f]),y=L.useCallback(t=>{h(xB(t)),f===`system`&&n&&!e&&_(`system`)},[f,e]);L.useEffect(()=>{let e=window.matchMedia(fB);return e.addListener(y),y(e),()=>e.removeListener(y)},[y]),L.useEffect(()=>{let e=e=>{e.key===i&&(e.newValue?p(e.newValue):v(o))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[v]),L.useEffect(()=>{_(e??f)},[e,f]);let b=L.useMemo(()=>({theme:f,setTheme:v,forcedTheme:e,resolvedTheme:f===`system`?m:f,themes:n?[...a,`system`]:a,systemTheme:n?m:void 0}),[f,v,e,m,n,a]);return L.createElement(mB.Provider,{value:b},L.createElement(vB,{forcedTheme:e,storageKey:i,attribute:s,enableSystem:n,enableColorScheme:r,defaultTheme:o,value:c,themes:a,nonce:u,scriptProps:d}),l)},vB=L.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return L.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${uB.toString()})(${u})`}})}),yB=(e,t)=>{if(pB)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},bB=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},xB=e=>(e||=window.matchMedia(fB),e.matches?`dark`:`light`),SB=()=>(0,L.useCallback)(e=>{e&&e.focus()},[]),CB=(e,...t)=>{let n=(0,L.useRef)(null),[r,i]=(0,L.useState)(t),a=(0,L.useMemo)(()=>r.length!==t.length||r.some((e,n)=>e!==t[n])?(i(t),t):r,[t,r]);return n.current||=Y.get(e),(0,L.useEffect)(()=>{let e=n.current;return e?.init?.(...a),()=>{e?.dispose?.()}},[a]),n.current};function wB(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e==`object`&&t===`[object Date]`?new e.constructor(+e):typeof e==`number`||t===`[object Number]`||typeof e==`string`||t===`[object String]`?new Date(e):new Date(NaN)}function TB(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}var EB=365.2425,DB=6048e5,OB=864e5,kB=43200,AB=1440,jB=3600*24;jB*7,jB*EB/12*3;var MB={};function NB(){return MB}function PB(e,t){let n=NB(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wB(e),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function FB(e){return PB(e,{weekStartsOn:1})}function IB(e){let t=wB(e),n=t.getFullYear(),r=TB(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let i=FB(r),a=TB(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let o=FB(a);return t.getTime()>=i.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function LB(e){let t=wB(e);return t.setHours(0,0,0,0),t}function RB(e){let t=wB(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function zB(e,t){let n=LB(e),r=LB(t),i=+n-RB(n),a=+r-RB(r);return Math.round((i-a)/OB)}function BB(e){let t=IB(e),n=TB(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),FB(n)}function VB(e,t){let n=wB(e),r=wB(t),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function HB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function UB(e){if(!HB(e)&&typeof e!=`number`)return!1;let t=wB(e);return!isNaN(Number(t))}function WB(e,t){let n=wB(e),r=wB(t),i=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return i*12+a}function GB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function KB(e,t){return wB(e)-+wB(t)}function qB(e){let t=wB(e);return t.setHours(23,59,59,999),t}function JB(e){let t=wB(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function YB(e){let t=wB(e);return+qB(t)==+JB(t)}function XB(e,t){let n=wB(e),r=wB(t),i=VB(n,r),a=Math.abs(WB(n,r)),o;if(a<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*a);let t=VB(n,r)===-i;YB(wB(e))&&a===1&&VB(e,r)===1&&(t=!1),o=i*(a-Number(t))}return o===0?0:o}function ZB(e,t,n){let r=KB(e,t)/1e3;return GB(n?.roundingMethod)(r)}function QB(e){let t=wB(e),n=TB(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}var $B={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},eV=(e,t,n)=>{let r,i=$B[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function tV(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var nV={date:tV({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:tV({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:tV({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},rV={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},iV=(e,t,n,r)=>rV[e];function aV(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var oV={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:aV({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:aV({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:aV({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:aV({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:aV({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function sV(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?lV(s,e=>e.test(o)):cV(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function cV(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function lV(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function uV(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var dV={code:`en-US`,formatDistance:eV,formatLong:nV,formatRelative:iV,localize:oV,match:{ordinalNumber:uV({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:sV({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:sV({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:sV({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:sV({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:sV({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function fV(e){let t=wB(e);return zB(t,QB(t))+1}function pV(e){let t=wB(e),n=FB(t)-+BB(t);return Math.round(n/DB)+1}function mV(e,t){let n=wB(e),r=n.getFullYear(),i=NB(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=TB(e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=PB(o,t),c=TB(e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=PB(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function hV(e,t){let n=NB(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=mV(e,t),a=TB(e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),PB(a,t)}function gV(e,t){let n=wB(e),r=PB(n,t)-+hV(n,t);return Math.round(r/DB)+1}function _V(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var vV={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return _V(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):_V(n+1,2)},d(e,t){return _V(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return _V(e.getHours()%12||12,t.length)},H(e,t){return _V(e.getHours(),t.length)},m(e,t){return _V(e.getMinutes(),t.length)},s(e,t){return _V(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return _V(Math.trunc(r*10**(n-3)),t.length)}},yV={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},bV={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return vV.y(e,t)},Y:function(e,t,n,r){let i=mV(e,r),a=i>0?i:1-i;return t===`YY`?_V(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):_V(a,t.length)},R:function(e,t){return _V(IB(e),t.length)},u:function(e,t){return _V(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return _V(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return _V(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return vV.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return _V(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=gV(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):_V(i,t.length)},I:function(e,t,n){let r=pV(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):_V(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):vV.d(e,t)},D:function(e,t,n){let r=fV(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):_V(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return _V(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return _V(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return _V(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?yV.noon:r===0?yV.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?yV.evening:r>=12?yV.afternoon:r>=4?yV.morning:yV.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return vV.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):vV.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):vV.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):vV.s(e,t)},S:function(e,t){return vV.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return SV(r);case`XXXX`:case`XX`:return CV(r);default:return CV(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return SV(r);case`xxxx`:case`xx`:return CV(r);default:return CV(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},t:function(e,t,n){return _V(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,n){return _V(e.getTime(),t.length)}};function xV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+_V(a,2)}function SV(e,t){return e%60==0?(e>0?`-`:`+`)+_V(Math.abs(e)/60,2):CV(e,t)}function CV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=_V(Math.trunc(r/60),2),a=_V(r%60,2);return n+i+t+a}var wV=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},TV=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},EV={p:TV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return wV(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,wV(r,t)).replace(`{{time}}`,TV(i,t))}},DV=/^D+$/,OV=/^Y+$/,kV=[`D`,`DD`,`YY`,`YYYY`];function AV(e){return DV.test(e)}function jV(e){return OV.test(e)}function MV(e,t,n){let r=NV(e,t,n);if(console.warn(r),kV.includes(e))throw RangeError(r)}function NV(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var PV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,FV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IV=/^'([^]*?)'?$/,LV=/''/g,RV=/[a-zA-Z]/;function zV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=wB(e);if(!UB(s))throw RangeError(`Invalid time value`);let c=t.match(FV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=EV[t];return n(e,i.formatLong)}return e}).join(``).match(PV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:BV(e)};if(bV[t])return{isToken:!0,value:e};if(t.match(RV))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&jV(a)||!n?.useAdditionalDayOfYearTokens&&AV(a))&&MV(a,t,String(e));let o=bV[a[0]];return o(s,a,i.localize,l)}).join(``)}function BV(e){let t=e.match(IV);return t?t[1].replace(LV,`'`):e}function VV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=VB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),s,c;a>0?(s=wB(t),c=wB(e)):(s=wB(e),c=wB(t));let l=ZB(c,s),u=(RB(c)-RB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/AB);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/kB),i.formatDistance(`aboutXMonths`,f,o);if(f=XB(c,s),f<12){let e=Math.round(d/kB);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function HV(e,t){return VV(e,Date.now(),t)}function UV(e,t=`dd.MM.yyyy, HH:mm`,n){if(!e)return``;let r=new Date(e);return Number.isNaN(r.getTime())?(console.warn(`Invalid date:`,e),``):zV(r,t,{locale:n})}var WV=()=>globalThis.location.origin,GV=e=>navigator.clipboard.writeText(e),Y=new class{registrations=new Map;register(e,t,n){this.registrations.set(e,{factory:t,scope:n.scope})}get(e){let t=this.registrations.get(e);if(!t)throw Error(`No provider found for ${e.name}`);return t.scope===`singleton`?(t.instance??=t.factory(),t.instance):t.factory()}},KV=class extends Error{constructor(){super(`Aborted`),this.name=`AbortError`}},X=class e{_data=null;_error=null;_isLoading=!1;_isLoaded=!1;_abortController=null;static of(t,n){return new e(t,n)}constructor(e,t){this.fetchFunction=e,this.options=t,f(this)}get data(){return this._data}get isLoading(){return this._isLoading}get isLoaded(){return this._isLoaded}get error(){return this._error}get errorMessage(){return this._error?.response.errors?.[0].message}abort(){this._abortController?.abort(),this._abortController=null}setDataDirectly(e){this._data=e,this._isLoaded=!0}async fetch(...e){this.abort(),this._abortController=new AbortController;let t=this._abortController.signal;this.options?.skipResetting||this.reset();try{this.setIsLoading(!0);let n=await this.fetchFunction(...e);return t.aborted?{isRight:!1,error:new KV}:(this.setData(n),{isRight:!0,data:n})}catch(e){return t.aborted?{isRight:!1,error:new KV}:(console.error(e),this.setError(e),{isRight:!1,error:e})}finally{this.setIsLoading(!1),this.setIsLoaded(!0)}}reset(){this.setIsLoading(!1),this.setData(null),this.setError(null)}setData(e){this._data=e}setIsLoading(e){this._isLoading=e}setIsLoaded(e){this._isLoaded=e}setError(e){this._error=e}};function qV(e){return!e.isRight&&e.error instanceof KV}var JV=class{values;constructor(e){this.values=e,f(this,{},{autoBind:!0})}setValue(e,t){this.values[e]=t}get isValid(){return Object.values(this.values).every(Boolean)}},YV=e=>{if(e&&e.startsWith(`/`)&&!e.startsWith(`//`))return e},XV=e=>{if(!e)return null;try{let t=JSON.parse(e)?.redirect;return typeof t==`string`?t:null}catch{return null}},ZV=e=>{if(e)return JSON.stringify({redirect:e})},QV=()=>YV(new URLSearchParams(globalThis.location.search).get(`redirect`)),$V=e=>{let t=YV(e);return!t||t===`/`?``:`?redirect=${encodeURIComponent(t)}`},eH=function(e){return e.Loading=`loading`,e.Empty=`empty`,e.List=`list`,e.NotFound=`notFound`,e.Error=`error`,e}({}),tH=class{_state=eH.Loading;_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=0;_isInitialLoad=!0;constructor(){f(this,{},{autoBind:!0})}get state(){return this._state}get items(){return this._items}get hasNextPage(){return this._hasNextPage}get endCursor(){return this._endCursor}get totalCount(){return this._totalCount}get isInitialLoad(){return this._isInitialLoad}get showLoading(){return this._state===eH.Loading&&this._isInitialLoad}get showEmpty(){return this._state===eH.Empty}get showNotFound(){return this._state===eH.NotFound}get showList(){return this._state===eH.List}get showError(){return this._state===eH.Error}setLoading(){this._state=eH.Loading}setError(){this._isInitialLoad=!1,this._state=eH.Error}setItems(e,t){this._isInitialLoad=!1,this._items=e,this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor,this._totalCount=t.totalCount,e.length>0?this._state=eH.List:t.isSearching?this._state=eH.NotFound:this._state=eH.Empty}appendItems(e,t){this._items=[...this._items,...e],this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor}removeItem(e){let t=this._items.length;this._items=this._items.filter(t=>!e(t));let n=t-this._items.length;this._totalCount=Math.max(0,this._totalCount-n)}updateStateAfterRemove(e){this._items.length===0&&(this._state=e?eH.NotFound:eH.Empty)}reset(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this._state=eH.Loading}resetToLoading(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._totalCount=0,this._isInitialLoad=!0,this._state=eH.Loading}},nH=class{cachedItemViewModels=u.map();constructor(e){this.dataSource=e,h(this,{cachedItemViewModels:u,showLoading:a,showEmpty:a,showList:a,showError:a,items:a,totalCount:a,hasNextPage:a,init:m,dispose:m,tryToFetchNextPage:m,getOrCreateItemViewModel:!1})}get showLoading(){return this.dataSource.state===eH.Loading&&this.dataSource.isInitialLoad}get showEmpty(){return this.dataSource.state===eH.Empty}get showList(){return this.dataSource.state===eH.List}get showError(){return this.dataSource.state===eH.Error}get items(){return this.dataSource.items.map(e=>this.getOrCreateItemViewModel(e))}get totalCount(){return this.dataSource.totalCount}get hasNextPage(){return this.dataSource.hasNextPage}init(){this.dataSource.load()}dispose(){this.dataSource.dispose(),this.cachedItemViewModels.clear()}async tryToFetchNextPage(){await this.dataSource.loadNextPage()}getOrCreateItemViewModel(e){let t=this.getItemKey(e),n=this.cachedItemViewModels.get(t);return n||(n=this.createItemViewModel(e),this.cachedItemViewModels.set(t,n)),n}},rH=class{listState=new tH;request;config;constructor(e,t={}){this.request=X.of(e,{skipResetting:!0}),this.config={pageSize:t.pageSize??50},h(this,{items:a,hasNextPage:a,totalCount:a,isLoading:a,isInitialLoad:a,state:a,load:m,loadNextPage:m,reset:m,dispose:m},{autoBind:!0})}get items(){return this.listState.items}get hasNextPage(){return this.listState.hasNextPage}get totalCount(){return this.listState.totalCount}get isLoading(){return this.request.isLoading}get isInitialLoad(){return this.listState.isInitialLoad}get state(){return this.listState.state}async load(e){this.listState.setLoading();let t=await this.request.fetch(this.buildFetchArgs(e));if(!t.isRight){if(qV(t))return;c(()=>{this.listState.setError()});return}c(()=>{let e=this.extractItems(t.data),n=this.extractPageInfo(t.data);this.listState.setItems(e,n)})}async loadNextPage(){if(!this.hasNextPage||this.isLoading)return!1;let e=await this.request.fetch(this.buildFetchArgs(void 0,this.listState.endCursor||void 0));return e.isRight?(c(()=>{let t=this.extractItems(e.data),n=this.extractPageInfo(e.data);this.listState.appendItems(t,{hasNextPage:n.hasNextPage,endCursor:n.endCursor})}),!0):!1}reset(){this.listState.reset(),this.request.abort()}dispose(){this.request.abort()}},iH=class{id=ds();pendingRequestInternal=null;resolverInternal=null;constructor(){h(this,{pendingRequestInternal:u,hasPendingRequest:a,pendingRequest:a,setPendingRequest:m,clearPendingRequest:m})}setResolver(e){this.resolverInternal=e}resolve(e){this.resolverInternal?.(e)}get hasPendingRequest(){return this.pendingRequestInternal!==null}get pendingRequest(){return this.pendingRequestInternal}setPendingRequest(e){this.pendingRequestInternal=e}clearPendingRequest(){this.pendingRequestInternal=null}init(){}dispose(){}};function aH(e,t,n){return{payload:e,resolve:t,reject:n}}var oH=class{stack=[];constructor(){h(this,{stack:u,initStack:m.bound,pushRequest:m.bound,resolveToParent:m.bound,rejectRequest:m.bound,cancelFromItem:m.bound,dispose:m.bound})}initStack(e){this.stack=[e],this.setupItemResolver(e)}pushRequest(e,t,n,r){let i=aH(t,n,r);e.setPendingRequest(i);let a=this.createItemForRequest(i);this.addItem(a)}resolveToParent(e,t){let n=this.stack.indexOf(e);if(n===-1)return;let r=this.stack[n-1];r?.pendingRequest&&(r.pendingRequest.resolve(t),r.clearPendingRequest()),this.stack.splice(n).forEach(e=>e.dispose())}rejectRequest(e){let t=this.stack.indexOf(e);t!==-1&&this.stack.splice(t+1).forEach(e=>e.dispose());let n=t-1;if(n>=0){let e=this.stack[n];e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest())}}cancelFromItem(e){let t=this.stack.indexOf(e);t!==-1&&(this.stack.splice(t+1).forEach(e=>e.dispose()),e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest()))}dispose(){this.stack.forEach(e=>e.dispose()),this.stack=[]}addItem(e){this.setupItemResolver(e),this.stack.push(e)}setupItemResolver(e){e.setResolver(t=>this.handleItemResult(e,t))}},sH=class{_isFullscreen=!1;_isInitialized=!1;_containerRef=null;constructor(){h(this,{_isFullscreen:u,_containerRef:u,setContainerRef:m.bound,toggleFullscreen:m.bound,init:m.bound,dispose:m.bound,handleFullscreenChange:m.bound})}get isFullscreen(){return this._isFullscreen}setContainerRef(e){this._containerRef=e}toggleFullscreen(){this._isFullscreen?this.exitFullscreen():this.enterFullscreen()}init(){this._isInitialized||(this._isInitialized=!0,document.addEventListener(`fullscreenchange`,this.handleFullscreenChange))}dispose(){this._isInitialized&&(this._isInitialized=!1,document.removeEventListener(`fullscreenchange`,this.handleFullscreenChange),this._containerRef=null,this._isFullscreen=!1)}async enterFullscreen(){if(this._containerRef)try{await this._containerRef.requestFullscreen()}catch(e){console.error(e)}}async exitFullscreen(){try{await document.exitFullscreen()}catch(e){console.error(e)}}handleFullscreenChange(){this._isFullscreen=document.fullscreenElement===this._containerRef}},cH=class{_timer=null;constructor(e){this.delayMs=e}schedule(e){this.cancel(),this._timer=setTimeout(e,this.delayMs)}cancel(){this._timer&&=(clearTimeout(this._timer),null)}dispose(){this.cancel()}},lH=class{constructor(e,t){this.operator=e,this.value=t,Object.defineProperty(this,`t`,{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},uH=class extends lH{},dH=class extends uH{constructor(e,t){if(!Array.isArray(t))throw Error(`"${e}" operator expects to receive an array of conditions`);super(e,t)}},fH=`__itself__`,pH=class extends lH{constructor(e,t,n){super(e,n),this.field=t}},mH=new uH(`__null__`,null),hH=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function gH(e,t){return t instanceof dH&&t.operator===e}function _H(e,t){return t.length===1?t[0]:new dH(e,function e(t,n,r){let i=r||[];for(let r=0,a=n.length;r<a;r++){let a=n[r];gH(t,a)?e(t,a.value,i):i.push(a)}return i}(e,t))}var vH=e=>e,yH=()=>Object.create(null),bH=Object.defineProperty(yH(),`__@type@__`,{value:`ignore value`});function xH(e,t,n=!1){if(!e||e&&e.constructor!==Object)return!1;for(let r in e)if(hH(e,r)&&hH(t,r)&&(!n||e[r]!==bH))return!0;return!1}function SH(e){let t=[];for(let n in e)hH(e,n)&&e[n]!==bH&&t.push(n);return t}function CH(e,t){t!==mH&&e.push(t)}var wH=e=>_H(`and`,e),TH={compound(e,t,n){let r=(Array.isArray(t)?t:[t]).map(e=>n.parse(e));return new dH(e.name,r)},field:(e,t,n)=>new pH(e.name,n.field,t),document:(e,t)=>new uH(e.name,t)},EH=class{constructor(e,t=yH()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:t.operatorToConditionName||vH,defaultOperatorName:t.defaultOperatorName||`eq`,mergeFinalConditions:t.mergeFinalConditions||wH},this.o=Object.keys(e).reduce((t,n)=>(t[n]=Object.assign({name:this.u.operatorToConditionName(n)},e[n]),t),{}),this.s=Object.assign({},t.fieldContext,{field:``,query:{},parse:this.parse,hasOperators:e=>xH(e,this.o,t.useIgnoreValue)}),this.i=Object.assign({},t.documentContext,{parse:this.parse,query:{}}),this.h=t.useIgnoreValue?SH:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,t,n,r){let i=this.o[t];if(!i)throw Error(`Unsupported operator "${t}"`);if(i.type!==`field`)throw Error(`Unexpected ${i.type} operator "${t}" at field level`);return this.s.field=e,this.s.query=r,this.parseInstruction(i,n,this.s)}parseInstruction(e,t,n){return typeof e.validate==`function`&&e.validate(e,t),(e.parse||TH[e.type])(e,t,n)}parseFieldOperators(e,t){let n=[],r=this.h(t);for(let i=0,a=r.length;i<a;i++){let a=r[i];if(!this.o[a])throw Error(`Field query for "${e}" may contain only operators or a plain object as a value`);CH(n,this.parseField(e,a,t[a],t))}return n}parse(e){let t=[],n=this.h(e);this.i.query=e;for(let r=0,i=n.length;r<i;r++){let i=n[r],a=e[i],o=this.o[i];if(o){if(o.type!==`document`&&o.type!==`compound`)throw Error(`Cannot use parsing instruction for operator "${i}" in "document" context as it is supposed to be used in "${o.type}" context`);CH(t,this.parseInstruction(o,a,this.i))}else this.s.hasOperators(a)?t.push(...this.parseFieldOperators(i,a)):CH(t,this.parseField(i,this.u.defaultOperatorName,a,e))}return this.u.mergeFinalConditions(t)}};function DH(e,t){let n=e[t];if(typeof n!=`function`)throw Error(`Unable to interpret "${t}" condition. Did you forget to register interpreter for it?`);return n}function OH(e){return e.operator}function kH(e,t){let n=t,r=n&&n.getInterpreterName||OH,i;switch(n?n.numberOfArguments:0){case 1:i=t=>DH(e,r(t,n))(t,a);break;case 3:i=(t,i,o)=>DH(e,r(t,n))(t,i,o,a);break;default:i=(t,i)=>DH(e,r(t,n))(t,i,a)}let a=Object.assign({},n,{interpret:i});return a.interpret}function AH(e,t){return(n,...r)=>{let i=e(n,...r),a=t.bind(null,i);return a.ast=i,a}}EH.prototype.parseInstruction;function jH(e,t){if(!Array.isArray(t))throw Error(`"${e.name}" expects value to be an array`)}function MH(e,t){if(jH(e,t),!t.length)throw Error(`"${e.name}" expects to have at least one element in array`)}var NH=e=>(t,n)=>{if(typeof n!==e)throw Error(`"${t.name}" expects value to be a "${e}"`)},PH={type:`compound`,validate:MH,parse(e,t,{parse:n}){let r=t.map(e=>n(e));return _H(e.name,r)}},FH=PH,IH={type:`compound`,validate:MH},LH={type:`field`,validate(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw Error(`"${e.name}" expects to receive either regular expression or object of field operators`)},parse(e,t,n){let r=t instanceof RegExp?new pH(`regex`,n.field,t):n.parse(t,n);return new dH(e.name,[r])}},RH={type:`field`,validate(e,t){if(!t||t.constructor!==Object)throw Error(`"${e.name}" expects to receive an object with nested query or field level operators`)},parse(e,t,{parse:n,field:r,hasOperators:i}){let a=i(t)?n(t,{field:fH}):n(t);return new pH(e.name,r,a)}},zH={type:`field`,validate:NH(`number`)},BH={type:`field`,validate:jH},VH=BH,HH=BH,UH={type:`field`,validate(e,t){if(!Array.isArray(t)||t.length!==2)throw Error(`"${e.name}" expects an array with 2 numeric elements`)}},WH={type:`field`,validate:NH(`boolean`)},GH={type:`field`,validate:function(e,t){if(!(typeof t==`string`||typeof t==`number`||t instanceof Date))throw Error(`"${e.name}" expects value to be comparable (i.e., string, number or date)`)}},KH=GH,qH=KH,JH=KH,YH={type:`field`},XH=YH,ZH={type:`field`,validate(e,t){if(!(t instanceof RegExp)&&typeof t!=`string`)throw Error(`"${e.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(e,t,n){let r=typeof t==`string`?new RegExp(t,n.query.$options||``):t;return new pH(e.name,n.field,r)}},QH={type:`field`,parse:()=>mH},$H={type:`document`,validate:NH(`function`)},eU=Object.freeze({__proto__:null,$and:PH,$or:FH,$nor:IH,$not:LH,$elemMatch:RH,$size:zH,$in:BH,$nin:VH,$all:HH,$mod:UH,$exists:WH,$gte:GH,$gt:KH,$lt:qH,$lte:JH,$eq:YH,$ne:XH,$regex:ZH,$options:QH,$where:$H}),tU=class extends EH{constructor(e){super(e,{defaultOperatorName:`$eq`,operatorToConditionName:e=>e.slice(1)})}parse(e,t){return t&&t.field?wH(this.parseFieldOperators(t.field,e)):super.parse(e)}},nU=eU;function rU(e,t,n){for(let r=0,i=e.length;r<i;r++)if(n(e[r],t)===0)return!0;return!1}function iU(e,t){return Array.isArray(e)&&Number.isNaN(Number(t))}function aU(e,t,n){if(!iU(e,t))return n(e,t);let r=[];for(let i=0;i<e.length;i++){let a=n(e[i],t);a!==void 0&&(r=r.concat(a))}return r}function oU(e){return(t,n,r)=>{let i=r.get(n,t.field);return Array.isArray(i)?i.some(n=>e(t,n,r)):e(t,i,r)}}var sU=(e,t)=>e[t];function cU(e,t,n){let r=t.lastIndexOf(`.`);return r===-1?[e,t]:[n(e,t.slice(0,r)),t.slice(r+1)]}function lU(e,t,n=sU){if(t===`__itself__`)return e;if(!e)throw Error(`Unable to get field "${t}" out of ${String(e)}.`);return function(e,t,n){if(t.indexOf(`.`)===-1)return aU(e,t,n);let r=t.split(`.`),i=e;for(let e=0,t=r.length;e<t;e++)if(i=aU(i,r[e],n),!i||typeof i!=`object`)return i;return i}(e,t,n)}function uU(e,t){return e===t?0:e>t?1:-1}function dU(e,t={}){return kH(e,Object.assign({get:lU,compare:uU},t))}var fU=(e,t,{interpret:n})=>e.value.some(e=>n(e,t)),pU=(e,t,n)=>!fU(e,t,n),mU=(e,t,{interpret:n})=>e.value.every(e=>n(e,t)),hU=(e,t,{interpret:n})=>!n(e.value[0],t),gU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&!Array.isArray(e.value)?rU(i,e.value,n):n(i,e.value)===0},_U=(e,t,n)=>!gU(e,t,n),vU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===-1}),yU=oU((e,t,n)=>n.compare(t,e.value)===-1),bU=oU((e,t,n)=>n.compare(t,e.value)===1),xU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===1}),SU=(e,t,{get:n})=>{if(e.field===`__itself__`)return t!==void 0;let[r,i]=cU(t,e.field,n),a=t=>t==null?!!t===e.value:t.hasOwnProperty(i)===e.value;return iU(r,i)?r.some(a):a(r)},CU=oU((e,t)=>typeof t==`number`&&t%e.value[0]===e.value[1]),wU=(e,t,{get:n})=>{let[r,i]=cU(t,e.field,n),a=t=>{let r=n(t,i);return Array.isArray(r)&&r.length===e.value};return e.field!==`__itself__`&&iU(r,i)?r.some(a):a(r)},TU=oU((e,t)=>typeof t==`string`&&e.value.test(t)),EU=oU((e,t,{compare:n})=>rU(e.value,t,n)),DU=(e,t,n)=>!EU(e,t,n),OU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&e.value.every(e=>rU(i,e,n))},kU=(e,t,{interpret:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&i.some(t=>n(e.value,t))},AU=Object.freeze({__proto__:null,or:fU,nor:pU,and:mU,not:hU,eq:gU,ne:_U,lte:vU,lt:yU,gt:bU,gte:xU,exists:SU,mod:CU,size:wU,regex:TU,within:EU,nin:DU,all:OU,elemMatch:kU,where:(e,t)=>e.value.call(t)}),jU=Object.assign({},AU,{in:EU});dU(jU);function MU(e){return typeof e!=`object`||!e?e:e instanceof Date?e.getTime():e&&typeof e.toJSON==`function`?e.toJSON():e}var NU=(e,t)=>uU(MU(e),MU(t));function PU(e,t,n){let r=new tU(e),i=dU(t,Object.assign({compare:NU},n));if(n&&n.forPrimitives){let e={field:fH},t=r.parse;r.setParse(n=>t(n,e))}return AH(r.parse,i)}PU(nU,jU),PU([`$and`,`$or`].reduce((e,t)=>(e[t]=Object.assign({},e[t],{type:`field`}),e),Object.assign({},nU,{$nor:Object.assign({},nU.$nor,{type:`field`,parse:TH.compound})})),jU,{forPrimitives:!0});var FU=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t));function IU(e){return Array.isArray(e)?e:[e]}var LU=`__caslSubjectType__`;function RU(e,t){if(t){if(!FU(t,LU))Object.defineProperty(t,LU,{value:e});else if(e!==t[LU])throw Error(`Trying to cast object to subject type ${e} but previously it was casted to ${t[LU]}`)}return t}var zU=e=>{let t=typeof e;return t===`string`||t===`function`},BU=e=>e.modelName||e.name;function VU(e){return typeof e==`string`?e:BU(e)}function HU(e){return FU(e,LU)?e[LU]:BU(e.constructor)}var UU={function:e=>e.constructor,string:HU};function WU(e,t,n){for(let r=n;r<t.length;r++)e.push(t[r])}function GU(e,t){if(!e||!e.length)return t||[];if(!t||!t.length)return e||[];let n=0,r=0,i=[];for(;n<e.length&&r<t.length;)e[n].priority<t[r].priority?(i.push(e[n]),n++):(i.push(t[r]),r++);return WU(i,e,n),WU(i,t,r),i}function KU(e,t,n){let r=e.get(t);return r||(r=n(),e.set(t,r)),r}var qU=e=>e;function JU(e,t){if(Array.isArray(e.fields)&&!e.fields.length)throw Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(e.fields&&!t.fieldMatcher)throw Error(`You need to pass "fieldMatcher" option in order to restrict access by fields`);if(e.conditions&&!t.conditionsMatcher)throw Error(`You need to pass "conditionsMatcher" option in order to restrict access by conditions`)}var YU=class{constructor(e,t,n=0){JU(e,t),this.action=t.resolveAction(e.action),this.subject=e.subject,this.inverted=!!e.inverted,this.conditions=e.conditions,this.reason=e.reason,this.origin=e,this.fields=e.fields?IU(e.fields):void 0,this.priority=n,this.t=t}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){let e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||zU(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||=this.t.fieldMatcher(this.fields),this.u(e)):!this.inverted:!0}};function XU(e,t){let n={value:e,prev:t,next:null};return t&&(t.next=n),n}function ZU(e){e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next),e.next=e.prev=null}var QU=e=>({value:e.value,prev:e.prev,next:e.next}),$U=()=>({rules:[],merged:!1}),eW=()=>new Map,tW=class{constructor(e=[],t={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:t.conditionsMatcher,fieldMatcher:t.fieldMatcher,resolveAction:t.resolveAction||qU},this.$=t.anyAction||`manage`,this.A=t.anySubjectType||`all`,this.m=e,this.M=!!t.detectSubjectType,this.j=t.detectSubjectType||HU,this.v(e)}get rules(){return this.m}detectSubjectType(e){return zU(e)?e:e?this.j(e):this.A}update(e){let t={rules:e,ability:this,target:this};return this._(`update`,t),this.m=e,this.v(e),this._(`updated`,t),this}v(e){let t=new Map,n;for(let r=e.length-1;r>=0;r--){let i=e.length-r-1,a=new YU(e[r],this.p,i),o=IU(a.action),s=IU(a.subject||this.A);!this.h&&a.fields&&(this.h=!0);for(let e=0;e<s.length;e++){let r=KU(t,s[e],eW);n===void 0&&(n=typeof s[e]),typeof s[e]!==n&&n!==`mixed`&&(n=`mixed`);for(let e=0;e<o.length;e++)KU(r,o[e],$U).rules.push(a)}}this.l=t,n!==`mixed`&&!this.M&&(this.j=UU[n]||UU.string)}possibleRulesFor(e,t=this.A){if(!zU(t))throw Error(`"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter`);let n=KU(this.l,t,eW),r=KU(n,e,$U);if(r.merged)return r.rules;let i=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0,a=GU(r.rules,i);return t!==this.A&&(a=GU(a,this.possibleRulesFor(e,this.A))),r.rules=a,r.merged=!0,a}rulesFor(e,t,n){let r=this.possibleRulesFor(e,t);if(n&&typeof n!=`string`)throw Error("The 3rd, `field` parameter is expected to be a string. See https://stalniy.github.io/casl/en/api/casl-ability#can-of-pure-ability for details");return this.h?r.filter(e=>e.matchesField(n)):r}actionsFor(e){if(!zU(e))throw Error(`"actionsFor" accepts only subject types (i.e., string or class) as a parameter`);let t=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(e=>t.add(e));let r=e===this.A?void 0:this.l.get(this.A);return r&&Array.from(r.keys()).forEach(e=>t.add(e)),Array.from(t)}on(e,t){this.F=this.F||new Map;let n=this.F,r=XU(t,n.get(e)||null);return n.set(e,r),()=>{let t=n.get(e);!r.next&&!r.prev&&t===r?n.delete(e):r===t&&n.set(e,r.prev),ZU(r)}}_(e,t){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){let e=n.prev?QU(n.prev):null;n.value(t),n=e}}},nW=class extends tW{can(e,t,n){let r=this.relevantRuleFor(e,t,n);return!!r&&!r.inverted}relevantRuleFor(e,t,n){let r=this.detectSubjectType(t),i=this.rulesFor(e,r,n);for(let e=0,n=i.length;e<n;e++)if(i[e].matchesConditions(t))return i[e];return null}cannot(e,t,n){return!this.can(e,t,n)}},rW=PU({$eq:YH,$ne:XH,$lt:qH,$lte:JH,$gt:KH,$gte:GH,$in:BH,$nin:VH,$all:HH,$size:zH,$regex:ZH,$options:QH,$elemMatch:RH,$exists:WH},{eq:gU,ne:_U,lt:yU,lte:vU,gt:bU,gte:xU,in:EU,nin:DU,all:OU,size:wU,regex:TU,elemMatch:kU,exists:SU,and:mU}),iW=/[-/\\^$+?.()|[\]{}]/g,aW=/\.?\*+\.?/g,oW=/\*+/,sW=/\./g;function cW(e,t,n){let r=n[0]===`*`||e[0]===`.`&&e[e.length-1]===`.`?`+`:`*`,i=e.indexOf(`**`)===-1?`[^.]`:`.`,a=e.replace(sW,`\\$&`).replace(oW,i+r);return t+e.length===n.length?`(?:${a})?`:a}function lW(e,t,n){return e===`.`&&(n[t-1]===`*`||n[t+1]===`*`)?e:`\\${e}`}function uW(e){let t=e.map(e=>e.replace(iW,lW).replace(aW,cW)),n=t.length>1?`(?:${t.join(`|`)})`:t[0];return RegExp(`^${n}$`)}var dW=e=>{let t;return n=>(t===void 0&&(t=e.every(e=>e.indexOf(`*`)===-1)?null:uW(e)),t===null?e.indexOf(n)!==-1:t.test(n))};function fW(e=[],t={}){return new nW(e,Object.assign({conditionsMatcher:rW,fieldMatcher:dW},t))}var pW=e=>`Cannot execute "${e.action}" on "${e.subjectType}"`,mW=function(e){this.message=e};mW.prototype=Object.create(Error.prototype);var hW=class extends mW{static setDefaultMessage(e){this.P=typeof e==`string`?()=>e:e}static from(e){return new this(e)}constructor(e){super(``),this.ability=e,typeof Error.captureStackTrace==`function`&&(this.name=`ForbiddenError`,Error.captureStackTrace(this,this.constructor))}setMessage(e){return this.message=e,this}throwUnlessCan(e,t,n){let r=this.unlessCan(e,t,n);if(r)throw r}unlessCan(e,t,n){let r=this.ability.relevantRuleFor(e,t,n);if(r&&!r.inverted)return;this.action=e,this.subject=t,this.subjectType=VU(this.ability.detectSubjectType(t)),this.field=n;let i=r?r.reason:``;return this.message=this.message||i||this.constructor.P(this),this}};hW.P=pW,Object.freeze({__proto__:null});var gW=new Set([`read-project-private`,`read-project-public`]),_W=[`Table`,`Row`,`Branch`,`Revision`,`Endpoint`],vW=class{ability=fW();loadedScopes=new Set;addSystemPermissions(e){let t=this.scopeToKey({type:`system`});if(this.loadedScopes.has(t))return;let n=this.permissionsToRules(e,null),r=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...r]),this.loadedScopes.add(t)}addOrganizationPermissions(e,t){let n=this.scopeToKey({type:`organization`,organizationId:e});if(this.loadedScopes.has(n))return;let r={organizationId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addProjectPermissions(e,t){let n=this.scopeToKey({type:`project`,projectId:e});if(this.loadedScopes.has(n))return;let r={projectId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addPublicReadPermissions(e){let t=`public:${e}`;if(this.loadedScopes.has(t))return;let n={projectId:e},r={action:`read`,subject:`Project`,conditions:{...n,isPublic:!0}},i=_W.map(e=>({action:`read`,subject:e,conditions:{...n}}));this.ability.update([...this.ability.rules,r,...i]),this.loadedScopes.add(t)}can(e,t,n){let r=RU(t,n?{...n}:{});return this.ability.can(e,r)}cannot(e,t,n){return!this.can(e,t,n)}hasScope(e){return this.loadedScopes.has(this.scopeToKey(e))}clearAll(){this.ability.update([]),this.loadedScopes.clear()}scopeToKey(e){switch(e.type){case`system`:return`system`;case`organization`:return`organization:${e.organizationId}`;case`project`:return`project:${e.projectId}`}}permissionsToRules(e,t){return e.map(e=>this.permissionToRule(e,t))}permissionToRule(e,t){let n={action:e.action,subject:e.subject},r=this.mergeConditions(e.condition,t);return r&&(n.conditions=r),n}mergeConditions(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(!(!n&&!r))return n&&r?{...e,...t}:n?{...e}:{...t}}expandPermissions(e,t){let n=[];for(let r of e)if(gW.has(r.id))for(let e of _W){let r={action:`read`,subject:e};t&&Object.keys(t).length>0&&(r.conditions={...t}),n.push(r)}return n}};Y.register(vW,()=>new vW,{scope:`singleton`});var yW=class{constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){let t=e.permissions.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addSystemPermissions(t)}}clearAll(){this.permissionService.clearAll()}get canCreateProject(){return this.permissionService.can(`create`,`Project`)}get canReadUser(){return this.permissionService.can(`read`,`User`)}get canCreateUser(){return this.permissionService.can(`create`,`User`)}get canAddUser(){return this.permissionService.can(`add`,`User`)}get canUpdateUser(){return this.permissionService.can(`update`,`User`)}get canDeleteUser(){return this.permissionService.can(`delete`,`User`)}get canManageUsers(){return this.canAddUser||this.canReadUser}get canReadOrganization(){return this.permissionService.can(`read`,`Organization`)}get canUpdateOrganization(){return this.permissionService.can(`update`,`Organization`)}get canDeleteOrganization(){return this.permissionService.can(`delete`,`Organization`)}};Y.register(yW,()=>new yW(Y.get(vW)),{scope:`singleton`});var bW=class{_contextProvider=null;constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setContextProvider(e){this._contextProvider=e}get context(){return this._contextProvider?.()??{projectId:null,organizationId:null,isPublic:!1,projectRoleName:null}}get projectId(){return this.context.projectId}get organizationId(){return this.context.organizationId}get isPublic(){return this.context.isPublic}get projectRoleName(){return this.context.projectRoleName}getProjectContext(){let e=this.context,t={};return e.projectId&&(t.projectId=e.projectId),e.organizationId&&(t.organizationId=e.organizationId),t}can(e,t,n){let r=n??this.getProjectContext();return this.permissionService.can(e,t,Object.keys(r).length>0?r:void 0)}get canReadProject(){return this.can(`read`,`Project`,{...this.getProjectContext(),isPublic:this.context.isPublic})}get canUpdateProject(){return this.can(`update`,`Project`)}get canDeleteProject(){return this.can(`delete`,`Project`)}get canReadBranch(){return this.can(`read`,`Branch`)}get canCreateBranch(){return this.can(`create`,`Branch`)}get canDeleteBranch(){return this.can(`delete`,`Branch`)}get canReadRevision(){return this.can(`read`,`Revision`)}get canCreateRevision(){return this.can(`create`,`Revision`)}get canRevertRevision(){return this.can(`revert`,`Revision`)}get canReadTable(){return this.can(`read`,`Table`)}get canCreateTable(){return this.can(`create`,`Table`)}get canUpdateTable(){return this.can(`update`,`Table`)}get canDeleteTable(){return this.can(`delete`,`Table`)}get canReadRow(){return this.can(`read`,`Row`)}get canCreateRow(){return this.can(`create`,`Row`)}get canUpdateRow(){return this.can(`update`,`Row`)}get canDeleteRow(){return this.can(`delete`,`Row`)}get canReadEndpoint(){return this.can(`read`,`Endpoint`)}get canCreateEndpoint(){return this.can(`create`,`Endpoint`)}get canDeleteEndpoint(){return this.can(`delete`,`Endpoint`)}get canAddUser(){return this.can(`add`,`User`)}get canUpdateUser(){return this.can(`update`,`User`)}get canDeleteUser(){return this.can(`delete`,`User`)}get canReadUser(){return this.can(`read`,`User`)}get canManageApiKeys(){return this.can(`manage`,`ApiKey`)}get canManageUsers(){return this.canAddUser||this.canReadUser}get canAccessSettings(){return this.canUpdateProject||this.canDeleteProject}get canWrite(){return this.canCreateTable||this.canUpdateTable||this.canDeleteTable||this.canCreateRow||this.canUpdateRow||this.canDeleteRow}get isReadOnly(){return!this.canWrite}};Y.register(bW,()=>new bW(Y.get(vW)),{scope:`singleton`});var xW;n((()=>{xW=function(){return xW=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xW.apply(this,arguments)}}))();var SW=new Map,CW=new Map,wW=!0,TW=!1;function EW(e){return e.replace(/[\s,]+/g,` `).trim()}function DW(e){return EW(e.source.body.substring(e.start,e.end))}function OW(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if(e.kind===`FragmentDefinition`){var r=e.name.value,i=DW(e.loc),a=CW.get(r);a&&!a.has(i)?wW&&console.warn(`Warning: fragment with name `+r+` already exists.
383
383
  graphql-tag enforces all fragment names across your application to be unique; read more about
384
384
  this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a||CW.set(r,a=new Set),a.add(i),t.has(i)||(t.add(i),n.push(e))}else n.push(e)}),xW(xW({},e),{definitions:n})}function kW(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&typeof r==`object`&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}function AW(e){var t=EW(e);if(!SW.has(t)){var n=see(e,{experimentalFragmentVariables:TW,allowLegacyFragmentVariables:TW});if(!n||n.kind!==`Document`)throw Error(`Not a valid GraphQL document.`);SW.set(t,kW(OW(n)))}return SW.get(t)}function jW(e){var t=[...arguments].slice(1);typeof e==`string`&&(e=[e]);var n=e[0];return t.forEach(function(t,r){t&&t.kind===`Document`?n+=t.loc.source.body:n+=t,n+=e[r+1]}),AW(n)}function MW(){SW.clear(),CW.clear()}function NW(){wW=!1}function PW(){TW=!0}function FW(){TW=!1}var IW={gql:jW,resetCaches:MW,disableFragmentWarnings:NW,enableExperimentalFragmentVariables:PW,disableExperimentalFragmentVariables:FW};(function(e){e.gql=IW.gql,e.resetCaches=IW.resetCaches,e.disableFragmentWarnings=IW.disableFragmentWarnings,e.enableExperimentalFragmentVariables=IW.enableExperimentalFragmentVariables,e.disableExperimentalFragmentVariables=IW.disableExperimentalFragmentVariables})(jW||={}),jW.default=jW;var Z=jW,LW=function(e){return e.Applied=`applied`,e.Failed=`failed`,e.Skipped=`skipped`,e}({}),RW=function(e){return e.Active=`active`,e.Cancelled=`cancelled`,e.EarlyAdopter=`early_adopter`,e.Free=`free`,e.PastDue=`past_due`,e}({}),zW=function(e){return e.Added=`ADDED`,e.Modified=`MODIFIED`,e.Removed=`REMOVED`,e.Renamed=`RENAMED`,e.RenamedAndModified=`RENAMED_AND_MODIFIED`,e}({}),BW=function(e){return e.Graphql=`GRAPHQL`,e.RestApi=`REST_API`,e}({}),VW=function(e){return e.CreatedAt=`createdAt`,e.Data=`data`,e.Id=`id`,e.PublishedAt=`publishedAt`,e.UpdatedAt=`updatedAt`,e}({}),HW=function(e){return e.Boolean=`boolean`,e.Float=`float`,e.Int=`int`,e.Text=`text`,e.Timestamp=`timestamp`,e}({}),UW=function(e){return e.Replace=`replace`,e}({}),WW=function(e){return e.Default=`default`,e.Insensitive=`insensitive`,e}({}),GW=function(e){return e.All=`all`,e.Booleans=`booleans`,e.Keys=`keys`,e.Numbers=`numbers`,e.Strings=`strings`,e.Values=`values`,e}({}),KW=function(e){return e.Phrase=`phrase`,e.Plain=`plain`,e.Prefix=`prefix`,e.Tsquery=`tsquery`,e}({}),qW=function(e){return e.Asc=`asc`,e.Desc=`desc`,e}({}),JW=function(e){return e.Developer=`developer`,e.Editor=`editor`,e.OrganizationAdmin=`organizationAdmin`,e.OrganizationOwner=`organizationOwner`,e.Reader=`reader`,e}({}),YW=function(e){return e.Developer=`developer`,e.Editor=`editor`,e.Reader=`reader`,e}({}),XW=function(e){return e.SystemAdmin=`systemAdmin`,e.SystemFullApiRead=`systemFullApiRead`,e.SystemUser=`systemUser`,e}({}),ZW=Z`
385
385
  fragment BranchLoaderFragment on BranchModel {
@@ -2163,7 +2163,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a
2163
2163
  }
2164
2164
  }
2165
2165
  ${LG}
2166
- `,jq=(e,t,n,r)=>e();function Mq(e,t=jq){return{getBranchForLoader(n,r){return t(t=>e.request(RG,n,{...r,...t}),`getBranchForLoader`,`query`,n)},organizationProjects(n,r){return t(t=>e.request(zG,n,{...r,...t}),`organizationProjects`,`query`,n)},getProject(n,r){return t(t=>e.request(BG,n,{...r,...t}),`getProject`,`query`,n)},getProjectForLoader(n,r){return t(t=>e.request(VG,n,{...r,...t}),`getProjectForLoader`,`query`,n)},getRevisionForLoader(n,r){return t(t=>e.request(HG,n,{...r,...t}),`getRevisionForLoader`,`query`,n)},getRowForLoader(n,r){return t(t=>e.request(UG,n,{...r,...t}),`getRowForLoader`,`query`,n)},getRowCountForeignKeysToForLoader(n,r){return t(t=>e.request(WG,n,{...r,...t}),`getRowCountForeignKeysToForLoader`,`query`,n)},ForeignKeysBy(n,r){return t(t=>e.request(GG,n,{...r,...t}),`ForeignKeysBy`,`query`,n)},ForeignKeysByRows(n,r){return t(t=>e.request(KG,n,{...r,...t}),`ForeignKeysByRows`,`query`,n)},getTableForLoader(n,r){return t(t=>e.request(qG,n,{...r,...t}),`getTableForLoader`,`query`,n)},updatePassword(n,r){return t(t=>e.request(JG,n,{...r,...t}),`updatePassword`,`mutation`,n)},myApiKeys(n,r){return t(t=>e.request(YG,n,{...r,...t}),`myApiKeys`,`query`,n)},serviceApiKeys(n,r){return t(t=>e.request(XG,n,{...r,...t}),`serviceApiKeys`,`query`,n)},apiKeyById(n,r){return t(t=>e.request(ZG,n,{...r,...t}),`apiKeyById`,`query`,n)},createPersonalApiKey(n,r){return t(t=>e.request(QG,n,{...r,...t}),`createPersonalApiKey`,`mutation`,n)},createServiceApiKey(n,r){return t(t=>e.request($G,n,{...r,...t}),`createServiceApiKey`,`mutation`,n)},revokeApiKey(n,r){return t(t=>e.request(eK,n,{...r,...t}),`revokeApiKey`,`mutation`,n)},rotateApiKey(n,r){return t(t=>e.request(tK,n,{...r,...t}),`rotateApiKey`,`mutation`,n)},createProject(n,r){return t(t=>e.request(nK,n,{...r,...t}),`createProject`,`mutation`,n)},findForeignKey(n,r){return t(t=>e.request(rK,n,{...r,...t}),`findForeignKey`,`query`,n)},adminCacheStats(n,r){return t(t=>e.request(iK,n,{...r,...t}),`adminCacheStats`,`query`,n)},adminResetAllCache(n,r){return t(t=>e.request(aK,n,{...r,...t}),`adminResetAllCache`,`mutation`,n)},AdminDashboardStats(n,r){return t(t=>e.request(oK,n,{...r,...t}),`AdminDashboardStats`,`query`,n)},adminGetUser(n,r){return t(t=>e.request(sK,n,{...r,...t}),`adminGetUser`,`query`,n)},adminResetPassword(n,r){return t(t=>e.request(cK,n,{...r,...t}),`adminResetPassword`,`mutation`,n)},adminUsers(n,r){return t(t=>e.request(lK,n,{...r,...t}),`adminUsers`,`query`,n)},adminUser(n,r){return t(t=>e.request(uK,n,{...r,...t}),`adminUser`,`query`,n)},assetsTablesData(n,r){return t(t=>e.request(dK,n,{...r,...t}),`assetsTablesData`,`query`,n)},assetsRowsData(n,r){return t(t=>e.request(fK,n,{...r,...t}),`assetsRowsData`,`query`,n)},subSchemaItemsData(n,r){return t(t=>e.request(pK,n,{...r,...t}),`subSchemaItemsData`,`query`,n)},getProjectBranches(n,r){return t(t=>e.request(mK,n,{...r,...t}),`getProjectBranches`,`query`,n)},deleteBranch(n,r){return t(t=>e.request(hK,n,{...r,...t}),`deleteBranch`,`mutation`,n)},getBranchesForSelect(n,r){return t(t=>e.request(gK,n,{...r,...t}),`getBranchesForSelect`,`query`,n)},getBranchRevisionsForCreate(n,r){return t(t=>e.request(_K,n,{...r,...t}),`getBranchRevisionsForCreate`,`query`,n)},createBranch(n,r){return t(t=>e.request(vK,n,{...r,...t}),`createBranch`,`mutation`,n)},GetRevisionChanges(n,r){return t(t=>e.request(yK,n,{...r,...t}),`GetRevisionChanges`,`query`,n)},GetTableChanges(n,r){return t(t=>e.request(bK,n,{...r,...t}),`GetTableChanges`,`query`,n)},confirmEmailCode(n,r){return t(t=>e.request(xK,n,{...r,...t}),`confirmEmailCode`,`mutation`,n)},getEndpointBranches(n,r){return t(t=>e.request(SK,n,{...r,...t}),`getEndpointBranches`,`query`,n)},getProjectEndpoints(n,r){return t(t=>e.request(CK,n,{...r,...t}),`getProjectEndpoints`,`query`,n)},getBranchRevisions(n,r){return t(t=>e.request(wK,n,{...r,...t}),`getBranchRevisions`,`query`,n)},createEndpoint(n,r){return t(t=>e.request(TK,n,{...r,...t}),`createEndpoint`,`mutation`,n)},deleteEndpoint(n,r){return t(t=>e.request(EK,n,{...r,...t}),`deleteEndpoint`,`mutation`,n)},issueAccessToken(n,r){return t(t=>e.request(DK,n,{...r,...t}),`issueAccessToken`,`query`,n)},loginGithub(n,r){return t(t=>e.request(OK,n,{...r,...t}),`loginGithub`,`mutation`,n)},loginGoogle(n,r){return t(t=>e.request(kK,n,{...r,...t}),`loginGoogle`,`mutation`,n)},login(n,r){return t(t=>e.request(AK,n,{...r,...t}),`login`,`mutation`,n)},getMigrationBranches(n,r){return t(t=>e.request(jK,n,{...r,...t}),`getMigrationBranches`,`query`,n)},getBranchMigrations(n,r){return t(t=>e.request(MK,n,{...r,...t}),`getBranchMigrations`,`query`,n)},applyMigrations(n,r){return t(t=>e.request(NK,n,{...r,...t}),`applyMigrations`,`mutation`,n)},getMigrations(n,r){return t(t=>e.request(PK,n,{...r,...t}),`getMigrations`,`query`,n)},activateEarlyAccess(n,r){return t(t=>e.request(FK,n,{...r,...t}),`activateEarlyAccess`,`mutation`,n)},createCheckout(n,r){return t(t=>e.request(IK,n,{...r,...t}),`createCheckout`,`mutation`,n)},cancelSubscription(n,r){return t(t=>e.request(LK,n,{...r,...t}),`cancelSubscription`,`mutation`,n)},getLimitsPageData(n,r){return t(t=>e.request(RK,n,{...r,...t}),`getLimitsPageData`,`query`,n)},getLimitsPagePlans(n,r){return t(t=>e.request(zK,n,{...r,...t}),`getLimitsPagePlans`,`query`,n)},getUsersOrganization(n,r){return t(t=>e.request(BK,n,{...r,...t}),`getUsersOrganization`,`query`,n)},addUserToOrganization(n,r){return t(t=>e.request(VK,n,{...r,...t}),`addUserToOrganization`,`mutation`,n)},removeUserFromOrganization(n,r){return t(t=>e.request(HK,n,{...r,...t}),`removeUserFromOrganization`,`mutation`,n)},adminValidateProjectFileBytes(n,r){return t(t=>e.request(UK,n,{...r,...t}),`adminValidateProjectFileBytes`,`query`,n)},adminRestoreProjectFileBytes(n,r){return t(t=>e.request(WK,n,{...r,...t}),`adminRestoreProjectFileBytes`,`mutation`,n)},updateProject(n,r){return t(t=>e.request(GK,n,{...r,...t}),`updateProject`,`mutation`,n)},deleteProjectForSettings(n,r){return t(t=>e.request(KK,n,{...r,...t}),`deleteProjectForSettings`,`mutation`,n)},fetchTableForStack(n,r){return t(t=>e.request(qK,n,{...r,...t}),`fetchTableForStack`,`query`,n)},createTableForStack(n,r){return t(t=>e.request(JK,n,{...r,...t}),`createTableForStack`,`mutation`,n)},updateTableForStack(n,r){return t(t=>e.request(YK,n,{...r,...t}),`updateTableForStack`,`mutation`,n)},renameTableForStack(n,r){return t(t=>e.request(XK,n,{...r,...t}),`renameTableForStack`,`mutation`,n)},rowPageData(n,r){return t(t=>e.request(ZK,n,{...r,...t}),`rowPageData`,`query`,n)},signUp(n,r){return t(t=>e.request(QK,n,{...r,...t}),`signUp`,`mutation`,n)},setUsername(n,r){return t(t=>e.request($K,n,{...r,...t}),`setUsername`,`mutation`,n)},getUsersProject(n,r){return t(t=>e.request(eq,n,{...r,...t}),`getUsersProject`,`query`,n)},searchUsers(n,r){return t(t=>e.request(tq,n,{...r,...t}),`searchUsers`,`query`,n)},addUserToProject(n,r){return t(t=>e.request(nq,n,{...r,...t}),`addUserToProject`,`mutation`,n)},removeUserFromProject(n,r){return t(t=>e.request(rq,n,{...r,...t}),`removeUserFromProject`,`mutation`,n)},updateUserProjectRole(n,r){return t(t=>e.request(iq,n,{...r,...t}),`updateUserProjectRole`,`mutation`,n)},createUser(n,r){return t(t=>e.request(aq,n,{...r,...t}),`createUser`,`mutation`,n)},configuration(n,r){return t(t=>e.request(oq,n,{...r,...t}),`configuration`,`query`,n)},getMe(n,r){return t(t=>e.request(sq,n,{...r,...t}),`getMe`,`query`,n)},getProjectGraph(n,r){return t(t=>e.request(cq,n,{...r,...t}),`getProjectGraph`,`query`,n)},findBranches(n,r){return t(t=>e.request(lq,n,{...r,...t}),`findBranches`,`query`,n)},findRevisions(n,r){return t(t=>e.request(uq,n,{...r,...t}),`findRevisions`,`query`,n)},meProjectsList(n,r){return t(t=>e.request(dq,n,{...r,...t}),`meProjectsList`,`query`,n)},GetRowChanges(n,r){return t(t=>e.request(fq,n,{...r,...t}),`GetRowChanges`,`query`,n)},GetTableChangesForFilter(n,r){return t(t=>e.request(pq,n,{...r,...t}),`GetTableChangesForFilter`,`query`,n)},foreignKeyTableWithRows(n,r){return t(t=>e.request(mq,n,{...r,...t}),`foreignKeyTableWithRows`,`query`,n)},createRowForStack(n,r){return t(t=>e.request(hq,n,{...r,...t}),`createRowForStack`,`mutation`,n)},updateRowForStack(n,r){return t(t=>e.request(gq,n,{...r,...t}),`updateRowForStack`,`mutation`,n)},renameRowForStack(n,r){return t(t=>e.request(_q,n,{...r,...t}),`renameRowForStack`,`mutation`,n)},RowListRows(n,r){return t(t=>e.request(vq,n,{...r,...t}),`RowListRows`,`query`,n)},DeleteRow(n,r){return t(t=>e.request(yq,n,{...r,...t}),`DeleteRow`,`mutation`,n)},DeleteRows(n,r){return t(t=>e.request(bq,n,{...r,...t}),`DeleteRows`,`mutation`,n)},PatchRowInline(n,r){return t(t=>e.request(xq,n,{...r,...t}),`PatchRowInline`,`mutation`,n)},GetTableViews(n,r){return t(t=>e.request(Sq,n,{...r,...t}),`GetTableViews`,`query`,n)},UpdateTableViews(n,r){return t(t=>e.request(Cq,n,{...r,...t}),`UpdateTableViews`,`mutation`,n)},searchRows(n,r){return t(t=>e.request(wq,n,{...r,...t}),`searchRows`,`query`,n)},revertChangesForSidebar(n,r){return t(t=>e.request(Tq,n,{...r,...t}),`revertChangesForSidebar`,`mutation`,n)},createRevisionForSidebar(n,r){return t(t=>e.request(Eq,n,{...r,...t}),`createRevisionForSidebar`,`mutation`,n)},createBranchForSidebar(n,r){return t(t=>e.request(Dq,n,{...r,...t}),`createBranchForSidebar`,`mutation`,n)},deleteTableForList(n,r){return t(t=>e.request(Oq,n,{...r,...t}),`deleteTableForList`,`mutation`,n)},tableListData(n,r){return t(t=>e.request(kq,n,{...r,...t}),`tableListData`,`query`,n)},tableRelationsData(n,r){return t(t=>e.request(Aq,n,{...r,...t}),`tableRelationsData`,`query`,n)}}}var Nq=class{constructor(){}get(e){let t=globalThis.__env__?.[e],n={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`69fec82`,MODE:`production`,PACKAGE_VERSION:`2.6.0-alpha.1`,PROD:!0,REACT_APP_ENDPOINT_HOST:``,REACT_APP_ENDPOINT_PORT:``,REACT_APP_ENDPOINT_SERVER_URL:`/endpoint`,REACT_APP_GRAPHQL_SERVER_URL:`/graphql`,REACT_APP_SWAGGER_SERVER_URL:`/api`,SSR:!1}[e];return t||n}};Y.register(Nq,()=>new Nq,{scope:`singleton`});var Pq=`revisium:sidebar-collapsed`,Fq=200,Iq=class{_isCollapsed=!1;_isHoverExpanded=!1;_hoverDelay=new cH(Fq);_leaveDelay=new cH(Fq);_keyboardHandler=null;constructor(e){this.storage=e,this._isCollapsed=e.getItem(Pq)===`true`,f(this,{},{autoBind:!0}),s(()=>this._isCollapsed,e=>{this.storage.setItem(Pq,String(e))})}get isCollapsed(){return this._isCollapsed}get isHoverExpanded(){return this._isHoverExpanded}get isSidebarVisible(){return!this._isCollapsed||this._isHoverExpanded}toggle(){this._isCollapsed=!this._isCollapsed,this._isHoverExpanded=!1}setHoverExpanded(e){this._isHoverExpanded=e}startHoverIntent(){this._leaveDelay.cancel(),this._hoverDelay.schedule(()=>{this.setHoverExpanded(!0)})}cancelHoverIntent(){this._hoverDelay.cancel()}startLeaveIntent(){this._leaveDelay.schedule(()=>{this.setHoverExpanded(!1)})}cancelLeaveIntent(){this._leaveDelay.cancel()}dismissOverlay(){this.setHoverExpanded(!1)}initKeyboard(){this._keyboardHandler||(this._keyboardHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key===`\\`&&(e.preventDefault(),this.toggle())},window.addEventListener(`keydown`,this._keyboardHandler))}disposeKeyboard(){this._keyboardHandler&&=(window.removeEventListener(`keydown`,this._keyboardHandler),null),this._hoverDelay.dispose(),this._leaveDelay.dispose()}};Y.register(Iq,()=>new Iq(localStorage),{scope:`singleton`});var Lq=({sidebar:e,footer:t})=>(0,I.jsxs)(I.Fragment,{children:[e,t&&(0,I.jsx)(A,{alignSelf:`center`,mt:`1rem`,children:t})]}),Rq=288,zq=48,Bq=`0.2s`,Vq=g(({hideSidebar:e,sidebar:t,title:n,actions:r,children:i,footer:a})=>{let o=Y.get(Iq);(0,L.useEffect)(()=>(o.initKeyboard(),()=>{o.disposeKeyboard()}),[o]);let s=!e,c=s&&o.isCollapsed,l=c&&o.isHoverExpanded,u=s?c?`${zq}px`:`${Rq}px`:`0px`;return(0,I.jsxs)(j,{minHeight:`100vh`,children:[s&&(0,I.jsx)(j,{width:u,minWidth:u,flexShrink:0,height:`100vh`,top:0,position:`sticky`,transition:`width ${Bq} ease, min-width ${Bq} ease`,overflow:`hidden`,children:c?(0,I.jsx)(j,{width:`${zq}px`,minWidth:`${zq}px`,height:`100vh`,flexDirection:`column`,alignItems:`center`,paddingTop:`20px`,onMouseEnter:o.startHoverIntent,onMouseLeave:o.cancelHoverIntent,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,onClick:o.toggle,"aria-label":`Toggle sidebar`,children:(0,I.jsx)(Zte,{})})}):(0,I.jsx)(j,{width:`${Rq}px`,minWidth:`${Rq}px`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,height:`100vh`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{position:`fixed`,left:0,top:0,width:`100vw`,height:`100vh`,zIndex:9,pointerEvents:l?`auto`:`none`,onClick:o.dismissOverlay}),(0,I.jsx)(j,{position:`fixed`,left:0,top:0,width:`${Rq}px`,height:`100vh`,zIndex:10,backgroundColor:`white`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,boxShadow:l?`4px 0 12px rgba(0, 0, 0, 0.08)`:`none`,transform:l?`translateX(0)`:`translateX(-${Rq}px)`,transition:`transform ${Bq} ease, box-shadow ${Bq} ease`,onMouseLeave:o.startLeaveIntent,onMouseEnter:o.cancelLeaveIntent,pointerEvents:l?`auto`:`none`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})]}),(0,I.jsxs)(j,{flex:1,minWidth:0,flexDirection:`column`,alignItems:`center`,children:[(n||r)&&(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,borderBottom:`1px solid`,borderBottomColor:`gray.50`,justifyContent:`space-between`,maxWidth:`900px`,padding:`8px`,width:`100%`,position:`sticky`,zIndex:1,top:0,children:[n,r]}),(0,I.jsx)(j,{flex:1,flexDirection:`column`,maxWidth:`900px`,padding:`1rem 1rem 0rem 1rem`,width:`100%`,children:i})]})]})}),Hq=({height:e=`2.5rem`,title:t,onClick:n,disabled:r,isSelected:i,isLoading:a,icon:o,dataTestId:s})=>(0,I.jsx)(N,{"data-testid":s,_hover:{color:`gray.400`,backgroundColor:`white`},_disabled:i?{backgroundColor:`gray.50`,cursor:`not-allowed`}:void 0,alignSelf:`flex-start`,color:`gray.300`,fontWeight:`500`,fontSize:16,height:e,disabled:r||i,loading:a,variant:`ghost`,onClick:n,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`0.5rem`,children:[o&&(0,I.jsx)(A,{fontSize:`sm`,children:o}),(0,I.jsx)(k,{children:t})]})}),Uq=e=>(0,I.jsx)(Hq,{...e,icon:(0,I.jsx)(af,{})}),Wq=({height:e=`2.5rem`,loading:t,isDisabled:n,onClick:r,title:i,dataTestId:a})=>(0,I.jsxs)(N,{"data-testid":a,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,loading:t,disabled:n,variant:`ghost`,onClick:r,width:`48px`,children:[(0,I.jsx)(Ve,{size:`sm`,mr:i?8:0,children:(0,I.jsx)(ef,{})}),i]}),Gq=({height:e=`2.5rem`,onClick:t,disabled:n,dataTestId:r})=>(0,I.jsx)(N,{"data-testid":r,disabled:n,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,variant:`ghost`,onClick:t,width:`48px`,children:(0,I.jsx)(Ve,{size:`md`,children:(0,I.jsx)(ip,{})})}),Kq=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,size:`lg`,width:`40px`,height:`40px`,...t,children:(0,I.jsx)(nf,{})}),qq=({value:e,placeholder:t,autoFocus:n,onChange:r,onBlur:i,onEnter:a,width:o,height:s,type:c,dataTestId:l,autoComplete:u})=>{let d=SB();return(0,I.jsx)(qt,{autoComplete:u,"data-testid":l,borderColor:`gray.100`,padding:`0 9px`,placeholder:t,ref:n?d:void 0,value:e,variant:`outline`,onChange:r,onBlur:i,width:o,height:s,type:c,onKeyDown:a?e=>{e.key===`Enter`&&a()}:void 0})},Jq=Rd({placement:`top`,pauseOnPageIdle:!0,duration:1500}),Yq=Rd({placement:`bottom`,pauseOnPageIdle:!0,duration:1500}),Xq=e=>(0,I.jsxs)(_t,{width:{md:`sm`},children:[e.type===`loading`?(0,I.jsx)(Ht,{size:`sm`,color:`blue.solid`}):(0,I.jsx)(ft,{}),(0,I.jsxs)(_e,{gap:`1`,flex:`1`,maxWidth:`100%`,children:[e.title&&(0,I.jsx)(eee,{children:e.title}),e.description&&(0,I.jsx)(ree,{color:`gray.500`,children:e.description})]}),e.action&&(0,I.jsx)(lt,{children:e.action.label}),e.closable&&(0,I.jsx)(Ft,{})]}),Zq=()=>(0,I.jsxs)(R,{children:[(0,I.jsx)(Rt,{toaster:Jq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})}),(0,I.jsx)(Rt,{toaster:Yq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})})]}),Qq=L.forwardRef(function(e,t){let{showArrow:n,children:r,disabled:i,portalled:a=!0,content:o,contentProps:s,portalRef:c,...l}=e;return i?r:(0,I.jsxs)(Wt,{...l,children:[(0,I.jsx)(Qt,{asChild:!0,children:r}),(0,I.jsx)(R,{disabled:!a,container:c,children:(0,I.jsx)(rt,{children:(0,I.jsxs)(Et,{ref:t,...s,children:[n&&(0,I.jsx)(Vt,{children:(0,I.jsx)(Yt,{})}),o]})})})]})}),$q={deprecated:{type:`boolean`},title:{type:`string`},description:{type:`string`}};({...$q});var eJ={type:{const:`string`},default:{type:`string`},readOnly:{type:`boolean`},pattern:{type:`string`,format:`regex`},enum:{type:`array`,items:{type:`string`},minItems:1,uniqueItems:!0},format:{type:`string`,enum:[`date-time`,`date`,`time`,`email`,`regex`]},contentMediaType:{type:`string`,enum:[`text/plain`,`text/markdown`,`text/html`,`application/json`,`application/schema+json`,`application/yaml`]},...$q};({...eJ}),{...eJ},{...$q},{...$q},{...$q},{...$q};var tJ=new(e(vd(),1)).default;tJ.addKeyword({keyword:`foreignKey`,type:`string`}),tJ.addFormat(`regex`,{type:`string`,validate:e=>{try{return new RegExp(e),!0}catch{return!1}}});var nJ=(e,t)=>({result:tJ.validate(e,t),errors:tJ.errors}),rJ=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,...t,children:(0,I.jsx)(qf,{})}),iJ={JsonCard:`_JsonCard_15gzu_1`,CopyButton:`_CopyButton_15gzu_1`},aJ=({data:e,readonly:t,onChange:n,schema:r,onBlur:i})=>{let[a,o]=(0,L.useState)(``),s=JSON.stringify(e,null,3),[c,l]=(0,L.useState)(s),u=(0,L.useRef)(!1),d=u.current?c:s,f=(0,L.useCallback)(async()=>{await navigator.clipboard.writeText(d),Jq.info({duration:1500,description:`Copied to clipboard`})},[d]),p=(0,L.useCallback)(e=>{l(e);try{let t=JSON.parse(e);if(r){let e=nJ(r,t);if(!e.result){o(`"${e.errors?.[0]?.instancePath||`/`}": ${e.errors?.[0]?.message}`);return}}o(``),n?.(t)}catch(e){console.error(e),o(`Invalid JSON`)}},[n,r]),m=(0,L.useCallback)(()=>{u.current=!0,l(s)},[s]),h=(0,L.useCallback)(()=>{u.current=!1,l(s),i?.()},[i,s]);return(0,I.jsxs)(j,{position:`relative`,width:`100%`,flex:1,className:iJ.JsonCard,direction:`column`,gap:`1rem`,children:[(0,I.jsxs)(A,{p:1,flex:1,children:[(0,I.jsx)(DO,{value:d,extensions:[G.lineWrapping,nk()],editable:!t,theme:pC,maxWidth:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0},onChange:p,onFocus:m,onBlur:h}),(0,I.jsx)(rJ,{dataTestId:`json-card-copy-button`,"aria-label":``,position:`absolute`,top:`8px`,right:`8px`,className:iJ.CopyButton,onClick:f})]}),(0,I.jsx)(j,{height:`40px`,paddingBottom:`8px`,alignItems:`flex-end`,backgroundColor:`white`,width:`100%`,position:`sticky`,bottom:0,justifyContent:`center`,children:(0,I.jsx)(k,{color:`gray`,children:a})})]})},oJ=g(()=>{let e=Y.get(Iq),t=e.isCollapsed&&e.isHoverExpanded,n=t?`Expand sidebar`:`Collapse sidebar`,r=t?Ite:Fte;return(0,I.jsx)(Qq,{content:n,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,flexShrink:0,onClick:e.toggle,opacity:+!!t,_groupHover:{opacity:1},transition:`opacity 0.15s ease`,"aria-label":n,children:(0,I.jsx)(r,{})})})}),sJ=({to:e,label:t,isActive:n,icon:r,onClick:i,badge:a})=>{let o=(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:i,children:[r&&(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t}),a!=null&&a>0&&(0,I.jsx)(A,{fontSize:`11px`,fontWeight:`600`,color:`newGray.400`,backgroundColor:`newGray.100`,borderRadius:`4px`,paddingX:`6px`,paddingY:`2px`,minWidth:`20px`,textAlign:`center`,children:a>99?`99+`:a})]});return e&&!i?(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:o}):o},cJ=g(({model:e,roleSlot:t,disableRemove:n})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`newGray.200`,borderRadius:`md`,padding:`1rem`,backgroundColor:`white`,_hover:{borderColor:`newGray.300`},transition:`border-color 0.2s`,children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(A,{color:`newGray.400`,children:(0,I.jsx)(zf,{size:20})}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontWeight:`500`,color:`newGray.600`,children:e.displayName}),e.username&&e.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.email})]})]}),(0,I.jsxs)(P,{gap:3,children:[t,e.canRemove&&(0,I.jsx)(N,{variant:`ghost`,size:`sm`,color:`red.500`,onClick:()=>e.remove(),loading:e.isRemoving,disabled:n,children:(0,I.jsx)(Rf,{})})]})]})})),lJ=g(({model:e,title:t,roleSelect:n})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`lg`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:t})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsx)(fn,{value:`search`,children:`Search User`}),e.canCreateUser&&(0,I.jsx)(fn,{value:`create`,children:`Create New`})]}),(0,I.jsx)(bt,{value:`search`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Search by username or email`}),(0,I.jsx)(qt,{placeholder:`Enter username or email...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),autoComplete:`off`})]}),e.isSearching?(0,I.jsx)(j,{justify:`center`,padding:`2rem`,children:(0,I.jsx)(Ht,{})}):e.searchResults.length>0?(0,I.jsx)(M,{align:`stretch`,gap:`0.5rem`,maxHeight:`200px`,overflowY:`auto`,children:e.searchResults.map(t=>(0,I.jsx)(A,{padding:`0.75rem`,borderWidth:`1px`,borderColor:e.selectedUserId===t.id?`blue.500`:`newGray.200`,borderRadius:`md`,backgroundColor:e.selectedUserId===t.id?`blue.50`:`white`,cursor:`pointer`,onClick:()=>e.setSelectedUserId(t.id),_hover:{borderColor:`blue.300`},transition:`all 0.2s`,children:(0,I.jsxs)(j,{align:`center`,justify:`space-between`,children:[(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(zf,{size:16}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,children:t.username||t.email||t.id}),t.username&&t.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.email})]})]}),e.selectedUserId===t.id&&(0,I.jsx)(Lte,{size:16,color:`var(--chakra-colors-blue-500)`})]})},t.id))}):e.searchQuery.length>0?(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,textAlign:`center`,padding:`2rem`,children:`No users found`}):null,(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})}),e.canCreateUser&&(0,I.jsx)(bt,{value:`create`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.newUsername,onChange:t=>e.setNewUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.newEmail,onChange:t=>e.setNewEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),e.activeTab===`search`?(0,I.jsx)(N,{onClick:e.addSelectedUser,disabled:!e.canAddSelectedUser,loading:e.isAdding,children:`Add User`}):(0,I.jsx)(N,{onClick:e.createAndAddUser,disabled:!e.canCreateNewUser,loading:e.isCreating,children:`Create & Add`})]}),(0,I.jsx)(Ie,{})]})})]})})),uJ=g(({model:e,sidebar:t,label:n,emptyTitle:r,emptySubtitle:i,subtitle:a,onAddClick:o,modal:s,children:c})=>e.showInitialLoading?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})})}):e.showError?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsxs)(k,{color:`red.500`,children:[`Error loading `,n.toLowerCase()]})})}):e.showNoMembers?(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsx)(A,{mb:`4rem`,children:(0,I.jsxs)(j,{justify:`center`,align:`center`,height:`200px`,flexDirection:`column`,gap:4,children:[(0,I.jsxs)(A,{textAlign:`center`,children:[(0,I.jsx)(Bf,{size:48,color:`var(--chakra-colors-newGray-400)`,style:{margin:`0 auto`}}),(0,I.jsx)(k,{color:`newGray.400`,mt:2,children:r}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mt:1,children:i})]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,focusRing:`none`,children:[(0,I.jsx)(Pf,{}),`Add`]})]})}),s]}):(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsxs)(j,{justify:`space-between`,align:`center`,marginBottom:`0.5rem`,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[n,` (`,e.totalCount,`)`]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,children:[(0,I.jsx)(Pf,{}),`Add`]})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,marginBottom:`1.5rem`,children:a}),(0,I.jsx)(M,{align:`stretch`,gap:3,children:c}),e.hasNextPage&&(0,I.jsx)(j,{justify:`center`,mt:4,children:(0,I.jsx)(N,{variant:`plain`,onClick:()=>e.tryToFetchNextPage(),loading:e.isLoading,children:`Load more`})})]}),s]})),dJ=class e{graphQLClient;client;onUnauthorized=null;constructor(t){this.environmentService=t;let n=this.environmentService.get(`REACT_APP_GRAPHQL_SERVER_URL`);if(!n)throw Error(`Invalid REACT_APP_GRAPHQL_SERVER_URL`);this.graphQLClient=new cee(n,{credentials:`include`,responseMiddleware:t=>{if(t instanceof Pn&&e.isUnauthorized(t))return;let n=t?.response?.errors?.[0]?.message;n&&Jq.info({duration:3e3,description:n})}}),this.wrapRequestWithRefreshRetry(),this.client=Mq(this.graphQLClient)}setToken(e){this.graphQLClient.setHeaders(e?{Authorization:`Bearer ${e}`}:{})}setUnauthorizedHandler(e){this.onUnauthorized=e}wrapRequestWithRefreshRetry(){let t=this.graphQLClient.request.bind(this.graphQLClient),n=async(n,r,i)=>{try{return await t(n,r,i)}catch(a){if(!e.isUnauthorized(a)||!this.onUnauthorized||!await this.onUnauthorized())throw a;return await t(n,r,i)}};this.graphQLClient.request=n}static isUnauthorized(e){if(!(e instanceof Pn))return!1;if(e.response.status===401)return!0;let t=e.response?.errors;return!Array.isArray(t)||t.length===0?!1:t.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;if(/^unauthorized$/i.test(n.trim()))return!0;let r=t.extensions?.code;return!!(typeof r==`string`&&/^UNAUTHENTICATED$/i.test(r)||t.extensions?.originalError?.statusCode===401)})}};Y.register(dJ,()=>new dJ(Y.get(Nq)),{scope:`singleton`});var Q=Y.get(dJ).client,fJ=`/api/auth/refresh`,pJ=`/api/auth/logout`,mJ=`rev_session`,hJ=class e{isLoaded=!1;user=null;token=null;refreshPromise=null;constructor(e,t,n){this.apiService=e,this.systemPermissions=t,this.permissionService=n,f(this),this.apiService.setUnauthorizedHandler(()=>this.tryRefresh())}async initialize(){if(!e.hasSessionCookie()){c(()=>{this.isLoaded=!0});return}try{await this.fetchMe()}catch{if(await this.tryRefresh())try{await this.fetchMe()}catch{}}c(()=>{this.isLoaded=!0})}async afterLogin(e){e!==void 0&&c(()=>{this.token=e}),await this.fetchMe()}setBearerToken(e){c(()=>{this.token=e}),this.apiService.setToken(e)}async logout(){try{await fetch(pJ,{method:`POST`,credentials:`include`})}catch{}this.apiService.setToken(null),c(()=>{this.user=null,this.token=null}),this.systemPermissions.clearAll()}async refresh(){return this.tryRefresh()}async fetchMe(){try{let e=await this.apiService.client.getMe();c(()=>{this.user=e.me}),this.systemPermissions.setUserRole(e.me.role??null),this.loadOrganizationPermissions(e.me)}catch(e){throw c(()=>{this.user=null}),e}}tryRefresh(){if(this.refreshPromise)return this.refreshPromise;let e=this.doRefresh();return c(()=>{this.refreshPromise=e}),e.finally(()=>{c(()=>{this.refreshPromise=null})}),e}async doRefresh(){try{return(await fetch(fJ,{method:`POST`,credentials:`include`})).ok}catch{return!1}}static hasSessionCookie(){if(typeof document>`u`)return!1;let e=document.cookie;return e?e.split(`;`).some(e=>e.trim()===`${mJ}=1`):!1}loadOrganizationPermissions(e){let t=e.organization?.userOrganization?.role?.permissions,n=e.organization?.id;if(t&&n){let e=t.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addOrganizationPermissions(n,e)}}};Y.register(hJ,()=>{let e=new hJ(Y.get(dJ),Y.get(yW),Y.get(vW));return e.initialize(),e},{scope:`singleton`});var gJ=class{isLoaded=!1;error=null;data=null;constructor(e){this.apiService=e,f(this)}async initialize(){await this.init()}get availableSignUp(){return this.availableEmailSignUp||this.availableGoogleOauth||this.availableGithubOauth}get availableEmailSignUp(){return this.data?.availableEmailSignUp}get availableGoogleOauth(){return!!this.data?.google.available}get googleOauthClientId(){if(!this.data?.google.clientId)throw Error(`Invalid Google client id`);return this.data?.google.clientId}get availableGithubOauth(){return!!this.data?.github.available}get githubOauthClientId(){if(!this.data?.github.clientId)throw Error(`Invalid Github client id`);return this.data?.github.clientId}get billingEnabled(){return this.data?.billing.enabled??!1}get cacheEnabled(){return this.data?.cache?.enabled??!1}get noAuth(){return this.data?.noAuth??!1}async init(){await this.request()}async request(){try{let e=await this.apiService.client.configuration();this.setData(e.configuration)}catch(e){this.setError(e),console.error(e)}finally{this.setIsLoaded(!0)}}setData(e){this.data=e}setError(e){this.error=e}setIsLoaded(e){this.isLoaded=e}};Y.register(gJ,()=>{let e=new gJ(Y.get(dJ));return e.initialize(),e},{scope:`singleton`});var _J=class{constructor(e,t){this.authService=e,this.configurationService=t,f(this)}get isLoaded(){return this.authService.isLoaded&&this.configurationService.isLoaded}};Y.register(_J,()=>new _J(Y.get(hJ),Y.get(gJ)),{scope:`singleton`});var vJ=`sandbox`,yJ=`login`,bJ=`logout`,xJ=`signup`,SJ=`username`,CJ=`github`,wJ=`google`,TJ=`authorize`,EJ=`get-token`,DJ=`get-mcp-token`,OJ=`completed`,kJ=`confirm`,AJ=`:organizationId`,jJ=`-/settings`,MJ=`-/members`,NJ=`-/limits`,PJ=`:projectName`,FJ=`-/settings`,IJ=`-/users`,LJ=`-/api-keys`,RJ=`-/mcp`,zJ=`:branchName`,BJ=`-/changes`,VJ=`-/assets`,HJ=`-/migrations`,UJ=`-/endpoints`,WJ=`-/branches`,GJ=`-/relations`,KJ=`-/branch-map`,qJ=`:revisionIdOrTag`,JJ=`:tableId`,YJ=`:rowId`,XJ=`draft`,ZJ=`head`,QJ=`admin`,$J=`users`,eY=`:userId`,tY=`organizations`,nY=`cache`,rY=function(e){return e.Organization=`organization`,e.Project=`project`,e.Branch=`branch`,e.Revision=`revision`,e.Table=`table`,e.Row=`row`,e.Changes=`changes`,e.Assets=`assets`,e.Migrations=`migrations`,e.Endpoints=`endpoints`,e.Branches=`branches`,e.Relations=`relations`,e.BranchMap=`branchMap`,e.OrganizationOverview=`organizationOverview`,e.OrganizationSettings=`organizationSettings`,e.OrganizationMembers=`organizationMembers`,e.OrganizationLimits=`organizationLimits`,e.ProjectSettings=`projectSettings`,e.ProjectUsers=`projectUsers`,e.ProjectApiKeys=`projectApiKeys`,e.ProjectMcp=`projectMcp`,e.Admin=`admin`,e.AdminUsers=`adminUsers`,e.AdminUserDetail=`adminUserDetail`,e.AdminOrganizations=`adminOrganizations`,e.AdminCache=`adminCache`,e}({}),iY=async()=>Y.get(yW).canReadUser?!0:Cn(`/`),aY=async({request:e})=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth)try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});return t.setBearerToken(e.login.accessToken),await t.afterLogin(),!0}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}let r=new URL(e.url),i=$V(`${r.pathname}${r.search}`);return Cn(`${n.availableSignUp?`/${xJ}`:`/${yJ}`}${i}`)}return t.user.username?!0:Cn(`/${SJ}`)},oY=async e=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth){try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});t.setBearerToken(e.login.accessToken),await t.afterLogin()}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}return!0}return!0}return t.user.username?!0:Cn(`/${SJ}`)},sY=async()=>Y.get(hJ).user?Cn(`/`):!0,cY=async()=>{let e=Y.get(hJ),t=Y.get(gJ);return e.user||!t.availableSignUp?Cn(`/`):!0},lY=(...e)=>async t=>{let n=null;for(let r of e){let e=await r(t);if(e&&typeof e==`object`&&`status`in e&&e.status===302)return e;n=e}return n},uY=async()=>!0,dY=class{statsRequest=X.of(Q.adminCacheStats);resetRequest=X.of(Q.adminResetAllCache);configurationService;_resetSuccess=!1;_showConfirm=!1;constructor(e){this.configurationService=e,f(this,{},{autoBind:!0})}get cacheEnabled(){return this.configurationService.cacheEnabled}get isLoading(){return this.statsRequest.isLoading}get isResetting(){return this.resetRequest.isLoading}get resetSuccess(){return this._resetSuccess}get showConfirm(){return this._showConfirm}get totalHits(){return this.statsRequest.data?.adminCacheStats.totalHits??0}get totalMisses(){return this.statsRequest.data?.adminCacheStats.totalMisses??0}get totalWrites(){return this.statsRequest.data?.adminCacheStats.totalWrites??0}get totalDeletes(){return this.statsRequest.data?.adminCacheStats.totalDeletes??0}get totalClears(){return this.statsRequest.data?.adminCacheStats.totalClears??0}get overallHitRate(){return this.statsRequest.data?.adminCacheStats.overallHitRate??0}get byCategory(){return this.statsRequest.data?.adminCacheStats.byCategory??[]}get resetError(){return this.resetRequest.errorMessage??null}openConfirm(){this._showConfirm=!0,this._resetSuccess=!1}closeConfirm(){this._showConfirm=!1}async confirmReset(){this._showConfirm=!1,(await this.resetRequest.fetch({})).isRight&&(c(()=>{this._resetSuccess=!0}),this.statsRequest.fetch({}))}init(){this.cacheEnabled&&this.statsRequest.fetch({})}dispose(){this.statsRequest.abort(),this.resetRequest.abort()}};Y.register(dY,()=>new dY(Y.get(gJ)),{scope:`request`});var fY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`160px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t})]}),pY=({keyName:e,hits:t,misses:n,writes:r,deletes:i,hitRate:a})=>(0,I.jsxs)(j,{padding:`12px 16px`,borderBottom:`1px solid`,borderColor:`gray.100`,alignItems:`center`,gap:`16px`,_last:{borderBottom:`none`},children:[(0,I.jsx)(k,{flex:`1`,fontSize:`sm`,fontWeight:`500`,fontFamily:`mono`,children:e}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[t,` hits`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[n,` misses`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[r,` writes`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[i,` del`]}),(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,minWidth:`60px`,textAlign:`right`,children:[(a*100).toFixed(1),`%`]})]}),mY=g(()=>{let e=CB(dY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Cache`})})})})})}),e.cacheEnabled?(0,I.jsxs)(A,{padding:`8px`,paddingTop:`16px`,children:[(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,marginBottom:`24px`,children:[(0,I.jsx)(fY,{label:`Hit Rate`,value:`${(e.overallHitRate*100).toFixed(1)}%`,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Hits`,value:e.totalHits,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Misses`,value:e.totalMisses,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Writes`,value:e.totalWrites,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Deletes`,value:e.totalDeletes,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Clears`,value:e.totalClears,isLoading:e.isLoading})]}),e.byCategory.length>0&&(0,I.jsxs)(A,{marginBottom:`24px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,marginBottom:`8px`,children:`By Cache Type`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`8px`,backgroundColor:`white`,children:e.byCategory.map(e=>(0,I.jsx)(pY,{keyName:e.key,hits:e.hits,misses:e.misses,writes:e.writes,deletes:e.deletes,hitRate:e.hitRate},e.key))})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(N,{colorPalette:`red`,variant:`outline`,size:`sm`,onClick:e.openConfirm,loading:e.isResetting,children:`Reset All Cache`}),e.resetSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Cache has been cleared successfully`}),e.resetError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetError})]})]}):(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.500`,children:`Caching is disabled`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,marginTop:`4px`,children:`Set CACHE_ENABLED=1 to enable caching.`})]})}),(0,I.jsx)(Ue,{open:e.showConfirm,onOpenChange:({open:t})=>!t&&e.closeConfirm(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Reset All Cache`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsx)(k,{children:`Are you sure you want to clear the entire cache?`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will flush all cached data including rows, revisions, auth, and billing caches. The cache will be rebuilt automatically as data is accessed.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.confirmReset,children:`Reset Cache`})]}),(0,I.jsx)(Ie,{})]})})]})})]})}),hY=class{usersRequest=X.of(Q.AdminDashboardStats);constructor(){f(this,{},{autoBind:!0})}get isLoadingUsers(){return this.usersRequest.isLoading}get isLoadingProjects(){return!1}get usersCount(){return this.usersRequest.data?.searchUsers.totalCount??null}get projectsCount(){return null}init(){this.usersRequest.fetch({first:1})}dispose(){this.usersRequest.abort()}};Y.register(hY,()=>new hY,{scope:`request`});var gY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`200px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t??`-`})]}),_Y=g(()=>{let e=CB(hY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Admin`})})})})})}),(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,children:[(0,I.jsx)(gY,{label:`Total Users`,value:e.usersCount,isLoading:e.isLoadingUsers}),(0,I.jsx)(gY,{label:`Total Projects`,value:e.projectsCount,isLoading:e.isLoadingProjects})]})})]})}),vY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get name(){return this.data.name}get prefix(){return this.data.prefix}get type(){return this.data.type}get isExpired(){return this.data.expiresAt?new Date(this.data.expiresAt)<new Date:!1}get isRevoked(){return this.data.revokedAt!==null}get isActive(){return!this.isExpired&&!this.isRevoked}get statusLabel(){return this.isRevoked?`Revoked`:this.isExpired?`Expired`:`Active`}get lastUsedAt(){return this.data.lastUsedAt??null}get createdAt(){return this.data.createdAt}get expiresAt(){return this.data.expiresAt??null}get readOnly(){return this.data.readOnly}get organizationId(){return this.data.organizationId??null}get projectIds(){return this.data.projectIds}get resolvedProjects(){return this.data.projects}get permissionLabel(){if(this.data.type===`PERSONAL`)return this.data.readOnly?`Read only`:`Full access`;let e=this.data.permissions?.rules?.[0]?.action??[];return e.includes(`delete`)?`Full access`:e.includes(`create`)||e.includes(`update`)?`Read & Write`:`Read only`}get permissionColorPalette(){switch(this.permissionLabel){case`Full access`:return`orange`;case`Read & Write`:return`blue`;default:return`gray`}}},yY={Active:{colorPalette:`green`},Expired:{colorPalette:`yellow`},Revoked:{colorPalette:`gray`}},bY=({status:e})=>{let t=yY[e];return(0,I.jsx)(It,{variant:`subtle`,colorPalette:t.colorPalette,size:`sm`,children:e})};function xY(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:HV(t,{addSuffix:!0})}var SY=({name:e,prefix:t,status:n,permissionLabel:r,permissionColor:i,projects:a,lastUsedAt:o,createdAt:s,expiresAt:c,actions:l})=>(0,I.jsx)(A,{width:`100%`,p:4,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,transition:`all 0.2s`,_hover:{borderColor:`gray.300`},children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:1,flex:1,minWidth:0,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,truncate:!0,children:e}),n!==`Active`&&(0,I.jsx)(bY,{status:n}),(0,I.jsx)(It,{variant:`outline`,colorPalette:i,size:`sm`,children:r})]}),(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`xs`,fontFamily:`mono`,color:`gray.400`,children:t}),a.length>0&&(0,I.jsx)(P,{gap:1,children:a.map(e=>(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:e.name},e.id))}),a.length===0&&(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:`All projects`})]}),(0,I.jsxs)(P,{gap:4,mt:1,flexWrap:`wrap`,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Created `,UV(s)]}),c&&(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Expires `,UV(c)]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:o?`Last used ${xY(o)}`:`Never used`})]})]}),l&&(0,I.jsx)(P,{gap:1,children:l})]})}),CY=[{value:`30d`,label:`30 days`},{value:`60d`,label:`60 days`},{value:`90d`,label:`90 days`},{value:`1y`,label:`1 year`},{value:`none`,label:`No expiration`}],wY=[{value:`read-only`,label:`Read only`,description:`Can only read data`},{value:`read-write`,label:`Read & Write`,description:`Can read, create, and update data`},{value:`full-access`,label:`Full access`,description:`Can read, create, update, and delete data`}],TY=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isCreateDialogOpen,onOpenChange:({open:t})=>!t&&e.closeCreateDialog(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:e.mode===`personal`?`Create Personal API Key`:`Create Service API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Name`}),(0,I.jsx)(qt,{placeholder:`e.g., CI/CD pipeline, Data sync...`,value:e.createKeyName,onChange:t=>e.setCreateKeyName(t.target.value),autoFocus:!0})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Expiration`}),(0,I.jsx)(P,{gap:2,flexWrap:`wrap`,children:CY.map(t=>(0,I.jsx)(N,{size:`sm`,variant:e.createKeyExpirationPreset===t.value?`solid`:`outline`,onClick:()=>e.setExpirationPreset(t.value),children:t.label},t.value))})]}),e.mode===`personal`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(P,{gap:2,children:(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setCreateKeyReadOnly(!e.createKeyReadOnly),display:`flex`,alignItems:`center`,gap:2,cursor:`pointer`,children:[(0,I.jsx)(A,{width:`18px`,height:`18px`,borderWidth:`1px`,borderColor:e.createKeyReadOnly?`blue.500`:`gray.300`,borderRadius:`sm`,bg:e.createKeyReadOnly?`blue.500`:`transparent`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`all 0.2s`,children:e.createKeyReadOnly&&(0,I.jsx)(k,{color:`white`,fontSize:`xs`,fontWeight:`bold`,lineHeight:1,children:`✓`})}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.700`,children:`Read only`})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,pl:`26px`,children:`Key can only read data, not modify it`})]}),e.mode===`service`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Permissions`}),(0,I.jsx)(M,{align:`stretch`,gap:2,children:wY.map(t=>(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setPermissionPreset(t.value),width:`100%`,p:3,borderWidth:`1px`,borderColor:e.createKeyPermissionPreset===t.value?`blue.400`:`gray.200`,borderRadius:`md`,bg:e.createKeyPermissionPreset===t.value?`blue.50`:`white`,cursor:`pointer`,textAlign:`left`,transition:`all 0.2s`,_hover:{borderColor:`blue.300`},children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:t.label}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.description})]},t.value))})]}),e.defaultProjectId&&(0,I.jsx)(j,{align:`center`,gap:2,p:3,bg:`blue.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`blue.200`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.700`,children:[`This key will be scoped to project `,(0,I.jsx)(`strong`,{children:e.defaultProjectId})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{onClick:e.createKey,disabled:!e.canCreateKey,loading:e.isMutating,children:`Create key`})]}),(0,I.jsx)(Ie,{})]})})]})})),EY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Revoke API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to revoke the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This action cannot be undone. Any applications using this key will immediately lose access.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:r,loading:n,children:`Revoke key`})]}),(0,I.jsx)(Ie,{})]})})]})})),DY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Rotate API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to rotate the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will generate a new secret and invalidate the current one. Any applications using the current key will need to be updated.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:r,loading:n,children:`Rotate key`})]}),(0,I.jsx)(Ie,{})]})})]})})),OY=g(({isOpen:e,secret:t,keyName:n,onClose:r})=>{let i=(0,L.useCallback)(async()=>{t&&(await navigator.clipboard.writeText(t),Jq.info({description:`Copied to clipboard`}))},[t]);return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&r(),size:`md`,closeOnInteractOutside:!1,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Your API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[n&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Key `,(0,I.jsx)(`strong`,{children:n}),` has been created successfully.`]}),(0,I.jsx)(A,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(qt,{value:t??``,readOnly:!0,fontFamily:`mono`,fontSize:`sm`,bg:`gray.50`}),(0,I.jsxs)(N,{variant:`outline`,onClick:i,flexShrink:0,children:[(0,I.jsx)(qf,{}),`Copy`]})]})}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`yellow.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`yellow.200`,children:[(0,I.jsx)(one,{color:`var(--chakra-colors-yellow-600)`}),(0,I.jsx)(k,{fontSize:`sm`,color:`yellow.800`,children:`Make sure to copy your API key now. You won't be able to see it again.`})]})]})}),(0,I.jsx)(w,{children:(0,I.jsx)(N,{onClick:r,children:`I've copied the key`})})]})})]})})}),kY=g(({model:e,showCreateButton:t=!0})=>((0,L.useEffect)(()=>(e.loadKeys(),()=>e.reset()),[e]),e.isLoaded?e.error?(0,I.jsx)(A,{p:4,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,children:(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.error})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[t&&!e.isEmpty&&(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`${e.sortedItems.length} key${e.sortedItems.length===1?``:`s`}`}),(0,I.jsxs)(N,{size:`sm`,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create key`]})]}),e.isEmpty&&e.isLoaded&&(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:e.emptyStateMessage}),t&&(0,I.jsxs)(N,{size:`sm`,mt:3,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create your first key`]})]}),e.sortedItems.map(t=>(0,I.jsx)(SY,{name:t.name,prefix:t.prefix,status:t.statusLabel,permissionLabel:t.permissionLabel,permissionColor:t.permissionColorPalette,projects:t.resolvedProjects,lastUsedAt:t.lastUsedAt,createdAt:t.createdAt,expiresAt:t.expiresAt,actions:t.isActive?(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`orange.600`,bg:`orange.50`},onClick:()=>e.openRotateDialog(t.id),children:(0,I.jsx)(Ate,{})}),(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`red.600`,bg:`red.50`},onClick:()=>e.openRevokeDialog(t.id),children:(0,I.jsx)(Rf,{})})]}):void 0},t.id)),(0,I.jsx)(TY,{model:e}),(0,I.jsx)(OY,{isOpen:e.isSecretDialogOpen,secret:e.lastSecret,keyName:e.lastCreatedKeyName,onClose:e.closeSecretDialog}),(0,I.jsx)(EY,{isOpen:e.isRevokeDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.revokeKey,onClose:e.closeRevokeDialog}),(0,I.jsx)(DY,{isOpen:e.isRotateDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.rotateKey,onClose:e.closeRotateDialog})]}):(0,I.jsx)(j,{justify:`center`,py:8,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}))),AY=class{myKeysRequest=X.of(Q.myApiKeys,{skipResetting:!0});serviceKeysRequest=X.of(Q.serviceApiKeys,{skipResetting:!0});createPersonalRequest=X.of(Q.createPersonalApiKey);createServiceRequest=X.of(Q.createServiceApiKey);revokeRequest=X.of(Q.revokeApiKey);rotateRequest=X.of(Q.rotateApiKey);constructor(){f(this)}get isLoading(){return this.myKeysRequest.isLoading||this.serviceKeysRequest.isLoading}get error(){return this.myKeysRequest.errorMessage??this.serviceKeysRequest.errorMessage??null}get isMutating(){return this.createPersonalRequest.isLoading||this.createServiceRequest.isLoading||this.revokeRequest.isLoading||this.rotateRequest.isLoading}fetchPersonalKeys(){return this.myKeysRequest.fetch()}fetchServiceKeys(e){return this.serviceKeysRequest.fetch({organizationId:e})}async createPersonalKey(e){let t=await this.createPersonalRequest.fetch({data:e});return t.isRight?t.data.createPersonalApiKey:null}async createServiceKey(e){let t=await this.createServiceRequest.fetch({data:e});return t.isRight?t.data.createServiceApiKey:null}async revokeKey(e){let t=await this.revokeRequest.fetch({id:e});return t.isRight?t.data.revokeApiKey:null}async rotateKey(e){let t=await this.rotateRequest.fetch({id:e});return t.isRight?t.data.rotateApiKey:null}dispose(){this.myKeysRequest.abort(),this.serviceKeysRequest.abort(),this.createPersonalRequest.abort(),this.createServiceRequest.abort(),this.revokeRequest.abort(),this.rotateRequest.abort()}};Y.register(AY,()=>new AY,{scope:`request`});var jY={"read-only":[{action:[`read`],subject:[`all`]}],"read-write":[{action:[`read`,`create`,`update`],subject:[`all`]}],"full-access":[{action:[`read`,`create`,`update`,`delete`],subject:[`all`]}]},MY=class{_config={mode:`personal`};_items=[];_isLoaded=!1;_isCreateDialogOpen=!1;_isSecretDialogOpen=!1;_isRevokeDialogOpen=!1;_isRotateDialogOpen=!1;_selectedKeyId=null;_lastSecret=null;_lastCreatedKeyName=null;createKeyName=``;createKeyReadOnly=!1;createKeyExpiresAt=null;createKeyExpirationPreset=`none`;createKeyPermissionPreset=`read-only`;constructor(e){this.dataSource=e,f(this,{},{autoBind:!0})}get mode(){return this._config.mode}get organizationId(){return this._config.organizationId}get defaultProjectId(){return this._config.defaultProjectId}get filterByProjectId(){return this._config.filterByProjectId}get items(){return this._items}get filteredItems(){if(!this._config.filterByProjectId)return this._items;let e=this._config.filterByProjectId;return this._items.filter(t=>t.projectIds.includes(e))}get sortedItems(){return[...this.filteredItems].sort((e,t)=>{let n={Active:0,Expired:1,Revoked:2},r=n[e.statusLabel]-n[t.statusLabel];return r===0?new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime():r})}get isLoading(){return this.dataSource.isLoading}get isLoaded(){return this._isLoaded}get isMutating(){return this.dataSource.isMutating}get error(){return this.dataSource.error}get isEmpty(){return this.filteredItems.length===0}get isCreateDialogOpen(){return this._isCreateDialogOpen}get isSecretDialogOpen(){return this._isSecretDialogOpen}get isRevokeDialogOpen(){return this._isRevokeDialogOpen}get isRotateDialogOpen(){return this._isRotateDialogOpen}get selectedKeyId(){return this._selectedKeyId}get lastSecret(){return this._lastSecret}get lastCreatedKeyName(){return this._lastCreatedKeyName}get selectedKey(){return this._items.find(e=>e.id===this._selectedKeyId)}get canCreateKey(){return this.createKeyName.trim().length>0&&!this.isMutating}get emptyStateMessage(){return this._config.mode===`personal`?`No API keys yet. Create one for programmatic access to your data.`:`No integration keys for this organization.`}configure(e){this._config=e}init(){}dispose(){this.dataSource.dispose()}reset(){this._items=[],this._isLoaded=!1}async loadKeys(){if(this._config.mode===`personal`){let e=await this.dataSource.fetchPersonalKeys();if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.myApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}else if(this._config.organizationId){let e=await this.dataSource.fetchServiceKeys(this._config.organizationId);if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.serviceApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}}openCreateDialog(){this._isCreateDialogOpen=!0,this.createKeyName=``,this.createKeyReadOnly=!1,this.createKeyExpiresAt=null,this.createKeyExpirationPreset=`none`,this.createKeyPermissionPreset=`read-only`}closeCreateDialog(){this._isCreateDialogOpen=!1}setCreateKeyName(e){this.createKeyName=e}setCreateKeyReadOnly(e){this.createKeyReadOnly=e}setExpirationPreset(e){this.createKeyExpirationPreset=e;let t=new Date;switch(e){case`30d`:t.setDate(t.getDate()+30),this.createKeyExpiresAt=t.toISOString();break;case`60d`:t.setDate(t.getDate()+60),this.createKeyExpiresAt=t.toISOString();break;case`90d`:t.setDate(t.getDate()+90),this.createKeyExpiresAt=t.toISOString();break;case`1y`:t.setFullYear(t.getFullYear()+1),this.createKeyExpiresAt=t.toISOString();break;case`none`:this.createKeyExpiresAt=null;break}}setPermissionPreset(e){this.createKeyPermissionPreset=e}async createKey(){if(this.canCreateKey){if(this._config.mode===`personal`){let e={name:this.createKeyName.trim(),readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0},t=await this.dataSource.createPersonalKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}else if(this._config.organizationId){let e={name:this.createKeyName.trim(),organizationId:this._config.organizationId,readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0,permissions:{rules:jY[this.createKeyPermissionPreset]}},t=await this.dataSource.createServiceKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}}}closeSecretDialog(){this._isSecretDialogOpen=!1,this._lastSecret=null,this._lastCreatedKeyName=null}openRevokeDialog(e){this._selectedKeyId=e,this._isRevokeDialogOpen=!0}closeRevokeDialog(){this._isRevokeDialogOpen=!1,this._selectedKeyId=null}async revokeKey(){this._selectedKeyId&&await this.dataSource.revokeKey(this._selectedKeyId)&&(c(()=>{this._isRevokeDialogOpen=!1,this._selectedKeyId=null}),await this.loadKeys())}openRotateDialog(e){this._selectedKeyId=e,this._isRotateDialogOpen=!0}closeRotateDialog(){this._isRotateDialogOpen=!1,this._selectedKeyId=null}async rotateKey(){if(!this._selectedKeyId)return;let e=await this.dataSource.rotateKey(this._selectedKeyId);e&&(c(()=>{this._lastSecret=e.secret,this._lastCreatedKeyName=e.apiKey.name,this._isRotateDialogOpen=!1,this._selectedKeyId=null,this._isSecretDialogOpen=!0}),await this.loadKeys())}};Y.register(MY,()=>new MY(Y.get(AY)),{scope:`request`});var NY=g(({model:e})=>{let t=(0,L.useCallback)(async()=>{await e.savePassword()&&Jq.success({description:`Password updated successfully`})},[e]);return(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Account Settings`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsxs)(fn,{value:`account`,children:[(0,I.jsx)(zf,{}),`Account`]}),(0,I.jsxs)(fn,{value:`password`,children:[(0,I.jsx)(Of,{}),`Password`]}),(0,I.jsxs)(fn,{value:`api-keys`,children:[(0,I.jsx)(Df,{}),`Personal Tokens`]})]}),(0,I.jsx)(bt,{value:`account`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.username&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username`}),(0,I.jsx)(qt,{value:e.username,readOnly:!0})]}),e.email&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email`}),(0,I.jsx)(qt,{value:e.email,readOnly:!0})]}),(0,I.jsx)(A,{paddingTop:`1rem`,borderTop:`1px solid`,borderTopColor:`newGray.100`,children:(0,I.jsxs)(N,{variant:`outline`,onClick:e.logout,width:`100%`,children:[(0,I.jsx)(tne,{}),`Sign out`]})})]})}),(0,I.jsx)(bt,{value:`password`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.hasPassword?(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Current Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter current password...`,value:e.oldPassword,onChange:t=>e.setOldPassword(t.target.value),autoComplete:`current-password`})]}):(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You signed in with a social account. Set a password to enable password login.`}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:e.hasPassword?`New Password`:`Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter new password (min 8 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Confirm Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Confirm new password...`,value:e.confirmPassword,onChange:t=>e.setConfirmPassword(t.target.value),autoComplete:`new-password`})]}),e.passwordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.passwordError}),e.error&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.error}),(0,I.jsx)(j,{justifyContent:`flex-end`,children:(0,I.jsx)(N,{onClick:t,disabled:!e.canSavePassword,loading:e.isLoading,children:e.hasPassword?`Update Password`:`Set Password`})})]})}),(0,I.jsx)(bt,{value:`api-keys`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:`Personal Access Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Personal keys act on your behalf and inherit your permissions. Use them for scripts, CLI tools, or any programmatic access to your data.`})]}),(0,I.jsx)(kY,{model:e.apiKeyManager})]})})]})}),(0,I.jsx)(Ie,{})]})})]})})}),PY=class{updatePasswordRequest=X.of(Q.updatePassword);constructor(){f(this)}get isLoading(){return this.updatePasswordRequest.isLoading}get error(){return this.updatePasswordRequest.errorMessage??null}async updatePassword(e){return(await this.updatePasswordRequest.fetch({data:{oldPassword:e.oldPassword,newPassword:e.newPassword}})).isRight}dispose(){this.updatePasswordRequest.abort()}};Y.register(PY,()=>new PY,{scope:`request`});var FY=class{_isOpen=!1;_activeTab=`account`;apiKeyManager;oldPassword=``;newPassword=``;confirmPassword=``;constructor(e,t,n){this.dataSource=e,this.authService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`personal`})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get username(){return this.authService.user?.username}get email(){return this.authService.user?.email}get hasPassword(){return this.authService.user?.hasPassword??!0}get canSavePassword(){return!(this.isLoading||this.newPassword.length<8||this.newPassword!==this.confirmPassword||this.hasPassword&&!this.oldPassword)}get passwordError(){return this.newPassword&&this.newPassword.length<8?`Password must be at least 8 characters`:this.confirmPassword&&this.newPassword!==this.confirmPassword?`Passwords do not match`:null}open(){this._isOpen=!0,this._activeTab=`account`,this.resetPasswordForm()}close(){this._isOpen=!1,this.resetPasswordForm()}setActiveTab(e){this._activeTab=e}setOldPassword(e){this.oldPassword=e}setNewPassword(e){this.newPassword=e}setConfirmPassword(e){this.confirmPassword=e}async savePassword(){if(!this.canSavePassword)return!1;let e=await this.dataSource.updatePassword({oldPassword:this.oldPassword,newPassword:this.newPassword});return e&&(this.resetPasswordForm(),await this.authService.fetchMe()),e}logout(){this.close(),globalThis.location.href=`/${bJ}`}resetPasswordForm(){this.oldPassword=``,this.newPassword=``,this.confirmPassword=``}init(){}dispose(){this.dataSource.dispose(),this.apiKeyManager.dispose()}};Y.register(FY,()=>new FY(Y.get(PY),Y.get(hJ),Y.get(MY)),{scope:`singleton`});var IY=g(()=>{let e=CB(FY);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:e.open,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(zf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Account Settings`})]}),(0,I.jsx)(NY,{model:e})]})}),LY=({onBack:e})=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:e,display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),RY=({to:e,label:t,isActive:n,icon:r})=>(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t})]})}),zY=g(()=>{let e=kn(),t=Tn(),n=e.pathname,r=n===`/${QJ}`,i=n.startsWith(`/${QJ}/${$J}`),a=n.startsWith(`/${QJ}/${tY}`),o=n.startsWith(`/${QJ}/${nY}`);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(LY,{onBack:(0,L.useCallback)(()=>{t(`/`)},[t])}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(RY,{to:`/${QJ}`,label:`Dashboard`,icon:(0,I.jsx)(Xte,{}),isActive:r}),(0,I.jsx)(RY,{to:`/${QJ}/${$J}`,label:`Users`,icon:(0,I.jsx)(Bf,{}),isActive:i}),(0,I.jsx)(RY,{to:`/${QJ}/${tY}`,label:`Organizations`,icon:(0,I.jsx)(Pte,{}),isActive:a}),(0,I.jsx)(RY,{to:`/${QJ}/${nY}`,label:`Cache`,icon:(0,I.jsx)(yf,{}),isActive:o})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),BY=()=>(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(zY,{}),children:(0,I.jsx)(En,{})}),VY=({breadcrumbs:e,headerRight:t,children:n})=>(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:[(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsxs)(Gt,{fontSize:`16px`,children:[(0,I.jsx)(Dt,{children:(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:`/${QJ}`,children:`Admin`})})}),e.map((e,t)=>(0,I.jsxs)(L.Fragment,{children:[(0,I.jsx)(ut,{children:`/`}),(0,I.jsx)(Dt,{children:e.to?(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:e.to,children:e.label})}):(0,I.jsx)(Xt,{color:`gray`,children:e.label})})]},t))]})})}),t]}),(0,I.jsx)(A,{flex:1,children:n})]}),HY=()=>(0,I.jsx)(VY,{breadcrumbs:[{label:`Organizations`}],children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`Coming soon`})})}),UY=class{request=X.of(Q.adminGetUser);resetPasswordRequest=X.of(Q.adminResetPassword);_userId=null;_user=null;_newPassword=``;_resetPasswordSuccess=!1;constructor(){f(this,{},{autoBind:!0})}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get user(){return this._user}get username(){return this._user?.username??null}get email(){return this._user?.email??null}get roleName(){return this._user?.role?.name??null}get newPassword(){return this._newPassword}get isResetPasswordLoading(){return this.resetPasswordRequest.isLoading}get resetPasswordError(){return this.resetPasswordRequest.errorMessage??null}get resetPasswordSuccess(){return this._resetPasswordSuccess}get canResetPassword(){return this._newPassword.length>=6}setUserId(e){this._userId=e,this.loadUser()}setNewPassword(e){this._newPassword=e,this._resetPasswordSuccess=!1}async resetPassword(){!this._userId||!this.canResetPassword||(await this.resetPasswordRequest.fetch({userId:this._userId,newPassword:this._newPassword})).isRight&&c(()=>{this._newPassword=``,this._resetPasswordSuccess=!0})}init(){this._userId&&this.loadUser()}dispose(){this.request.abort(),this.resetPasswordRequest.abort()}async loadUser(){if(!this._userId)return;let e=await this.request.fetch({userId:this._userId});e.isRight&&c(()=>{this._user=e.data.adminUser??null})}};Y.register(UY,()=>new UY,{scope:`request`});var WY=({label:e,value:t})=>(0,I.jsxs)(j,{gap:`16px`,alignItems:`baseline`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,minWidth:`80px`,children:e}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.600`,children:t||`-`})]}),GY=g(({model:e})=>(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,marginTop:`16px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`Reset Password`}),(0,I.jsxs)(j,{gap:`12px`,alignItems:`flex-start`,children:[(0,I.jsx)(qt,{placeholder:`New password (min 6 characters)`,type:`password`,size:`sm`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),maxWidth:`300px`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`gray`,onClick:e.resetPassword,disabled:!e.canResetPassword,loading:e.isResetPasswordLoading,children:`Reset`})]}),e.resetPasswordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetPasswordError}),e.resetPasswordSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Password has been reset successfully`})]})),KY=g(()=>{let{userId:e}=bn(),t=CB(UY);return(0,L.useEffect)(()=>{e&&t.setUserId(e)},[e,t]),(0,I.jsx)(VY,{breadcrumbs:(0,L.useMemo)(()=>[{label:`Users`,to:`/${QJ}/${$J}`},{label:t.username||e||``}],[t.username,e]),children:(0,I.jsxs)(A,{flex:1,padding:`8px`,children:[t.isLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,paddingY:`48px`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),t.error&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load user`}),(0,I.jsx)(k,{fontSize:`sm`,children:t.error})]}),!t.isLoading&&!t.error&&!t.user&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`User not found`})}),t.user&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`User Info`}),(0,I.jsxs)(M,{alignItems:`flex-start`,gap:`8px`,children:[(0,I.jsx)(WY,{label:`ID`,value:t.user.id}),(0,I.jsx)(WY,{label:`Username`,value:t.username}),(0,I.jsx)(WY,{label:`Email`,value:t.email}),(0,I.jsx)(WY,{label:`Role`,value:t.roleName})]})]}),(0,I.jsx)(GY,{model:t})]})]})})}),qY=class{request=X.of(Q.createUser);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}async create(e){let t=await this.request.fetch({username:e.username,password:e.password,email:e.email,roleId:e.roleId});return t.isRight&&t.data.createUser}dispose(){this.request.abort()}};Y.register(qY,()=>new qY,{scope:`request`});var JY=class{_isOpen=!1;_username=``;_password=``;_email=``;_selectedRole=XW.SystemUser;constructor(e,t,n){this.dataSource=e,this.systemPermissions=t,this.onUserCreated=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get canCreateUser(){return this.systemPermissions.canCreateUser}get username(){return this._username}get password(){return this._password}get email(){return this._email}get selectedRole(){return this._selectedRole}get isCreating(){return this.dataSource.isLoading}get canSubmit(){return this._username.trim().length>0&&this._password.length>=6&&!this.isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setUsername(e){this._username=e}setPassword(e){this._password=e}setEmail(e){this._email=e}setSelectedRole(e){this._selectedRole=e}async createUser(){if(!this.canSubmit)return;let e=await this.dataSource.create({username:this._username.trim(),password:this._password,email:this._email.trim()||void 0,roleId:this._selectedRole});c(()=>{e&&(this.onUserCreated(),this.close())})}dispose(){this.dataSource.dispose()}reset(){this._username=``,this._password=``,this._email=``,this._selectedRole=XW.SystemUser}},YY=class extends rH{currentFilters={};constructor(){super(Q.adminUsers,{pageSize:50})}extractItems(e){return e.adminUsers.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.adminUsers.pageInfo.hasNextPage,endCursor:e.adminUsers.pageInfo.endCursor||null,totalCount:e.adminUsers.totalCount}}buildFetchArgs(e,t){return e&&(this.currentFilters=e),{first:this.config.pageSize,after:t,search:this.currentFilters.search||void 0}}};Y.register(YY,()=>new YY,{scope:`request`});var XY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get username(){return this.data.username??null}get email(){return this.data.email??null}get roleName(){return this.data.role?.name??null}get link(){return Dn(`/${QJ}/${$J}/:userId`,{userId:this.data.id})}},ZY=class extends nH{createUserModal;_searchQuery=``;_debounceTimer=null;constructor(e,t,n){super(e),this.createUserModal=new JY(t,n,()=>this.reload()),h(this,{_searchQuery:u,searchQuery:a,canCreateUser:a,setSearchQuery:m,reload:m,init:_,dispose:_})}getItemKey(e){return e.id}createItemViewModel(e){return new XY(e)}get canCreateUser(){return this.createUserModal.canCreateUser}get searchQuery(){return this._searchQuery}init(){this.dataSource.load()}dispose(){this._debounceTimer&&clearTimeout(this._debounceTimer),super.dispose(),this.createUserModal.dispose()}reload(){this.dataSource.load({search:this._searchQuery||void 0})}setSearchQuery(e){this._searchQuery=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this.dataSource.load({search:e||void 0})},300)}};Y.register(ZY,()=>new ZY(Y.get(YY),Y.get(qY),Y.get(yW)),{scope:`request`});var QY={[XW.SystemAdmin]:`System Admin`,[XW.SystemFullApiRead]:`Full API Read`,[XW.SystemUser]:`User`},$Y=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`160px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(XW).map(e=>(0,I.jsx)(`option`,{value:e,children:QY[e]},e))})})),eX=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Create User`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.username,onChange:t=>e.setUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.password,onChange:t=>e.setPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.email,onChange:t=>e.setEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`System Role`}),(0,I.jsx)($Y,{value:e.selectedRole,onChange:t=>e.setSelectedRole(t)})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),(0,I.jsx)(N,{onClick:e.createUser,disabled:!e.canSubmit,loading:e.isCreating,children:`Create`})]}),(0,I.jsx)(Ie,{})]})})]})})),tX=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(An,{to:e.link,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,height:`100%`,children:[(0,I.jsx)(j,{width:`200px`,children:(0,I.jsx)(k,{maxWidth:`190px`,textDecoration:`underline`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:e.username||e.email||`No username`})}),(0,I.jsx)(j,{alignItems:`center`,flex:1,minHeight:`40px`,children:(0,I.jsx)(k,{color:`gray.400`,fontWeight:`300`,ml:`16px`,children:e.roleName||`-`})})]})})})),nX=g(()=>{let e=CB(ZY);return(0,I.jsxs)(VY,{breadcrumbs:[{label:`Users`}],headerRight:(0,I.jsx)(j,{alignItems:`center`,gap:`8px`,children:(0,I.jsx)(qt,{placeholder:`Search...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),variant:`flushed`,size:`sm`,width:`200px`,_placeholder:{color:`gray.400`}})}),children:[(0,I.jsxs)(A,{flex:1,paddingX:`16px`,paddingTop:`16px`,children:[e.canCreateUser&&(0,I.jsx)(j,{paddingBottom:`16px`,children:(0,I.jsxs)(N,{variant:`ghost`,size:`sm`,color:`gray`,onClick:()=>e.createUserModal.open(),children:[(0,I.jsx)(Pf,{}),`Add`]})}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load users`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(Bf,{size:48}),(0,I.jsx)(k,{fontSize:`md`,children:`No users found`})]}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.items.length,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(tX,{model:n},n.id):null}})]}),(0,I.jsx)(eX,{model:e.createUserModal})]})}),rX=i((e=>{e.removeLeadingAndTrailingHTTPWhitespace=e=>e.replace(/^[ \t\n\r]+/u,``).replace(/[ \t\n\r]+$/u,``),e.removeTrailingHTTPWhitespace=e=>e.replace(/[ \t\n\r]+$/u,``),e.isHTTPWhitespaceChar=e=>e===` `||e===` `||e===`
2166
+ `,jq=(e,t,n,r)=>e();function Mq(e,t=jq){return{getBranchForLoader(n,r){return t(t=>e.request(RG,n,{...r,...t}),`getBranchForLoader`,`query`,n)},organizationProjects(n,r){return t(t=>e.request(zG,n,{...r,...t}),`organizationProjects`,`query`,n)},getProject(n,r){return t(t=>e.request(BG,n,{...r,...t}),`getProject`,`query`,n)},getProjectForLoader(n,r){return t(t=>e.request(VG,n,{...r,...t}),`getProjectForLoader`,`query`,n)},getRevisionForLoader(n,r){return t(t=>e.request(HG,n,{...r,...t}),`getRevisionForLoader`,`query`,n)},getRowForLoader(n,r){return t(t=>e.request(UG,n,{...r,...t}),`getRowForLoader`,`query`,n)},getRowCountForeignKeysToForLoader(n,r){return t(t=>e.request(WG,n,{...r,...t}),`getRowCountForeignKeysToForLoader`,`query`,n)},ForeignKeysBy(n,r){return t(t=>e.request(GG,n,{...r,...t}),`ForeignKeysBy`,`query`,n)},ForeignKeysByRows(n,r){return t(t=>e.request(KG,n,{...r,...t}),`ForeignKeysByRows`,`query`,n)},getTableForLoader(n,r){return t(t=>e.request(qG,n,{...r,...t}),`getTableForLoader`,`query`,n)},updatePassword(n,r){return t(t=>e.request(JG,n,{...r,...t}),`updatePassword`,`mutation`,n)},myApiKeys(n,r){return t(t=>e.request(YG,n,{...r,...t}),`myApiKeys`,`query`,n)},serviceApiKeys(n,r){return t(t=>e.request(XG,n,{...r,...t}),`serviceApiKeys`,`query`,n)},apiKeyById(n,r){return t(t=>e.request(ZG,n,{...r,...t}),`apiKeyById`,`query`,n)},createPersonalApiKey(n,r){return t(t=>e.request(QG,n,{...r,...t}),`createPersonalApiKey`,`mutation`,n)},createServiceApiKey(n,r){return t(t=>e.request($G,n,{...r,...t}),`createServiceApiKey`,`mutation`,n)},revokeApiKey(n,r){return t(t=>e.request(eK,n,{...r,...t}),`revokeApiKey`,`mutation`,n)},rotateApiKey(n,r){return t(t=>e.request(tK,n,{...r,...t}),`rotateApiKey`,`mutation`,n)},createProject(n,r){return t(t=>e.request(nK,n,{...r,...t}),`createProject`,`mutation`,n)},findForeignKey(n,r){return t(t=>e.request(rK,n,{...r,...t}),`findForeignKey`,`query`,n)},adminCacheStats(n,r){return t(t=>e.request(iK,n,{...r,...t}),`adminCacheStats`,`query`,n)},adminResetAllCache(n,r){return t(t=>e.request(aK,n,{...r,...t}),`adminResetAllCache`,`mutation`,n)},AdminDashboardStats(n,r){return t(t=>e.request(oK,n,{...r,...t}),`AdminDashboardStats`,`query`,n)},adminGetUser(n,r){return t(t=>e.request(sK,n,{...r,...t}),`adminGetUser`,`query`,n)},adminResetPassword(n,r){return t(t=>e.request(cK,n,{...r,...t}),`adminResetPassword`,`mutation`,n)},adminUsers(n,r){return t(t=>e.request(lK,n,{...r,...t}),`adminUsers`,`query`,n)},adminUser(n,r){return t(t=>e.request(uK,n,{...r,...t}),`adminUser`,`query`,n)},assetsTablesData(n,r){return t(t=>e.request(dK,n,{...r,...t}),`assetsTablesData`,`query`,n)},assetsRowsData(n,r){return t(t=>e.request(fK,n,{...r,...t}),`assetsRowsData`,`query`,n)},subSchemaItemsData(n,r){return t(t=>e.request(pK,n,{...r,...t}),`subSchemaItemsData`,`query`,n)},getProjectBranches(n,r){return t(t=>e.request(mK,n,{...r,...t}),`getProjectBranches`,`query`,n)},deleteBranch(n,r){return t(t=>e.request(hK,n,{...r,...t}),`deleteBranch`,`mutation`,n)},getBranchesForSelect(n,r){return t(t=>e.request(gK,n,{...r,...t}),`getBranchesForSelect`,`query`,n)},getBranchRevisionsForCreate(n,r){return t(t=>e.request(_K,n,{...r,...t}),`getBranchRevisionsForCreate`,`query`,n)},createBranch(n,r){return t(t=>e.request(vK,n,{...r,...t}),`createBranch`,`mutation`,n)},GetRevisionChanges(n,r){return t(t=>e.request(yK,n,{...r,...t}),`GetRevisionChanges`,`query`,n)},GetTableChanges(n,r){return t(t=>e.request(bK,n,{...r,...t}),`GetTableChanges`,`query`,n)},confirmEmailCode(n,r){return t(t=>e.request(xK,n,{...r,...t}),`confirmEmailCode`,`mutation`,n)},getEndpointBranches(n,r){return t(t=>e.request(SK,n,{...r,...t}),`getEndpointBranches`,`query`,n)},getProjectEndpoints(n,r){return t(t=>e.request(CK,n,{...r,...t}),`getProjectEndpoints`,`query`,n)},getBranchRevisions(n,r){return t(t=>e.request(wK,n,{...r,...t}),`getBranchRevisions`,`query`,n)},createEndpoint(n,r){return t(t=>e.request(TK,n,{...r,...t}),`createEndpoint`,`mutation`,n)},deleteEndpoint(n,r){return t(t=>e.request(EK,n,{...r,...t}),`deleteEndpoint`,`mutation`,n)},issueAccessToken(n,r){return t(t=>e.request(DK,n,{...r,...t}),`issueAccessToken`,`query`,n)},loginGithub(n,r){return t(t=>e.request(OK,n,{...r,...t}),`loginGithub`,`mutation`,n)},loginGoogle(n,r){return t(t=>e.request(kK,n,{...r,...t}),`loginGoogle`,`mutation`,n)},login(n,r){return t(t=>e.request(AK,n,{...r,...t}),`login`,`mutation`,n)},getMigrationBranches(n,r){return t(t=>e.request(jK,n,{...r,...t}),`getMigrationBranches`,`query`,n)},getBranchMigrations(n,r){return t(t=>e.request(MK,n,{...r,...t}),`getBranchMigrations`,`query`,n)},applyMigrations(n,r){return t(t=>e.request(NK,n,{...r,...t}),`applyMigrations`,`mutation`,n)},getMigrations(n,r){return t(t=>e.request(PK,n,{...r,...t}),`getMigrations`,`query`,n)},activateEarlyAccess(n,r){return t(t=>e.request(FK,n,{...r,...t}),`activateEarlyAccess`,`mutation`,n)},createCheckout(n,r){return t(t=>e.request(IK,n,{...r,...t}),`createCheckout`,`mutation`,n)},cancelSubscription(n,r){return t(t=>e.request(LK,n,{...r,...t}),`cancelSubscription`,`mutation`,n)},getLimitsPageData(n,r){return t(t=>e.request(RK,n,{...r,...t}),`getLimitsPageData`,`query`,n)},getLimitsPagePlans(n,r){return t(t=>e.request(zK,n,{...r,...t}),`getLimitsPagePlans`,`query`,n)},getUsersOrganization(n,r){return t(t=>e.request(BK,n,{...r,...t}),`getUsersOrganization`,`query`,n)},addUserToOrganization(n,r){return t(t=>e.request(VK,n,{...r,...t}),`addUserToOrganization`,`mutation`,n)},removeUserFromOrganization(n,r){return t(t=>e.request(HK,n,{...r,...t}),`removeUserFromOrganization`,`mutation`,n)},adminValidateProjectFileBytes(n,r){return t(t=>e.request(UK,n,{...r,...t}),`adminValidateProjectFileBytes`,`query`,n)},adminRestoreProjectFileBytes(n,r){return t(t=>e.request(WK,n,{...r,...t}),`adminRestoreProjectFileBytes`,`mutation`,n)},updateProject(n,r){return t(t=>e.request(GK,n,{...r,...t}),`updateProject`,`mutation`,n)},deleteProjectForSettings(n,r){return t(t=>e.request(KK,n,{...r,...t}),`deleteProjectForSettings`,`mutation`,n)},fetchTableForStack(n,r){return t(t=>e.request(qK,n,{...r,...t}),`fetchTableForStack`,`query`,n)},createTableForStack(n,r){return t(t=>e.request(JK,n,{...r,...t}),`createTableForStack`,`mutation`,n)},updateTableForStack(n,r){return t(t=>e.request(YK,n,{...r,...t}),`updateTableForStack`,`mutation`,n)},renameTableForStack(n,r){return t(t=>e.request(XK,n,{...r,...t}),`renameTableForStack`,`mutation`,n)},rowPageData(n,r){return t(t=>e.request(ZK,n,{...r,...t}),`rowPageData`,`query`,n)},signUp(n,r){return t(t=>e.request(QK,n,{...r,...t}),`signUp`,`mutation`,n)},setUsername(n,r){return t(t=>e.request($K,n,{...r,...t}),`setUsername`,`mutation`,n)},getUsersProject(n,r){return t(t=>e.request(eq,n,{...r,...t}),`getUsersProject`,`query`,n)},searchUsers(n,r){return t(t=>e.request(tq,n,{...r,...t}),`searchUsers`,`query`,n)},addUserToProject(n,r){return t(t=>e.request(nq,n,{...r,...t}),`addUserToProject`,`mutation`,n)},removeUserFromProject(n,r){return t(t=>e.request(rq,n,{...r,...t}),`removeUserFromProject`,`mutation`,n)},updateUserProjectRole(n,r){return t(t=>e.request(iq,n,{...r,...t}),`updateUserProjectRole`,`mutation`,n)},createUser(n,r){return t(t=>e.request(aq,n,{...r,...t}),`createUser`,`mutation`,n)},configuration(n,r){return t(t=>e.request(oq,n,{...r,...t}),`configuration`,`query`,n)},getMe(n,r){return t(t=>e.request(sq,n,{...r,...t}),`getMe`,`query`,n)},getProjectGraph(n,r){return t(t=>e.request(cq,n,{...r,...t}),`getProjectGraph`,`query`,n)},findBranches(n,r){return t(t=>e.request(lq,n,{...r,...t}),`findBranches`,`query`,n)},findRevisions(n,r){return t(t=>e.request(uq,n,{...r,...t}),`findRevisions`,`query`,n)},meProjectsList(n,r){return t(t=>e.request(dq,n,{...r,...t}),`meProjectsList`,`query`,n)},GetRowChanges(n,r){return t(t=>e.request(fq,n,{...r,...t}),`GetRowChanges`,`query`,n)},GetTableChangesForFilter(n,r){return t(t=>e.request(pq,n,{...r,...t}),`GetTableChangesForFilter`,`query`,n)},foreignKeyTableWithRows(n,r){return t(t=>e.request(mq,n,{...r,...t}),`foreignKeyTableWithRows`,`query`,n)},createRowForStack(n,r){return t(t=>e.request(hq,n,{...r,...t}),`createRowForStack`,`mutation`,n)},updateRowForStack(n,r){return t(t=>e.request(gq,n,{...r,...t}),`updateRowForStack`,`mutation`,n)},renameRowForStack(n,r){return t(t=>e.request(_q,n,{...r,...t}),`renameRowForStack`,`mutation`,n)},RowListRows(n,r){return t(t=>e.request(vq,n,{...r,...t}),`RowListRows`,`query`,n)},DeleteRow(n,r){return t(t=>e.request(yq,n,{...r,...t}),`DeleteRow`,`mutation`,n)},DeleteRows(n,r){return t(t=>e.request(bq,n,{...r,...t}),`DeleteRows`,`mutation`,n)},PatchRowInline(n,r){return t(t=>e.request(xq,n,{...r,...t}),`PatchRowInline`,`mutation`,n)},GetTableViews(n,r){return t(t=>e.request(Sq,n,{...r,...t}),`GetTableViews`,`query`,n)},UpdateTableViews(n,r){return t(t=>e.request(Cq,n,{...r,...t}),`UpdateTableViews`,`mutation`,n)},searchRows(n,r){return t(t=>e.request(wq,n,{...r,...t}),`searchRows`,`query`,n)},revertChangesForSidebar(n,r){return t(t=>e.request(Tq,n,{...r,...t}),`revertChangesForSidebar`,`mutation`,n)},createRevisionForSidebar(n,r){return t(t=>e.request(Eq,n,{...r,...t}),`createRevisionForSidebar`,`mutation`,n)},createBranchForSidebar(n,r){return t(t=>e.request(Dq,n,{...r,...t}),`createBranchForSidebar`,`mutation`,n)},deleteTableForList(n,r){return t(t=>e.request(Oq,n,{...r,...t}),`deleteTableForList`,`mutation`,n)},tableListData(n,r){return t(t=>e.request(kq,n,{...r,...t}),`tableListData`,`query`,n)},tableRelationsData(n,r){return t(t=>e.request(Aq,n,{...r,...t}),`tableRelationsData`,`query`,n)}}}var Nq=class{constructor(){}get(e){let t=globalThis.__env__?.[e],n={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`4c22f33`,MODE:`production`,PACKAGE_VERSION:`2.6.0`,PROD:!0,REACT_APP_ENDPOINT_HOST:``,REACT_APP_ENDPOINT_PORT:``,REACT_APP_ENDPOINT_SERVER_URL:`/endpoint`,REACT_APP_GRAPHQL_SERVER_URL:`/graphql`,REACT_APP_SWAGGER_SERVER_URL:`/api`,SSR:!1}[e];return t||n}};Y.register(Nq,()=>new Nq,{scope:`singleton`});var Pq=`revisium:sidebar-collapsed`,Fq=200,Iq=class{_isCollapsed=!1;_isHoverExpanded=!1;_hoverDelay=new cH(Fq);_leaveDelay=new cH(Fq);_keyboardHandler=null;constructor(e){this.storage=e,this._isCollapsed=e.getItem(Pq)===`true`,f(this,{},{autoBind:!0}),s(()=>this._isCollapsed,e=>{this.storage.setItem(Pq,String(e))})}get isCollapsed(){return this._isCollapsed}get isHoverExpanded(){return this._isHoverExpanded}get isSidebarVisible(){return!this._isCollapsed||this._isHoverExpanded}toggle(){this._isCollapsed=!this._isCollapsed,this._isHoverExpanded=!1}setHoverExpanded(e){this._isHoverExpanded=e}startHoverIntent(){this._leaveDelay.cancel(),this._hoverDelay.schedule(()=>{this.setHoverExpanded(!0)})}cancelHoverIntent(){this._hoverDelay.cancel()}startLeaveIntent(){this._leaveDelay.schedule(()=>{this.setHoverExpanded(!1)})}cancelLeaveIntent(){this._leaveDelay.cancel()}dismissOverlay(){this.setHoverExpanded(!1)}initKeyboard(){this._keyboardHandler||(this._keyboardHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key===`\\`&&(e.preventDefault(),this.toggle())},window.addEventListener(`keydown`,this._keyboardHandler))}disposeKeyboard(){this._keyboardHandler&&=(window.removeEventListener(`keydown`,this._keyboardHandler),null),this._hoverDelay.dispose(),this._leaveDelay.dispose()}};Y.register(Iq,()=>new Iq(localStorage),{scope:`singleton`});var Lq=({sidebar:e,footer:t})=>(0,I.jsxs)(I.Fragment,{children:[e,t&&(0,I.jsx)(A,{alignSelf:`center`,mt:`1rem`,children:t})]}),Rq=288,zq=48,Bq=`0.2s`,Vq=g(({hideSidebar:e,sidebar:t,title:n,actions:r,children:i,footer:a})=>{let o=Y.get(Iq);(0,L.useEffect)(()=>(o.initKeyboard(),()=>{o.disposeKeyboard()}),[o]);let s=!e,c=s&&o.isCollapsed,l=c&&o.isHoverExpanded,u=s?c?`${zq}px`:`${Rq}px`:`0px`;return(0,I.jsxs)(j,{minHeight:`100vh`,children:[s&&(0,I.jsx)(j,{width:u,minWidth:u,flexShrink:0,height:`100vh`,top:0,position:`sticky`,transition:`width ${Bq} ease, min-width ${Bq} ease`,overflow:`hidden`,children:c?(0,I.jsx)(j,{width:`${zq}px`,minWidth:`${zq}px`,height:`100vh`,flexDirection:`column`,alignItems:`center`,paddingTop:`20px`,onMouseEnter:o.startHoverIntent,onMouseLeave:o.cancelHoverIntent,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,onClick:o.toggle,"aria-label":`Toggle sidebar`,children:(0,I.jsx)(Zte,{})})}):(0,I.jsx)(j,{width:`${Rq}px`,minWidth:`${Rq}px`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,height:`100vh`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{position:`fixed`,left:0,top:0,width:`100vw`,height:`100vh`,zIndex:9,pointerEvents:l?`auto`:`none`,onClick:o.dismissOverlay}),(0,I.jsx)(j,{position:`fixed`,left:0,top:0,width:`${Rq}px`,height:`100vh`,zIndex:10,backgroundColor:`white`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,boxShadow:l?`4px 0 12px rgba(0, 0, 0, 0.08)`:`none`,transform:l?`translateX(0)`:`translateX(-${Rq}px)`,transition:`transform ${Bq} ease, box-shadow ${Bq} ease`,onMouseLeave:o.startLeaveIntent,onMouseEnter:o.cancelLeaveIntent,pointerEvents:l?`auto`:`none`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})]}),(0,I.jsxs)(j,{flex:1,minWidth:0,flexDirection:`column`,alignItems:`center`,children:[(n||r)&&(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,borderBottom:`1px solid`,borderBottomColor:`gray.50`,justifyContent:`space-between`,maxWidth:`900px`,padding:`8px`,width:`100%`,position:`sticky`,zIndex:1,top:0,children:[n,r]}),(0,I.jsx)(j,{flex:1,flexDirection:`column`,maxWidth:`900px`,padding:`1rem 1rem 0rem 1rem`,width:`100%`,children:i})]})]})}),Hq=({height:e=`2.5rem`,title:t,onClick:n,disabled:r,isSelected:i,isLoading:a,icon:o,dataTestId:s})=>(0,I.jsx)(N,{"data-testid":s,_hover:{color:`gray.400`,backgroundColor:`white`},_disabled:i?{backgroundColor:`gray.50`,cursor:`not-allowed`}:void 0,alignSelf:`flex-start`,color:`gray.300`,fontWeight:`500`,fontSize:16,height:e,disabled:r||i,loading:a,variant:`ghost`,onClick:n,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`0.5rem`,children:[o&&(0,I.jsx)(A,{fontSize:`sm`,children:o}),(0,I.jsx)(k,{children:t})]})}),Uq=e=>(0,I.jsx)(Hq,{...e,icon:(0,I.jsx)(af,{})}),Wq=({height:e=`2.5rem`,loading:t,isDisabled:n,onClick:r,title:i,dataTestId:a})=>(0,I.jsxs)(N,{"data-testid":a,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,loading:t,disabled:n,variant:`ghost`,onClick:r,width:`48px`,children:[(0,I.jsx)(Ve,{size:`sm`,mr:i?8:0,children:(0,I.jsx)(ef,{})}),i]}),Gq=({height:e=`2.5rem`,onClick:t,disabled:n,dataTestId:r})=>(0,I.jsx)(N,{"data-testid":r,disabled:n,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,variant:`ghost`,onClick:t,width:`48px`,children:(0,I.jsx)(Ve,{size:`md`,children:(0,I.jsx)(ip,{})})}),Kq=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,size:`lg`,width:`40px`,height:`40px`,...t,children:(0,I.jsx)(nf,{})}),qq=({value:e,placeholder:t,autoFocus:n,onChange:r,onBlur:i,onEnter:a,width:o,height:s,type:c,dataTestId:l,autoComplete:u})=>{let d=SB();return(0,I.jsx)(qt,{autoComplete:u,"data-testid":l,borderColor:`gray.100`,padding:`0 9px`,placeholder:t,ref:n?d:void 0,value:e,variant:`outline`,onChange:r,onBlur:i,width:o,height:s,type:c,onKeyDown:a?e=>{e.key===`Enter`&&a()}:void 0})},Jq=Rd({placement:`top`,pauseOnPageIdle:!0,duration:1500}),Yq=Rd({placement:`bottom`,pauseOnPageIdle:!0,duration:1500}),Xq=e=>(0,I.jsxs)(_t,{width:{md:`sm`},children:[e.type===`loading`?(0,I.jsx)(Ht,{size:`sm`,color:`blue.solid`}):(0,I.jsx)(ft,{}),(0,I.jsxs)(_e,{gap:`1`,flex:`1`,maxWidth:`100%`,children:[e.title&&(0,I.jsx)(eee,{children:e.title}),e.description&&(0,I.jsx)(ree,{color:`gray.500`,children:e.description})]}),e.action&&(0,I.jsx)(lt,{children:e.action.label}),e.closable&&(0,I.jsx)(Ft,{})]}),Zq=()=>(0,I.jsxs)(R,{children:[(0,I.jsx)(Rt,{toaster:Jq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})}),(0,I.jsx)(Rt,{toaster:Yq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})})]}),Qq=L.forwardRef(function(e,t){let{showArrow:n,children:r,disabled:i,portalled:a=!0,content:o,contentProps:s,portalRef:c,...l}=e;return i?r:(0,I.jsxs)(Wt,{...l,children:[(0,I.jsx)(Qt,{asChild:!0,children:r}),(0,I.jsx)(R,{disabled:!a,container:c,children:(0,I.jsx)(rt,{children:(0,I.jsxs)(Et,{ref:t,...s,children:[n&&(0,I.jsx)(Vt,{children:(0,I.jsx)(Yt,{})}),o]})})})]})}),$q={deprecated:{type:`boolean`},title:{type:`string`},description:{type:`string`}};({...$q});var eJ={type:{const:`string`},default:{type:`string`},readOnly:{type:`boolean`},pattern:{type:`string`,format:`regex`},enum:{type:`array`,items:{type:`string`},minItems:1,uniqueItems:!0},format:{type:`string`,enum:[`date-time`,`date`,`time`,`email`,`regex`]},contentMediaType:{type:`string`,enum:[`text/plain`,`text/markdown`,`text/html`,`application/json`,`application/schema+json`,`application/yaml`]},...$q};({...eJ}),{...eJ},{...$q},{...$q},{...$q},{...$q};var tJ=new(e(vd(),1)).default;tJ.addKeyword({keyword:`foreignKey`,type:`string`}),tJ.addFormat(`regex`,{type:`string`,validate:e=>{try{return new RegExp(e),!0}catch{return!1}}});var nJ=(e,t)=>({result:tJ.validate(e,t),errors:tJ.errors}),rJ=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,...t,children:(0,I.jsx)(qf,{})}),iJ={JsonCard:`_JsonCard_15gzu_1`,CopyButton:`_CopyButton_15gzu_1`},aJ=({data:e,readonly:t,onChange:n,schema:r,onBlur:i})=>{let[a,o]=(0,L.useState)(``),s=JSON.stringify(e,null,3),[c,l]=(0,L.useState)(s),u=(0,L.useRef)(!1),d=u.current?c:s,f=(0,L.useCallback)(async()=>{await navigator.clipboard.writeText(d),Jq.info({duration:1500,description:`Copied to clipboard`})},[d]),p=(0,L.useCallback)(e=>{l(e);try{let t=JSON.parse(e);if(r){let e=nJ(r,t);if(!e.result){o(`"${e.errors?.[0]?.instancePath||`/`}": ${e.errors?.[0]?.message}`);return}}o(``),n?.(t)}catch(e){console.error(e),o(`Invalid JSON`)}},[n,r]),m=(0,L.useCallback)(()=>{u.current=!0,l(s)},[s]),h=(0,L.useCallback)(()=>{u.current=!1,l(s),i?.()},[i,s]);return(0,I.jsxs)(j,{position:`relative`,width:`100%`,flex:1,className:iJ.JsonCard,direction:`column`,gap:`1rem`,children:[(0,I.jsxs)(A,{p:1,flex:1,children:[(0,I.jsx)(DO,{value:d,extensions:[G.lineWrapping,nk()],editable:!t,theme:pC,maxWidth:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0},onChange:p,onFocus:m,onBlur:h}),(0,I.jsx)(rJ,{dataTestId:`json-card-copy-button`,"aria-label":``,position:`absolute`,top:`8px`,right:`8px`,className:iJ.CopyButton,onClick:f})]}),(0,I.jsx)(j,{height:`40px`,paddingBottom:`8px`,alignItems:`flex-end`,backgroundColor:`white`,width:`100%`,position:`sticky`,bottom:0,justifyContent:`center`,children:(0,I.jsx)(k,{color:`gray`,children:a})})]})},oJ=g(()=>{let e=Y.get(Iq),t=e.isCollapsed&&e.isHoverExpanded,n=t?`Expand sidebar`:`Collapse sidebar`,r=t?Ite:Fte;return(0,I.jsx)(Qq,{content:n,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,flexShrink:0,onClick:e.toggle,opacity:+!!t,_groupHover:{opacity:1},transition:`opacity 0.15s ease`,"aria-label":n,children:(0,I.jsx)(r,{})})})}),sJ=({to:e,label:t,isActive:n,icon:r,onClick:i,badge:a})=>{let o=(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:i,children:[r&&(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t}),a!=null&&a>0&&(0,I.jsx)(A,{fontSize:`11px`,fontWeight:`600`,color:`newGray.400`,backgroundColor:`newGray.100`,borderRadius:`4px`,paddingX:`6px`,paddingY:`2px`,minWidth:`20px`,textAlign:`center`,children:a>99?`99+`:a})]});return e&&!i?(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:o}):o},cJ=g(({model:e,roleSlot:t,disableRemove:n})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`newGray.200`,borderRadius:`md`,padding:`1rem`,backgroundColor:`white`,_hover:{borderColor:`newGray.300`},transition:`border-color 0.2s`,children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(A,{color:`newGray.400`,children:(0,I.jsx)(zf,{size:20})}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontWeight:`500`,color:`newGray.600`,children:e.displayName}),e.username&&e.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.email})]})]}),(0,I.jsxs)(P,{gap:3,children:[t,e.canRemove&&(0,I.jsx)(N,{variant:`ghost`,size:`sm`,color:`red.500`,onClick:()=>e.remove(),loading:e.isRemoving,disabled:n,children:(0,I.jsx)(Rf,{})})]})]})})),lJ=g(({model:e,title:t,roleSelect:n})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`lg`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:t})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsx)(fn,{value:`search`,children:`Search User`}),e.canCreateUser&&(0,I.jsx)(fn,{value:`create`,children:`Create New`})]}),(0,I.jsx)(bt,{value:`search`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Search by username or email`}),(0,I.jsx)(qt,{placeholder:`Enter username or email...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),autoComplete:`off`})]}),e.isSearching?(0,I.jsx)(j,{justify:`center`,padding:`2rem`,children:(0,I.jsx)(Ht,{})}):e.searchResults.length>0?(0,I.jsx)(M,{align:`stretch`,gap:`0.5rem`,maxHeight:`200px`,overflowY:`auto`,children:e.searchResults.map(t=>(0,I.jsx)(A,{padding:`0.75rem`,borderWidth:`1px`,borderColor:e.selectedUserId===t.id?`blue.500`:`newGray.200`,borderRadius:`md`,backgroundColor:e.selectedUserId===t.id?`blue.50`:`white`,cursor:`pointer`,onClick:()=>e.setSelectedUserId(t.id),_hover:{borderColor:`blue.300`},transition:`all 0.2s`,children:(0,I.jsxs)(j,{align:`center`,justify:`space-between`,children:[(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(zf,{size:16}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,children:t.username||t.email||t.id}),t.username&&t.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.email})]})]}),e.selectedUserId===t.id&&(0,I.jsx)(Lte,{size:16,color:`var(--chakra-colors-blue-500)`})]})},t.id))}):e.searchQuery.length>0?(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,textAlign:`center`,padding:`2rem`,children:`No users found`}):null,(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})}),e.canCreateUser&&(0,I.jsx)(bt,{value:`create`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.newUsername,onChange:t=>e.setNewUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.newEmail,onChange:t=>e.setNewEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),e.activeTab===`search`?(0,I.jsx)(N,{onClick:e.addSelectedUser,disabled:!e.canAddSelectedUser,loading:e.isAdding,children:`Add User`}):(0,I.jsx)(N,{onClick:e.createAndAddUser,disabled:!e.canCreateNewUser,loading:e.isCreating,children:`Create & Add`})]}),(0,I.jsx)(Ie,{})]})})]})})),uJ=g(({model:e,sidebar:t,label:n,emptyTitle:r,emptySubtitle:i,subtitle:a,onAddClick:o,modal:s,children:c})=>e.showInitialLoading?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})})}):e.showError?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsxs)(k,{color:`red.500`,children:[`Error loading `,n.toLowerCase()]})})}):e.showNoMembers?(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsx)(A,{mb:`4rem`,children:(0,I.jsxs)(j,{justify:`center`,align:`center`,height:`200px`,flexDirection:`column`,gap:4,children:[(0,I.jsxs)(A,{textAlign:`center`,children:[(0,I.jsx)(Bf,{size:48,color:`var(--chakra-colors-newGray-400)`,style:{margin:`0 auto`}}),(0,I.jsx)(k,{color:`newGray.400`,mt:2,children:r}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mt:1,children:i})]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,focusRing:`none`,children:[(0,I.jsx)(Pf,{}),`Add`]})]})}),s]}):(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsxs)(j,{justify:`space-between`,align:`center`,marginBottom:`0.5rem`,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[n,` (`,e.totalCount,`)`]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,children:[(0,I.jsx)(Pf,{}),`Add`]})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,marginBottom:`1.5rem`,children:a}),(0,I.jsx)(M,{align:`stretch`,gap:3,children:c}),e.hasNextPage&&(0,I.jsx)(j,{justify:`center`,mt:4,children:(0,I.jsx)(N,{variant:`plain`,onClick:()=>e.tryToFetchNextPage(),loading:e.isLoading,children:`Load more`})})]}),s]})),dJ=class e{graphQLClient;client;onUnauthorized=null;constructor(t){this.environmentService=t;let n=this.environmentService.get(`REACT_APP_GRAPHQL_SERVER_URL`);if(!n)throw Error(`Invalid REACT_APP_GRAPHQL_SERVER_URL`);this.graphQLClient=new cee(n,{credentials:`include`,responseMiddleware:t=>{if(t instanceof Pn&&e.isUnauthorized(t))return;let n=t?.response?.errors?.[0]?.message;n&&Jq.info({duration:3e3,description:n})}}),this.wrapRequestWithRefreshRetry(),this.client=Mq(this.graphQLClient)}setToken(e){this.graphQLClient.setHeaders(e?{Authorization:`Bearer ${e}`}:{})}setUnauthorizedHandler(e){this.onUnauthorized=e}wrapRequestWithRefreshRetry(){let t=this.graphQLClient.request.bind(this.graphQLClient),n=async(n,r,i)=>{try{return await t(n,r,i)}catch(a){if(!e.isUnauthorized(a)||!this.onUnauthorized||!await this.onUnauthorized())throw a;return await t(n,r,i)}};this.graphQLClient.request=n}static isUnauthorized(e){if(!(e instanceof Pn))return!1;if(e.response.status===401)return!0;let t=e.response?.errors;return!Array.isArray(t)||t.length===0?!1:t.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;if(/^unauthorized$/i.test(n.trim()))return!0;let r=t.extensions?.code;return!!(typeof r==`string`&&/^UNAUTHENTICATED$/i.test(r)||t.extensions?.originalError?.statusCode===401)})}};Y.register(dJ,()=>new dJ(Y.get(Nq)),{scope:`singleton`});var Q=Y.get(dJ).client,fJ=`/api/auth/refresh`,pJ=`/api/auth/logout`,mJ=`rev_session`,hJ=class e{isLoaded=!1;user=null;token=null;refreshPromise=null;constructor(e,t,n){this.apiService=e,this.systemPermissions=t,this.permissionService=n,f(this),this.apiService.setUnauthorizedHandler(()=>this.tryRefresh())}async initialize(){if(!e.hasSessionCookie()){c(()=>{this.isLoaded=!0});return}try{await this.fetchMe()}catch{if(await this.tryRefresh())try{await this.fetchMe()}catch{}}c(()=>{this.isLoaded=!0})}async afterLogin(e){e!==void 0&&c(()=>{this.token=e}),await this.fetchMe()}setBearerToken(e){c(()=>{this.token=e}),this.apiService.setToken(e)}async logout(){try{await fetch(pJ,{method:`POST`,credentials:`include`})}catch{}this.apiService.setToken(null),c(()=>{this.user=null,this.token=null}),this.systemPermissions.clearAll()}async refresh(){return this.tryRefresh()}async fetchMe(){try{let e=await this.apiService.client.getMe();c(()=>{this.user=e.me}),this.systemPermissions.setUserRole(e.me.role??null),this.loadOrganizationPermissions(e.me)}catch(e){throw c(()=>{this.user=null}),e}}tryRefresh(){if(this.refreshPromise)return this.refreshPromise;let e=this.doRefresh();return c(()=>{this.refreshPromise=e}),e.finally(()=>{c(()=>{this.refreshPromise=null})}),e}async doRefresh(){try{return(await fetch(fJ,{method:`POST`,credentials:`include`})).ok}catch{return!1}}static hasSessionCookie(){if(typeof document>`u`)return!1;let e=document.cookie;return e?e.split(`;`).some(e=>e.trim()===`${mJ}=1`):!1}loadOrganizationPermissions(e){let t=e.organization?.userOrganization?.role?.permissions,n=e.organization?.id;if(t&&n){let e=t.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addOrganizationPermissions(n,e)}}};Y.register(hJ,()=>{let e=new hJ(Y.get(dJ),Y.get(yW),Y.get(vW));return e.initialize(),e},{scope:`singleton`});var gJ=class{isLoaded=!1;error=null;data=null;constructor(e){this.apiService=e,f(this)}async initialize(){await this.init()}get availableSignUp(){return this.availableEmailSignUp||this.availableGoogleOauth||this.availableGithubOauth}get availableEmailSignUp(){return this.data?.availableEmailSignUp}get availableGoogleOauth(){return!!this.data?.google.available}get googleOauthClientId(){if(!this.data?.google.clientId)throw Error(`Invalid Google client id`);return this.data?.google.clientId}get availableGithubOauth(){return!!this.data?.github.available}get githubOauthClientId(){if(!this.data?.github.clientId)throw Error(`Invalid Github client id`);return this.data?.github.clientId}get billingEnabled(){return this.data?.billing.enabled??!1}get cacheEnabled(){return this.data?.cache?.enabled??!1}get noAuth(){return this.data?.noAuth??!1}async init(){await this.request()}async request(){try{let e=await this.apiService.client.configuration();this.setData(e.configuration)}catch(e){this.setError(e),console.error(e)}finally{this.setIsLoaded(!0)}}setData(e){this.data=e}setError(e){this.error=e}setIsLoaded(e){this.isLoaded=e}};Y.register(gJ,()=>{let e=new gJ(Y.get(dJ));return e.initialize(),e},{scope:`singleton`});var _J=class{constructor(e,t){this.authService=e,this.configurationService=t,f(this)}get isLoaded(){return this.authService.isLoaded&&this.configurationService.isLoaded}};Y.register(_J,()=>new _J(Y.get(hJ),Y.get(gJ)),{scope:`singleton`});var vJ=`sandbox`,yJ=`login`,bJ=`logout`,xJ=`signup`,SJ=`username`,CJ=`github`,wJ=`google`,TJ=`authorize`,EJ=`get-token`,DJ=`get-mcp-token`,OJ=`completed`,kJ=`confirm`,AJ=`:organizationId`,jJ=`-/settings`,MJ=`-/members`,NJ=`-/limits`,PJ=`:projectName`,FJ=`-/settings`,IJ=`-/users`,LJ=`-/api-keys`,RJ=`-/mcp`,zJ=`:branchName`,BJ=`-/changes`,VJ=`-/assets`,HJ=`-/migrations`,UJ=`-/endpoints`,WJ=`-/branches`,GJ=`-/relations`,KJ=`-/branch-map`,qJ=`:revisionIdOrTag`,JJ=`:tableId`,YJ=`:rowId`,XJ=`draft`,ZJ=`head`,QJ=`admin`,$J=`users`,eY=`:userId`,tY=`organizations`,nY=`cache`,rY=function(e){return e.Organization=`organization`,e.Project=`project`,e.Branch=`branch`,e.Revision=`revision`,e.Table=`table`,e.Row=`row`,e.Changes=`changes`,e.Assets=`assets`,e.Migrations=`migrations`,e.Endpoints=`endpoints`,e.Branches=`branches`,e.Relations=`relations`,e.BranchMap=`branchMap`,e.OrganizationOverview=`organizationOverview`,e.OrganizationSettings=`organizationSettings`,e.OrganizationMembers=`organizationMembers`,e.OrganizationLimits=`organizationLimits`,e.ProjectSettings=`projectSettings`,e.ProjectUsers=`projectUsers`,e.ProjectApiKeys=`projectApiKeys`,e.ProjectMcp=`projectMcp`,e.Admin=`admin`,e.AdminUsers=`adminUsers`,e.AdminUserDetail=`adminUserDetail`,e.AdminOrganizations=`adminOrganizations`,e.AdminCache=`adminCache`,e}({}),iY=async()=>Y.get(yW).canReadUser?!0:Cn(`/`),aY=async({request:e})=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth)try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});return t.setBearerToken(e.login.accessToken),await t.afterLogin(),!0}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}let r=new URL(e.url),i=$V(`${r.pathname}${r.search}`);return Cn(`${n.availableSignUp?`/${xJ}`:`/${yJ}`}${i}`)}return t.user.username?!0:Cn(`/${SJ}`)},oY=async e=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth){try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});t.setBearerToken(e.login.accessToken),await t.afterLogin()}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}return!0}return!0}return t.user.username?!0:Cn(`/${SJ}`)},sY=async()=>Y.get(hJ).user?Cn(`/`):!0,cY=async()=>{let e=Y.get(hJ),t=Y.get(gJ);return e.user||!t.availableSignUp?Cn(`/`):!0},lY=(...e)=>async t=>{let n=null;for(let r of e){let e=await r(t);if(e&&typeof e==`object`&&`status`in e&&e.status===302)return e;n=e}return n},uY=async()=>!0,dY=class{statsRequest=X.of(Q.adminCacheStats);resetRequest=X.of(Q.adminResetAllCache);configurationService;_resetSuccess=!1;_showConfirm=!1;constructor(e){this.configurationService=e,f(this,{},{autoBind:!0})}get cacheEnabled(){return this.configurationService.cacheEnabled}get isLoading(){return this.statsRequest.isLoading}get isResetting(){return this.resetRequest.isLoading}get resetSuccess(){return this._resetSuccess}get showConfirm(){return this._showConfirm}get totalHits(){return this.statsRequest.data?.adminCacheStats.totalHits??0}get totalMisses(){return this.statsRequest.data?.adminCacheStats.totalMisses??0}get totalWrites(){return this.statsRequest.data?.adminCacheStats.totalWrites??0}get totalDeletes(){return this.statsRequest.data?.adminCacheStats.totalDeletes??0}get totalClears(){return this.statsRequest.data?.adminCacheStats.totalClears??0}get overallHitRate(){return this.statsRequest.data?.adminCacheStats.overallHitRate??0}get byCategory(){return this.statsRequest.data?.adminCacheStats.byCategory??[]}get resetError(){return this.resetRequest.errorMessage??null}openConfirm(){this._showConfirm=!0,this._resetSuccess=!1}closeConfirm(){this._showConfirm=!1}async confirmReset(){this._showConfirm=!1,(await this.resetRequest.fetch({})).isRight&&(c(()=>{this._resetSuccess=!0}),this.statsRequest.fetch({}))}init(){this.cacheEnabled&&this.statsRequest.fetch({})}dispose(){this.statsRequest.abort(),this.resetRequest.abort()}};Y.register(dY,()=>new dY(Y.get(gJ)),{scope:`request`});var fY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`160px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t})]}),pY=({keyName:e,hits:t,misses:n,writes:r,deletes:i,hitRate:a})=>(0,I.jsxs)(j,{padding:`12px 16px`,borderBottom:`1px solid`,borderColor:`gray.100`,alignItems:`center`,gap:`16px`,_last:{borderBottom:`none`},children:[(0,I.jsx)(k,{flex:`1`,fontSize:`sm`,fontWeight:`500`,fontFamily:`mono`,children:e}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[t,` hits`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[n,` misses`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[r,` writes`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[i,` del`]}),(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,minWidth:`60px`,textAlign:`right`,children:[(a*100).toFixed(1),`%`]})]}),mY=g(()=>{let e=CB(dY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Cache`})})})})})}),e.cacheEnabled?(0,I.jsxs)(A,{padding:`8px`,paddingTop:`16px`,children:[(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,marginBottom:`24px`,children:[(0,I.jsx)(fY,{label:`Hit Rate`,value:`${(e.overallHitRate*100).toFixed(1)}%`,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Hits`,value:e.totalHits,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Misses`,value:e.totalMisses,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Writes`,value:e.totalWrites,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Deletes`,value:e.totalDeletes,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Clears`,value:e.totalClears,isLoading:e.isLoading})]}),e.byCategory.length>0&&(0,I.jsxs)(A,{marginBottom:`24px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,marginBottom:`8px`,children:`By Cache Type`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`8px`,backgroundColor:`white`,children:e.byCategory.map(e=>(0,I.jsx)(pY,{keyName:e.key,hits:e.hits,misses:e.misses,writes:e.writes,deletes:e.deletes,hitRate:e.hitRate},e.key))})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(N,{colorPalette:`red`,variant:`outline`,size:`sm`,onClick:e.openConfirm,loading:e.isResetting,children:`Reset All Cache`}),e.resetSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Cache has been cleared successfully`}),e.resetError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetError})]})]}):(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.500`,children:`Caching is disabled`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,marginTop:`4px`,children:`Set CACHE_ENABLED=1 to enable caching.`})]})}),(0,I.jsx)(Ue,{open:e.showConfirm,onOpenChange:({open:t})=>!t&&e.closeConfirm(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Reset All Cache`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsx)(k,{children:`Are you sure you want to clear the entire cache?`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will flush all cached data including rows, revisions, auth, and billing caches. The cache will be rebuilt automatically as data is accessed.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.confirmReset,children:`Reset Cache`})]}),(0,I.jsx)(Ie,{})]})})]})})]})}),hY=class{usersRequest=X.of(Q.AdminDashboardStats);constructor(){f(this,{},{autoBind:!0})}get isLoadingUsers(){return this.usersRequest.isLoading}get isLoadingProjects(){return!1}get usersCount(){return this.usersRequest.data?.searchUsers.totalCount??null}get projectsCount(){return null}init(){this.usersRequest.fetch({first:1})}dispose(){this.usersRequest.abort()}};Y.register(hY,()=>new hY,{scope:`request`});var gY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`200px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t??`-`})]}),_Y=g(()=>{let e=CB(hY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Admin`})})})})})}),(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,children:[(0,I.jsx)(gY,{label:`Total Users`,value:e.usersCount,isLoading:e.isLoadingUsers}),(0,I.jsx)(gY,{label:`Total Projects`,value:e.projectsCount,isLoading:e.isLoadingProjects})]})})]})}),vY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get name(){return this.data.name}get prefix(){return this.data.prefix}get type(){return this.data.type}get isExpired(){return this.data.expiresAt?new Date(this.data.expiresAt)<new Date:!1}get isRevoked(){return this.data.revokedAt!==null}get isActive(){return!this.isExpired&&!this.isRevoked}get statusLabel(){return this.isRevoked?`Revoked`:this.isExpired?`Expired`:`Active`}get lastUsedAt(){return this.data.lastUsedAt??null}get createdAt(){return this.data.createdAt}get expiresAt(){return this.data.expiresAt??null}get readOnly(){return this.data.readOnly}get organizationId(){return this.data.organizationId??null}get projectIds(){return this.data.projectIds}get resolvedProjects(){return this.data.projects}get permissionLabel(){if(this.data.type===`PERSONAL`)return this.data.readOnly?`Read only`:`Full access`;let e=this.data.permissions?.rules?.[0]?.action??[];return e.includes(`delete`)?`Full access`:e.includes(`create`)||e.includes(`update`)?`Read & Write`:`Read only`}get permissionColorPalette(){switch(this.permissionLabel){case`Full access`:return`orange`;case`Read & Write`:return`blue`;default:return`gray`}}},yY={Active:{colorPalette:`green`},Expired:{colorPalette:`yellow`},Revoked:{colorPalette:`gray`}},bY=({status:e})=>{let t=yY[e];return(0,I.jsx)(It,{variant:`subtle`,colorPalette:t.colorPalette,size:`sm`,children:e})};function xY(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:HV(t,{addSuffix:!0})}var SY=({name:e,prefix:t,status:n,permissionLabel:r,permissionColor:i,projects:a,lastUsedAt:o,createdAt:s,expiresAt:c,actions:l})=>(0,I.jsx)(A,{width:`100%`,p:4,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,transition:`all 0.2s`,_hover:{borderColor:`gray.300`},children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:1,flex:1,minWidth:0,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,truncate:!0,children:e}),n!==`Active`&&(0,I.jsx)(bY,{status:n}),(0,I.jsx)(It,{variant:`outline`,colorPalette:i,size:`sm`,children:r})]}),(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`xs`,fontFamily:`mono`,color:`gray.400`,children:t}),a.length>0&&(0,I.jsx)(P,{gap:1,children:a.map(e=>(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:e.name},e.id))}),a.length===0&&(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:`All projects`})]}),(0,I.jsxs)(P,{gap:4,mt:1,flexWrap:`wrap`,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Created `,UV(s)]}),c&&(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Expires `,UV(c)]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:o?`Last used ${xY(o)}`:`Never used`})]})]}),l&&(0,I.jsx)(P,{gap:1,children:l})]})}),CY=[{value:`30d`,label:`30 days`},{value:`60d`,label:`60 days`},{value:`90d`,label:`90 days`},{value:`1y`,label:`1 year`},{value:`none`,label:`No expiration`}],wY=[{value:`read-only`,label:`Read only`,description:`Can only read data`},{value:`read-write`,label:`Read & Write`,description:`Can read, create, and update data`},{value:`full-access`,label:`Full access`,description:`Can read, create, update, and delete data`}],TY=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isCreateDialogOpen,onOpenChange:({open:t})=>!t&&e.closeCreateDialog(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:e.mode===`personal`?`Create Personal API Key`:`Create Service API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Name`}),(0,I.jsx)(qt,{placeholder:`e.g., CI/CD pipeline, Data sync...`,value:e.createKeyName,onChange:t=>e.setCreateKeyName(t.target.value),autoFocus:!0})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Expiration`}),(0,I.jsx)(P,{gap:2,flexWrap:`wrap`,children:CY.map(t=>(0,I.jsx)(N,{size:`sm`,variant:e.createKeyExpirationPreset===t.value?`solid`:`outline`,onClick:()=>e.setExpirationPreset(t.value),children:t.label},t.value))})]}),e.mode===`personal`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(P,{gap:2,children:(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setCreateKeyReadOnly(!e.createKeyReadOnly),display:`flex`,alignItems:`center`,gap:2,cursor:`pointer`,children:[(0,I.jsx)(A,{width:`18px`,height:`18px`,borderWidth:`1px`,borderColor:e.createKeyReadOnly?`blue.500`:`gray.300`,borderRadius:`sm`,bg:e.createKeyReadOnly?`blue.500`:`transparent`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`all 0.2s`,children:e.createKeyReadOnly&&(0,I.jsx)(k,{color:`white`,fontSize:`xs`,fontWeight:`bold`,lineHeight:1,children:`✓`})}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.700`,children:`Read only`})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,pl:`26px`,children:`Key can only read data, not modify it`})]}),e.mode===`service`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Permissions`}),(0,I.jsx)(M,{align:`stretch`,gap:2,children:wY.map(t=>(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setPermissionPreset(t.value),width:`100%`,p:3,borderWidth:`1px`,borderColor:e.createKeyPermissionPreset===t.value?`blue.400`:`gray.200`,borderRadius:`md`,bg:e.createKeyPermissionPreset===t.value?`blue.50`:`white`,cursor:`pointer`,textAlign:`left`,transition:`all 0.2s`,_hover:{borderColor:`blue.300`},children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:t.label}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.description})]},t.value))})]}),e.defaultProjectId&&(0,I.jsx)(j,{align:`center`,gap:2,p:3,bg:`blue.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`blue.200`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.700`,children:[`This key will be scoped to project `,(0,I.jsx)(`strong`,{children:e.defaultProjectId})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{onClick:e.createKey,disabled:!e.canCreateKey,loading:e.isMutating,children:`Create key`})]}),(0,I.jsx)(Ie,{})]})})]})})),EY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Revoke API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to revoke the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This action cannot be undone. Any applications using this key will immediately lose access.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:r,loading:n,children:`Revoke key`})]}),(0,I.jsx)(Ie,{})]})})]})})),DY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Rotate API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to rotate the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will generate a new secret and invalidate the current one. Any applications using the current key will need to be updated.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:r,loading:n,children:`Rotate key`})]}),(0,I.jsx)(Ie,{})]})})]})})),OY=g(({isOpen:e,secret:t,keyName:n,onClose:r})=>{let i=(0,L.useCallback)(async()=>{t&&(await navigator.clipboard.writeText(t),Jq.info({description:`Copied to clipboard`}))},[t]);return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&r(),size:`md`,closeOnInteractOutside:!1,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Your API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[n&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Key `,(0,I.jsx)(`strong`,{children:n}),` has been created successfully.`]}),(0,I.jsx)(A,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(qt,{value:t??``,readOnly:!0,fontFamily:`mono`,fontSize:`sm`,bg:`gray.50`}),(0,I.jsxs)(N,{variant:`outline`,onClick:i,flexShrink:0,children:[(0,I.jsx)(qf,{}),`Copy`]})]})}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`yellow.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`yellow.200`,children:[(0,I.jsx)(one,{color:`var(--chakra-colors-yellow-600)`}),(0,I.jsx)(k,{fontSize:`sm`,color:`yellow.800`,children:`Make sure to copy your API key now. You won't be able to see it again.`})]})]})}),(0,I.jsx)(w,{children:(0,I.jsx)(N,{onClick:r,children:`I've copied the key`})})]})})]})})}),kY=g(({model:e,showCreateButton:t=!0})=>((0,L.useEffect)(()=>(e.loadKeys(),()=>e.reset()),[e]),e.isLoaded?e.error?(0,I.jsx)(A,{p:4,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,children:(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.error})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[t&&!e.isEmpty&&(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`${e.sortedItems.length} key${e.sortedItems.length===1?``:`s`}`}),(0,I.jsxs)(N,{size:`sm`,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create key`]})]}),e.isEmpty&&e.isLoaded&&(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:e.emptyStateMessage}),t&&(0,I.jsxs)(N,{size:`sm`,mt:3,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create your first key`]})]}),e.sortedItems.map(t=>(0,I.jsx)(SY,{name:t.name,prefix:t.prefix,status:t.statusLabel,permissionLabel:t.permissionLabel,permissionColor:t.permissionColorPalette,projects:t.resolvedProjects,lastUsedAt:t.lastUsedAt,createdAt:t.createdAt,expiresAt:t.expiresAt,actions:t.isActive?(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`orange.600`,bg:`orange.50`},onClick:()=>e.openRotateDialog(t.id),children:(0,I.jsx)(Ate,{})}),(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`red.600`,bg:`red.50`},onClick:()=>e.openRevokeDialog(t.id),children:(0,I.jsx)(Rf,{})})]}):void 0},t.id)),(0,I.jsx)(TY,{model:e}),(0,I.jsx)(OY,{isOpen:e.isSecretDialogOpen,secret:e.lastSecret,keyName:e.lastCreatedKeyName,onClose:e.closeSecretDialog}),(0,I.jsx)(EY,{isOpen:e.isRevokeDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.revokeKey,onClose:e.closeRevokeDialog}),(0,I.jsx)(DY,{isOpen:e.isRotateDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.rotateKey,onClose:e.closeRotateDialog})]}):(0,I.jsx)(j,{justify:`center`,py:8,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}))),AY=class{myKeysRequest=X.of(Q.myApiKeys,{skipResetting:!0});serviceKeysRequest=X.of(Q.serviceApiKeys,{skipResetting:!0});createPersonalRequest=X.of(Q.createPersonalApiKey);createServiceRequest=X.of(Q.createServiceApiKey);revokeRequest=X.of(Q.revokeApiKey);rotateRequest=X.of(Q.rotateApiKey);constructor(){f(this)}get isLoading(){return this.myKeysRequest.isLoading||this.serviceKeysRequest.isLoading}get error(){return this.myKeysRequest.errorMessage??this.serviceKeysRequest.errorMessage??null}get isMutating(){return this.createPersonalRequest.isLoading||this.createServiceRequest.isLoading||this.revokeRequest.isLoading||this.rotateRequest.isLoading}fetchPersonalKeys(){return this.myKeysRequest.fetch()}fetchServiceKeys(e){return this.serviceKeysRequest.fetch({organizationId:e})}async createPersonalKey(e){let t=await this.createPersonalRequest.fetch({data:e});return t.isRight?t.data.createPersonalApiKey:null}async createServiceKey(e){let t=await this.createServiceRequest.fetch({data:e});return t.isRight?t.data.createServiceApiKey:null}async revokeKey(e){let t=await this.revokeRequest.fetch({id:e});return t.isRight?t.data.revokeApiKey:null}async rotateKey(e){let t=await this.rotateRequest.fetch({id:e});return t.isRight?t.data.rotateApiKey:null}dispose(){this.myKeysRequest.abort(),this.serviceKeysRequest.abort(),this.createPersonalRequest.abort(),this.createServiceRequest.abort(),this.revokeRequest.abort(),this.rotateRequest.abort()}};Y.register(AY,()=>new AY,{scope:`request`});var jY={"read-only":[{action:[`read`],subject:[`all`]}],"read-write":[{action:[`read`,`create`,`update`],subject:[`all`]}],"full-access":[{action:[`read`,`create`,`update`,`delete`],subject:[`all`]}]},MY=class{_config={mode:`personal`};_items=[];_isLoaded=!1;_isCreateDialogOpen=!1;_isSecretDialogOpen=!1;_isRevokeDialogOpen=!1;_isRotateDialogOpen=!1;_selectedKeyId=null;_lastSecret=null;_lastCreatedKeyName=null;createKeyName=``;createKeyReadOnly=!1;createKeyExpiresAt=null;createKeyExpirationPreset=`none`;createKeyPermissionPreset=`read-only`;constructor(e){this.dataSource=e,f(this,{},{autoBind:!0})}get mode(){return this._config.mode}get organizationId(){return this._config.organizationId}get defaultProjectId(){return this._config.defaultProjectId}get filterByProjectId(){return this._config.filterByProjectId}get items(){return this._items}get filteredItems(){if(!this._config.filterByProjectId)return this._items;let e=this._config.filterByProjectId;return this._items.filter(t=>t.projectIds.includes(e))}get sortedItems(){return[...this.filteredItems].sort((e,t)=>{let n={Active:0,Expired:1,Revoked:2},r=n[e.statusLabel]-n[t.statusLabel];return r===0?new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime():r})}get isLoading(){return this.dataSource.isLoading}get isLoaded(){return this._isLoaded}get isMutating(){return this.dataSource.isMutating}get error(){return this.dataSource.error}get isEmpty(){return this.filteredItems.length===0}get isCreateDialogOpen(){return this._isCreateDialogOpen}get isSecretDialogOpen(){return this._isSecretDialogOpen}get isRevokeDialogOpen(){return this._isRevokeDialogOpen}get isRotateDialogOpen(){return this._isRotateDialogOpen}get selectedKeyId(){return this._selectedKeyId}get lastSecret(){return this._lastSecret}get lastCreatedKeyName(){return this._lastCreatedKeyName}get selectedKey(){return this._items.find(e=>e.id===this._selectedKeyId)}get canCreateKey(){return this.createKeyName.trim().length>0&&!this.isMutating}get emptyStateMessage(){return this._config.mode===`personal`?`No API keys yet. Create one for programmatic access to your data.`:`No integration keys for this organization.`}configure(e){this._config=e}init(){}dispose(){this.dataSource.dispose()}reset(){this._items=[],this._isLoaded=!1}async loadKeys(){if(this._config.mode===`personal`){let e=await this.dataSource.fetchPersonalKeys();if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.myApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}else if(this._config.organizationId){let e=await this.dataSource.fetchServiceKeys(this._config.organizationId);if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.serviceApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}}openCreateDialog(){this._isCreateDialogOpen=!0,this.createKeyName=``,this.createKeyReadOnly=!1,this.createKeyExpiresAt=null,this.createKeyExpirationPreset=`none`,this.createKeyPermissionPreset=`read-only`}closeCreateDialog(){this._isCreateDialogOpen=!1}setCreateKeyName(e){this.createKeyName=e}setCreateKeyReadOnly(e){this.createKeyReadOnly=e}setExpirationPreset(e){this.createKeyExpirationPreset=e;let t=new Date;switch(e){case`30d`:t.setDate(t.getDate()+30),this.createKeyExpiresAt=t.toISOString();break;case`60d`:t.setDate(t.getDate()+60),this.createKeyExpiresAt=t.toISOString();break;case`90d`:t.setDate(t.getDate()+90),this.createKeyExpiresAt=t.toISOString();break;case`1y`:t.setFullYear(t.getFullYear()+1),this.createKeyExpiresAt=t.toISOString();break;case`none`:this.createKeyExpiresAt=null;break}}setPermissionPreset(e){this.createKeyPermissionPreset=e}async createKey(){if(this.canCreateKey){if(this._config.mode===`personal`){let e={name:this.createKeyName.trim(),readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0},t=await this.dataSource.createPersonalKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}else if(this._config.organizationId){let e={name:this.createKeyName.trim(),organizationId:this._config.organizationId,readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0,permissions:{rules:jY[this.createKeyPermissionPreset]}},t=await this.dataSource.createServiceKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}}}closeSecretDialog(){this._isSecretDialogOpen=!1,this._lastSecret=null,this._lastCreatedKeyName=null}openRevokeDialog(e){this._selectedKeyId=e,this._isRevokeDialogOpen=!0}closeRevokeDialog(){this._isRevokeDialogOpen=!1,this._selectedKeyId=null}async revokeKey(){this._selectedKeyId&&await this.dataSource.revokeKey(this._selectedKeyId)&&(c(()=>{this._isRevokeDialogOpen=!1,this._selectedKeyId=null}),await this.loadKeys())}openRotateDialog(e){this._selectedKeyId=e,this._isRotateDialogOpen=!0}closeRotateDialog(){this._isRotateDialogOpen=!1,this._selectedKeyId=null}async rotateKey(){if(!this._selectedKeyId)return;let e=await this.dataSource.rotateKey(this._selectedKeyId);e&&(c(()=>{this._lastSecret=e.secret,this._lastCreatedKeyName=e.apiKey.name,this._isRotateDialogOpen=!1,this._selectedKeyId=null,this._isSecretDialogOpen=!0}),await this.loadKeys())}};Y.register(MY,()=>new MY(Y.get(AY)),{scope:`request`});var NY=g(({model:e})=>{let t=(0,L.useCallback)(async()=>{await e.savePassword()&&Jq.success({description:`Password updated successfully`})},[e]);return(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Account Settings`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsxs)(fn,{value:`account`,children:[(0,I.jsx)(zf,{}),`Account`]}),(0,I.jsxs)(fn,{value:`password`,children:[(0,I.jsx)(Of,{}),`Password`]}),(0,I.jsxs)(fn,{value:`api-keys`,children:[(0,I.jsx)(Df,{}),`Personal Tokens`]})]}),(0,I.jsx)(bt,{value:`account`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.username&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username`}),(0,I.jsx)(qt,{value:e.username,readOnly:!0})]}),e.email&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email`}),(0,I.jsx)(qt,{value:e.email,readOnly:!0})]}),(0,I.jsx)(A,{paddingTop:`1rem`,borderTop:`1px solid`,borderTopColor:`newGray.100`,children:(0,I.jsxs)(N,{variant:`outline`,onClick:e.logout,width:`100%`,children:[(0,I.jsx)(tne,{}),`Sign out`]})})]})}),(0,I.jsx)(bt,{value:`password`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.hasPassword?(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Current Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter current password...`,value:e.oldPassword,onChange:t=>e.setOldPassword(t.target.value),autoComplete:`current-password`})]}):(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You signed in with a social account. Set a password to enable password login.`}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:e.hasPassword?`New Password`:`Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter new password (min 8 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Confirm Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Confirm new password...`,value:e.confirmPassword,onChange:t=>e.setConfirmPassword(t.target.value),autoComplete:`new-password`})]}),e.passwordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.passwordError}),e.error&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.error}),(0,I.jsx)(j,{justifyContent:`flex-end`,children:(0,I.jsx)(N,{onClick:t,disabled:!e.canSavePassword,loading:e.isLoading,children:e.hasPassword?`Update Password`:`Set Password`})})]})}),(0,I.jsx)(bt,{value:`api-keys`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:`Personal Access Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Personal keys act on your behalf and inherit your permissions. Use them for scripts, CLI tools, or any programmatic access to your data.`})]}),(0,I.jsx)(kY,{model:e.apiKeyManager})]})})]})}),(0,I.jsx)(Ie,{})]})})]})})}),PY=class{updatePasswordRequest=X.of(Q.updatePassword);constructor(){f(this)}get isLoading(){return this.updatePasswordRequest.isLoading}get error(){return this.updatePasswordRequest.errorMessage??null}async updatePassword(e){return(await this.updatePasswordRequest.fetch({data:{oldPassword:e.oldPassword,newPassword:e.newPassword}})).isRight}dispose(){this.updatePasswordRequest.abort()}};Y.register(PY,()=>new PY,{scope:`request`});var FY=class{_isOpen=!1;_activeTab=`account`;apiKeyManager;oldPassword=``;newPassword=``;confirmPassword=``;constructor(e,t,n){this.dataSource=e,this.authService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`personal`})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get username(){return this.authService.user?.username}get email(){return this.authService.user?.email}get hasPassword(){return this.authService.user?.hasPassword??!0}get canSavePassword(){return!(this.isLoading||this.newPassword.length<8||this.newPassword!==this.confirmPassword||this.hasPassword&&!this.oldPassword)}get passwordError(){return this.newPassword&&this.newPassword.length<8?`Password must be at least 8 characters`:this.confirmPassword&&this.newPassword!==this.confirmPassword?`Passwords do not match`:null}open(){this._isOpen=!0,this._activeTab=`account`,this.resetPasswordForm()}close(){this._isOpen=!1,this.resetPasswordForm()}setActiveTab(e){this._activeTab=e}setOldPassword(e){this.oldPassword=e}setNewPassword(e){this.newPassword=e}setConfirmPassword(e){this.confirmPassword=e}async savePassword(){if(!this.canSavePassword)return!1;let e=await this.dataSource.updatePassword({oldPassword:this.oldPassword,newPassword:this.newPassword});return e&&(this.resetPasswordForm(),await this.authService.fetchMe()),e}logout(){this.close(),globalThis.location.href=`/${bJ}`}resetPasswordForm(){this.oldPassword=``,this.newPassword=``,this.confirmPassword=``}init(){}dispose(){this.dataSource.dispose(),this.apiKeyManager.dispose()}};Y.register(FY,()=>new FY(Y.get(PY),Y.get(hJ),Y.get(MY)),{scope:`singleton`});var IY=g(()=>{let e=CB(FY);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:e.open,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(zf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Account Settings`})]}),(0,I.jsx)(NY,{model:e})]})}),LY=({onBack:e})=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:e,display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),RY=({to:e,label:t,isActive:n,icon:r})=>(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t})]})}),zY=g(()=>{let e=kn(),t=Tn(),n=e.pathname,r=n===`/${QJ}`,i=n.startsWith(`/${QJ}/${$J}`),a=n.startsWith(`/${QJ}/${tY}`),o=n.startsWith(`/${QJ}/${nY}`);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(LY,{onBack:(0,L.useCallback)(()=>{t(`/`)},[t])}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(RY,{to:`/${QJ}`,label:`Dashboard`,icon:(0,I.jsx)(Xte,{}),isActive:r}),(0,I.jsx)(RY,{to:`/${QJ}/${$J}`,label:`Users`,icon:(0,I.jsx)(Bf,{}),isActive:i}),(0,I.jsx)(RY,{to:`/${QJ}/${tY}`,label:`Organizations`,icon:(0,I.jsx)(Pte,{}),isActive:a}),(0,I.jsx)(RY,{to:`/${QJ}/${nY}`,label:`Cache`,icon:(0,I.jsx)(yf,{}),isActive:o})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),BY=()=>(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(zY,{}),children:(0,I.jsx)(En,{})}),VY=({breadcrumbs:e,headerRight:t,children:n})=>(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:[(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsxs)(Gt,{fontSize:`16px`,children:[(0,I.jsx)(Dt,{children:(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:`/${QJ}`,children:`Admin`})})}),e.map((e,t)=>(0,I.jsxs)(L.Fragment,{children:[(0,I.jsx)(ut,{children:`/`}),(0,I.jsx)(Dt,{children:e.to?(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:e.to,children:e.label})}):(0,I.jsx)(Xt,{color:`gray`,children:e.label})})]},t))]})})}),t]}),(0,I.jsx)(A,{flex:1,children:n})]}),HY=()=>(0,I.jsx)(VY,{breadcrumbs:[{label:`Organizations`}],children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`Coming soon`})})}),UY=class{request=X.of(Q.adminGetUser);resetPasswordRequest=X.of(Q.adminResetPassword);_userId=null;_user=null;_newPassword=``;_resetPasswordSuccess=!1;constructor(){f(this,{},{autoBind:!0})}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get user(){return this._user}get username(){return this._user?.username??null}get email(){return this._user?.email??null}get roleName(){return this._user?.role?.name??null}get newPassword(){return this._newPassword}get isResetPasswordLoading(){return this.resetPasswordRequest.isLoading}get resetPasswordError(){return this.resetPasswordRequest.errorMessage??null}get resetPasswordSuccess(){return this._resetPasswordSuccess}get canResetPassword(){return this._newPassword.length>=6}setUserId(e){this._userId=e,this.loadUser()}setNewPassword(e){this._newPassword=e,this._resetPasswordSuccess=!1}async resetPassword(){!this._userId||!this.canResetPassword||(await this.resetPasswordRequest.fetch({userId:this._userId,newPassword:this._newPassword})).isRight&&c(()=>{this._newPassword=``,this._resetPasswordSuccess=!0})}init(){this._userId&&this.loadUser()}dispose(){this.request.abort(),this.resetPasswordRequest.abort()}async loadUser(){if(!this._userId)return;let e=await this.request.fetch({userId:this._userId});e.isRight&&c(()=>{this._user=e.data.adminUser??null})}};Y.register(UY,()=>new UY,{scope:`request`});var WY=({label:e,value:t})=>(0,I.jsxs)(j,{gap:`16px`,alignItems:`baseline`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,minWidth:`80px`,children:e}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.600`,children:t||`-`})]}),GY=g(({model:e})=>(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,marginTop:`16px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`Reset Password`}),(0,I.jsxs)(j,{gap:`12px`,alignItems:`flex-start`,children:[(0,I.jsx)(qt,{placeholder:`New password (min 6 characters)`,type:`password`,size:`sm`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),maxWidth:`300px`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`gray`,onClick:e.resetPassword,disabled:!e.canResetPassword,loading:e.isResetPasswordLoading,children:`Reset`})]}),e.resetPasswordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetPasswordError}),e.resetPasswordSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Password has been reset successfully`})]})),KY=g(()=>{let{userId:e}=bn(),t=CB(UY);return(0,L.useEffect)(()=>{e&&t.setUserId(e)},[e,t]),(0,I.jsx)(VY,{breadcrumbs:(0,L.useMemo)(()=>[{label:`Users`,to:`/${QJ}/${$J}`},{label:t.username||e||``}],[t.username,e]),children:(0,I.jsxs)(A,{flex:1,padding:`8px`,children:[t.isLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,paddingY:`48px`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),t.error&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load user`}),(0,I.jsx)(k,{fontSize:`sm`,children:t.error})]}),!t.isLoading&&!t.error&&!t.user&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`User not found`})}),t.user&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`User Info`}),(0,I.jsxs)(M,{alignItems:`flex-start`,gap:`8px`,children:[(0,I.jsx)(WY,{label:`ID`,value:t.user.id}),(0,I.jsx)(WY,{label:`Username`,value:t.username}),(0,I.jsx)(WY,{label:`Email`,value:t.email}),(0,I.jsx)(WY,{label:`Role`,value:t.roleName})]})]}),(0,I.jsx)(GY,{model:t})]})]})})}),qY=class{request=X.of(Q.createUser);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}async create(e){let t=await this.request.fetch({username:e.username,password:e.password,email:e.email,roleId:e.roleId});return t.isRight&&t.data.createUser}dispose(){this.request.abort()}};Y.register(qY,()=>new qY,{scope:`request`});var JY=class{_isOpen=!1;_username=``;_password=``;_email=``;_selectedRole=XW.SystemUser;constructor(e,t,n){this.dataSource=e,this.systemPermissions=t,this.onUserCreated=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get canCreateUser(){return this.systemPermissions.canCreateUser}get username(){return this._username}get password(){return this._password}get email(){return this._email}get selectedRole(){return this._selectedRole}get isCreating(){return this.dataSource.isLoading}get canSubmit(){return this._username.trim().length>0&&this._password.length>=6&&!this.isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setUsername(e){this._username=e}setPassword(e){this._password=e}setEmail(e){this._email=e}setSelectedRole(e){this._selectedRole=e}async createUser(){if(!this.canSubmit)return;let e=await this.dataSource.create({username:this._username.trim(),password:this._password,email:this._email.trim()||void 0,roleId:this._selectedRole});c(()=>{e&&(this.onUserCreated(),this.close())})}dispose(){this.dataSource.dispose()}reset(){this._username=``,this._password=``,this._email=``,this._selectedRole=XW.SystemUser}},YY=class extends rH{currentFilters={};constructor(){super(Q.adminUsers,{pageSize:50})}extractItems(e){return e.adminUsers.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.adminUsers.pageInfo.hasNextPage,endCursor:e.adminUsers.pageInfo.endCursor||null,totalCount:e.adminUsers.totalCount}}buildFetchArgs(e,t){return e&&(this.currentFilters=e),{first:this.config.pageSize,after:t,search:this.currentFilters.search||void 0}}};Y.register(YY,()=>new YY,{scope:`request`});var XY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get username(){return this.data.username??null}get email(){return this.data.email??null}get roleName(){return this.data.role?.name??null}get link(){return Dn(`/${QJ}/${$J}/:userId`,{userId:this.data.id})}},ZY=class extends nH{createUserModal;_searchQuery=``;_debounceTimer=null;constructor(e,t,n){super(e),this.createUserModal=new JY(t,n,()=>this.reload()),h(this,{_searchQuery:u,searchQuery:a,canCreateUser:a,setSearchQuery:m,reload:m,init:_,dispose:_})}getItemKey(e){return e.id}createItemViewModel(e){return new XY(e)}get canCreateUser(){return this.createUserModal.canCreateUser}get searchQuery(){return this._searchQuery}init(){this.dataSource.load()}dispose(){this._debounceTimer&&clearTimeout(this._debounceTimer),super.dispose(),this.createUserModal.dispose()}reload(){this.dataSource.load({search:this._searchQuery||void 0})}setSearchQuery(e){this._searchQuery=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this.dataSource.load({search:e||void 0})},300)}};Y.register(ZY,()=>new ZY(Y.get(YY),Y.get(qY),Y.get(yW)),{scope:`request`});var QY={[XW.SystemAdmin]:`System Admin`,[XW.SystemFullApiRead]:`Full API Read`,[XW.SystemUser]:`User`},$Y=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`160px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(XW).map(e=>(0,I.jsx)(`option`,{value:e,children:QY[e]},e))})})),eX=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Create User`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.username,onChange:t=>e.setUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.password,onChange:t=>e.setPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.email,onChange:t=>e.setEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`System Role`}),(0,I.jsx)($Y,{value:e.selectedRole,onChange:t=>e.setSelectedRole(t)})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),(0,I.jsx)(N,{onClick:e.createUser,disabled:!e.canSubmit,loading:e.isCreating,children:`Create`})]}),(0,I.jsx)(Ie,{})]})})]})})),tX=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(An,{to:e.link,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,height:`100%`,children:[(0,I.jsx)(j,{width:`200px`,children:(0,I.jsx)(k,{maxWidth:`190px`,textDecoration:`underline`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:e.username||e.email||`No username`})}),(0,I.jsx)(j,{alignItems:`center`,flex:1,minHeight:`40px`,children:(0,I.jsx)(k,{color:`gray.400`,fontWeight:`300`,ml:`16px`,children:e.roleName||`-`})})]})})})),nX=g(()=>{let e=CB(ZY);return(0,I.jsxs)(VY,{breadcrumbs:[{label:`Users`}],headerRight:(0,I.jsx)(j,{alignItems:`center`,gap:`8px`,children:(0,I.jsx)(qt,{placeholder:`Search...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),variant:`flushed`,size:`sm`,width:`200px`,_placeholder:{color:`gray.400`}})}),children:[(0,I.jsxs)(A,{flex:1,paddingX:`16px`,paddingTop:`16px`,children:[e.canCreateUser&&(0,I.jsx)(j,{paddingBottom:`16px`,children:(0,I.jsxs)(N,{variant:`ghost`,size:`sm`,color:`gray`,onClick:()=>e.createUserModal.open(),children:[(0,I.jsx)(Pf,{}),`Add`]})}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load users`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(Bf,{size:48}),(0,I.jsx)(k,{fontSize:`md`,children:`No users found`})]}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.items.length,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(tX,{model:n},n.id):null}})]}),(0,I.jsx)(eX,{model:e.createUserModal})]})}),rX=i((e=>{e.removeLeadingAndTrailingHTTPWhitespace=e=>e.replace(/^[ \t\n\r]+/u,``).replace(/[ \t\n\r]+$/u,``),e.removeTrailingHTTPWhitespace=e=>e.replace(/[ \t\n\r]+$/u,``),e.isHTTPWhitespaceChar=e=>e===` `||e===` `||e===`
2167
2167
  `||e===`\r`,e.solelyContainsHTTPTokenCodePoints=e=>/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(e),e.soleyContainsHTTPQuotedStringTokenCodePoints=e=>/^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(e),e.asciiLowercase=e=>e.replace(/[A-Z]/gu,e=>e.toLowerCase()),e.collectAnHTTPQuotedString=(e,t)=>{let n=``;for(t++;;){for(;t<e.length&&e[t]!==`"`&&e[t]!==`\\`;)n+=e[t],++t;if(t>=e.length)break;let r=e[t];if(++t,r===`\\`){if(t>=e.length){n+=`\\`;break}n+=e[t],++t}else break}return[n,t]}})),iX=i(((e,t)=>{var{asciiLowercase:n,solelyContainsHTTPTokenCodePoints:r,soleyContainsHTTPQuotedStringTokenCodePoints:i}=rX();t.exports=class{constructor(e){this._map=e}get size(){return this._map.size}get(e){return e=n(String(e)),this._map.get(e)}has(e){return e=n(String(e)),this._map.has(e)}set(e,t){if(e=n(String(e)),t=String(t),!r(e))throw Error(`Invalid MIME type parameter name "${e}": only HTTP token code points are valid.`);if(!i(t))throw Error(`Invalid MIME type parameter value "${t}": only HTTP quoted-string token code points are valid.`);return this._map.set(e,t)}clear(){this._map.clear()}delete(e){return e=n(String(e)),this._map.delete(e)}forEach(e,t){this._map.forEach(e,t)}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}}})),aX=i(((e,t)=>{var{removeLeadingAndTrailingHTTPWhitespace:n,removeTrailingHTTPWhitespace:r,isHTTPWhitespaceChar:i,solelyContainsHTTPTokenCodePoints:a,soleyContainsHTTPQuotedStringTokenCodePoints:o,asciiLowercase:s,collectAnHTTPQuotedString:c}=rX();t.exports=e=>{e=n(e);let t=0,l=``;for(;t<e.length&&e[t]!==`/`;)l+=e[t],++t;if(l.length===0||!a(l)||t>=e.length)return null;++t;let u=``;for(;t<e.length&&e[t]!==`;`;)u+=e[t],++t;if(u=r(u),u.length===0||!a(u))return null;let d={type:s(l),subtype:s(u),parameters:new Map};for(;t<e.length;){for(++t;i(e[t]);)++t;let n=``;for(;t<e.length&&e[t]!==`;`&&e[t]!==`=`;)n+=e[t],++t;if(n=s(n),t<e.length){if(e[t]===`;`)continue;++t}let l=null;if(e[t]===`"`)for([l,t]=c(e,t);t<e.length&&e[t]!==`;`;)++t;else{for(l=``;t<e.length&&e[t]!==`;`;)l+=e[t],++t;if(l=r(l),l===``)continue}n.length>0&&a(n)&&o(l)&&!d.parameters.has(n)&&d.parameters.set(n,l)}return d}})),oX=i(((e,t)=>{var{solelyContainsHTTPTokenCodePoints:n}=rX();t.exports=e=>{let t=`${e.type}/${e.subtype}`;if(e.parameters.size===0)return t;for(let[r,i]of e.parameters)t+=`;`,t+=r,t+=`=`,(!n(i)||i.length===0)&&(i=i.replace(/(["\\])/gu,`\\$1`),i=`"${i}"`),t+=i;return t}})),sX=e(i(((e,t)=>{var n=iX(),r=aX(),i=oX(),{asciiLowercase:a,solelyContainsHTTPTokenCodePoints:o}=rX();t.exports=class{constructor(e){e=String(e);let t=r(e);if(t===null)throw Error(`Could not parse MIME type string "${e}"`);this._type=t.type,this._subtype=t.subtype,this._parameters=new n(t.parameters)}static parse(e){try{return new this(e)}catch{return null}}get essence(){return`${this.type}/${this.subtype}`}get type(){return this._type}set type(e){if(e=a(String(e)),e.length===0)throw Error(`Invalid type: must be a non-empty string`);if(!o(e))throw Error(`Invalid type ${e}: must contain only HTTP token code points`);this._type=e}get subtype(){return this._subtype}set subtype(e){if(e=a(String(e)),e.length===0)throw Error(`Invalid subtype: must be a non-empty string`);if(!o(e))throw Error(`Invalid subtype ${e}: must contain only HTTP token code points`);this._subtype=e}get parameters(){return this._parameters}toString(){return i(this)}isJavaScript({prohibitParameters:e=!1}={}){switch(this._type){case`text`:switch(this._subtype){case`ecmascript`:case`javascript`:case`javascript1.0`:case`javascript1.1`:case`javascript1.2`:case`javascript1.3`:case`javascript1.4`:case`javascript1.5`:case`jscript`:case`livescript`:case`x-ecmascript`:case`x-javascript`:return!e||this._parameters.size===0;default:return!1}case`application`:switch(this._subtype){case`ecmascript`:case`javascript`:case`x-ecmascript`:case`x-javascript`:return!e||this._parameters.size===0;default:return!1}default:return!1}}isXML(){return this._subtype===`xml`&&(this._type===`text`||this._type===`application`)||this._subtype.endsWith(`+xml`)}isHTML(){return this._subtype===`html`&&this._type===`text`}}}))(),1);function cX(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=lX(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
2168
2168
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lX(e,t){if(e){if(typeof e==`string`)return uX(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return uX(e,t)}}function uX(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dX(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function fX(e,t,n){return t&&dX(e.prototype,t),n&&dX(e,n),e}var pX=function(){return typeof Symbol==`function`},mX=function(e){return pX()&&!!Symbol[e]},hX=function(e){return mX(e)?Symbol[e]:`@@`+e};pX()&&!mX(`observable`)&&(Symbol.observable=Symbol(`observable`));var gX=hX(`iterator`),_X=hX(`observable`),vX=hX(`species`);function yX(e,t){var n=e[t];if(n!=null){if(typeof n!=`function`)throw TypeError(n+` is not a function`);return n}}function bX(e){var t=e.constructor;return t!==void 0&&(t=t[vX],t===null&&(t=void 0)),t===void 0?jX:t}function xX(e){return e instanceof jX}function SX(e){SX.log?SX.log(e):setTimeout(function(){throw e})}function CX(e){Promise.resolve().then(function(){try{e()}catch(e){SX(e)}})}function wX(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,t))try{if(typeof t==`function`)t();else{var n=yX(t,`unsubscribe`);n&&n.call(t)}}catch(e){SX(e)}}function TX(e){e._observer=void 0,e._queue=void 0,e._state=`closed`}function EX(e){var t=e._queue;if(t){e._queue=void 0,e._state=`ready`;for(var n=0;n<t.length&&(DX(e,t[n].type,t[n].value),e._state!==`closed`);++n);}}function DX(e,t,n){e._state=`running`;var r=e._observer;try{var i=yX(r,t);switch(t){case`next`:i&&i.call(r,n);break;case`error`:if(TX(e),i)i.call(r,n);else throw n;break;case`complete`:TX(e),i&&i.call(r);break}}catch(e){SX(e)}e._state===`closed`?wX(e):e._state===`running`&&(e._state=`ready`)}function OX(e,t,n){if(e._state!==`closed`){if(e._state===`buffering`){e._queue.push({type:t,value:n});return}if(e._state!==`ready`){e._state=`buffering`,e._queue=[{type:t,value:n}],CX(function(){return EX(e)});return}DX(e,t,n)}}var kX=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state=`initializing`;var n=new AX(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}this._state===`initializing`&&(this._state=`ready`)}var t=e.prototype;return t.unsubscribe=function(){this._state!==`closed`&&(TX(this),wX(this))},fX(e,[{key:`closed`,get:function(){return this._state===`closed`}}]),e}(),AX=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){OX(this._subscription,`next`,e)},t.error=function(e){OX(this._subscription,`error`,e)},t.complete=function(){OX(this._subscription,`complete`)},fX(e,[{key:`closed`,get:function(){return this._subscription._state===`closed`}}]),e}(),jX=function(){function e(t){if(!(this instanceof e))throw TypeError(`Observable cannot be called as a function`);if(typeof t!=`function`)throw TypeError(`Observable initializer must be a function`);this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return(typeof e!=`object`||!e)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new kX(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if(typeof e!=`function`){r(TypeError(e+` is not a function`));return}function i(){a.unsubscribe(),n()}var a=t.subscribe({next:function(t){try{e(t,i)}catch(e){r(e),a.unsubscribe()}},error:r,complete:n})})},t.map=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(bX(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(bX(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);var n=bX(this),r=arguments.length>1,i=!1,a=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(TypeError(`Cannot reduce an empty sequence`));n.next(a),n.complete()}})})},t.concat=function(){var e=this,t=[...arguments],n=bX(this);return new n(function(r){var i,a=0;function o(e){i=e.subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){a===t.length?(i=void 0,r.complete()):o(n.from(t[a++]))}})}return o(e),function(){i&&=(i.unsubscribe(),void 0)}})},t.flatMap=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);var n=bX(this);return new n(function(r){var i=[],a=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var a=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(a);e>=0&&i.splice(e,1),o()}});i.push(a)},error:function(e){r.error(e)},complete:function(){o()}});function o(){a.closed&&i.length===0&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),a.unsubscribe()}})},t[_X]=function(){return this},e.from=function(t){var n=typeof this==`function`?this:e;if(t==null)throw TypeError(t+` is not an object`);var r=yX(t,_X);if(r){var i=r.call(t);if(Object(i)!==i)throw TypeError(i+` is not an object`);return xX(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(mX(`iterator`)&&(r=yX(t,gX),r))return new n(function(e){CX(function(){if(!e.closed){for(var n=cX(r.call(t)),i;!(i=n()).done;){var a=i.value;if(e.next(a),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){CX(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw TypeError(t+` is not observable`)},e.of=function(){var t=[...arguments];return new(typeof this==`function`?this:e)(function(e){CX(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})})},fX(e,null,[{key:vX,get:function(){return this}}]),e}();pX()&&Object.defineProperty(jX,Symbol(`extensions`),{value:{symbol:_X,hostReportError:SX},configurable:!0});var MX=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}));function NX(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function PX(e){return NX(e)===`object`}function FX(e){return Array.isArray(e)&&e.length>0&&e.every(e=>`message`in e)}function IX(e,t){return e.length<124?e:t}var LX=`graphql-transport-ws`,RX;(function(e){e[e.InternalServerError=4500]=`InternalServerError`,e[e.InternalClientError=4005]=`InternalClientError`,e[e.BadRequest=4400]=`BadRequest`,e[e.BadResponse=4004]=`BadResponse`,e[e.Unauthorized=4401]=`Unauthorized`,e[e.Forbidden=4403]=`Forbidden`,e[e.SubprotocolNotAcceptable=4406]=`SubprotocolNotAcceptable`,e[e.ConnectionInitialisationTimeout=4408]=`ConnectionInitialisationTimeout`,e[e.ConnectionAcknowledgementTimeout=4504]=`ConnectionAcknowledgementTimeout`,e[e.SubscriberAlreadyExists=4409]=`SubscriberAlreadyExists`,e[e.TooManyInitialisationRequests=4429]=`TooManyInitialisationRequests`})(RX||={});var zX;(function(e){e.ConnectionInit=`connection_init`,e.ConnectionAck=`connection_ack`,e.Ping=`ping`,e.Pong=`pong`,e.Subscribe=`subscribe`,e.Next=`next`,e.Error=`error`,e.Complete=`complete`})(zX||={});function BX(e){if(!PX(e))throw Error(`Message is expected to be an object, but got ${NX(e)}`);if(!e.type)throw Error(`Message is missing the 'type' property`);if(typeof e.type!=`string`)throw Error(`Message is expects the 'type' property to be a string, but got ${NX(e.type)}`);switch(e.type){case zX.ConnectionInit:case zX.ConnectionAck:case zX.Ping:case zX.Pong:if(e.payload!=null&&!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case zX.Subscribe:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${NX(e.payload)}`);if(typeof e.payload.query!=`string`)throw Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${NX(e.payload.query)}`);if(e.payload.variables!=null&&!PX(e.payload.variables))throw Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${NX(e.payload.variables)}`);if(e.payload.operationName!=null&&NX(e.payload.operationName)!==`string`)throw Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${NX(e.payload.operationName)}`);if(e.payload.extensions!=null&&!PX(e.payload.extensions))throw Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${NX(e.payload.extensions)}`);break;case zX.Next:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${NX(e.payload)}`);break;case zX.Error:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!FX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case zX.Complete:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw Error(`Invalid message 'type' property "${e.type}"`)}return e}function VX(e,t){return BX(typeof e==`string`?JSON.parse(e,t):e)}function HX(e,t){return BX(e),JSON.stringify(e,t)}var UX=function(e){return this instanceof UX?(this.v=e,this):new UX(e)},WX=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof UX?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function GX(e){let{url:t,connectionParams:n,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:a=0,keepAlive:o=0,disablePong:s,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(e){let t=1e3;for(let n=0;n<e;n++)t*=2;await new Promise(e=>setTimeout(e,t+Math.floor(Math.random()*2700+300)))},shouldRetry:d=qX,isFatalConnectionProblem:f,on:p,webSocketImpl:m,generateID:h=function(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==`x`?t:t&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:_}=e,v;if(m){if(!YX(m))throw Error(`Invalid WebSocket implementation provided`);v=m}else typeof WebSocket<`u`?v=WebSocket:typeof global<`u`?v=global.WebSocket||global.MozWebSocket:typeof window<`u`&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let y=v,b=(()=>{let e=(()=>{let e={};return{on(t,n){return e[t]=n,()=>{delete e[t]}},emit(t){var n;`id`in t&&((n=e[t.id])==null||n.call(e,t))}}})(),t={connecting:p?.connecting?[p.connecting]:[],opened:p?.opened?[p.opened]:[],connected:p?.connected?[p.connected]:[],ping:p?.ping?[p.ping]:[],pong:p?.pong?[p.pong]:[],message:p?.message?[e.emit,p.message]:[e.emit],closed:p?.closed?[p.closed]:[],error:p?.error?[p.error]:[]};return{onMessage:e.on,on(e,n){let r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e,...n){for(let r of[...t[e]])r(...n)}}})();function x(e){let t=[b.on(`error`,n=>{t.forEach(e=>e()),e(n)}),b.on(`closed`,n=>{t.forEach(e=>e()),e(n)})]}let S,C=0,w,T=!1,E=0,D=!1;async function ee(){clearTimeout(w);let[e,r]=await(S??=new Promise((e,r)=>(async()=>{if(T){if(await u(E),!C)return S=void 0,r({code:1e3,reason:`All Subscriptions Gone`});E++}b.emit(`connecting`,T);let i=new y(typeof t==`function`?await t():t,LX),a,l;function d(){isFinite(o)&&o>0&&(clearTimeout(l),l=setTimeout(()=>{i.readyState===y.OPEN&&(i.send(HX({type:zX.Ping})),b.emit(`ping`,!1,void 0))},o))}x(e=>{S=void 0,clearTimeout(a),clearTimeout(l),r(e),e instanceof KX&&(i.close(4499,`Terminated`),i.onerror=null,i.onclose=null)}),i.onerror=e=>b.emit(`error`,e),i.onclose=e=>b.emit(`closed`,e),i.onopen=async()=>{try{b.emit(`opened`,i);let e=typeof n==`function`?await n():n;if(i.readyState!==y.OPEN)return;i.send(HX(e?{type:zX.ConnectionInit,payload:e}:{type:zX.ConnectionInit},g)),isFinite(c)&&c>0&&(a=setTimeout(()=>{i.close(RX.ConnectionAcknowledgementTimeout,`Connection acknowledgement timeout`)},c)),d()}catch(e){b.emit(`error`,e),i.close(RX.InternalClientError,IX(e instanceof Error?e.message:Error(e).message,`Internal client error`))}};let f=!1;i.onmessage=({data:t})=>{try{let n=VX(t,_);if(b.emit(`message`,n),n.type===`ping`||n.type===`pong`){b.emit(n.type,!0,n.payload),n.type===`pong`?d():s||(i.send(HX(n.payload?{type:zX.Pong,payload:n.payload}:{type:zX.Pong})),b.emit(`pong`,!1,n.payload));return}if(f)return;if(n.type!==zX.ConnectionAck)throw Error(`First message cannot be of type ${n.type}`);clearTimeout(a),f=!0,b.emit(`connected`,i,n.payload,T),T=!1,E=0,e([i,new Promise((e,t)=>x(t))])}catch(e){i.onmessage=null,b.emit(`error`,e),i.close(RX.BadResponse,IX(e instanceof Error?e.message:Error(e).message,`Bad response`))}}})()));e.readyState===y.CLOSING&&await r;let i=()=>{},l=new Promise(e=>i=e);return[e,i,Promise.race([l.then(()=>{if(!C){let t=()=>e.close(1e3,`Normal Closure`);isFinite(a)&&a>0?w=setTimeout(()=>{e.readyState===y.OPEN&&t()},a):t()}}),r])]}function te(e){if(qX(e)&&(JX(e.code)||[RX.InternalServerError,RX.InternalClientError,RX.BadRequest,RX.BadResponse,RX.Unauthorized,RX.SubprotocolNotAcceptable,RX.SubscriberAlreadyExists,RX.TooManyInitialisationRequests].includes(e.code)))throw e;if(D)return!1;if(qX(e)&&e.code===1e3)return C>0;if(!l||E>=l||!d(e)||f?.(e))throw e;return T=!0}r||(async()=>{for(C++;;)try{let[,,e]=await ee();await e}catch(e){try{if(!te(e))return}catch(e){return i?.(e)}}})();function ne(e,t){let n=h(e),r=!1,i=!1,a=()=>{C--,r=!0};return(async()=>{for(C++;;)try{let[o,s,c]=await ee();if(r)return s();let l=b.onMessage(n,e=>{switch(e.type){case zX.Next:t.next(e.payload);return;case zX.Error:i=!0,r=!0,t.error(e.payload),a();return;case zX.Complete:r=!0,a();return}});o.send(HX({id:n,type:zX.Subscribe,payload:e},g)),a=()=>{!r&&o.readyState===y.OPEN&&o.send(HX({id:n,type:zX.Complete},g)),C--,r=!0,s()},await c.finally(l);return}catch(e){if(!te(e))return}})().then(()=>{i||t.complete()}).catch(e=>{t.error(e)}),()=>{r||a()}}return{on:b.on,subscribe:ne,iterate(e){let t=[],n={done:!1,error:null,resolve:()=>{}},r=ne(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),i=(function(){return WX(this,arguments,function*(){for(;;){for(t.length||(yield UX(new Promise(e=>n.resolve=e)));t.length;)yield yield UX(t.shift());if(n.error)throw n.error;if(n.done)return yield UX(void 0)}})})();return i.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),i.return=async()=>(r(),{done:!0,value:void 0}),i},async dispose(){if(D=!0,S){let[e]=await S;e.close(1e3,`Normal Closure`)}},terminate(){S&&b.emit(`closed`,new KX)}}}var KX=class extends Error{constructor(){super(...arguments),this.name=`TerminatedCloseEvent`,this.message=`4499: Terminated`,this.code=4499,this.reason=`Terminated`,this.wasClean=!1}};function qX(e){return PX(e)&&`code`in e&&`reason`in e}function JX(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function YX(e){return typeof e==`function`&&`constructor`in e&&`CLOSED`in e&&`CLOSING`in e&&`CONNECTING`in e&&`OPEN`in e}var XX=i(((e,t)=>{t.exports=n;function n(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}n.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}})),ZX=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){return typeof e==`string`}e.default=t})),QX=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){return typeof e==`object`&&!!e}e.default=t}));function $X(e){var t,n=e.Symbol;return typeof n==`function`?n.observable?t=n.observable:(t=n(`observable`),n.observable=t):t=`@@observable`,t}var eZ=n((()=>{})),tZ=r({default:()=>rZ}),nZ,rZ,iZ=n((()=>{eZ(),nZ=typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:typeof module<`u`?module:Function(`return this`)(),rZ=$X(nZ)})),aZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GRAPHQL_SUBSCRIPTIONS=e.GRAPHQL_WS=void 0,e.GRAPHQL_WS=`graphql-ws`,e.GRAPHQL_SUBSCRIPTIONS=`graphql-subscriptions`})),oZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.WS_TIMEOUT=e.MIN_WS_TIMEOUT=void 0,e.MIN_WS_TIMEOUT=1e3,e.WS_TIMEOUT=3e4})),sZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){function e(){throw Error(`Static Class`)}return e.GQL_CONNECTION_INIT=`connection_init`,e.GQL_CONNECTION_ACK=`connection_ack`,e.GQL_CONNECTION_ERROR=`connection_error`,e.GQL_CONNECTION_KEEP_ALIVE=`ka`,e.GQL_CONNECTION_TERMINATE=`connection_terminate`,e.GQL_START=`start`,e.GQL_DATA=`data`,e.GQL_ERROR=`error`,e.GQL_COMPLETE=`complete`,e.GQL_STOP=`stop`,e.SUBSCRIPTION_START=`subscription_start`,e.SUBSCRIPTION_DATA=`subscription_data`,e.SUBSCRIPTION_SUCCESS=`subscription_success`,e.SUBSCRIPTION_FAIL=`subscription_fail`,e.SUBSCRIPTION_END=`subscription_end`,e.INIT=`init`,e.INIT_SUCCESS=`init_success`,e.INIT_FAIL=`init_fail`,e.KEEP_ALIVE=`keepalive`,e}()})),cZ=i((e=>{var n=e&&e.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},r=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},i=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},a=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscriptionClient=void 0;var o=typeof global<`u`?global:typeof window<`u`?window:{},s=o.WebSocket||o.MozWebSocket,c=XX(),l=MX(),u=ZX(),d=QX(),f=(Mn(),t(Fn)),p=(Nn(),t(In)),m=(iZ(),t(tZ)),h=aZ(),g=oZ(),_=sZ();e.SubscriptionClient=function(){function e(e,t,n,r){var i=t||{},a=i.connectionCallback,o=a===void 0?void 0:a,u=i.connectionParams,d=u===void 0?{}:u,f=i.minTimeout,p=f===void 0?g.MIN_WS_TIMEOUT:f,m=i.timeout,_=m===void 0?g.WS_TIMEOUT:m,v=i.reconnect,y=v===void 0?!1:v,b=i.reconnectionAttempts,x=b===void 0?1/0:b,S=i.lazy,C=S===void 0?!1:S,w=i.inactivityTimeout,T=w===void 0?0:w,E=i.wsOptionArguments,D=E===void 0?[]:E;if(this.wsImpl=n||s,!this.wsImpl)throw Error(`Unable to find native implementation, or alternative implementation for WebSocket!`);this.wsProtocols=r||h.GRAPHQL_WS,this.connectionCallback=o,this.url=e,this.operations={},this.nextOperationId=0,this.minWsTimeout=p,this.wsTimeout=_,this.unsentMessagesQueue=[],this.reconnect=y,this.reconnecting=!1,this.reconnectionAttempts=x,this.lazy=!!C,this.inactivityTimeout=T,this.closedByUser=!1,this.backoff=new c({jitter:.5}),this.eventEmitter=new l.EventEmitter,this.middlewares=[],this.client=null,this.maxConnectTimeGenerator=this.createMaxConnectTimeGenerator(),this.connectionParams=this.getConnectionParams(d),this.wsOptionArguments=D,this.lazy||this.connect()}return Object.defineProperty(e.prototype,`status`,{get:function(){return this.client===null?this.wsImpl.CLOSED:this.client.readyState},enumerable:!1,configurable:!0}),e.prototype.close=function(e,t){e===void 0&&(e=!0),t===void 0&&(t=!0),this.clearInactivityTimeout(),this.client!==null&&(this.closedByUser=t,e&&(this.clearCheckConnectionInterval(),this.clearMaxConnectTimeout(),this.clearTryReconnectTimeout(),this.unsubscribeAll(),this.sendMessage(void 0,_.default.GQL_CONNECTION_TERMINATE,null)),this.client.close(),this.client.onopen=null,this.client.onclose=null,this.client.onerror=null,this.client.onmessage=null,this.client=null,this.eventEmitter.emit(`disconnected`),e||this.tryReconnect())},e.prototype.request=function(e){var t,n=this.getObserver.bind(this),r=this.executeOperation.bind(this),i=this.unsubscribe.bind(this),a;return this.clearInactivityTimeout(),t={},t[m.default]=function(){return this},t.subscribe=function(t,o,s){var c=n(t,o,s);return a=r(e,function(e,t){e===null&&t===null?c.complete&&c.complete():e?c.error&&c.error(e[0]):c.next&&c.next(t)}),{unsubscribe:function(){a&&=(i(a),null)}}},t},e.prototype.on=function(e,t,n){var r=this.eventEmitter.on(e,t,n);return function(){r.off(e,t,n)}},e.prototype.onConnected=function(e,t){return this.on(`connected`,e,t)},e.prototype.onConnecting=function(e,t){return this.on(`connecting`,e,t)},e.prototype.onDisconnected=function(e,t){return this.on(`disconnected`,e,t)},e.prototype.onReconnected=function(e,t){return this.on(`reconnected`,e,t)},e.prototype.onReconnecting=function(e,t){return this.on(`reconnecting`,e,t)},e.prototype.onError=function(e,t){return this.on(`error`,e,t)},e.prototype.unsubscribeAll=function(){var e=this;Object.keys(this.operations).forEach(function(t){e.unsubscribe(t)})},e.prototype.applyMiddlewares=function(e){var t=this;return new Promise(function(n,r){(function(t,i){var a=function(o){if(o)r(o);else if(t.length>0){var s=t.shift();s&&s.applyMiddleware.apply(i,[e,a])}else n(e)};a()})(a([],t.middlewares,!0),t)})},e.prototype.use=function(e){var t=this;return e.map(function(e){if(typeof e.applyMiddleware==`function`)t.middlewares.push(e);else throw Error(`Middleware must implement the applyMiddleware function.`)}),this},e.prototype.getConnectionParams=function(e){return function(){return new Promise(function(t,n){if(typeof e==`function`)try{return t(e.call(null))}catch(e){return n(e)}t(e)})}},e.prototype.executeOperation=function(e,t){var n=this;this.client===null&&this.connect();var r=this.generateOperationId();return this.operations[r]={options:e,handler:t},this.applyMiddlewares(e).then(function(e){n.checkOperationOptions(e,t),n.operations[r]&&(n.operations[r]={options:e,handler:t},n.sendMessage(r,_.default.GQL_START,e))}).catch(function(e){n.unsubscribe(r),t(n.formatErrors(e))}),r},e.prototype.getObserver=function(e,t,n){return typeof e==`function`?{next:function(t){return e(t)},error:function(e){return t&&t(e)},complete:function(){return n&&n()}}:e},e.prototype.createMaxConnectTimeGenerator=function(){var e=this.minWsTimeout,t=this.wsTimeout;return new c({min:e,max:t,factor:1.2})},e.prototype.clearCheckConnectionInterval=function(){this.checkConnectionIntervalId&&=(clearInterval(this.checkConnectionIntervalId),null)},e.prototype.clearMaxConnectTimeout=function(){this.maxConnectTimeoutId&&=(clearTimeout(this.maxConnectTimeoutId),null)},e.prototype.clearTryReconnectTimeout=function(){this.tryReconnectTimeoutId&&=(clearTimeout(this.tryReconnectTimeoutId),null)},e.prototype.clearInactivityTimeout=function(){this.inactivityTimeoutId&&=(clearTimeout(this.inactivityTimeoutId),null)},e.prototype.setInactivityTimeout=function(){var e=this;this.inactivityTimeout>0&&Object.keys(this.operations).length===0&&(this.inactivityTimeoutId=setTimeout(function(){Object.keys(e.operations).length===0&&e.close()},this.inactivityTimeout))},e.prototype.checkOperationOptions=function(e,t){var n=e.query,r=e.variables,i=e.operationName;if(!n)throw Error(`Must provide a query.`);if(!t)throw Error(`Must provide an handler.`);if(!(0,u.default)(n)&&!(0,p.getOperationAST)(n,i)||i&&!(0,u.default)(i)||r&&!(0,d.default)(r))throw Error("Incorrect option types. query must be a string or a document,`operationName` must be a string, and `variables` must be an object.")},e.prototype.buildMessage=function(e,t,r){return{id:e,type:t,payload:r&&r.query?n(n({},r),{query:typeof r.query==`string`?r.query:(0,f.print)(r.query)}):r}},e.prototype.formatErrors=function(e){return Array.isArray(e)?e:e&&e.errors?this.formatErrors(e.errors):e&&e.message?[e]:[{name:`FormatedError`,message:`Unknown error`,originalError:e}]},e.prototype.sendMessage=function(e,t,n){this.sendMessageRaw(this.buildMessage(e,t,n))},e.prototype.sendMessageRaw=function(e){switch(this.status){case this.wsImpl.OPEN:var t=JSON.stringify(e);try{JSON.parse(t)}catch{this.eventEmitter.emit(`error`,Error(`Message must be JSON-serializable. Got: `+e))}this.client.send(t);break;case this.wsImpl.CONNECTING:this.unsentMessagesQueue.push(e);break;default:this.reconnecting||this.eventEmitter.emit(`error`,Error(`A message was not sent because socket is not connected, is closing or is already closed. Message was: `+JSON.stringify(e)))}},e.prototype.generateOperationId=function(){return String(++this.nextOperationId)},e.prototype.tryReconnect=function(){var e=this;if(!(!this.reconnect||this.backoff.attempts>=this.reconnectionAttempts)){this.reconnecting||=(Object.keys(this.operations).forEach(function(t){e.unsentMessagesQueue.push(e.buildMessage(t,_.default.GQL_START,e.operations[t].options))}),!0),this.clearTryReconnectTimeout();var t=this.backoff.duration();this.tryReconnectTimeoutId=setTimeout(function(){e.connect()},t)}},e.prototype.flushUnsentMessagesQueue=function(){var e=this;this.unsentMessagesQueue.forEach(function(t){e.sendMessageRaw(t)}),this.unsentMessagesQueue=[]},e.prototype.checkConnection=function(){if(this.wasKeepAliveReceived){this.wasKeepAliveReceived=!1;return}this.reconnecting||this.close(!1,!0)},e.prototype.checkMaxConnectTimeout=function(){var e=this;this.clearMaxConnectTimeout(),this.maxConnectTimeoutId=setTimeout(function(){e.status!==e.wsImpl.OPEN&&(e.reconnecting=!0,e.close(!1,!0))},this.maxConnectTimeGenerator.duration())},e.prototype.connect=function(){var e,t=this;this.client=new((e=this.wsImpl).bind.apply(e,a([void 0,this.url,this.wsProtocols],this.wsOptionArguments,!1))),this.checkMaxConnectTimeout(),this.client.onopen=function(){return r(t,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:if(this.status!==this.wsImpl.OPEN)return[3,4];this.clearMaxConnectTimeout(),this.closedByUser=!1,this.eventEmitter.emit(this.reconnecting?`reconnecting`:`connecting`),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.connectionParams()];case 2:return e=n.sent(),this.sendMessage(void 0,_.default.GQL_CONNECTION_INIT,e),this.flushUnsentMessagesQueue(),[3,4];case 3:return t=n.sent(),this.sendMessage(void 0,_.default.GQL_CONNECTION_ERROR,t),this.flushUnsentMessagesQueue(),[3,4];case 4:return[2]}})})},this.client.onclose=function(){t.closedByUser||t.close(!1,!1)},this.client.onerror=function(e){t.eventEmitter.emit(`error`,e)},this.client.onmessage=function(e){var n=e.data;t.processReceivedData(n)}},e.prototype.processReceivedData=function(e){var t,r;try{t=JSON.parse(e),r=t.id}catch{throw Error(`Message must be JSON-parseable. Got: `+e)}if([_.default.GQL_DATA,_.default.GQL_COMPLETE,_.default.GQL_ERROR].indexOf(t.type)!==-1&&!this.operations[r]){this.unsubscribe(r);return}switch(t.type){case _.default.GQL_CONNECTION_ERROR:this.connectionCallback&&this.connectionCallback(t.payload);break;case _.default.GQL_CONNECTION_ACK:this.eventEmitter.emit(this.reconnecting?`reconnected`:`connected`,t.payload),this.reconnecting=!1,this.backoff.reset(),this.maxConnectTimeGenerator.reset(),this.connectionCallback&&this.connectionCallback();break;case _.default.GQL_COMPLETE:var i=this.operations[r].handler;delete this.operations[r],i.call(this,null,null);break;case _.default.GQL_ERROR:this.operations[r].handler(this.formatErrors(t.payload),null),delete this.operations[r];break;case _.default.GQL_DATA:var a=t.payload.errors?n(n({},t.payload),{errors:this.formatErrors(t.payload.errors)}):t.payload;this.operations[r].handler(null,a);break;case _.default.GQL_CONNECTION_KEEP_ALIVE:var o=this.wasKeepAliveReceived===void 0;this.wasKeepAliveReceived=!0,o&&this.checkConnection(),this.checkConnectionIntervalId&&(clearInterval(this.checkConnectionIntervalId),this.checkConnection()),this.checkConnectionIntervalId=setInterval(this.checkConnection.bind(this),this.wsTimeout);break;default:throw Error(`Invalid message type!`)}},e.prototype.unsubscribe=function(e){this.operations[e]&&(delete this.operations[e],this.setInactivityTimeout(),this.sendMessage(e,_.default.GQL_STOP,void 0))},e}()})),lZ=e(MX(),1),uZ=cZ(),dZ=(e=!1)=>e?`https://embed.apollo.local:3000`:`https://sandbox.embed.apollographql.com`,fZ=`SchemaError`,pZ=`SchemaResponse`,mZ=`ExplorerRequest`,hZ=`ExplorerResponse`,gZ=`ExplorerSubscriptionRequest`,_Z=`ExplorerSubscriptionResponse`,vZ=`ExplorerSubscriptionTermination`,yZ=`ExplorerSetSocketError`,bZ=`ExplorerSetSocketStatus`,xZ=e=>`apollo-embed-${e}`,SZ=`ExplorerListeningForHandshake`,CZ=`HandshakeResponse`,wZ=`SetPartialAuthenticationTokenForParent`,TZ=`TriggerLogoutInParent`,EZ=`ExplorerListeningForPartialToken`,DZ=`PartialAuthenticationTokenResponse`,OZ=`PreflightOAuthRequest`,kZ=`PreflightOAuthProviderResponse`,AZ=`PreflightOAuthResponse`,jZ=`IntrospectionQueryWithHeaders`,MZ=`ParentLogoutSuccess`,NZ=({legacyIncludeCookies:e})=>(t,n)=>fetch(t,Object.assign(Object.assign({},n),e?{credentials:`include`}:e===void 0?{}:{credentials:`omit`}));function PZ(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function FZ(e,t){if(e.body===null)throw Error(`Missing body`);if(typeof e.body.tee!=`function`)throw Error(`Streaming bodies not supported by provided fetch implementation`);let n=new TextDecoder(`utf-8`),r=``,i=`--${t.parameters.get(`boundary`)||`-`}`,a=e.body.getReader();return{closeReadableStream:()=>a.cancel(),observable:new jX(e=>{function t(){a.read().then(a=>{var o,s;if(a.done){(o=e.complete)==null||o.call(e);return}let c=n.decode(a.value);r+=c;let l=r.indexOf(i);for(;l>-1;){let t=r.slice(0,l);if(r=r.slice(l+i.length),t.trim()){let n=`\r
2169
2169
  \r
package/dist/index.html CHANGED
@@ -21,7 +21,7 @@
21
21
  opacity: 1;
22
22
  }
23
23
  </style>
24
- <script type="module" crossorigin src="/assets/index-CncI0rgJ.js"></script>
24
+ <script type="module" crossorigin src="/assets/index-CTRDk3g_.js"></script>
25
25
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-COnpUsM8.js">
26
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-chakra-D7rbFWyN.js">
27
27
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-Bj2o6Vez.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revisium/admin",
3
- "version": "2.6.0-alpha.1",
3
+ "version": "2.6.0",
4
4
  "description": "Revisium is a tool (UI/API) inspired by JSON (JSON Schema) and Git, designed to provide a flexible and low-level headless CMS solution.",
5
5
  "private": false,
6
6
  "homepage": "https://revisium.io",