@lobu/runtime-server 21.2.0 → 21.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/owletto/dist/assets/_-CLhipgJI.js +1 -0
  3. package/dist/owletto/dist/assets/{_-C1iPVDAS.js → _-D0ZVGAIA.js} +2 -2
  4. package/dist/owletto/dist/assets/{_agentId-DvhFYLLv.js → _agentId-BLXUf3ot.js} +1 -1
  5. package/dist/owletto/dist/assets/_agentId-DnI66MF3.js +1 -0
  6. package/dist/owletto/dist/assets/{_automationId-NuFSEFlw.js → _automationId-ziwseLb7.js} +1 -1
  7. package/dist/owletto/dist/assets/{_connectorKey._connectionId-D_FhMGN1.js → _connectorKey._connectionId-B6V3ySFK.js} +1 -1
  8. package/dist/owletto/dist/assets/{_connectorKey.index-B8AZikVg.js → _connectorKey.index-CR5u_dtt.js} +1 -1
  9. package/dist/owletto/dist/assets/{_conversationId-D1Cx42I0.js → _conversationId-FBMYmOl8.js} +1 -1
  10. package/dist/owletto/dist/assets/{_deploymentId-BjtZC8Oo.js → _deploymentId-DNTXbT_m.js} +1 -1
  11. package/dist/owletto/dist/assets/_name-B37LKIxH.js +1 -0
  12. package/dist/owletto/dist/assets/{_owner-c8L8M4FP.js → _owner-BxYumqC2.js} +1 -1
  13. package/dist/owletto/dist/assets/_shape-Bxz-04jR.js +1 -0
  14. package/dist/owletto/dist/assets/_skillKey-D5MFbiw2.js +1 -0
  15. package/dist/owletto/dist/assets/{_slug-Nlm2ziLr.js → _slug-Dlhit09k.js} +1 -1
  16. package/dist/owletto/dist/assets/_viewKey-C6535i-t.js +1 -0
  17. package/dist/owletto/dist/assets/_viewKey-CQCtY3Y8.js +1 -0
  18. package/dist/owletto/dist/assets/_viewKey-CxKfKbRa.js +1 -0
  19. package/dist/owletto/dist/assets/{accept-invitation-BfqbITxp.js → accept-invitation-BQQwec3R.js} +1 -1
  20. package/dist/owletto/dist/assets/{activity-route-view-CTQEg3Us.js → activity-route-view-BwThvdGs.js} +1 -1
  21. package/dist/owletto/dist/assets/{agent-card-controls-49SIdmyU.js → agent-card-controls-B3RhzsPz.js} +1 -1
  22. package/dist/owletto/dist/assets/{agent-client-setup-list-ChwHMq4Q.js → agent-client-setup-list-BFtgRwe8.js} +1 -1
  23. package/dist/owletto/dist/assets/{agent-connect-pages-CJntJskO.js → agent-connect-pages-BO4wQn4L.js} +1 -1
  24. package/dist/owletto/dist/assets/{agent-editor-form-CEEFNek5.js → agent-editor-form-BYC4uSNz.js} +1 -1
  25. package/dist/owletto/dist/assets/{agent-guardrails-route-BF_RvzHv.js → agent-guardrails-route-Dp02G1AQ.js} +1 -1
  26. package/dist/owletto/dist/assets/{agent-loading-shells-Cve_XIMW.js → agent-loading-shells-OagauQzV.js} +1 -1
  27. package/dist/owletto/dist/assets/{agent-permissions-matrix-DEYa123T.js → agent-permissions-matrix-B9Ho3P1t.js} +1 -1
  28. package/dist/owletto/dist/assets/{agent-skill-context-DuS7Ojm_.js → agent-skill-context-BAr2Dw3F.js} +1 -1
  29. package/dist/owletto/dist/assets/{agent-skills-route-BItudd8s.js → agent-skills-route-B4VUnVi0.js} +1 -1
  30. package/dist/owletto/dist/assets/{agent-subpage-shell-BkGzpmv5.js → agent-subpage-shell-Dz8I-GUt.js} +1 -1
  31. package/dist/owletto/dist/assets/{agent-thread-DhCFggHZ.js → agent-thread-B9-cdkaV.js} +1 -1
  32. package/dist/owletto/dist/assets/agents-D0CIg4b9.js +1 -0
  33. package/dist/owletto/dist/assets/{agents-workbench-BZaoiFNY.js → agents-workbench-C2sr5h82.js} +1 -1
  34. package/dist/owletto/dist/assets/{app._appId-0fp8NC9-.js → app._appId-DLsJ_QWS.js} +1 -1
  35. package/dist/owletto/dist/assets/{automation-detail-content-C08Ef137.js → automation-detail-content-9Rjb_I9j.js} +1 -1
  36. package/dist/owletto/dist/assets/automations-D0CIg4b9.js +1 -0
  37. package/dist/owletto/dist/assets/{calendar-CvEqJnKS.js → calendar-DAiyi1ZL.js} +1 -1
  38. package/dist/owletto/dist/assets/{callback-BfjlxUcL.js → callback-CaRe2TOT.js} +1 -1
  39. package/dist/owletto/dist/assets/{card-MXMmjz9G.js → card-CMmh2mzo.js} +1 -1
  40. package/dist/owletto/dist/assets/{claim-B5igXpyF.js → claim-CYHnUF7G.js} +1 -1
  41. package/dist/owletto/dist/assets/{clients-DqMOcwpO.js → clients-Cp1BJ28u.js} +1 -1
  42. package/dist/owletto/dist/assets/{code-editor-bpbaa7f6.js → code-editor-CYsR2VBP.js} +1 -1
  43. package/dist/owletto/dist/assets/connect-CZip2g_B.js +1 -0
  44. package/dist/owletto/dist/assets/connect._clientId-CEKY8Dnv.js +1 -0
  45. package/dist/owletto/dist/assets/{connected._clientId-BWVr-PMm.js → connected._clientId-C5xRjxNO.js} +1 -1
  46. package/dist/owletto/dist/assets/{connection-D-dXA43c.js → connection-C06HZ241.js} +1 -1
  47. package/dist/owletto/dist/assets/{connection-feed-detail-XYK-ubKG.js → connection-feed-detail-D1whY5hL.js} +1 -1
  48. package/dist/owletto/dist/assets/{connector-provenance-RL_DcF2q.js → connector-provenance-BjKiUhYE.js} +1 -1
  49. package/dist/owletto/dist/assets/{connectors-B2_PLuXP.js → connectors-Baejya0T.js} +1 -1
  50. package/dist/owletto/dist/assets/{consent-CMrkyIfi.js → consent-CfYDldcF.js} +1 -1
  51. package/dist/owletto/dist/assets/{core.esm-BrIR85HL.js → core.esm-QA7BQgiK.js} +1 -1
  52. package/dist/owletto/dist/assets/create-C3P-3_8O.js +1 -0
  53. package/dist/owletto/dist/assets/create-CwnrPUEw.js +1 -0
  54. package/dist/owletto/dist/assets/{create-UTXCruIl.js → create-DOScS9Gl.js} +1 -1
  55. package/dist/owletto/dist/assets/{create-automation-form-BHir-pIp.js → create-automation-form-CuxiIRCF.js} +1 -1
  56. package/dist/owletto/dist/assets/{create._connectorKey-qjd3B6p5.js → create._connectorKey-Bjv3lCf8.js} +1 -1
  57. package/dist/owletto/dist/assets/{cronstrue-BwvvZn_Y.js → cronstrue-2GHCtD7h.js} +1 -1
  58. package/dist/owletto/dist/assets/{deployments-DHAx8TBs.js → deployments-ByBv1DW-.js} +1 -1
  59. package/dist/owletto/dist/assets/deployments-C-_ECORv.js +1 -0
  60. package/dist/owletto/dist/assets/{deployments-body-B54mJoZC.js → deployments-body-Bm2upStd.js} +1 -1
  61. package/dist/owletto/dist/assets/{device-Bi_9KNKQ.js → device-B0i7Xp8y.js} +1 -1
  62. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkmmka9d.js → device-pin-tombstone-Bd6vS2zu.js} +1 -1
  63. package/dist/owletto/dist/assets/{device-rows-CkTAaZ3m.js → device-rows-Bwf8qDte.js} +1 -1
  64. package/dist/owletto/dist/assets/{device._deviceId-B_WqDhY5.js → device._deviceId-DJLAesm3.js} +1 -1
  65. package/dist/owletto/dist/assets/{entity-options-Bm1sbpmt.js → entity-options-CrbS6K-i.js} +1 -1
  66. package/dist/owletto/dist/assets/{entity-page-DZUGex-P.js → entity-page-ijZe_1-6.js} +1 -1
  67. package/dist/owletto/dist/assets/{entity-type-page-DSBcVv9e.js → entity-type-page-onp2Tk_E.js} +1 -1
  68. package/dist/owletto/dist/assets/{event-page-B837JclA.js → event-page-C0B2UDY-.js} +1 -1
  69. package/dist/owletto/dist/assets/{events-feed-BgvLTppV.js → events-feed-DK35T4g7.js} +1 -1
  70. package/dist/owletto/dist/assets/{full-page-spinner-ByBsHimW.js → full-page-spinner-Dd8eEaxq.js} +1 -1
  71. package/dist/owletto/dist/assets/guardrails-DKO8_J-G.js +1 -0
  72. package/dist/owletto/dist/assets/identity-CKM54vrM.js +1 -0
  73. package/dist/owletto/dist/assets/{index-DjYcFuq9.js → index--VmN5WxW.js} +1 -1
  74. package/dist/owletto/dist/assets/{index-GZkujXG1.js → index-B2AmRqYh.js} +1589 -1589
  75. package/dist/owletto/dist/assets/{index-Be5BLMwZ.js → index-B_rcEgFX.js} +1 -1
  76. package/dist/owletto/dist/assets/{index-Dpf0I2N4.js → index-BmhGe6-Z.js} +1 -1
  77. package/dist/owletto/dist/assets/index-C1dJSGrL.js +1 -0
  78. package/dist/owletto/dist/assets/index-CAFw4qCb.js +1 -0
  79. package/dist/owletto/dist/assets/{index-DBs2lhwE.js → index-CCcc_xBw.js} +1 -1
  80. package/dist/owletto/dist/assets/{index-DqrjJ9LB.js → index-CLU3gXVm.js} +1 -1
  81. package/dist/owletto/dist/assets/{index-Cane2GT3.js → index-Cf0GJoiG.js} +1 -1
  82. package/dist/owletto/dist/assets/index-CqQVnAY-.js +1 -0
  83. package/dist/owletto/dist/assets/{index-BrT0gBIi.js → index-CxT0uyIe.js} +1 -1
  84. package/dist/owletto/dist/assets/index-DR08e6Ec.js +1 -0
  85. package/dist/owletto/dist/assets/index-DYb9L5FC.js +1 -0
  86. package/dist/owletto/dist/assets/{index-C1MV7ajb.js → index-DlepU3cY.js} +1 -1
  87. package/dist/owletto/dist/assets/index-SUUcQGT-.js +1 -0
  88. package/dist/owletto/dist/assets/index-SdiFOfR1.js +1 -0
  89. package/dist/owletto/dist/assets/index-zcfi5r1l.js +1 -0
  90. package/dist/owletto/dist/assets/{json-diff-D6sv990W.js → json-diff-ClBBYBQD.js} +1 -1
  91. package/dist/owletto/dist/assets/{list-skeleton-B39wKVT1.js → list-skeleton-BtWn2eo2.js} +1 -1
  92. package/dist/owletto/dist/assets/{login-DxnhCvKx.js → login-d3PdO-qV.js} +1 -1
  93. package/dist/owletto/dist/assets/{logout-Lvib6Kk7.js → logout-DgckxwLn.js} +1 -1
  94. package/dist/owletto/dist/assets/{member-scope-gate-CM-GNviT.js → member-scope-gate-DXOCfx-v.js} +1 -1
  95. package/dist/owletto/dist/assets/{memory-browse-page-DKmyI1FJ.js → memory-browse-page-CeAnKoTR.js} +1 -1
  96. package/dist/owletto/dist/assets/{missing-view-CAFqvZpi.js → missing-view-DrZ8m8yo.js} +1 -1
  97. package/dist/owletto/dist/assets/{model-selector-BoudNhPZ.js → model-selector-CapL1ARf.js} +1 -1
  98. package/dist/owletto/dist/assets/models-CB8mhq7j.js +1 -0
  99. package/dist/owletto/dist/assets/{new-Jp_DtYBt.js → new-BBUb-VR4.js} +1 -1
  100. package/dist/owletto/dist/assets/{new-e3C5Yokb.js → new-CBLJ25_w.js} +1 -1
  101. package/dist/owletto/dist/assets/{new-CKSjnGM9.js → new-tTXB4qBW.js} +1 -1
  102. package/dist/owletto/dist/assets/{oauth-workspace-access-DuPiMSr2.js → oauth-workspace-access-DearynqZ.js} +1 -1
  103. package/dist/owletto/dist/assets/{organization-DUPBruFP.js → organization-BgdBg-PJ.js} +1 -1
  104. package/dist/owletto/dist/assets/{permissions-DqkX4mTH.js → permissions-h_qSft1A.js} +1 -1
  105. package/dist/owletto/dist/assets/{proposal-review-shell-C04RG1qM.js → proposal-review-shell-D4YNrrye.js} +1 -1
  106. package/dist/owletto/dist/assets/{recent-BmxCZQ8j.js → recent-JiBNvZzD.js} +1 -1
  107. package/dist/owletto/dist/assets/{renderer-eFSU65zm.js → renderer-DgPLyEbx.js} +1 -1
  108. package/dist/owletto/dist/assets/{reset-password-BinCwene.js → reset-password-B8tWPtIj.js} +1 -1
  109. package/dist/owletto/dist/assets/{runs-DwThk2CI.js → runs-oHveuEUB.js} +1 -1
  110. package/dist/owletto/dist/assets/{runs-panel-DfxWCV7K.js → runs-panel-C56GDaJm.js} +1 -1
  111. package/dist/owletto/dist/assets/{runs-table-Dh7FL3Va.js → runs-table-BUKDjiBc.js} +1 -1
  112. package/dist/owletto/dist/assets/{schema-value-normalization-CPLeOm7K.js → schema-value-normalization-3JuM_r1H.js} +1 -1
  113. package/dist/owletto/dist/assets/settings-DaKg6U5O.js +1 -0
  114. package/dist/owletto/dist/assets/{settings-DLg89oqz.js → settings-DhnRi2nq.js} +1 -1
  115. package/dist/owletto/dist/assets/skills-BpQncuMC.js +1 -0
  116. package/dist/owletto/dist/assets/{switch-Dcx3_8kM.js → switch-BQ40_DMb.js} +1 -1
  117. package/dist/owletto/dist/assets/{use-applied-views-BpvIIgWG.js → use-applied-views-B-Z-Weji.js} +1 -1
  118. package/dist/owletto/dist/assets/{use-mention-search-Vndny_Gd.js → use-mention-search-B4DfZFm5.js} +1 -1
  119. package/dist/owletto/dist/assets/{view-frame-DxiuLSGA.js → view-frame-C7ciEoLo.js} +1 -1
  120. package/dist/owletto/dist/index.html +1 -1
  121. package/dist/server-main.bundle.mjs +2266 -2125
  122. package/npm-shrinkwrap.json +5 -5
  123. package/package.json +1 -1
  124. package/vendor/connector-sdk/package.json +1 -1
  125. package/vendor/core/package.json +1 -1
  126. package/vendor/views/dist/api.d.ts +42 -5
  127. package/vendor/views/dist/api.js +63 -6
  128. package/vendor/views/package.json +1 -1
  129. package/dist/owletto/dist/assets/_-TlzPuBqI.js +0 -1
  130. package/dist/owletto/dist/assets/_agentId-DutmYPK7.js +0 -1
  131. package/dist/owletto/dist/assets/_name-DTlirHDv.js +0 -1
  132. package/dist/owletto/dist/assets/_shape-DQaUs_O7.js +0 -1
  133. package/dist/owletto/dist/assets/_skillKey-CJSEeyG0.js +0 -1
  134. package/dist/owletto/dist/assets/_viewKey-BK9NZs21.js +0 -1
  135. package/dist/owletto/dist/assets/_viewKey-D-Og614G.js +0 -1
  136. package/dist/owletto/dist/assets/_viewKey-DIFCFECi.js +0 -1
  137. package/dist/owletto/dist/assets/agents-BIA5SCAT.js +0 -1
  138. package/dist/owletto/dist/assets/automations-BIA5SCAT.js +0 -1
  139. package/dist/owletto/dist/assets/connect-DpQrbviv.js +0 -1
  140. package/dist/owletto/dist/assets/connect._clientId-A_F-UzTr.js +0 -1
  141. package/dist/owletto/dist/assets/create-DhxcVjNh.js +0 -1
  142. package/dist/owletto/dist/assets/create-jVkf6V76.js +0 -1
  143. package/dist/owletto/dist/assets/deployments-CSJHFlJz.js +0 -1
  144. package/dist/owletto/dist/assets/guardrails-cMGe6IIe.js +0 -1
  145. package/dist/owletto/dist/assets/identity-BORtpi5L.js +0 -1
  146. package/dist/owletto/dist/assets/index-B5lGxbbZ.js +0 -1
  147. package/dist/owletto/dist/assets/index-BGz-9DDG.js +0 -1
  148. package/dist/owletto/dist/assets/index-BrzsfXR-.js +0 -1
  149. package/dist/owletto/dist/assets/index-C31QOVZH.js +0 -1
  150. package/dist/owletto/dist/assets/index-C6USRbY8.js +0 -1
  151. package/dist/owletto/dist/assets/index-Dh8ubWqr.js +0 -1
  152. package/dist/owletto/dist/assets/index-DpgsgDFc.js +0 -1
  153. package/dist/owletto/dist/assets/index-pFFCzVi5.js +0 -1
  154. package/dist/owletto/dist/assets/models-B8BuBmLu.js +0 -1
  155. package/dist/owletto/dist/assets/settings-CSrpSUqR.js +0 -1
  156. package/dist/owletto/dist/assets/skills-PQP0fNxc.js +0 -1
@@ -1 +1 @@
1
- import{az as U}from"./index-GZkujXG1.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
1
+ import{az as U}from"./index-B2AmRqYh.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
@@ -1 +1 @@
1
- import{cw as r,f3 as l,aj as i,e9 as u,cx as c,ac as d}from"./index-GZkujXG1.js";function o(e,a=""){return`${d}/api/${e}/deployments${a}`}const y=50;function f(e){const{slug:a}=r();return l({queryKey:["deployments-feed",a,e?.resourceKind,e?.resourceId],queryFn:async({pageParam:t})=>{const n=new URLSearchParams({limit:String(y)});t!==null&&n.set("before_id",String(t)),e&&(n.set("resource_kind",e.resourceKind),n.set("resource_id",e.resourceId));const s=await i(o(a,`?${n.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await u(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!a,staleTime:15e3,retry:!1})}function h(e){const{slug:a}=r();return c({queryKey:["deployment-detail",a,e],queryFn:async()=>{const t=await i(o(a,`/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch deployment"),await t.json())},enabled:!!a&&!!e,staleTime:15e3,retry:!1})}function g(e){const{slug:a}=r();return c({queryKey:["deployment-change-detail",a,e],queryFn:async()=>{const t=await i(o(a,`/changes/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch change"),(await t.json()).change)},enabled:!!a&&!!e,staleTime:15e3,retry:!1})}export{g as a,h as b,f as u};
1
+ import{cw as r,f3 as l,aj as i,e9 as u,cx as c,ac as d}from"./index-B2AmRqYh.js";function o(e,a=""){return`${d}/api/${e}/deployments${a}`}const y=50;function f(e){const{slug:a}=r();return l({queryKey:["deployments-feed",a,e?.resourceKind,e?.resourceId],queryFn:async({pageParam:t})=>{const n=new URLSearchParams({limit:String(y)});t!==null&&n.set("before_id",String(t)),e&&(n.set("resource_kind",e.resourceKind),n.set("resource_id",e.resourceId));const s=await i(o(a,`?${n.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await u(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!a,staleTime:15e3,retry:!1})}function h(e){const{slug:a}=r();return c({queryKey:["deployment-detail",a,e],queryFn:async()=>{const t=await i(o(a,`/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch deployment"),await t.json())},enabled:!!a&&!!e,staleTime:15e3,retry:!1})}function g(e){const{slug:a}=r();return c({queryKey:["deployment-change-detail",a,e],queryFn:async()=>{const t=await i(o(a,`/changes/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch change"),(await t.json()).change)},enabled:!!a&&!!e,staleTime:15e3,retry:!1})}export{g as a,h as b,f as u};
@@ -0,0 +1 @@
1
+ import{j as t,Y as o}from"./index-B2AmRqYh.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +1 @@
1
- import{j as a,c6 as x,c7 as p,bk as m,h0 as c,B as f,x as o,L as i,h1 as h,ab as r}from"./index-GZkujXG1.js";import{u as g}from"./deployments-DHAx8TBs.js";function y(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function j(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function N(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const u="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function B({owner:e}){const t=g(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(x,{label:"deployments"})}):t.isError?a.jsx(p,{label:"deployments"}):n.length===0?a.jsx(m,{icon:c,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const d=l===n.length-1;return s.type==="deployment"?a.jsx(v,{item:s,owner:e,isLast:d},s.id):a.jsx(b,{item:s,owner:e,isLast:d},s.id)})}),t.hasNextPage?a.jsx(f,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function v({item:e,owner:t,isLast:n}){const l=[N(e.counts),e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(c,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),y(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function b({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),j(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{B as D,j as c,y as d};
1
+ import{j as a,c6 as x,c7 as p,bk as m,h0 as c,B as f,x as o,L as i,h1 as h,ab as r}from"./index-B2AmRqYh.js";import{u as g}from"./deployments-ByBv1DW-.js";function y(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function j(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function N(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const u="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function B({owner:e}){const t=g(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(x,{label:"deployments"})}):t.isError?a.jsx(p,{label:"deployments"}):n.length===0?a.jsx(m,{icon:c,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const d=l===n.length-1;return s.type==="deployment"?a.jsx(v,{item:s,owner:e,isLast:d},s.id):a.jsx(b,{item:s,owner:e,isLast:d},s.id)})}),t.hasNextPage?a.jsx(f,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function v({item:e,owner:t,isLast:n}){const l=[N(e.counts),e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(c,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),y(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function b({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),j(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{B as D,j as c,y as d};
@@ -1 +1 @@
1
- import{aa as ge,p as xe,r as o,j as e,a7 as ve,B as R,ab as X,ac as oe}from"./index-GZkujXG1.js";import{s as ye,g as we,u as je,a as be,b as ke,A as Ce,W as Ne}from"./oauth-workspace-access-DuPiMSr2.js";import{C as Z,a as ee,b as se,d as re,c as te}from"./card-MXMmjz9G.js";function W(r){return r.trim().toUpperCase()}const Se=15e3;async function Ae(r){const c=new AbortController,_=window.setTimeout(()=>c.abort(),Se);try{const i=await fetch(`${oe}/oauth/device/info?user_code=${encodeURIComponent(r)}`,{credentials:"include",signal:c.signal}),b=await i.json().catch(()=>null);return{response:i,data:b}}catch(i){throw c.signal.aborted?new Error("Verification timed out. Check your connection and try again."):i}finally{window.clearTimeout(_)}}function P(r,c){return typeof r?.error_description=="string"&&r.error_description||typeof r?.error=="string"&&r.error||c}function Te(){const r=ge.useSearch(),{session:c,isReady:_}=xe(),i=!_,[b,ne]=o.useState(r.user_code||""),[n,f]=o.useState(null),[O,a]=o.useState(null),[l,ce]=o.useState(null),[I,E]=o.useState(null),[T,L]=o.useState(null),[D,U]=o.useState(!1),g=o.useRef(0),v=r.return_to,M=v?"app":"terminal",ie=!!r.user_code,k=W(b),d=I?.code===k?I:null,h=d!==null,y=d?.scopes??[],ae=o.useMemo(()=>ye(y,T),[T,y]),F=y.some(s=>s.startsWith("mcp:")),C=y.includes("device_worker:run"),le=y.includes("connections:token"),V=C||le,N=we(d?.resource),w=h&&F&&!N,B=d?.multiWorkspaceGrantsEnabled===!0,{orgList:$,workspaceAccess:de,setWorkspaceAccess:ue,selectedOrgIds:G,toggleSelectedOrgId:pe,resetWorkspaceSelection:he,personalOrgId:me,orgsLoading:q,orgsError:S,retryOrgs:Y,workspaceSelectionReady:fe}=je({requirePersonal:w&&C,allowMultiple:B}),x=$.find(s=>s.id===me)??null,A=h&&C&&!N,H=w?fe:!A||!q&&!S&&x!==null,z=o.useCallback(async s=>{const u=++g.current;f("verify"),a(null),U(!1);try{const{response:m,data:t}=await Ae(s);if(u!==g.current)return;if(m.status===401){const j=new URL("/auth/login",window.location.origin);j.searchParams.set("callbackUrl",window.location.href),window.location.href=j.toString();return}if(!m.ok||!t)throw new Error(P(t,"Failed to verify device authorization code"));const p=Array.isArray(t.scopes)?t.scopes:[];E({code:s,clientName:t.client_name??null,scopes:p,resource:typeof t.resource=="string"?t.resource:null,multiWorkspaceGrantsEnabled:t.multi_workspace_grants_enabled===!0}),L(be(p))}catch(m){if(u!==g.current)return;E(null),a(m instanceof Error?m.message:"Unexpected error")}finally{u===g.current&&f(null)}},[]);ke(!!c,i),o.useEffect(()=>{if(!(i||!c||!r.user_code))return z(W(r.user_code)),()=>{g.current+=1}},[c,i,r.user_code,z]);const J=async s=>{const u=k;if(!u){a(`Please enter the code shown in your ${M}.`);return}if(!h){a("Verify the device code before approving or denying access.");return}if(s&&V&&!D){a("Confirm that you initiated this request and that the device code matches.");return}if(s&&!H){a(S?"Workspaces could not be loaded. Retry before approving.":A&&!x?"Your personal workspace is required before this device can be approved.":"Choose at least one workspace before approving.");return}const m=d?.clientName??null;f(s?"approve":"deny"),a(null);try{const t=await fetch(`${oe}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:u,approved:s,...s?{scope:ae.join(" ")}:{},...s&&w?{workspace_access:de,organization_ids:G}:{},...s&&A&&x?{organization_id:x.id}:{}})}),p=await t.json().catch(()=>null);if(t.status===401){const Q=new URL("/auth/login",window.location.origin);Q.searchParams.set("callbackUrl",window.location.href),window.location.href=Q.toString();return}if(!t.ok)throw new Error(P(p,"Failed to process device authorization"));const j=s?"approved":"denied";if(p?.status!==j)throw new Error(P(p,s?"The server did not confirm this approval. The device is still waiting — try again.":"The server did not confirm this denial. Try again."));const K=typeof p.user_code=="string"?W(p.user_code):null;if(K!==null&&K!==u)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");f(null),ce({outcome:j,code:u,clientName:m})}catch(t){f(null),a(t instanceof Error?t.message:"Unexpected error")}};return o.useEffect(()=>{if(l?.outcome!=="approved"||!v)return;const s=window.setTimeout(()=>{window.location.href=v},600);return()=>window.clearTimeout(s)},[l,v]),i||!c?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):l?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(Z,{className:"w-full max-w-lg",role:"status","aria-live":"polite",children:[e.jsxs(ee,{children:[e.jsx(se,{children:l.outcome==="approved"?ie?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(re,{children:l.outcome==="approved"?v?"Returning you to the app...":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab."})]}),e.jsx(te,{className:"text-sm",children:e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:l.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:l.code}),l.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:l.clientName})]}):null]})})]})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(Z,{className:"w-full max-w-lg",children:[e.jsxs(ee,{children:[e.jsx(se,{asChild:!0,children:e.jsx("h1",{children:h?"Authorize application":"Connect a device"})}),e.jsx(re,{children:h?"Review the application, access level, and workspaces.":`Enter the code shown in your ${M}.`})]}),e.jsxs(te,{className:"space-y-5","aria-busy":n!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(ve,{id:"user-code",value:b,disabled:n==="approve"||n==="deny",onChange:s=>{g.current+=1,ne(s.target.value.toUpperCase()),E(null),L(null),he(),U(!1),f(null),a(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!r.user_code})]}),d&&e.jsx(Ce,{idPrefix:"oauth-device",clientName:d.clientName,requestedScopes:d.scopes,accessLevel:T,onAccessLevelChange:L,sensitiveScopesAcknowledged:D,onSensitiveScopesAcknowledgedChange:U,disabled:n!==null}),w&&e.jsx(Ne,{idPrefix:"oauth-device",allowMultiple:B,orgList:$,selectedOrgIds:G,onWorkspaceAccessChange:ue,onSelectedOrgChange:pe,orgsLoading:q,orgsError:S,onRetry:Y,disabled:n!==null,personalRequired:C}),h&&F&&N&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",N]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),A&&!w&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Device home"}),q?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your personal workspace..."}):S?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",onClick:Y,children:"Retry"})]}):x?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:x.name}),e.jsx(X,{variant:"outline",children:"Personal"}),e.jsx(X,{variant:"secondary",children:"Required"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Device data stays in your personal workspace."})]}):e.jsx("p",{role:"alert",className:"text-destructive",children:"A personal workspace is required to authorize this device."})]}),O&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:O}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>J(!1),disabled:n!==null,children:n==="deny"?"Denying...":"Deny"}),e.jsx(R,{type:"button",onClick:()=>J(!0),disabled:n!==null||!H||V&&!D,children:n==="approve"?"Approving...":"Approve"})]}):e.jsx(R,{type:"button",onClick:()=>z(k),disabled:n!==null||!k,children:n==="verify"?"Verifying...":"Continue"})})]})]})})}export{Te as component};
1
+ import{aa as ge,p as xe,r as o,j as e,a7 as ve,B as R,ab as X,ac as oe}from"./index-B2AmRqYh.js";import{s as ye,g as we,u as je,a as be,b as ke,A as Ce,W as Ne}from"./oauth-workspace-access-DearynqZ.js";import{C as Z,a as ee,b as se,d as re,c as te}from"./card-CMmh2mzo.js";function W(r){return r.trim().toUpperCase()}const Se=15e3;async function Ae(r){const c=new AbortController,_=window.setTimeout(()=>c.abort(),Se);try{const i=await fetch(`${oe}/oauth/device/info?user_code=${encodeURIComponent(r)}`,{credentials:"include",signal:c.signal}),b=await i.json().catch(()=>null);return{response:i,data:b}}catch(i){throw c.signal.aborted?new Error("Verification timed out. Check your connection and try again."):i}finally{window.clearTimeout(_)}}function P(r,c){return typeof r?.error_description=="string"&&r.error_description||typeof r?.error=="string"&&r.error||c}function Te(){const r=ge.useSearch(),{session:c,isReady:_}=xe(),i=!_,[b,ne]=o.useState(r.user_code||""),[n,f]=o.useState(null),[O,a]=o.useState(null),[l,ce]=o.useState(null),[I,E]=o.useState(null),[T,L]=o.useState(null),[D,U]=o.useState(!1),g=o.useRef(0),v=r.return_to,M=v?"app":"terminal",ie=!!r.user_code,k=W(b),d=I?.code===k?I:null,h=d!==null,y=d?.scopes??[],ae=o.useMemo(()=>ye(y,T),[T,y]),F=y.some(s=>s.startsWith("mcp:")),C=y.includes("device_worker:run"),le=y.includes("connections:token"),V=C||le,N=we(d?.resource),w=h&&F&&!N,B=d?.multiWorkspaceGrantsEnabled===!0,{orgList:$,workspaceAccess:de,setWorkspaceAccess:ue,selectedOrgIds:G,toggleSelectedOrgId:pe,resetWorkspaceSelection:he,personalOrgId:me,orgsLoading:q,orgsError:S,retryOrgs:Y,workspaceSelectionReady:fe}=je({requirePersonal:w&&C,allowMultiple:B}),x=$.find(s=>s.id===me)??null,A=h&&C&&!N,H=w?fe:!A||!q&&!S&&x!==null,z=o.useCallback(async s=>{const u=++g.current;f("verify"),a(null),U(!1);try{const{response:m,data:t}=await Ae(s);if(u!==g.current)return;if(m.status===401){const j=new URL("/auth/login",window.location.origin);j.searchParams.set("callbackUrl",window.location.href),window.location.href=j.toString();return}if(!m.ok||!t)throw new Error(P(t,"Failed to verify device authorization code"));const p=Array.isArray(t.scopes)?t.scopes:[];E({code:s,clientName:t.client_name??null,scopes:p,resource:typeof t.resource=="string"?t.resource:null,multiWorkspaceGrantsEnabled:t.multi_workspace_grants_enabled===!0}),L(be(p))}catch(m){if(u!==g.current)return;E(null),a(m instanceof Error?m.message:"Unexpected error")}finally{u===g.current&&f(null)}},[]);ke(!!c,i),o.useEffect(()=>{if(!(i||!c||!r.user_code))return z(W(r.user_code)),()=>{g.current+=1}},[c,i,r.user_code,z]);const J=async s=>{const u=k;if(!u){a(`Please enter the code shown in your ${M}.`);return}if(!h){a("Verify the device code before approving or denying access.");return}if(s&&V&&!D){a("Confirm that you initiated this request and that the device code matches.");return}if(s&&!H){a(S?"Workspaces could not be loaded. Retry before approving.":A&&!x?"Your personal workspace is required before this device can be approved.":"Choose at least one workspace before approving.");return}const m=d?.clientName??null;f(s?"approve":"deny"),a(null);try{const t=await fetch(`${oe}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:u,approved:s,...s?{scope:ae.join(" ")}:{},...s&&w?{workspace_access:de,organization_ids:G}:{},...s&&A&&x?{organization_id:x.id}:{}})}),p=await t.json().catch(()=>null);if(t.status===401){const Q=new URL("/auth/login",window.location.origin);Q.searchParams.set("callbackUrl",window.location.href),window.location.href=Q.toString();return}if(!t.ok)throw new Error(P(p,"Failed to process device authorization"));const j=s?"approved":"denied";if(p?.status!==j)throw new Error(P(p,s?"The server did not confirm this approval. The device is still waiting — try again.":"The server did not confirm this denial. Try again."));const K=typeof p.user_code=="string"?W(p.user_code):null;if(K!==null&&K!==u)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");f(null),ce({outcome:j,code:u,clientName:m})}catch(t){f(null),a(t instanceof Error?t.message:"Unexpected error")}};return o.useEffect(()=>{if(l?.outcome!=="approved"||!v)return;const s=window.setTimeout(()=>{window.location.href=v},600);return()=>window.clearTimeout(s)},[l,v]),i||!c?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):l?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(Z,{className:"w-full max-w-lg",role:"status","aria-live":"polite",children:[e.jsxs(ee,{children:[e.jsx(se,{children:l.outcome==="approved"?ie?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(re,{children:l.outcome==="approved"?v?"Returning you to the app...":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab."})]}),e.jsx(te,{className:"text-sm",children:e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:l.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:l.code}),l.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:l.clientName})]}):null]})})]})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(Z,{className:"w-full max-w-lg",children:[e.jsxs(ee,{children:[e.jsx(se,{asChild:!0,children:e.jsx("h1",{children:h?"Authorize application":"Connect a device"})}),e.jsx(re,{children:h?"Review the application, access level, and workspaces.":`Enter the code shown in your ${M}.`})]}),e.jsxs(te,{className:"space-y-5","aria-busy":n!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(ve,{id:"user-code",value:b,disabled:n==="approve"||n==="deny",onChange:s=>{g.current+=1,ne(s.target.value.toUpperCase()),E(null),L(null),he(),U(!1),f(null),a(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!r.user_code})]}),d&&e.jsx(Ce,{idPrefix:"oauth-device",clientName:d.clientName,requestedScopes:d.scopes,accessLevel:T,onAccessLevelChange:L,sensitiveScopesAcknowledged:D,onSensitiveScopesAcknowledgedChange:U,disabled:n!==null}),w&&e.jsx(Ne,{idPrefix:"oauth-device",allowMultiple:B,orgList:$,selectedOrgIds:G,onWorkspaceAccessChange:ue,onSelectedOrgChange:pe,orgsLoading:q,orgsError:S,onRetry:Y,disabled:n!==null,personalRequired:C}),h&&F&&N&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",N]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),A&&!w&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Device home"}),q?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your personal workspace..."}):S?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",onClick:Y,children:"Retry"})]}):x?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:x.name}),e.jsx(X,{variant:"outline",children:"Personal"}),e.jsx(X,{variant:"secondary",children:"Required"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Device data stays in your personal workspace."})]}):e.jsx("p",{role:"alert",className:"text-destructive",children:"A personal workspace is required to authorize this device."})]}),O&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:O}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>J(!1),disabled:n!==null,children:n==="deny"?"Denying...":"Deny"}),e.jsx(R,{type:"button",onClick:()=>J(!0),disabled:n!==null||!H||V&&!D,children:n==="approve"?"Approving...":"Approve"})]}):e.jsx(R,{type:"button",onClick:()=>z(k),disabled:n!==null||!k,children:n==="verify"?"Verifying...":"Continue"})})]})]})})}export{Te as component};
@@ -1 +1 @@
1
- import{j as e,fP as C,i as w,hO as k,r as x,n as b,bk as F,hP as v,B as u,hQ as L,x as A,bu as I,af as P,aP as S,hR as y,aA as R,hS as E,hT as O,eL as _,L as $,P as z,b as T,hU as B,hV as D,o as V,hW as K,eN as q}from"./index-GZkujXG1.js";import{a as M,R as U}from"./runs-panel-DfxWCV7K.js";import{S as H,g as Q,c as N,b as W,d as X}from"./runs-table-Dh7FL3Va.js";function ae({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(M,{}),e.jsx(C,{rows:s})]})}function G(s,a){const n=s?.display_name;return typeof n=="string"&&n.trim()?n:a?.trim()||"Folder"}function J({connectionId:s}){const{data:a=[],isLoading:n}=w(s),o=k(),[c,r]=x.useState(null),i=a.filter(t=>t.config?.folder_id!=null),d=()=>{window.location.href=y("feeds/add"),R("Opening Lobu…",{description:"Choose a folder in the Lobu app. It appears here after the next sync."})},l=t=>{const m=t.config?.folder_id;typeof m=="string"&&(window.location.href=y(`feeds/remove?folder_id=${encodeURIComponent(m)}`)),o.mutate(t.id),r(null)};return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{size:"lg"})}):i.length===0?e.jsx(F,{icon:v,title:"No folders yet",description:"Add a local folder for Lobu to read text files from.",actionLabel:"Add folder",onAction:d}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Folders"}),e.jsxs(u,{variant:"outline",size:"sm",onClick:d,children:[e.jsx(L,{className:"mr-2 h-4 w-4"}),"Add folder"]})]}),e.jsx("div",{className:"space-y-2",children:i.map(t=>e.jsxs("div",{className:P(S,"flex items-center justify-between gap-3 px-3 py-2"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:G(t.config,t.display_name)}),e.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[t.event_count>0?`${t.event_count} document${t.event_count===1?"":"s"}`:"No documents yet",t.last_sync_at?` · synced ${A(t.last_sync_at)}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(H,{status:Q(t.status),children:t.status}),c===t.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"destructive",size:"sm",onClick:()=>l(t),children:"Remove"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>r(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive","aria-label":"Remove folder",onClick:()=>r(t.id),children:e.jsx(I,{className:"h-4 w-4"})})]})]},t.id))})]})}function ne({connection:s,connectorDef:a,ownerSlug:n,openSettings:o=!1,authResult:c,showActivity:r=!0,embedded:i=!1}){const[d,l]=x.useState(o);x.useEffect(()=>{o&&l(!0)},[o]);const t=s.id,m=s.connector_key,h=s.facets?.chat??!1,p=h?"Channels":"Feeds",f=s.has_operations===!0,j=s.feed_count>0||N(a),g=e.jsx(D,{connection:s,connectorDef:a,ownerSlug:n});return e.jsxs("div",{className:"space-y-6",children:[c&&e.jsx(E,{result:c}),s.auth_profile_kind==="oauth_account"&&e.jsx(O,{connection:s,connectorDef:a,onReview:()=>{l(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),m==="local.directory"&&e.jsx(J,{connectionId:t}),(j||f)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[j&&(i?e.jsx(_,{title:p,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:N(a)?e.jsx(u,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs($,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:n,connectorKey:m,connectionId:String(t)},search:{addFeed:!0},children:[e.jsx(z,{className:"h-3.5 w-3.5"}),h?"Add channel":"Add source"]})}):null,children:e.jsx(W,{connection:s,ownerSlug:n,connectorKey:m,connectorDef:a})}):e.jsx(X,{connection:s,ownerSlug:n,title:p})),f&&(i?e.jsx(T,{connection:s,ownerSlug:n}):e.jsx(Y,{connection:s,ownerSlug:n}))]}),i?e.jsx(B,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:d,onOpenChange:l,children:g}):g,r&&!h&&e.jsx(_,{title:"Recent activity",children:e.jsx(U,{scope:{connectionId:t},ownerSlug:n})})]})}function Y({connection:s,ownerSlug:a}){const n=V(),{data:o=[],isLoading:c,isError:r}=K(s.id),i=o.filter(l=>l.readiness==="scope_upgrade_required").length,d=c?"Loading actions…":r?"Could not load actions — open to retry":`${o.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(q,{title:"Actions",summary:d,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:a}})})}const Z=new Set(["Device was removed","Device was moved to another workspace"]);function ie(s){const a=s.error_message??null;return!a||!Z.has(a)?a:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:a}export{ne as C,ae as R,ie as c};
1
+ import{j as e,fP as C,i as w,hO as k,r as x,n as b,bk as F,hP as v,B as u,hQ as L,x as A,bu as I,af as P,aP as S,hR as y,aA as R,hS as E,hT as O,eL as _,L as $,P as z,b as T,hU as B,hV as D,o as V,hW as K,eN as q}from"./index-B2AmRqYh.js";import{a as M,R as U}from"./runs-panel-C56GDaJm.js";import{S as H,g as Q,c as N,b as W,d as X}from"./runs-table-BUKDjiBc.js";function ae({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(M,{}),e.jsx(C,{rows:s})]})}function G(s,a){const n=s?.display_name;return typeof n=="string"&&n.trim()?n:a?.trim()||"Folder"}function J({connectionId:s}){const{data:a=[],isLoading:n}=w(s),o=k(),[c,r]=x.useState(null),i=a.filter(t=>t.config?.folder_id!=null),d=()=>{window.location.href=y("feeds/add"),R("Opening Lobu…",{description:"Choose a folder in the Lobu app. It appears here after the next sync."})},l=t=>{const m=t.config?.folder_id;typeof m=="string"&&(window.location.href=y(`feeds/remove?folder_id=${encodeURIComponent(m)}`)),o.mutate(t.id),r(null)};return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{size:"lg"})}):i.length===0?e.jsx(F,{icon:v,title:"No folders yet",description:"Add a local folder for Lobu to read text files from.",actionLabel:"Add folder",onAction:d}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Folders"}),e.jsxs(u,{variant:"outline",size:"sm",onClick:d,children:[e.jsx(L,{className:"mr-2 h-4 w-4"}),"Add folder"]})]}),e.jsx("div",{className:"space-y-2",children:i.map(t=>e.jsxs("div",{className:P(S,"flex items-center justify-between gap-3 px-3 py-2"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:G(t.config,t.display_name)}),e.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[t.event_count>0?`${t.event_count} document${t.event_count===1?"":"s"}`:"No documents yet",t.last_sync_at?` · synced ${A(t.last_sync_at)}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(H,{status:Q(t.status),children:t.status}),c===t.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"destructive",size:"sm",onClick:()=>l(t),children:"Remove"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>r(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive","aria-label":"Remove folder",onClick:()=>r(t.id),children:e.jsx(I,{className:"h-4 w-4"})})]})]},t.id))})]})}function ne({connection:s,connectorDef:a,ownerSlug:n,openSettings:o=!1,authResult:c,showActivity:r=!0,embedded:i=!1}){const[d,l]=x.useState(o);x.useEffect(()=>{o&&l(!0)},[o]);const t=s.id,m=s.connector_key,h=s.facets?.chat??!1,p=h?"Channels":"Feeds",f=s.has_operations===!0,j=s.feed_count>0||N(a),g=e.jsx(D,{connection:s,connectorDef:a,ownerSlug:n});return e.jsxs("div",{className:"space-y-6",children:[c&&e.jsx(E,{result:c}),s.auth_profile_kind==="oauth_account"&&e.jsx(O,{connection:s,connectorDef:a,onReview:()=>{l(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),m==="local.directory"&&e.jsx(J,{connectionId:t}),(j||f)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[j&&(i?e.jsx(_,{title:p,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:N(a)?e.jsx(u,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs($,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:n,connectorKey:m,connectionId:String(t)},search:{addFeed:!0},children:[e.jsx(z,{className:"h-3.5 w-3.5"}),h?"Add channel":"Add source"]})}):null,children:e.jsx(W,{connection:s,ownerSlug:n,connectorKey:m,connectorDef:a})}):e.jsx(X,{connection:s,ownerSlug:n,title:p})),f&&(i?e.jsx(T,{connection:s,ownerSlug:n}):e.jsx(Y,{connection:s,ownerSlug:n}))]}),i?e.jsx(B,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:d,onOpenChange:l,children:g}):g,r&&!h&&e.jsx(_,{title:"Recent activity",children:e.jsx(U,{scope:{connectionId:t},ownerSlug:n})})]})}function Y({connection:s,ownerSlug:a}){const n=V(),{data:o=[],isLoading:c,isError:r}=K(s.id),i=o.filter(l=>l.readiness==="scope_upgrade_required").length,d=c?"Loading actions…":r?"Could not load actions — open to retry":`${o.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(q,{title:"Actions",summary:d,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:a}})})}const Z=new Set(["Device was removed","Device was moved to another workspace"]);function ie(s){const a=s.error_message??null;return!a||!Z.has(a)?a:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:a}export{ne as C,ae as R,ie as c};
@@ -1 +1 @@
1
- import{co as u,eM as l,bo as f}from"./index-GZkujXG1.js";function p(n){return l(n)&&n.required_capability!=="os.files"}const m={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function _(n){return n==="macos"?"macOS":n==="ios"?"iOS":n==="chrome-extension"?"Chrome":n??"Unknown platform"}function y(n,c,o){const s=new Map(c.map(e=>[e.connector_key,e]));return n.map(e=>{const i={...m};for(const r of e.connectors){if(r.organization_slug!==o)continue;const a=s.get(r.connector_key);if(a?.connections.some(t=>t.id===r.connection_id))for(const t of Object.keys(i))i[t]||=a.facets[t]}return{device:e,facets:i,connector:{key:`device-row:${e.id}`,name:u(e),description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:e.online?"active":"inactive",login_enabled:!1,installed:!0}}})}function b(n){const c=_(f(n)),o=n.connector_count,s=`${o} ${o===1?"connector":"connectors"}`;return[c,s,n.online?"online":"offline"].join(" · ")}export{y as b,p as c,b as d};
1
+ import{co as u,eM as l,bo as f}from"./index-B2AmRqYh.js";function p(n){return l(n)&&n.required_capability!=="os.files"}const m={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function _(n){return n==="macos"?"macOS":n==="ios"?"iOS":n==="chrome-extension"?"Chrome":n??"Unknown platform"}function y(n,c,o){const s=new Map(c.map(e=>[e.connector_key,e]));return n.map(e=>{const i={...m};for(const r of e.connectors){if(r.organization_slug!==o)continue;const a=s.get(r.connector_key);if(a?.connections.some(t=>t.id===r.connection_id))for(const t of Object.keys(i))i[t]||=a.facets[t]}return{device:e,facets:i,connector:{key:`device-row:${e.id}`,name:u(e),description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:e.online?"active":"inactive",login_enabled:!1,installed:!0}}})}function b(n){const c=_(f(n)),o=n.connector_count,s=`${o} ${o===1?"connector":"connectors"}`;return[c,s,n.online?"online":"offline"].join(" · ")}export{y as b,p as c,b as d};
@@ -1 +1 @@
1
- import{d7 as K,hG as O,j as e,eL as b,S as _,B as j,bo as A,L as w,dj as E,r as N,c_ as F,d0 as G,d1 as H,a as V,_ as W,b9 as Y,hH as q,hI as J,hJ as U,b5 as Q,ba as P,hK as X,hL as Z,hk as ee,bD as se,gA as ne,hM as L,a7 as te,co as R,n as $,bu as ae,F as ie,bn as ce,gB as oe,gC as re,x as le,hN as B,aS as de}from"./index-GZkujXG1.js";import{c as me,C as xe,R as ue}from"./device-pin-tombstone-Dkmmka9d.js";import{R as he}from"./runs-panel-DfxWCV7K.js";import{S as pe,g as fe}from"./runs-table-Dh7FL3Va.js";import{c as ge}from"./connection-label-BobuYiAG.js";import{c as je}from"./device-rows-CkTAaZ3m.js";import"./runs-DwThk2CI.js";function ve({device:t,organizationId:s,ownerSlug:r,selectedConnection:p,openSettings:u}){const{data:d=[],isLoading:g,isError:h,refetch:l}=K(s),c=new Map(d.map(i=>[i.key,i])),a=new Map,m=[];for(const i of t.connectors){if(i.organization_slug!==r)continue;const o=c.get(i.connector_key);if(!o||!je(o)){m.push(i);continue}const v=o.required_capability??`connector:${o.key}`,f=a.get(v)??{key:v,name:o.name,connections:[]};f.name=O[v]??o.name,f.connections.push(i),a.set(v,f)}return e.jsxs(e.Fragment,{children:[e.jsxs(b,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),t.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!s||g?e.jsx(_,{className:"h-24 w-full"}):h?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void l(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(i=>e.jsx(Ne,{group:i,deviceId:t.id,organizationId:s,ownerSlug:r,definitionsByKey:c,selectedConnection:p,openSettings:u},i.key))}),A(t)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),s&&m.length>0&&!g&&!h?e.jsxs(b,{title:"Connections",count:String(m.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:m.map(i=>e.jsxs(w,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:r,connectorKey:i.connector_key,connectionId:String(i.connection_id)},search:{},className:"flex items-center gap-3 py-3 text-sm hover:text-primary",children:[e.jsx("span",{className:"min-w-0 flex-1",children:i.display_name||c.get(i.connector_key)?.name||i.connector_key}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.status}),e.jsx(E,{className:"size-3.5 text-muted-foreground"})]},i.connection_id))})]}):null]})}function Ne({group:t,deviceId:s,organizationId:r,ownerSlug:p,definitionsByKey:u,selectedConnection:d,openSettings:g}){const h=t.connections.some(a=>a.connection_id===d),[l,c]=N.useState(h);return N.useEffect(()=>{h&&d!==void 0&&c(!0)},[h,d]),e.jsxs(F,{open:l,onOpenChange:c,children:[e.jsxs(G,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(E,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:t.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:t.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":t.connections.length>1?`${t.connections.length} connections`:"Configured"})]}),e.jsx(H,{forceMount:!0,hidden:!l,className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:t.connections.map(a=>e.jsx(be,{summary:a,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u.get(a.connector_key),openSettings:a.connection_id===d&&g},a.connection_id))})})]})}function be({summary:t,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u,openSettings:d}){const{data:g=[],isLoading:h,isError:l,refetch:c}=V(r,{connectionIds:[t.connection_id]}),a=g.find(o=>o.id===t.connection_id&&o.device_worker_id===s),m=u?.name??t.connector_key,i=a?me(a):null;return e.jsxs("section",{id:`connection-${t.connection_id}`,"aria-label":m,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:ge(a)}),e.jsx("span",{children:a.status})]}):null,h||!r?e.jsx(_,{className:"h-24 w-full"}):l?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void c(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[i?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:i}):null,e.jsx(xe,{connection:a,connectorDef:u,ownerSlug:p,openSettings:d,showActivity:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function _e({ownerSlug:t,deviceId:s,organizationId:r,selectedConnection:p,openSettings:u}){const d=W(),{data:g=[],isLoading:h}=Y(),l=q(),c=J(),[a,m]=N.useState(!1),[i,o]=N.useState(!1),[v,f]=N.useState(""),n=U(g,s),y=n?.id??s,{data:k=[]}=Q(r,{profileKind:"browser_session"}),C=N.useMemo(()=>k.filter(x=>x.device_worker_id===y&&x.status!=="revoked"),[k,y]),D=n?.label?.trim()??"";if(N.useEffect(()=>{i||f(D)},[D,i]),h)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 rounded"}),e.jsx(_,{className:"h-5 w-40"})]}),e.jsx(ue,{})]});if(!n)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const I=A(n),T=X(n.app_version),z=Z(n,T),S=()=>{const x=v.trim(),M=n.label?.trim()??"";if(x===M){o(!1);return}c.mutate({deviceWorkerId:n.id,label:x.length===0?null:x},{onSuccess:()=>o(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(ee,{header:e.jsx(ne,{breadcrumb:e.jsx(oe,{crumbs:[e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:re,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{platform:I,className:"h-5 w-5"}),title:i?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(te,{"aria-label":"Device name",value:v,onChange:x=>f(x.target.value),placeholder:R({...n,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),a||S()):x.key==="Escape"&&(m(!1),f(n.label?.trim()??""),o(!1))}}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",n.connector_count>0?`and un-pins ${n.connector_count} connector${n.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(j,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>{m(!1),d({to:"/$owner/connectors",params:{owner:t},search:{}})}}),children:[l.isPending?e.jsx($,{className:"mr-1.5"}):null,l.isPending?"Removing...":"Confirm remove"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:l.isPending,onClick:()=>m(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{size:"sm",onClick:S,disabled:c.isPending,children:[c.isPending?e.jsx($,{className:"mr-1.5"}):null,c.isPending?"Saving...":"Save"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c.isPending,onClick:()=>{f(n.label?.trim()??""),o(!1)},children:"Cancel"}),e.jsxs(j,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:c.isPending||l.isPending,onClick:()=>m(!0),children:[e.jsx(ae,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[R(n),e.jsx(j,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{m(!1),f(n.label?.trim()??""),o(!0)},children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${n.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),n.online?n.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:z||void 0,caption:`Last seen ${L(new Date(n.last_seen_at),{addSuffix:!0})}${n.last_sync_at?` · Last sync ${L(new Date(n.last_sync_at),{addSuffix:!0})}`:""}`}),children:[n.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),n.connector_error_count," connector",n.connector_error_count===1?"":"s"," pinned to this device ",n.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(ve,{device:n,organizationId:r,ownerSlug:t,selectedConnection:p,openSettings:u}),C.length>0?e.jsx(b,{title:"Browser auth profiles",children:e.jsx(ye,{profiles:C})}):null,e.jsx(b,{title:"Runs",children:e.jsx(he,{scope:{deviceId:y},ownerSlug:t})})]})})}function ye({profiles:t}){return t.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:t.map(s=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:s.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.connector_key??"Any connector"}),s.browser_kind?e.jsxs("span",{children:["· ",s.browser_kind]}):null,s.captured_at?e.jsxs("span",{title:s.captured_at,children:["· captured ",le(s.captured_at)]}):null,typeof s.cookie_count=="number"?e.jsxs("span",{children:["· ",s.cookie_count," cookie",s.cookie_count===1?"":"s"]}):null]})]}),e.jsx(pe,{status:s.is_expired?"error":fe(s.status),showDot:!0,children:s.is_expired?"expired":s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},s.id))})})}function Re(){const{owner:t,deviceId:s}=B.useParams(),{connection:r,settings:p}=B.useSearch();return e.jsx(de,{owner:t,children:({ownerSlug:u,organizationId:d})=>e.jsx(_e,{ownerSlug:u,deviceId:s,organizationId:d,selectedConnection:r,openSettings:p})})}export{Re as component};
1
+ import{d7 as K,hG as O,j as e,eL as b,S as _,B as j,bo as A,L as w,dj as E,r as N,c_ as F,d0 as G,d1 as H,a as V,_ as W,b9 as Y,hH as q,hI as J,hJ as U,b5 as Q,ba as P,hK as X,hL as Z,hk as ee,bD as se,gA as ne,hM as L,a7 as te,co as R,n as $,bu as ae,F as ie,bn as ce,gB as oe,gC as re,x as le,hN as B,aS as de}from"./index-B2AmRqYh.js";import{c as me,C as xe,R as ue}from"./device-pin-tombstone-Bd6vS2zu.js";import{R as he}from"./runs-panel-C56GDaJm.js";import{S as pe,g as fe}from"./runs-table-BUKDjiBc.js";import{c as ge}from"./connection-label-BobuYiAG.js";import{c as je}from"./device-rows-Bwf8qDte.js";import"./runs-oHveuEUB.js";function ve({device:t,organizationId:s,ownerSlug:r,selectedConnection:p,openSettings:u}){const{data:d=[],isLoading:g,isError:h,refetch:l}=K(s),c=new Map(d.map(i=>[i.key,i])),a=new Map,m=[];for(const i of t.connectors){if(i.organization_slug!==r)continue;const o=c.get(i.connector_key);if(!o||!je(o)){m.push(i);continue}const v=o.required_capability??`connector:${o.key}`,f=a.get(v)??{key:v,name:o.name,connections:[]};f.name=O[v]??o.name,f.connections.push(i),a.set(v,f)}return e.jsxs(e.Fragment,{children:[e.jsxs(b,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),t.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!s||g?e.jsx(_,{className:"h-24 w-full"}):h?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void l(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(i=>e.jsx(Ne,{group:i,deviceId:t.id,organizationId:s,ownerSlug:r,definitionsByKey:c,selectedConnection:p,openSettings:u},i.key))}),A(t)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),s&&m.length>0&&!g&&!h?e.jsxs(b,{title:"Connections",count:String(m.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:m.map(i=>e.jsxs(w,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:r,connectorKey:i.connector_key,connectionId:String(i.connection_id)},search:{},className:"flex items-center gap-3 py-3 text-sm hover:text-primary",children:[e.jsx("span",{className:"min-w-0 flex-1",children:i.display_name||c.get(i.connector_key)?.name||i.connector_key}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.status}),e.jsx(E,{className:"size-3.5 text-muted-foreground"})]},i.connection_id))})]}):null]})}function Ne({group:t,deviceId:s,organizationId:r,ownerSlug:p,definitionsByKey:u,selectedConnection:d,openSettings:g}){const h=t.connections.some(a=>a.connection_id===d),[l,c]=N.useState(h);return N.useEffect(()=>{h&&d!==void 0&&c(!0)},[h,d]),e.jsxs(F,{open:l,onOpenChange:c,children:[e.jsxs(G,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(E,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:t.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:t.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":t.connections.length>1?`${t.connections.length} connections`:"Configured"})]}),e.jsx(H,{forceMount:!0,hidden:!l,className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:t.connections.map(a=>e.jsx(be,{summary:a,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u.get(a.connector_key),openSettings:a.connection_id===d&&g},a.connection_id))})})]})}function be({summary:t,deviceId:s,organizationId:r,ownerSlug:p,connectorDef:u,openSettings:d}){const{data:g=[],isLoading:h,isError:l,refetch:c}=V(r,{connectionIds:[t.connection_id]}),a=g.find(o=>o.id===t.connection_id&&o.device_worker_id===s),m=u?.name??t.connector_key,i=a?me(a):null;return e.jsxs("section",{id:`connection-${t.connection_id}`,"aria-label":m,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:ge(a)}),e.jsx("span",{children:a.status})]}):null,h||!r?e.jsx(_,{className:"h-24 w-full"}):l?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>void c(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[i?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:i}):null,e.jsx(xe,{connection:a,connectorDef:u,ownerSlug:p,openSettings:d,showActivity:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function _e({ownerSlug:t,deviceId:s,organizationId:r,selectedConnection:p,openSettings:u}){const d=W(),{data:g=[],isLoading:h}=Y(),l=q(),c=J(),[a,m]=N.useState(!1),[i,o]=N.useState(!1),[v,f]=N.useState(""),n=U(g,s),y=n?.id??s,{data:k=[]}=Q(r,{profileKind:"browser_session"}),C=N.useMemo(()=>k.filter(x=>x.device_worker_id===y&&x.status!=="revoked"),[k,y]),D=n?.label?.trim()??"";if(N.useEffect(()=>{i||f(D)},[D,i]),h)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 rounded"}),e.jsx(_,{className:"h-5 w-40"})]}),e.jsx(ue,{})]});if(!n)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const I=A(n),T=X(n.app_version),z=Z(n,T),S=()=>{const x=v.trim(),M=n.label?.trim()??"";if(x===M){o(!1);return}c.mutate({deviceWorkerId:n.id,label:x.length===0?null:x},{onSuccess:()=>o(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(ee,{header:e.jsx(ne,{breadcrumb:e.jsx(oe,{crumbs:[e.jsx(w,{to:"/$owner/connectors",params:{owner:t},search:{},className:re,children:"Connectors"},"connectors")]}),icon:e.jsx(ce,{platform:I,className:"h-5 w-5"}),title:i?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(te,{"aria-label":"Device name",value:v,onChange:x=>f(x.target.value),placeholder:R({...n,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),a||S()):x.key==="Escape"&&(m(!1),f(n.label?.trim()??""),o(!1))}}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",n.connector_count>0?`and un-pins ${n.connector_count} connector${n.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(j,{variant:"destructive",size:"sm",disabled:l.isPending,onClick:()=>l.mutate(n.id,{onSuccess:()=>{m(!1),d({to:"/$owner/connectors",params:{owner:t},search:{}})}}),children:[l.isPending?e.jsx($,{className:"mr-1.5"}):null,l.isPending?"Removing...":"Confirm remove"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:l.isPending,onClick:()=>m(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{size:"sm",onClick:S,disabled:c.isPending,children:[c.isPending?e.jsx($,{className:"mr-1.5"}):null,c.isPending?"Saving...":"Save"]}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c.isPending,onClick:()=>{f(n.label?.trim()??""),o(!1)},children:"Cancel"}),e.jsxs(j,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:c.isPending||l.isPending,onClick:()=>m(!0),children:[e.jsx(ae,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[R(n),e.jsx(j,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{m(!1),f(n.label?.trim()??""),o(!0)},children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${n.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),n.online?n.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:z||void 0,caption:`Last seen ${L(new Date(n.last_seen_at),{addSuffix:!0})}${n.last_sync_at?` · Last sync ${L(new Date(n.last_sync_at),{addSuffix:!0})}`:""}`}),children:[n.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),n.connector_error_count," connector",n.connector_error_count===1?"":"s"," pinned to this device ",n.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(ve,{device:n,organizationId:r,ownerSlug:t,selectedConnection:p,openSettings:u}),C.length>0?e.jsx(b,{title:"Browser auth profiles",children:e.jsx(ye,{profiles:C})}):null,e.jsx(b,{title:"Runs",children:e.jsx(he,{scope:{deviceId:y},ownerSlug:t})})]})})}function ye({profiles:t}){return t.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:t.map(s=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:s.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.connector_key??"Any connector"}),s.browser_kind?e.jsxs("span",{children:["· ",s.browser_kind]}):null,s.captured_at?e.jsxs("span",{title:s.captured_at,children:["· captured ",le(s.captured_at)]}):null,typeof s.cookie_count=="number"?e.jsxs("span",{children:["· ",s.cookie_count," cookie",s.cookie_count===1?"":"s"]}):null]})]}),e.jsx(pe,{status:s.is_expired?"error":fe(s.status),showDot:!0,children:s.is_expired?"expired":s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},s.id))})})}function Re(){const{owner:t,deviceId:s}=B.useParams(),{connection:r,settings:p}=B.useSearch();return e.jsx(de,{owner:t,children:({ownerSlug:u,organizationId:d})=>e.jsx(_e,{ownerSlug:u,deviceId:s,organizationId:d,selectedConnection:r,openSettings:p})})}export{Re as component};
@@ -1 +1 @@
1
- import{_ as x,q as _,j as e,bR as C,bS as m,bT as S,bU as b,bV as c,fh as u}from"./index-GZkujXG1.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function T({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:d,placeholder:g="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:p="Connection"}){const f=x(),l=_().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:d,children:[e.jsx(m,{"aria-label":p,children:e.jsx(S,{placeholder:g})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{T as C,v as f};
1
+ import{_ as x,q as _,j as e,bR as C,bS as m,bT as S,bU as b,bV as c,fh as u}from"./index-B2AmRqYh.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function T({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:d,placeholder:g="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:p="Connection"}){const f=x(),l=_().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:d,children:[e.jsx(m,{"aria-label":p,children:e.jsx(S,{placeholder:g})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{T as C,v as f};
@@ -1 +1 @@
1
- import{Z as Q,ip as re,r as _,j as e,S as F,_ as O,iq as le,ab as G,af as E,cy as oe,ir as ce,dE as C,a3 as de,is as U,it as me,aP as ee,fZ as ue,eS as xe,eW as ge,eU as he,eX as H,fR as pe,fS as fe,fL as ye,dr as se,fT as ve,iu as je,cb as be,cc as S,fP as Ne,cf as we,a6 as I,a7 as W,dY as _e,bD as Se,B as N,g2 as ke,ek as Ce,fU as Ee,L as Te,eD as De,iv as Pe,o as Le,iw as $e,dC as Fe,c9 as Ie}from"./index-GZkujXG1.js";import{a as J,c as q,S as Oe,D as Re,E as Ae}from"./schema-value-normalization-CPLeOm7K.js";import{V as K,T as ze,a as Me,b as X,c as Y}from"./view-frame-DxiuLSGA.js";import{V as Z,M as Ve}from"./missing-view-CAFqvZpi.js";import{u as Be}from"./use-applied-views-BpvIIgWG.js";import"./calendar-CvEqJnKS.js";import"./app-bridge-BH3g2mKG.js";function Ue({entityId:s,ownerSlug:t}){const{orgContext:n}=Q(),{data:l,isLoading:a}=re(s,n),i=_.useMemo(()=>{if(!l)return[];const r=new Map;for(const c of l.rows){const d=r.get(c.relationship_type_slug);d?d.rows.push(c):r.set(c.relationship_type_slug,{slug:c.relationship_type_slug,label:c.relationship_type_name,rows:[c]})}return[...r.values()]},[l]);return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"h-4 w-32"}),e.jsx(F,{className:"h-12 w-full rounded-lg"}),e.jsx(F,{className:"h-12 w-full rounded-lg"})]}):!l||l.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:i.map(({slug:r,label:c,rows:d})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:d.length})]}),e.jsx("ul",{className:"space-y-1",children:d.map(x=>e.jsx(He,{entityId:s,row:x,ownerSlug:t},x.id))})]},r))})}function He({entityId:s,row:t,ownerSlug:n}){const l=O(),{orgContext:a}=Q(),[i,r]=_.useState(!1),[c,d]=_.useState(!1),x=t.from_entity_id===t.to_entity_id,h=t.from_entity_id===s,p=x?"this entity":h?t.to_entity_name??`Entity #${t.to_entity_id}`:t.from_entity_name??`Entity #${t.from_entity_id}`,u=h?t.to_entity_type:t.from_entity_type,g=h?t.to_entity_id:t.from_entity_id,o=u?`${u} · ${p}`:p;async function f(){r(!0),d(!1);try{const w=[],j=new Set;let b=g;for(;b!==null;){if(j.has(b))throw new Error("Cyclic entity ancestry");j.add(b);const{entity:y}=await oe("manage_entity",{action:"get",entity_id:b},ce(a));w.unshift({entity_type:y.entity_type,slug:y.slug}),b=y.parent_id}await l({to:C(n,w)})}catch{d(!0)}finally{r(!1)}}return e.jsxs("li",{className:E("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(le,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),x||!u?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:o}):e.jsxs("button",{type:"button",onClick:f,disabled:i,"aria-busy":i,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:o}),u?e.jsx(G,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:u}):null]}),c?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}function We(s,t){const n=new Set([...Object.keys(s),...Object.keys(t)]);let l=!1;const a={};for(const i of n){const r=i in s,c=i in t;if(!r&&c){a[i]=t[i];continue}r&&(a[i]=s[i],(!c||JSON.stringify(s[i])!==JSON.stringify(t[i]))&&(l=!0))}return l?a:void 0}function Je({entity:s,entityTypeSlug:t,orgContext:n,onDeleted:l}){const{isAdmin:a,isLoading:i}=ye(n.organizationId),r=a&&!i,{data:c,isLoading:d}=se(t,n),x=ve(),h=je(),p=c?.metadata_schema,u=s.field_controls,g=_.useMemo(()=>J(s.metadata??{},p),[s.metadata,p]),o=be(s.id,{name:s.name,slug:s.slug,metadata:g},p),[f,w]=o.field("name"),[j,b]=o.field("slug"),[y,m]=o.field("metadata"),[R,A]=S(s.id,""),[z,T]=S(s.id,null),[te,D]=S(s.id,!1),[M,P]=S(s.id,null),L=_.useMemo(()=>o.hasInvalidInput?void 0:We(q(y),q(o.baseline.metadata)),[o.baseline.metadata,y,o.hasInvalidInput]),$=L!==void 0,ae=f!==o.baseline.name||j!==o.baseline.slug||$,ne=async v=>{if(v.preventDefault(),!(!r||!o.canSubmit)){if(T(null),!f.trim()){T("Name is required");return}try{await x.mutateAsync({entityId:s.id,name:f.trim()!==o.baseline.name.trim()?f.trim():void 0,slug:j,metadata:L,field_note:$&&R.trim()||void 0}),o.accept(o.values,{name:f.trim(),slug:j,metadata:J({...Ce(o.baseline.metadata),...L},p)}),A("")}catch(B){T(B instanceof Error?B.message:"Failed to update entity")}}},ie=async()=>{if(r){P(null);try{await h.mutateAsync({entityId:s.id}),D(!1),l?.()}catch(v){P(v instanceof Error?v.message:"Failed to delete entity")}}},V=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return d?e.jsx(Ne,{rows:6}):e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsx(we,{visible:o.hasConflict,onReload:o.reset}),!r&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:i?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(I,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(W,{id:"sidebar-name",readOnly:!r,value:f,onChange:v=>w(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(I,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(W,{id:"sidebar-slug",readOnly:!r,value:j,onChange:v=>b(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),o.revision&&Object.keys(o.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(Re,{schema:o.revision,values:y,onValuesChange:m,readonly:!r,fieldControls:u,orgContext:n})]}),r&&$&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(I,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(_e,{id:"sidebar-correction-note",value:R,onChange:v=>A(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),z&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:z}),r&&(te?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Se,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),V&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",V,". This cannot be easily undone."]})]})]}),M&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:M}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{D(!1),P(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:ie,disabled:h.isPending,children:h.isPending?"Deleting...":`Delete ${c?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>D(!0),children:"Delete"}),e.jsx(N,{type:"submit",size:"sm",disabled:!o.canSubmit||!ae||x.isPending||!f.trim(),children:x.isPending?"Saving...":"Save"})]}))]})}function qe({entity:s}){const t=new Set(s.measure_columns??[]),n=s.metadata??{},l=Object.keys(n).filter(a=>a!=="id"&&a!=="slug"&&a!=="name");return e.jsx("div",{className:"mt-4 max-w-2xl",children:e.jsx("div",{className:"rounded-lg border",children:e.jsx(xe,{children:e.jsx(ge,{children:l.map(a=>{const i=t.has(a);return e.jsxs(he,{children:[e.jsx(H,{className:"w-44 align-top font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[i?a:pe(a.replace(/_/g," ")),i&&e.jsx(G,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]})}),e.jsx(H,{className:E("break-words align-top",i?"text-right tabular-nums":""),children:fe(n[a])})]},a)})})})})})}const k=":overview",Ke={},Xe=()=>{};function Ye({namespace:s,entity:t,recordUrl:n,viewKey:l,onDeleted:a}){const i=de({strict:!1}),r=O(),c={slug:s.slug,organizationId:s.id},d=Be(c),x=d.data??[],h={type:t.entity_type,id:t.id,slug:t.slug,parentId:t.parent_id},p=U(x,h,"overview"),u=U(x,h,"tab"),g=me(u,l),o=m=>`${n}${ke(m)}`,f=m=>void r({to:".",search:m,replace:!0}),w={type:t.entity_type,entity:t.is_derived?t.slug:t.id},j=t.is_derived?e.jsx(qe,{entity:t}):e.jsx(Je,{entity:t,entityTypeSlug:t.entity_type,orgContext:c,onDeleted:a}),b=t.id>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Relationships"}),e.jsx(Ue,{entityId:t.id,ownerSlug:s.slug})]}),y=e.jsxs(e.Fragment,{children:[d.isError&&e.jsx(Z,{onRetry:()=>void d.refetch()}),p.map(m=>e.jsx("section",{className:E(ee,"mb-4 p-2"),"data-testid":"view-card","data-view":m.key,children:e.jsx(K,{orgSlug:s.slug,viewKey:m.key,scope:w,params:Ke,onParamsChange:Xe,contentHash:m.content_hash,title:m.name,minHeight:160})},m.key)),b,e.jsx("div",{className:"mt-4",children:j})]});return l&&d.data===void 0?d.isError?e.jsx(Z,{onRetry:()=>void d.refetch()}):null:g.kind==="missing"?e.jsx(Ve,{viewKey:g.key,backTo:n,backLabel:`Back to ${t.name}`}):u.length===0?e.jsx("div",{className:"mt-4 max-w-xl",children:y}):e.jsx("div",{className:"mt-4",children:e.jsxs(ze,{value:g.kind==="tab"?g.view.key:k,onValueChange:m=>void r({to:m===k?n:o(m)}),children:[e.jsxs(Me,{children:[e.jsx(X,{value:k,children:"Overview"}),u.map(m=>e.jsx(X,{value:m.key,"data-testid":`tab-${m.key}`,children:m.name},m.key))]}),e.jsx(Y,{value:k,className:"max-w-xl",children:y}),g.kind==="tab"&&e.jsx(Y,{value:g.view.key,children:e.jsx(K,{orgSlug:s.slug,viewKey:g.view.key,scope:w,params:ue(i),onParamsChange:f,contentHash:g.view.content_hash,title:g.view.name,minHeight:320})})]})})}function Ze(s){return typeof s=="string"?s:s===null?"None":JSON.stringify(s)??String(s)}function Qe({records:s}){const t=Fe(),[n,l]=_.useState(null);return s.length===0?null:e.jsxs("details",{className:E(ee,"px-4 py-3"),children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Merged records (",s.length,")"]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map(a=>e.jsxs("div",{className:"rounded-lg bg-background p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Merged ",new Date(a.merged_at).toLocaleString()]})]}),a.can_unmerge?n===a.id?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:t.isPending,onClick:()=>t.mutate({entityId:a.id},{onSettled:()=>l(null)}),children:"Confirm undo"}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>l(null),children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>l(a.id),children:[e.jsx(Ie,{className:"mr-1.5 size-3.5"}),"Undo merge"]}):null]}),Object.keys(a.metadata).length>0?e.jsx("dl",{className:"mt-3 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:Object.entries(a.metadata).map(([i,r])=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:i}),e.jsx("dd",{className:"break-words",children:Ze(r)})]},i))}):null]},a.id))})]})}function Ge(s){return s?.trim()?s:void 0}function es({ownerSlug:s,entityName:t,activityHref:n}){const l=Le();return e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>l?.open({href:n,title:`${t} · Activity`,owner:s}),disabled:!l,children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"See activity"]})}function os({namespace:s,path:t,entity:n,mergedFrom:l,viewKey:a}){const i=O(),{data:r}=se(n.entity_type,{slug:s.slug}),c=Ge(r?.icon),d=t.map(u=>({entity_type:u.entity_type,slug:u.slug})),x=`/${s.slug}/${Ee(n.entity_type)}`,h=C(s.slug,d),p=t.length>1?C(s.slug,d.slice(0,-1)):x;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[l?e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm",children:[e.jsx("strong",{children:l})," was merged into this canonical record."]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx(N,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(Te,{to:p,children:[e.jsx(De,{className:"mr-1 h-4 w-4"}),"Back"]})}),n.id>0&&e.jsx("div",{className:"ml-auto",children:e.jsx(es,{ownerSlug:s.slug,entityName:n.name,activityHref:`/${s.slug}/events/${Pe(d)}`})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ae,{metadata:n.metadata,metadataSchema:r?.metadata_schema,name:n.name,typeIcon:c,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:n.name})]})]}),e.jsx(Qe,{records:n.merged_records??[]}),e.jsx(Ye,{namespace:s,entity:n,recordUrl:h,viewKey:a,onDeleted:()=>{const u=t.slice(0,-1);u.length>0?i({to:C(s.slug,u)}):i({to:x})}})]})}export{os as EntityPage};
1
+ import{Z as Q,ip as re,r as _,j as e,S as F,_ as O,iq as le,ab as G,af as E,cy as oe,ir as ce,dE as C,a3 as de,is as U,it as me,aP as ee,fZ as ue,eS as xe,eW as ge,eU as he,eX as H,fR as pe,fS as fe,fL as ye,dr as se,fT as ve,iu as je,cb as be,cc as S,fP as Ne,cf as we,a6 as I,a7 as W,dY as _e,bD as Se,B as N,g2 as ke,ek as Ce,fU as Ee,L as Te,eD as De,iv as Pe,o as Le,iw as $e,dC as Fe,c9 as Ie}from"./index-B2AmRqYh.js";import{a as J,c as q,S as Oe,D as Re,E as Ae}from"./schema-value-normalization-3JuM_r1H.js";import{V as K,T as ze,a as Me,b as X,c as Y}from"./view-frame-C7ciEoLo.js";import{V as Z,M as Ve}from"./missing-view-DrZ8m8yo.js";import{u as Be}from"./use-applied-views-B-Z-Weji.js";import"./calendar-DAiyi1ZL.js";import"./app-bridge-BH3g2mKG.js";function Ue({entityId:s,ownerSlug:t}){const{orgContext:n}=Q(),{data:l,isLoading:a}=re(s,n),i=_.useMemo(()=>{if(!l)return[];const r=new Map;for(const c of l.rows){const d=r.get(c.relationship_type_slug);d?d.rows.push(c):r.set(c.relationship_type_slug,{slug:c.relationship_type_slug,label:c.relationship_type_name,rows:[c]})}return[...r.values()]},[l]);return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"h-4 w-32"}),e.jsx(F,{className:"h-12 w-full rounded-lg"}),e.jsx(F,{className:"h-12 w-full rounded-lg"})]}):!l||l.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:i.map(({slug:r,label:c,rows:d})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:d.length})]}),e.jsx("ul",{className:"space-y-1",children:d.map(x=>e.jsx(He,{entityId:s,row:x,ownerSlug:t},x.id))})]},r))})}function He({entityId:s,row:t,ownerSlug:n}){const l=O(),{orgContext:a}=Q(),[i,r]=_.useState(!1),[c,d]=_.useState(!1),x=t.from_entity_id===t.to_entity_id,h=t.from_entity_id===s,p=x?"this entity":h?t.to_entity_name??`Entity #${t.to_entity_id}`:t.from_entity_name??`Entity #${t.from_entity_id}`,u=h?t.to_entity_type:t.from_entity_type,g=h?t.to_entity_id:t.from_entity_id,o=u?`${u} · ${p}`:p;async function f(){r(!0),d(!1);try{const w=[],j=new Set;let b=g;for(;b!==null;){if(j.has(b))throw new Error("Cyclic entity ancestry");j.add(b);const{entity:y}=await oe("manage_entity",{action:"get",entity_id:b},ce(a));w.unshift({entity_type:y.entity_type,slug:y.slug}),b=y.parent_id}await l({to:C(n,w)})}catch{d(!0)}finally{r(!1)}}return e.jsxs("li",{className:E("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(le,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),x||!u?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:o}):e.jsxs("button",{type:"button",onClick:f,disabled:i,"aria-busy":i,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:o}),u?e.jsx(G,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:u}):null]}),c?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}function We(s,t){const n=new Set([...Object.keys(s),...Object.keys(t)]);let l=!1;const a={};for(const i of n){const r=i in s,c=i in t;if(!r&&c){a[i]=t[i];continue}r&&(a[i]=s[i],(!c||JSON.stringify(s[i])!==JSON.stringify(t[i]))&&(l=!0))}return l?a:void 0}function Je({entity:s,entityTypeSlug:t,orgContext:n,onDeleted:l}){const{isAdmin:a,isLoading:i}=ye(n.organizationId),r=a&&!i,{data:c,isLoading:d}=se(t,n),x=ve(),h=je(),p=c?.metadata_schema,u=s.field_controls,g=_.useMemo(()=>J(s.metadata??{},p),[s.metadata,p]),o=be(s.id,{name:s.name,slug:s.slug,metadata:g},p),[f,w]=o.field("name"),[j,b]=o.field("slug"),[y,m]=o.field("metadata"),[R,A]=S(s.id,""),[z,T]=S(s.id,null),[te,D]=S(s.id,!1),[M,P]=S(s.id,null),L=_.useMemo(()=>o.hasInvalidInput?void 0:We(q(y),q(o.baseline.metadata)),[o.baseline.metadata,y,o.hasInvalidInput]),$=L!==void 0,ae=f!==o.baseline.name||j!==o.baseline.slug||$,ne=async v=>{if(v.preventDefault(),!(!r||!o.canSubmit)){if(T(null),!f.trim()){T("Name is required");return}try{await x.mutateAsync({entityId:s.id,name:f.trim()!==o.baseline.name.trim()?f.trim():void 0,slug:j,metadata:L,field_note:$&&R.trim()||void 0}),o.accept(o.values,{name:f.trim(),slug:j,metadata:J({...Ce(o.baseline.metadata),...L},p)}),A("")}catch(B){T(B instanceof Error?B.message:"Failed to update entity")}}},ie=async()=>{if(r){P(null);try{await h.mutateAsync({entityId:s.id}),D(!1),l?.()}catch(v){P(v instanceof Error?v.message:"Failed to delete entity")}}},V=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return d?e.jsx(Ne,{rows:6}):e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsx(we,{visible:o.hasConflict,onReload:o.reset}),!r&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:i?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(I,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(W,{id:"sidebar-name",readOnly:!r,value:f,onChange:v=>w(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(I,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(W,{id:"sidebar-slug",readOnly:!r,value:j,onChange:v=>b(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),o.revision&&Object.keys(o.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(Re,{schema:o.revision,values:y,onValuesChange:m,readonly:!r,fieldControls:u,orgContext:n})]}),r&&$&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(I,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(_e,{id:"sidebar-correction-note",value:R,onChange:v=>A(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),z&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:z}),r&&(te?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Se,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),V&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",V,". This cannot be easily undone."]})]})]}),M&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:M}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{D(!1),P(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:ie,disabled:h.isPending,children:h.isPending?"Deleting...":`Delete ${c?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>D(!0),children:"Delete"}),e.jsx(N,{type:"submit",size:"sm",disabled:!o.canSubmit||!ae||x.isPending||!f.trim(),children:x.isPending?"Saving...":"Save"})]}))]})}function qe({entity:s}){const t=new Set(s.measure_columns??[]),n=s.metadata??{},l=Object.keys(n).filter(a=>a!=="id"&&a!=="slug"&&a!=="name");return e.jsx("div",{className:"mt-4 max-w-2xl",children:e.jsx("div",{className:"rounded-lg border",children:e.jsx(xe,{children:e.jsx(ge,{children:l.map(a=>{const i=t.has(a);return e.jsxs(he,{children:[e.jsx(H,{className:"w-44 align-top font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[i?a:pe(a.replace(/_/g," ")),i&&e.jsx(G,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]})}),e.jsx(H,{className:E("break-words align-top",i?"text-right tabular-nums":""),children:fe(n[a])})]},a)})})})})})}const k=":overview",Ke={},Xe=()=>{};function Ye({namespace:s,entity:t,recordUrl:n,viewKey:l,onDeleted:a}){const i=de({strict:!1}),r=O(),c={slug:s.slug,organizationId:s.id},d=Be(c),x=d.data??[],h={type:t.entity_type,id:t.id,slug:t.slug,parentId:t.parent_id},p=U(x,h,"overview"),u=U(x,h,"tab"),g=me(u,l),o=m=>`${n}${ke(m)}`,f=m=>void r({to:".",search:m,replace:!0}),w={type:t.entity_type,entity:t.is_derived?t.slug:t.id},j=t.is_derived?e.jsx(qe,{entity:t}):e.jsx(Je,{entity:t,entityTypeSlug:t.entity_type,orgContext:c,onDeleted:a}),b=t.id>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Relationships"}),e.jsx(Ue,{entityId:t.id,ownerSlug:s.slug})]}),y=e.jsxs(e.Fragment,{children:[d.isError&&e.jsx(Z,{onRetry:()=>void d.refetch()}),p.map(m=>e.jsx("section",{className:E(ee,"mb-4 p-2"),"data-testid":"view-card","data-view":m.key,children:e.jsx(K,{orgSlug:s.slug,viewKey:m.key,scope:w,params:Ke,onParamsChange:Xe,contentHash:m.content_hash,title:m.name,minHeight:160})},m.key)),b,e.jsx("div",{className:"mt-4",children:j})]});return l&&d.data===void 0?d.isError?e.jsx(Z,{onRetry:()=>void d.refetch()}):null:g.kind==="missing"?e.jsx(Ve,{viewKey:g.key,backTo:n,backLabel:`Back to ${t.name}`}):u.length===0?e.jsx("div",{className:"mt-4 max-w-xl",children:y}):e.jsx("div",{className:"mt-4",children:e.jsxs(ze,{value:g.kind==="tab"?g.view.key:k,onValueChange:m=>void r({to:m===k?n:o(m)}),children:[e.jsxs(Me,{children:[e.jsx(X,{value:k,children:"Overview"}),u.map(m=>e.jsx(X,{value:m.key,"data-testid":`tab-${m.key}`,children:m.name},m.key))]}),e.jsx(Y,{value:k,className:"max-w-xl",children:y}),g.kind==="tab"&&e.jsx(Y,{value:g.view.key,children:e.jsx(K,{orgSlug:s.slug,viewKey:g.view.key,scope:w,params:ue(i),onParamsChange:f,contentHash:g.view.content_hash,title:g.view.name,minHeight:320})})]})})}function Ze(s){return typeof s=="string"?s:s===null?"None":JSON.stringify(s)??String(s)}function Qe({records:s}){const t=Fe(),[n,l]=_.useState(null);return s.length===0?null:e.jsxs("details",{className:E(ee,"px-4 py-3"),children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Merged records (",s.length,")"]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map(a=>e.jsxs("div",{className:"rounded-lg bg-background p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Merged ",new Date(a.merged_at).toLocaleString()]})]}),a.can_unmerge?n===a.id?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:t.isPending,onClick:()=>t.mutate({entityId:a.id},{onSettled:()=>l(null)}),children:"Confirm undo"}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>l(null),children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>l(a.id),children:[e.jsx(Ie,{className:"mr-1.5 size-3.5"}),"Undo merge"]}):null]}),Object.keys(a.metadata).length>0?e.jsx("dl",{className:"mt-3 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:Object.entries(a.metadata).map(([i,r])=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("dt",{className:"text-muted-foreground",children:i}),e.jsx("dd",{className:"break-words",children:Ze(r)})]},i))}):null]},a.id))})]})}function Ge(s){return s?.trim()?s:void 0}function es({ownerSlug:s,entityName:t,activityHref:n}){const l=Le();return e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>l?.open({href:n,title:`${t} · Activity`,owner:s}),disabled:!l,children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"See activity"]})}function os({namespace:s,path:t,entity:n,mergedFrom:l,viewKey:a}){const i=O(),{data:r}=se(n.entity_type,{slug:s.slug}),c=Ge(r?.icon),d=t.map(u=>({entity_type:u.entity_type,slug:u.slug})),x=`/${s.slug}/${Ee(n.entity_type)}`,h=C(s.slug,d),p=t.length>1?C(s.slug,d.slice(0,-1)):x;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[l?e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm",children:[e.jsx("strong",{children:l})," was merged into this canonical record."]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx(N,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(Te,{to:p,children:[e.jsx(De,{className:"mr-1 h-4 w-4"}),"Back"]})}),n.id>0&&e.jsx("div",{className:"ml-auto",children:e.jsx(es,{ownerSlug:s.slug,entityName:n.name,activityHref:`/${s.slug}/events/${Pe(d)}`})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ae,{metadata:n.metadata,metadataSchema:r?.metadata_schema,name:n.name,typeIcon:c,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:n.name})]})]}),e.jsx(Qe,{records:n.merged_records??[]}),e.jsx(Ye,{namespace:s,entity:n,recordUrl:h,viewKey:a,onDeleted:()=>{const u=t.slice(0,-1);u.length>0?i({to:C(s.slug,u)}):i({to:x})}})]})}export{os as EntityPage};
@@ -1 +1 @@
1
- import{j as e,ab as $,Z as H,fC as me,dx as xe,fF as Y,c6 as ae,r as x,fD as he,fE as pe,cp as ge,cq as fe,B as f,P as V,ct as je,a6 as C,bR as q,bS as P,bT as M,bU as L,bV as R,a7 as T,n as ve,fK as Ne,g5 as ye,dH as be,X as W,cs as ne,dj as re,ag as we,bu as le,g6 as ie,g7 as Se,bD as oe,g8 as Ce,g9 as ke,cb as Ee,cc as Z,cf as _e,dY as Re,b_ as Te,ga as De,gb as Oe,af as G}from"./index-GZkujXG1.js";import{J as B}from"./json-diff-D6sv990W.js";import{C as ce}from"./code-editor-bpbaa7f6.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=H(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==Y),d=i.filter(m=>m.purpose===Y),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ie,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=H(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Le,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Le({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Ie({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=H(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[O,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},D=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const K=k.trim()||F(g);if(!K){_("Slug is required");return}l=(await u.mutateAsync({slug:K,name:g.trim(),is_symmetric:O})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),D(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:D,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:O,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ve({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ue=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Je({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ue.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ve,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function Q({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function X(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function He({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),X(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),D=u.some(F=>F.name.trim());m(D?JSON.stringify(v,null,2):""),a(D?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),O=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),X(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(Q,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(Q,{value:h,onChange:O,error:S})]})}function We(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,O]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=Z(i,n),[p,v]=Z(i,null),D=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(We(l))},U=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=D?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:D?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:D?void 0:E,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),D?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(He,{value:E,onChange:O})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Xe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=De(),{data:y,isLoading:b}=Oe(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",O=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ke,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(qe,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Xe as E};
1
+ import{j as e,ab as $,Z as H,fC as me,dx as xe,fF as Y,c6 as ae,r as x,fD as he,fE as pe,cp as ge,cq as fe,B as f,P as V,ct as je,a6 as C,bR as q,bS as P,bT as M,bU as L,bV as R,a7 as T,n as ve,fK as Ne,g5 as ye,dH as be,X as W,cs as ne,dj as re,ag as we,bu as le,g6 as ie,g7 as Se,bD as oe,g8 as Ce,g9 as ke,cb as Ee,cc as Z,cf as _e,dY as Re,b_ as Te,ga as De,gb as Oe,af as G}from"./index-B2AmRqYh.js";import{J as B}from"./json-diff-ClBBYBQD.js";import{C as ce}from"./code-editor-CYsR2VBP.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=H(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==Y),d=i.filter(m=>m.purpose===Y),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ie,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=H(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Le,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Le({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Ie({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=H(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[O,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},D=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const K=k.trim()||F(g);if(!K){_("Slug is required");return}l=(await u.mutateAsync({slug:K,name:g.trim(),is_symmetric:O})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),D(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:D,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:O,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ve({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ue=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Je({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ue.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ve,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function Q({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function X(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function He({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),X(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),D=u.some(F=>F.name.trim());m(D?JSON.stringify(v,null,2):""),a(D?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),O=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),X(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(Q,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(Q,{value:h,onChange:O,error:S})]})}function We(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,O]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=Z(i,n),[p,v]=Z(i,null),D=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(We(l))},U=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=D?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:D?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:D?void 0:E,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),D?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(He,{value:E,onChange:O})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Xe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=De(),{data:y,isLoading:b}=Oe(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",O=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ke,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(qe,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Xe as E};
@@ -1 +1 @@
1
- import{j as e,aS as V,p as T,q as y,a3 as L,_ as N,g_ as S,fZ as $,g2 as U}from"./index-GZkujXG1.js";import{E as h,u as B}from"./events-feed-BgvLTppV.js";import{T as C,a as O,b as g,c as f,V as P}from"./view-frame-DxiuLSGA.js";import{M as w,V as _}from"./missing-view-CAFqvZpi.js";const o=":event";function H({owner:l,eventId:t,viewKey:n}){return l==="me"?e.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 px-4 py-6 lg:px-6",children:n?e.jsx(w,{viewKey:n,backTo:`/me/events/${t}`,backLabel:"Back to the event"}):e.jsx(h,{organizationId:null,ownerSlug:"me",filters:{contentIds:[t],sortBy:"date",sortOrder:"desc"}})}):e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:e.jsx(V,{owner:l,children:i=>i.organizationId?e.jsx(z,{organizationId:i.organizationId,ownerSlug:i.ownerSlug,eventId:t,viewKey:n}):e.jsx("div",{className:"mx-auto h-40 w-full max-w-3xl animate-pulse rounded-md bg-muted/40"})})})}function z({organizationId:l,ownerSlug:t,eventId:n,viewKey:i}){const{isAuthenticated:x,isReady:d}=T(),{isMember:j,isLoading:b}=y(),m=d&&x&&j,r=B(m?{slug:t,organizationId:l}:null,n),k=L({strict:!1}),v=N(),c=`/${t}/events/${n}`,p=s=>`${c}${U(s)}`,E=s=>void v({to:".",search:s,replace:!0}),u=e.jsx("div",{className:"mx-auto w-full max-w-3xl","data-testid":"event-native",children:e.jsx(h,{organizationId:l,ownerSlug:t,filters:{contentIds:[n]}})});if(i&&(!d||x&&b))return null;if(!m)return u;if(i&&r.isLoading)return null;if(i&&r.isError)return e.jsx(_,{onRetry:r.refetch});const a=S(r.views,i);return a.kind==="missing"?e.jsx(w,{viewKey:a.key,backTo:c,backLabel:"Back to the event"}):r.views.length===0?u:e.jsxs(C,{value:a.kind==="view"?a.view.key:o,onValueChange:s=>void v({to:s===o?c:p(s)}),children:[e.jsxs(O,{children:[e.jsx(g,{value:o,"data-testid":"tab-event",children:"Event"}),r.views.map(s=>e.jsx(g,{value:s.key,"data-testid":`tab-${s.key}`,children:s.name},s.key))]}),e.jsx(f,{value:o,children:u}),a.kind==="view"&&e.jsx(f,{value:a.view.key,children:e.jsx(P,{orgSlug:t,viewKey:a.view.key,scope:{event:n},params:$(k),onParamsChange:E,contentHash:a.view.content_hash,title:a.view.name,minHeight:320})})]})}export{H as E};
1
+ import{j as e,aS as V,p as T,q as y,a3 as L,_ as N,g_ as S,fZ as $,g2 as U}from"./index-B2AmRqYh.js";import{E as h,u as B}from"./events-feed-DK35T4g7.js";import{T as C,a as O,b as g,c as f,V as P}from"./view-frame-C7ciEoLo.js";import{M as w,V as _}from"./missing-view-DrZ8m8yo.js";const o=":event";function H({owner:l,eventId:t,viewKey:n}){return l==="me"?e.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 px-4 py-6 lg:px-6",children:n?e.jsx(w,{viewKey:n,backTo:`/me/events/${t}`,backLabel:"Back to the event"}):e.jsx(h,{organizationId:null,ownerSlug:"me",filters:{contentIds:[t],sortBy:"date",sortOrder:"desc"}})}):e.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:e.jsx(V,{owner:l,children:i=>i.organizationId?e.jsx(z,{organizationId:i.organizationId,ownerSlug:i.ownerSlug,eventId:t,viewKey:n}):e.jsx("div",{className:"mx-auto h-40 w-full max-w-3xl animate-pulse rounded-md bg-muted/40"})})})}function z({organizationId:l,ownerSlug:t,eventId:n,viewKey:i}){const{isAuthenticated:x,isReady:d}=T(),{isMember:j,isLoading:b}=y(),m=d&&x&&j,r=B(m?{slug:t,organizationId:l}:null,n),k=L({strict:!1}),v=N(),c=`/${t}/events/${n}`,p=s=>`${c}${U(s)}`,E=s=>void v({to:".",search:s,replace:!0}),u=e.jsx("div",{className:"mx-auto w-full max-w-3xl","data-testid":"event-native",children:e.jsx(h,{organizationId:l,ownerSlug:t,filters:{contentIds:[n]}})});if(i&&(!d||x&&b))return null;if(!m)return u;if(i&&r.isLoading)return null;if(i&&r.isError)return e.jsx(_,{onRetry:r.refetch});const a=S(r.views,i);return a.kind==="missing"?e.jsx(w,{viewKey:a.key,backTo:c,backLabel:"Back to the event"}):r.views.length===0?u:e.jsxs(C,{value:a.kind==="view"?a.view.key:o,onValueChange:s=>void v({to:s===o?c:p(s)}),children:[e.jsxs(O,{children:[e.jsx(g,{value:o,"data-testid":"tab-event",children:"Event"}),r.views.map(s=>e.jsx(g,{value:s.key,"data-testid":`tab-${s.key}`,children:s.name},s.key))]}),e.jsx(f,{value:o,children:u}),a.kind==="view"&&e.jsx(f,{value:a.view.key,children:e.jsx(P,{orgSlug:t,viewKey:a.view.key,scope:{event:n},params:$(k),onParamsChange:E,contentHash:a.view.content_hash,title:a.view.name,minHeight:320})})]})}export{H as E};