@camstack/addon-admin-ui 1.2.478 → 1.2.480

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 (128) hide show
  1. package/dist/assets/{AddonAssetIcon-B_-30Ezl.js → AddonAssetIcon-Dl8uxsbh.js} +1 -1
  2. package/dist/assets/Addons-D0-Lkqak.js +5 -0
  3. package/dist/assets/{AdminPage-3JxWocN3.js → AdminPage-CSXKwqkg.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BByl6Zss.js → AdminSectionedPage-BKgqha3i.js} +1 -1
  5. package/dist/assets/AiProfiles-PVMMhQkj.js +3 -0
  6. package/dist/assets/{BrokerForm-D6ln7R0A.js → BrokerForm-DXNZ4XDs.js} +1 -1
  7. package/dist/assets/Build-CoXA7FyI.js +40 -0
  8. package/dist/assets/{Calendars-G5xKjOn2.js → Calendars-BMYW6Lcd.js} +1 -1
  9. package/dist/assets/{Cluster-w5Kcsast.js → Cluster-DcCFmoWl.js} +1 -1
  10. package/dist/assets/CompositionBlockEditor-CS7j_Q0n.js +1 -0
  11. package/dist/assets/CompositionEditorPage-BzXIuasc.js +1 -0
  12. package/dist/assets/{Data-r1IoElgA.js → Data-xdGxogBF.js} +2 -2
  13. package/dist/assets/{DeviceDetail-Dz6PV7rK.js → DeviceDetail-DTa2bPN4.js} +2 -2
  14. package/dist/assets/{DeviceDoActionFields-gklZW8H7.js → DeviceDoActionFields-C0BliAs3.js} +1 -1
  15. package/dist/assets/{Devices-z5XqFK0f.js → Devices-BF451zpL.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-Ccf5hGui.js → EmbedPlayerPage-BYk9lSle.js} +1 -1
  17. package/dist/assets/HelperWizard-Dne7XMRs.js +2 -0
  18. package/dist/assets/{History-DLllXIdk.js → History-DwCuiCyt.js} +1 -1
  19. package/dist/assets/Identity-BxOtJf9f.js +1 -0
  20. package/dist/assets/IntegrationDetail-CNdjHgkg.js +1 -0
  21. package/dist/assets/{IntegrationHub-Dv8jClEP.js → IntegrationHub-CurQ0MIP.js} +1 -1
  22. package/dist/assets/Integrations-BDnjzX7X.js +1 -0
  23. package/dist/assets/{Integrations-B9RbWg-F.js → Integrations-CkJHWfhP.js} +1 -1
  24. package/dist/assets/{Library-BXbZKXfl.js → Library-DP1Wr2c7.js} +1 -1
  25. package/dist/assets/{Locations-CjHnNjAh.js → Locations-J4ikH0b7.js} +1 -1
  26. package/dist/assets/{Logs-D7ADXC_5.js → Logs-Bd5V0nh-.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-UFmJUhUS.js → MaskShapeCanvas-Tcd9Y5RA.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-BTxe4DbF.js → MotionZonesSettings-CRoT6tmj.js} +1 -1
  29. package/dist/assets/MyAccess-BjobXXGx.js +2 -0
  30. package/dist/assets/Network-xmsnvwQH.js +1 -0
  31. package/dist/assets/{NodeAddonsSettingsPanel-GEn1r68w.js → NodeAddonsSettingsPanel-DkJRjjUs.js} +1 -1
  32. package/dist/assets/Notifications-BKotbSiz.js +1 -0
  33. package/dist/assets/{Pipeline-B6AdA9Ua.js → Pipeline-DdvNlpdi.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-D6kokNvH.js → PrivacyMaskSettings-D5ozyRW7.js} +1 -1
  35. package/dist/assets/{Recordings-2Ej5v6LZ.js → Recordings-Bc6TV4zS.js} +1 -1
  36. package/dist/assets/ScanNetworkModal-DoDbqBMU.js +1 -0
  37. package/dist/assets/{SceneMonitorEditor-CrDKfkgT.js → SceneMonitorEditor-CrwhZjau.js} +1 -1
  38. package/dist/assets/SessionsList-Ci2UotT9.js +2 -0
  39. package/dist/assets/{Showroom-eCnhoQBD.js → Showroom-DX5blOP5.js} +1 -1
  40. package/dist/assets/{System-AxGI_wdI.js → System-Cj0zNzyx.js} +1 -1
  41. package/dist/assets/{Terminal-Br0QNfMN.js → Terminal-CrQfybLK.js} +1 -1
  42. package/dist/assets/{Viewer-DwNVIy-u.js → Viewer-NPWQx4Po.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QiJARN9B.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-vDZqJbgM.js} +1 -1
  44. package/dist/assets/{addon-icons-context-lrP_33gc.js → addon-icons-context-C_QjLbbK.js} +1 -1
  45. package/dist/assets/{archive-Brq5E-qM.js → archive-W1ZaOIy6.js} +1 -1
  46. package/dist/assets/{assignment-candidates-BMhC6h3l.js → assignment-candidates-B-td3IjI.js} +1 -1
  47. package/dist/assets/{authed-media-CnaIhiH3.js → authed-media-DmqjjIKA.js} +1 -1
  48. package/dist/assets/{bell-off-CDjOfT8K.js → bell-off-BpuHdEmA.js} +1 -1
  49. package/dist/assets/{board-model--9Jw6SCm.js → board-model-j7i6ZAYf.js} +1 -1
  50. package/dist/assets/{boxes-0ut2NdHU.js → boxes-BP6lUc_5.js} +1 -1
  51. package/dist/assets/circle-slash-C9MZOlOA.js +1 -0
  52. package/dist/assets/client-COfGFdJB.js +358 -0
  53. package/dist/assets/{cloud-upload-M9JxZe_d.js → cloud-upload-ARBEZ-Y1.js} +1 -1
  54. package/dist/assets/crop-CcnscEEp.js +1 -0
  55. package/dist/assets/{device-integration-icon-DEZs4Umq.js → device-integration-icon-Ch_ZPOzM.js} +1 -1
  56. package/dist/assets/device-picker-model-Ch3e43SQ.js +1 -0
  57. package/dist/assets/{dist-B9cEBPZ1.js → dist-B2eSaq-o.js} +1 -1
  58. package/dist/assets/{eraser-Bs0PJaPY.js → eraser-C0EhIwNf.js} +1 -1
  59. package/dist/assets/{format-fYneBFV6.js → format-uKtM7bQx.js} +1 -1
  60. package/dist/assets/{hard-drive-download-iRJR_Xj9.js → hard-drive-download-CrDu4V4S.js} +1 -1
  61. package/dist/assets/{hostInit-DB6u6qxU.js → hostInit-BW_Uzp68.js} +1 -1
  62. package/dist/assets/{i18n-D0o08mg-.js → i18n-D1Cc22Zf.js} +1 -1
  63. package/dist/assets/{icons-apbWMCU4.js → icons-DanAyxOR.js} +1 -1
  64. package/dist/assets/{index-XXQ5yMw_.js → index-C8EgBFV_.js} +3 -3
  65. package/dist/assets/{key-Crd8m-SP.js → key-BSKPngWG.js} +1 -1
  66. package/dist/assets/{key-round-DG341WFZ.js → key-round-Dh6fcJDV.js} +1 -1
  67. package/dist/assets/{layers-BnsQ5ORI.js → layers-khG7TS-L.js} +1 -1
  68. package/dist/assets/{linked-devices-model-DMEJU3bE.js → linked-devices-model-ou0VkTvM.js} +1 -1
  69. package/dist/assets/{list-ordered-BIo7AnFy.js → list-ordered-B5DA6_oa.js} +1 -1
  70. package/dist/assets/{location-owned-usage-8xhfNE7j.js → location-owned-usage-CQzY3VS7.js} +1 -1
  71. package/dist/assets/{log-in-D1BPSCDn.js → log-in-CoYLZEi7.js} +1 -1
  72. package/dist/assets/{memory-stick-CjPBCMfd.js → memory-stick-MOirwg5Y.js} +1 -1
  73. package/dist/assets/{message-square-plus-C4N5hy0x.js → message-square-plus-CEVi2ZAP.js} +1 -1
  74. package/dist/assets/{mf-entry-bootstrap-0-dcdd32c2.js → mf-entry-bootstrap-0-a83f6fea.js} +2 -2
  75. package/dist/assets/{mic-off-CgPfA49W.js → mic-off-Cilr4Bli.js} +1 -1
  76. package/dist/assets/{monitor-off-Ib2v0VDF.js → monitor-off-DLVIYtnd.js} +1 -1
  77. package/dist/assets/{monitor-smartphone-6w2T5Ht_.js → monitor-smartphone-TMWTIuue.js} +1 -1
  78. package/dist/assets/mount-Ch3e43SQ.js +1 -0
  79. package/dist/assets/{player-overlays-Dbv95cvz.js → player-overlays-By2E2OWX.js} +1 -1
  80. package/dist/assets/{recycle-DcScXiTi.js → recycle-DSYCQWpK.js} +1 -1
  81. package/dist/assets/remoteEntry-Bisv2xsg.js +1 -0
  82. package/dist/assets/{scan-eye-CWOvobjP.js → scan-eye-qMn599c3.js} +1 -1
  83. package/dist/assets/{scissors-NpyrGUBV.js → scissors-DzKs5SeF.js} +1 -1
  84. package/dist/assets/{search-x-CKQw--aU.js → search-x-0pY78yhl.js} +1 -1
  85. package/dist/assets/{send-402PlgqT.js → send-x-DGZeSf.js} +1 -1
  86. package/dist/assets/{settings-2-BbwQVFbm.js → settings-2-CBTEttT3.js} +1 -1
  87. package/dist/assets/{speaker-DCHkSyjS.js → speaker-EkvC7jK4.js} +1 -1
  88. package/dist/assets/src-Kh1mC91U.js +67 -0
  89. package/dist/assets/{step-inspector-model-CI19RBoT.js → step-inspector-model-X_yncKWE.js} +1 -1
  90. package/dist/assets/{table-2-CTZnEliG.js → table-2-Ctei20ip.js} +1 -1
  91. package/dist/assets/{timer-reset-DZ3bTFWu.js → timer-reset-CVElL395.js} +1 -1
  92. package/dist/assets/{ungroup-3fOR8xo7.js → ungroup-B8d2LiRM.js} +1 -1
  93. package/dist/assets/{unlink-vu-wpZmU.js → unlink-DcYhq2lS.js} +1 -1
  94. package/dist/assets/{usb-CGOBq5r2.js → usb-hziv0KIU.js} +1 -1
  95. package/dist/assets/{use-scenes-feed-D80maECB.js → use-scenes-feed-tvKKb38m.js} +1 -1
  96. package/dist/assets/{use-stationary-objects-DBEa50KS.js → use-stationary-objects-CXoxdg6S.js} +1 -1
  97. package/dist/assets/useEventInvalidation-Ch3e43SQ.js +1 -0
  98. package/dist/assets/{useNodeUrlSelection-DWbo46bM.js → useNodeUrlSelection-BKeCycvy.js} +1 -1
  99. package/dist/assets/user-round-BrkQjamf.js +1 -0
  100. package/dist/assets/{user-x-CjUfhy0O.js → user-x-B7WeA-ce.js} +1 -1
  101. package/dist/assets/{video-D7jv0spx.js → video-DKRf0Ic4.js} +1 -1
  102. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CglCXJMd.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-qrmMxESr.js} +2 -2
  103. package/dist/index.html +9 -9
  104. package/dist/server/addon.js +1 -1
  105. package/package.json +1 -1
  106. package/dist/assets/Addons-DAuTfOiO.js +0 -5
  107. package/dist/assets/AiProfiles-Cvu3UHy2.js +0 -3
  108. package/dist/assets/Build-C0J5ce6Z.js +0 -40
  109. package/dist/assets/CompositionBlockEditor-BsmLsHO7.js +0 -1
  110. package/dist/assets/CompositionEditorPage-AIRu6m_i.js +0 -1
  111. package/dist/assets/HelperWizard-B5Evcb8G.js +0 -2
  112. package/dist/assets/Identity-gwaZ5bXU.js +0 -1
  113. package/dist/assets/IntegrationDetail-P1tm0l2J.js +0 -1
  114. package/dist/assets/Integrations-BLXg84-0.js +0 -1
  115. package/dist/assets/MyAccess-id2Dmf9N.js +0 -2
  116. package/dist/assets/Network-BS9VI_eu.js +0 -1
  117. package/dist/assets/Notifications-CIXn3wxj.js +0 -1
  118. package/dist/assets/ScanNetworkModal-CJoDRy24.js +0 -1
  119. package/dist/assets/SessionsList-CMV9rDkY.js +0 -2
  120. package/dist/assets/circle-slash-CaxGVwz5.js +0 -1
  121. package/dist/assets/client-DvJxGh2F.js +0 -358
  122. package/dist/assets/crop-eK4NEtXI.js +0 -1
  123. package/dist/assets/device-picker-model-CUPf26ML.js +0 -1
  124. package/dist/assets/mount-CUPf26ML.js +0 -1
  125. package/dist/assets/remoteEntry-CVuKB7K_.js +0 -1
  126. package/dist/assets/src-DntJrWmU.js +0 -67
  127. package/dist/assets/useEventInvalidation-CUPf26ML.js +0 -1
  128. package/dist/assets/user-round-CmncOV9r.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Br as l,Cn as u,Nt as d,Q as f,Si as p,Wr as m,bi as h,bn as g,dt as _,or as v}from"./player-overlays-Dbv95cvz.js";import{Ma as y,ka as b}from"./client-DvJxGh2F.js";import{Ua as x,da as S,eo as C,fa as w,fo as T,fs as E,mi as D,no as O,sa as k,xo as A}from"./src-DntJrWmU.js";import{t as j}from"./useTranslation-BJr-n0es.js";import"./mount-CUPf26ML.js";import{P as M,lr as N}from"./index-XXQ5yMw_.js";import{t as P}from"./BrokerForm-D6ln7R0A.js";s();var F=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],I=f(`/addon/import-alexa`),L=2e3;function R(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function z(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function B(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function V(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function H(e,t,n){let r=await fetch(`${I}${e}`,{method:`POST`,headers:V(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function U(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${I}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!z(i))throw Error(`Unexpected status response from server`);return i}async function W(e){try{await fetch(`${I}/login/cancel`,{method:`POST`,headers:V(),body:JSON.stringify({sessionId:e})})}catch{}}function G({brokerId:n,onResolved:s,onCancel:c}){let{t:u}=j(),[f,p]=o(`amazon.it`),[m,h]=o(`Alexa account`),[_,y]=o({kind:`idle`}),b=t(!0);a(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=t(null),S=t(null),C=r(()=>{S.current!==null&&(clearInterval(S.current),S.current=null)},[]),w=r(async e=>{C(),b.current&&y({kind:`committing`,sessionId:e});try{let t=await H(`/login/commit`,{sessionId:e,name:m.trim().length>0?m.trim():`Alexa account`,...n===void 0?{}:{brokerId:n}},B);x.current=null,s(t.brokerId)}catch(t){let n=t instanceof Error?t.message:String(t);b.current&&y({kind:`error`,message:n,sessionId:e})}},[n,m,s,C]),T=r((e,t)=>{C();let n=async()=>{try{let n=await U(e);if(n.phase===`captured`){C(),w(e);return}if(n.phase===`error`){C(),b.current&&y({kind:`error`,message:n.error??u(`integrations.alexaLoginStep.loginProxyReturnedAnError`,`Login proxy returned an error`),sessionId:e});return}if(n.phase===`cancelled`){C(),b.current&&y({kind:`idle`});return}b.current&&y({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);b.current&&y(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};S.current=setInterval(()=>{n()},L)},[C,w,u]);a(()=>()=>{C(),x.current!==null&&W(x.current)},[C]);let E=async()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`starting`});try{let e=await H(`/login/start`,{amazonDomain:f},R);x.current=e.sessionId,y({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),T(e.sessionId,e.loginUrl)}catch(e){y({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},D=()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`idle`})},O=()=>{D()},k=_.kind===`idle`,A=_.kind===`starting`,M=_.kind===`polling`,P=_.kind===`committing`,I=_.kind===`error`,z=A||M||P,V=_.kind===`polling`?_.phase:null,G=_.kind===`polling`?_.loginUrl:null,K=M&&V===`awaiting-login`,q=M&&(V===`starting`||V===null);return e(`div`,{className:`space-y-4`,children:[(k||I)&&e(`div`,{className:`space-y-3`,children:[n===void 0&&e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.accountName`,`Account name`)}),i(`input`,{id:`alexa-account-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:u(`integrations.alexaLoginStep.alexaAccount`,`Alexa account`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.amazonRegion`,`Amazon region`)}),i(`select`,{id:`alexa-amazon-region`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:F.map(e=>i(`option`,{value:e,children:e},e))})]})]}),I&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[i(d,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),i(`span`,{children:_.message})]}),A&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.startingLoginProxy`,`Starting login proxy…`)]}),q&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.waitingForProxyToBe`,`Waiting for proxy to be ready…`)]}),P&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.savingCredentials`,`Saving credentials…`)]}),K&&G!==null&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[i(`p`,{className:`text-xs font-semibold text-foreground`,children:u(`integrations.alexaLoginStep.openTheLinkBelowTo`,`Open the link below to log in to your Amazon account`)}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.alexaLoginStep.afterCompletingTheLoginAnd`,`After completing the login and any 2FA steps, this wizard will continue automatically.`)}),e(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[i(l,{className:`h-3.5 w-3.5`}),u(`integrations.alexaLoginStep.loginToAmazon`,`Login to Amazon`)]})]}),i(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[10px] text-warning`,children:i(N,{i18nKey:`integrations.alexaLoginStep.proxyNote`,components:{b:i(`strong`,{}),code:i(`code`,{className:`font-mono`})}})}),e(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[i(v,{className:`h-3 w-3 animate-spin`}),u(`integrations.alexaLoginStep.waitingForAmazonLoginTo`,`Waiting for Amazon login to complete…`)]})]}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(`button`,{type:`button`,onClick:z?D:c,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:z?u(`integrations.alexaLoginStep.cancelLogin`,`Cancel login`):u(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[I&&e(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[i(g,{className:`h-3.5 w-3.5`}),u(`common.retry`,`Retry`)]}),k&&i(`button`,{type:`button`,onClick:()=>{E()},disabled:n===void 0&&m.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:u(`integrations.alexaLoginStep.startLogin`,`Start login`)})]})]})]})}s();var K=`alexa`;function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function J(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Y={connected:`bg-success/15 text-success`,connecting:`bg-warning/15 text-warning`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function X({kind:t,onResolved:r,onBack:a}){let{t:s}=j(),[c,l]=o(t===K?`alexa-login`:`existing`),u=S({kind:t}),d=n(()=>q(u.data).filter(e=>e.kind===t),[u.data,t]),f=w(),p=n(()=>{for(let e of J(f.data))if(e.kinds.some(e=>e.kind===t))return e.addonId},[f.data,t]),[m,g]=o(null),[_,y]=o(``),b=k({}),x=()=>{m&&r(m)},C=async e=>{_.trim().length!==0&&r((await b.mutateAsync({kind:t,name:_.trim(),settings:e,...p===void 0?{}:{addonId:p}})).id)},T=e=>{e===`new`?g(null):b.reset(),l(e)};return e(`div`,{className:`space-y-4`,children:[e(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[i(h,{className:`h-3.5 w-3.5`}),` `,s(`common.back`)]}),e(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[t===K&&i(`button`,{type:`button`,onClick:()=>T(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.loginInteractively`,`Login interactively`)}),i(`button`,{type:`button`,onClick:()=>T(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.useExisting`,`Use existing`)}),i(`button`,{type:`button`,onClick:()=>T(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:t===K?s(`integrations.brokerStep.pasteCookie`,`Paste cookie`):s(`integrations.brokerStep.createNew`,`Create new`)})]}),c===`alexa-login`&&i(G,{onResolved:r,onCancel:a}),c===`existing`&&e(`div`,{className:`space-y-3`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(v,{className:`h-3.5 w-3.5 animate-spin`}),` `,s(`integrations.brokerStep.loadingBrokers`)]}),u.isError&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[s(`integrations.brokerStep.failedToLoadBrokers`,`Failed to load brokers:`),` `,u.error instanceof Error?u.error.message:s(`integrations.brokerStep.unknownError`,`Unknown error`)]}),!u.isLoading&&!u.isError&&d.length===0&&i(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:i(N,{i18nKey:`integrations.brokerStep.noBrokers`,values:{mode:t===K?s(`integrations.brokerStep.loginInteractively`,`Login interactively`):s(`integrations.brokerStep.createNew`,`Create new`)},components:{b:i(`span`,{className:`font-medium text-foreground`})}})}),i(`div`,{className:`space-y-2`,children:d.map(t=>e(`button`,{type:`button`,onClick:()=>g(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${m===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[i(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Y[t.status]}`,children:t.status})]},t.id))}),d.length>0&&i(`div`,{className:`flex justify-end pt-1`,children:i(`button`,{type:`button`,onClick:x,disabled:!m,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:s(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]}),c===`new`&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`integrations.brokerStep.name`,`Name`)}),i(`input`,{type:`text`,value:_,onChange:e=>y(e.target.value),placeholder:s(`integrations.brokerStep.myHomeAssistant`,`My Home Assistant`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),i(P,{kind:t,...p===void 0?{}:{addonId:p},onSubmit:e=>{C(e).catch(()=>{})},onCancel:a,submitLabel:b.isPending?s(`integrations.brokerStep.creating`,`Creating…`):s(`integrations.brokerStep.createBroker`,`Create broker`),disabled:b.isPending||_.trim().length===0}),_.trim().length===0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`integrations.brokerStep.enterANameBeforeCreating`,`Enter a name before creating.`)})]})]})}s();function Z(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var Q={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function ee({addonId:t,configSchema:n,canTest:r=!0,initialName:a,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=j(),[p,m]=o(a??``),[h,g]=o(s??{}),[_,v]=o(null),x=E({onSuccess:e=>v(Z(e)),onError:e=>v({status:`inconclusive`,error:String(e)})}),S=D(),C=!r||_?.status===`validated`,w=!l&&p.trim().length===0,T=!w&&C;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[i(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),i(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":w,"aria-describedby":w?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${w?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),w&&i(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&i(M,{schema:n,values:h,onChange:e=>{g(e),v(null)},onAction:async(e,i,a)=>{let o=await S.mutateAsync({addonId:t,action:e,input:a??{}});if(r&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=y(n,r);g(i),v(null),x.mutate({addonId:t,settings:i})}return o}}),_&&i(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${Q[_.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(_)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>x.mutate({addonId:t,settings:y(n,h)}),disabled:x.isPending||!r,title:r?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[w&&i(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),i(`button`,{onClick:()=>{w||u({name:p,config:y(n,h),secretKeys:[...b(n)]})},disabled:!T,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})]})}s();function te({open:t,onClose:a,scope:s}){let{t:c}=j(),l=x(),[d,f]=o(new Set),[h,g]=o(new Set),{data:y}=T({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),S=r(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await l.mutateAsync({addonId:e,candidate:t}),f(e=>new Set(e).add(t.stableId))}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[l]),C=r((t,n)=>{let r=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=b.has(n.stableId),o=d.has(n.stableId)||a,s=h.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),r&&i(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:r})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5`}),` `,a?c(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):c(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void S(t,n),disabled:s,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[s?i(v,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),c(`common.add`,`Add`)]})]},n.stableId)},[d,h,b,S,c]);if(!t)return null;let w=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:a}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(u,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:w})]}),i(`button`,{onClick:a,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(_,{className:`h-4 w-4`})})]}),s?i(re,{scope:s,onAdopt:C,onReset:()=>f(new Set)}):i(ne,{onAdopt:C,onReset:()=>f(new Set)})]})]})}function ne({onAdopt:t,onReset:o}){let{t:s}=j(),l=C(),u=r(()=>{o(),l.mutate({})},[l,o]);a(()=>{!l.isPending&&!l.data&&u()},[]);let d=n(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=n(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return e(c,{children:[i(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:u,disabled:l.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[i(g,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&i(ie,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&i($,{}),!l.isPending&&l.data&&d.length===0&&i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(n=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-[11px] font-semibold text-foreground`,children:n.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.candidates.length,`)`]})]}),n.candidates.map(e=>t(n.addonId,e))]},n.addonId))]})]})}function re({scope:t,onAdopt:n,onReset:a}){let{t:s}=j(),l=A({addonId:t.addonId}).data??null,[d,f]=o({}),p=O(),m=r(()=>{a(),p.mutate({addonId:t.addonId,params:d})},[p,t.addonId,d,a]),h=p.data?.candidates??[];return i(c,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&i(M,{schema:l,values:d,onChange:f}),e(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?i(v,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),p.isPending?s(`integrations.scanNetworkModal.scanning`,`Scanning…`):s(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&i($,{}),!p.isPending&&p.data&&h.length===0&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&h.length>0&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.foundShort`,{count:h.length})}),h.map(e=>n(t.addonId,e))]})]})})}function ie({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(v,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function $(){let{t}=j();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{ee as n,X as r,te as t};
@@ -1,2 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,It as l,Rr as u,cn as d,dt as f,or as p,ot as m,pi as h,sa as g,sn as _}from"./player-overlays-Dbv95cvz.js";import{a as v,i as y,s as b}from"./video-D7jv0spx.js";import{t as x}from"./key-round-DG341WFZ.js";import{$r as S,$u as C,Bn as ee,Dr as w,Gr as T,Hn as te,Ju as E,Kn as D,Kr as O,Ot as k,Ru as A,Sn as j,Tn as M,Un as N,Wr as P,_r as F,ct as ne,ed as I,ei as L,fo as re,gn as R,gr as z,gt as ie,hn as B,hr as V,lt as ae,mn as H,mr as U,mt as oe,pr as W,sd as G,vr as K,wn as se,yd as q,yr as J}from"./src-DntJrWmU.js";import{t as Y}from"./i18n-D0o08mg-.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{$n as ce,lr as le,n as Z,t as ue}from"./index-XXQ5yMw_.js";s();function de({id:t,title:n,icon:r,description:a,actions:o,tone:s=`default`,notice:l=null,onDismissNotice:u,children:d}){return i(j,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:G(`text-[11px] leading-relaxed`,s===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&i(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:h,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:y,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:t,onDismiss:n}){let{t:r}=X(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:G(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),i(`span`,{className:`min-w-0 flex-1`,children:t.message}),n!==void 0&&i(I,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=A();return n(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return Y.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return i(S,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:n}){if(!n.isAvailable(t))return null;let r=n.icon,a=n.busyId===t.id;return e(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.onRun(t),disabled:n.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:n.label,name:t.name}),className:n.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(r,{className:`h-3 w-3`,"aria-hidden":!0}),n.label]})}function Ce(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[i(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[i(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&i(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>i(xe,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>i(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:i(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}s();var we=6,Te={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Ee(e){let t=Te[e];return t===void 0?e:Y.t(t)}function De(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:De(e,t)})}function Oe(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function ke(e,t){let n=e.slice(0,we).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>we?[Y.t(`access.bulk.previewMore`,{count:e.length-we})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:Oe(e)}),``,...n,...r].join(`
2
- `)}async function Ae(e,t,n){let r=String(t.length),i=await e({title:Y.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:ke(t,n),label:Y.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:Y.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:Y.t(`access.bulk.confirmMismatch`,{expected:r,noun:De(2,n)})});return i!==null&&i.trim()===r}function je(e,t){let n=T(),r=q.auth.revokeCredentials.useMutation(),[i,a]=o(null);return{run:async i=>{if(i.length===0||!await Ae(n,i,e))return!1;a(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Ee(e.reason));return a({tone:`success`,message:n.length>0?Y.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):Y.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return a({tone:`danger`,message:Y.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:Y.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:i,dismiss:()=>a(null)}}function Me(e,t,n){let r=T(),[i,a]=o(!1),[s,c]=o(null);return{run:async i=>{if(i.length===0||!await Ae(r,i,e))return!1;c(null),a(!0);let o=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){o.push(`${e.name}: ${t instanceof Error?t.message:Y.t(`access.bulk.requestFailed`)}`)}return a(!1),n(),o.length===0?(c({tone:`success`,message:Y.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:Y.t(o.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:o.length,details:o.slice(0,3).join(`; `)})}),s>0)},busy:i,outcome:s,dismiss:()=>c(null)}}s();var Ne={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Pe={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Fe=e=>e.status!==`current`,Ie=[`active`,`current`];function Le({rows:t,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:m,defaultStatus:h=Ie}){let{t:g}=X(),[_]=o(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=H(t,Ne,_),[y,b]=o(()=>new Set),x=u??g(`access.credentialColumns.never`),S=n(()=>Ce({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,g]),C=n(()=>m===void 0?()=>!1:e=>Fe(e)&&m.isSelectable(e),[m]),ee=n(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return a?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:r})]}):s===null?e(`div`,{className:`space-y-3`,children:[i(B,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Pe[e.id]===void 0?e.id:g(Pe[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:g(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&i(Re,{bulk:m,shown:v.rows.filter(C),targets:ee,onSelect:b}),i(se,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:M,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:r}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:De(1,m.noun)})}}})]}):i(w,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function Re({bulk:t,shown:n,targets:r,onSelect:a}){let{t:o}=X(),{revoke:s,noun:c}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:n.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(r)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[n.length>0&&i(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(n.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:n.length})}),u.map(t=>e(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),r.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(r.length,c)})}),e(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[i(f,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(O,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(l,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(r.length,c)})]})]})]})}var ze=(e,t)=>t===null?`—`:e.get(t)??t;function Be(e,t){return e!=null&&e<=t?`expired`:`active`}function Ve(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:ze(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function He(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Ue=`All permissions`,We=`View link`,Ge=`Scoped`,Ke={"grid-view":`Grid`,"events-view":`Events`};function qe(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Je(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ye(e,t,n){return e===`*`?Ue:Je(e)?`${`${Ke[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${qe(e.grant.deviceIds,t)}`:n(e)}function Xe(e){return e.includes(`*`)?Ue:e.some(Je)?We:Ge}function Ze(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:ze(t,e.subjectId),kind:Xe(e.scopes),scope:n,status:e.revokedAt===null?Be(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Qe(e){return`${e.provider}\u0000${e.subject}`}function $e(e,t){return{id:Qe(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:ze(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var et=40,tt=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],nt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],rt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function it(e,t){return e.find(e=>e.test.test(t))?.name??null}function at(e){return e.length<=et?e:`${e.slice(0,et)}…`}function ot(e){if(e===null||e.trim().length===0)return{label:Y.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=it(rt,t);if(n!==null)return{label:n,raw:t};let r=it(tt,t),i=it(nt,t);return r!==null&&i!==null?{label:Y.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:at(t),raw:t}:{label:r,raw:t}}var st={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,exchange:`helpers.sessionClient.method.exchange`};function ct(e){let t=st[e];return t===void 0?e:Y.t(t)}function lt(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}s();function ut(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function dt(n){let{t:a}=X(),s=m(),[c,l]=o(!1),[u,d]=o(``),[f,h]=o(null),[g,_]=o(null),v=t(null),y=r(e=>{v.current?.(e),v.current=null,l(!1),d(``),h(null),_(null)},[]),b=r(()=>new Promise(e=>{v.current?.(null),v.current=e,_(null),l(!0)}),[]),S=async()=>{h(`password`),_(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});y(e)}catch(e){_(ut(e,`Password is incorrect`)),h(null)}},ee=async()=>{h(`passkey`),_(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!ue(e))throw Error(`passkey authentication options missing challenge`);let t=await Z({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});y(n)}catch(e){_(ut(e,`Passkey verification failed`)),h(null)}};return{requestProof:b,dialog:i(W,{open:c,onOpenChange:e=>!e&&y(null),children:e(V,{children:[e(K,{children:[i(J,{children:a(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),i(z,{children:a(`auth.reauthDialog.needsPassword`,{action:n})})]}),e(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&f===null&&S()},children:[i(C,{type:`password`,autoComplete:`current-password`,placeholder:a(`auth.reauthDialog.currentPassword`,`Current password`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`auth.reauthDialog.currentPassword`,`Current password`)}),g!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:g}),e(F,{className:`flex flex-wrap gap-2`,children:[e(O,{type:`button`,variant:`outline`,disabled:f!==null,onClick:()=>void ee(),children:[f===`passkey`?i(p,{className:`h-4 w-4 animate-spin`}):i(x,{className:`h-4 w-4`}),a(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),e(O,{type:`submit`,disabled:u.length===0||f!==null,children:[f===`password`&&i(p,{className:`h-4 w-4 animate-spin`}),a(`common.confirm`,`Confirm`)]})]})]})]})})}}function ft({token:t,label:n,onClose:r}){let{t:a}=X();return i(W,{open:!0,onOpenChange:e=>!e&&r(),children:e(V,{width:`md`,scroll:`body`,children:[i(K,{children:i(J,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:n})})}),e(U,{className:`space-y-3`,children:[i(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),i(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(F,{children:[i(R,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),i(O,{type:`button`,variant:`primary`,size:`sm`,onClick:r,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var pt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};s();var mt=80,$=86400,ht=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],gt={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},_t={type:`capability`,target:``,access:[`view`,`create`]};function vt({open:t,users:r,onClose:s,onSubmit:c,submitting:l,formError:f,awaitingProof:m}){let{t:h}=X(),v=g(),{user:y}=ce(),b=y?.isAdmin===!0,S=b?null:y?.scopes??[],[w,T]=o(`scopes`),[k,A]=o(y?.id??``),[j,M]=o(``),[P,F]=o([_t]),[I,re]=o([]),[R,z]=o(`grid-view`),[B,V]=o(!1),[H,U]=o(`30`);a(()=>{t||(T(`scopes`),A(y?.id??``),M(``),F([_t]),re([]),z(`grid-view`),V(!1),U(`30`))},[t,y?.id]),a(()=>{w!==`view-link`&&H===`never`&&U(`30`)},[w,H]);let oe=n(()=>ht.filter(e=>e.seconds!==`never`||w===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?h(`access.createTokenModal.never`,`Never (until revoked)`):h(`access.createTokenModal.days`,{count:Number(e.value)})})),[w,h]),W=j.trim(),G=w===`scopes`?ae(P,v):null,K=I.map(Number).filter(e=>Number.isInteger(e)&&e>=0),se=ht.find(e=>e.value===H)?.seconds??30*$,q=()=>w===`all`?[`*`]:w===`view-link`?[{type:`share-view`,grant:{kind:R,deviceIds:K,...B?{talk:!0}:{}}}]:P,J=W.length>0&&W.length<=mt&&!l&&!m&&(w===`all`?b:w===`view-link`?K.length>0:P.length>0&&G===null),Y=()=>{if(!J)return;let e=b&&w!==`all`&&k!==``&&k!==y?.id;c({scopes:q(),expiresIn:se,label:W,...e?{subjectId:k}:{}})},Z=w===`all`,ue=Z?d:_;return i(ie,{open:t,onClose:s,title:h(`access.createTokenModal.createToken`,`Create token`),icon:Z?d:x,error:f,width:`md`,testId:`create-token-dialog`,footer:e(O,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:Y,disabled:!J,"data-testid":`create-token-submit`,children:[l||m?i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):i(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),h(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.whatItMayDo`,`What it may do`)}),i(ee,{appearance:`pills`,value:w,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&T(e)},children:e(te,{"aria-label":h(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(N,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(N,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[i(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachViewLink`,`View link`)]}),b?e(N,{value:`all`,"data-testid":`token-reach-all`,children:[i(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?i(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:i(`p`,{children:i(le,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:i(`strong`,{})}})})}):null,b&&w!==`all`&&r.length>1?e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-user`,children:h(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),i(E,{id:`token-user`,value:k,onChange:e=>A(e.target.value),options:r.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-name`,children:h(`access.createTokenModal.label`,`Label`)}),i(C,{id:`token-name`,value:j,maxLength:mt,required:!0,onChange:e=>M(e.target.value),placeholder:w===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),w===`scopes`?e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.scopes`,`Scopes`)}),i(ne,{value:P,onChange:F,clampToParent:S}),G&&i(`p`,{className:`text-[10px] text-danger`,children:G}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:h(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,w===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.cameras`,`Cameras`)}),i(L,{field:{...gt,label:h(`access.createTokenModal.cameras`,`Cameras`)},value:I,onChange:e=>re(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-view-kind`,children:h(`access.createTokenModal.viewKind`,`Shows`)}),i(E,{id:`token-view-kind`,value:R,onChange:e=>z(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:h(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:h(`access.createTokenModal.viewEvents`,`Events`)}]})]}),R===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[i(`input`,{type:`checkbox`,className:`mt-0.5`,checked:B,onChange:e=>V(e.target.checked),"data-testid":`token-view-talk`}),i(`span`,{children:h(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-lifetime`,children:h(`access.createTokenModal.expires`,`Expires after`)}),i(E,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:oe})]})]})})}s();var yt={key:`access.nouns.token`};function bt(e){return typeof e==`object`&&!!e&&`kind`in e}function xt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${bt(e.selector)?k(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function St({headerOwnsCreate:t=!1,createRequested:r=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:u}=X(),d=g(),{user:f}=ce(),p=P(),m=q.useUtils(),h=me(),{data:_}=A(),v=n(()=>_??[],[_]),{data:y}=re({}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),S=q.auth.listTokens.useQuery(void 0),{requestProof:C,dialog:ee}=dt(`Creating a token with all permissions`),{state:w,openNew:T,close:te}=oe({newKey:pt.token}),[E,D]=o(null),[k,j]=o(null),[M,N]=o(!1),[F,ne]=o(null),[I,L]=o(null);a(()=>{r&&(T(),s?.())},[r,T,s]);let R=()=>{m.auth.listTokens.invalidate(),m.auth.listAuthAudit.invalidate()},z=q.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{R(),te(),j(null),N(!1),ne({token:e,label:t.label})},onError:e=>{j(`Create failed: ${e.message}`),N(!1)}}),ie=q.auth.revokeToken.useMutation({onSuccess:()=>{L(null),R()},onError:e=>{L(null),D(`Revoke failed: ${e.message}`)}}),B=je(yt,R),V=Date.now(),ae=(S.data??[]).filter(e=>!c||e.subjectId===f?.id).map(e=>Ze(e,h,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ye(e,b,e=>xt(e,d))).join(`, `),V)),H=async e=>{await p({title:u(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?u(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):u(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:u(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(D(null),L(e.id),ie.mutate({id:e.id}))},U=e=>{(async()=>{D(null),j(null);let t;if(e.scopes.includes(`*`)){N(!0);let e=await C();if(N(!1),e===null)return;t=e}z.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[ee,i(de,{notice:he(E,B.outcome),onDismissNotice:()=>{D(null),B.dismiss()},id:c?`my-tokens`:`tokens`,title:c?u(`access.tokensSection.myTokens`,`My tokens`):u(`access.tokensSection.tokens`,`Tokens`),icon:x,actions:t?void 0:e(O,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:T,children:[i(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`system.access.newToken`,`New token`)]}),description:u(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:i(Le,{rows:ae,label:u(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:u(`access.tokensSection.noTokens`,`No tokens.`),action:{label:u(`access.tokensSection.revoke2`,`Revoke`),icon:l,isAvailable:e=>e.status===`active`,onRun:e=>void H(e),busyId:I,disabled:B.busy||I!==null},...f?.isAdmin===!0?{bulk:{revoke:B,noun:yt,isSelectable:e=>e.status===`active`}}:{}})}),i(vt,{open:w.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{te(),j(null),N(!1)},submitting:z.isPending,formError:k,awaitingProof:M,onSubmit:U}),F&&i(ft,{token:F.token,label:F.label,onClose:()=>ne(null)})]})}var Ct=864e5,wt={qr:`QR (by an admin)`,self:`Self-enrolled`},Tt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function Et(e){return e.status===`revoked`}function Dt(e){return e.status!==`revoked`}function Ot(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function kt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Ct)}function At(e,t){let n=kt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function jt(e,t){let n=kt(e,t);return n===null?Y.t(`helpers.certificateModel.unknown`):n===0?Y.t(`helpers.certificateModel.today`):n>0?Y.t(`helpers.certificateModel.inDays`,{count:n}):Y.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Mt(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Nt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Pt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Ft(e){if(!e.online)return{allowed:!1,reason:Y.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var It={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Lt(e){if(e.ok)return{tone:`success`,message:Y.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Pt(e.newSerial)})};let t=e.keptPreviousLeaf?Y.t(`helpers.certificateModel.keptPrevious`):Y.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:Y.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:Y.t(It[e.stage]),reason:e.reason,kept:t})}}function Rt(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var zt=11;function Bt(e,t){let n=e.slice(0,zt);return t===null?n:`${n} · ${t}`}function Vt(e){return{id:e.id,name:e.deviceName,detail:Bt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Tt[e.platform],scope:wt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ht(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Tt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ut({sessions:t,isLoading:n,loadError:r,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=X();return n?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):r===null?t.length===0?i(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>i(Wt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,r]})}function Wt({session:t,revoking:n,onRevoke:r}){let{t:a}=X(),o=ot(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[i(v,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&i(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:ct(t.method)}),i(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),i(`span`,{children:a(`auth.sessionsList.lastActive`,{when:lt(t.lastUsedAt)})}),i(`span`,{children:a(`auth.sessionsList.expires`,{when:lt(t.expiresAt)})})]})]}),!t.current&&e(`button`,{onClick:r,disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?i(p,{className:`h-3 w-3 animate-spin`}):i(b,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{me as A,He as C,Me as D,je as E,de as O,$e as S,Le as T,dt as _,Dt as a,lt as b,jt as c,Ot as d,Ft as f,pt as g,St as h,Et as i,he as k,Lt as l,Pt as m,Vt as n,Rt as o,Nt as p,Ht as r,Mt as s,Ut as t,At as u,ot as v,Ve as w,Qe as x,ct as y};
@@ -1 +0,0 @@
1
- import{na as e}from"./player-overlays-Dbv95cvz.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};