@omniviewdev/runtime 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/api.cjs +1 -1
  2. package/dist/api.d.ts +15 -14
  3. package/dist/api.js +110 -125
  4. package/dist/bindings/encoding/json/index.d.ts +1 -0
  5. package/dist/bindings/encoding/json/models.d.ts +6 -0
  6. package/dist/bindings/github.com/omniviewdev/omniview/appservice.d.ts +18 -0
  7. package/dist/bindings/github.com/omniviewdev/omniview/backend/diagnostics/diagnosticsclient.d.ts +51 -0
  8. package/dist/bindings/github.com/omniviewdev/omniview/backend/diagnostics/index.d.ts +2 -0
  9. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/data/index.d.ts +2 -0
  10. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/data/servicewrapper.d.ts +5 -0
  11. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/index.d.ts +3 -0
  12. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/models.d.ts +132 -0
  13. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/servicewrapper.d.ts +12 -0
  14. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/exec/index.d.ts +2 -0
  15. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/exec/servicewrapper.d.ts +22 -0
  16. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/index.d.ts +3 -0
  17. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/lifecycle/index.d.ts +1 -0
  18. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/lifecycle/models.d.ts +29 -0
  19. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/logs/index.d.ts +2 -0
  20. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/logs/servicewrapper.d.ts +11 -0
  21. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/index.d.ts +3 -0
  22. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/models.d.ts +39 -0
  23. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/servicewrapper.d.ts +16 -0
  24. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/models.d.ts +72 -0
  25. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/networker/index.d.ts +2 -0
  26. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/networker/servicewrapper.d.ts +11 -0
  27. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/index.d.ts +3 -0
  28. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/models.d.ts +24 -0
  29. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/servicewrapper.d.ts +7 -0
  30. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/registry/index.d.ts +1 -0
  31. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/registry/models.d.ts +94 -0
  32. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graph/index.d.ts +2 -0
  33. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graph/models.d.ts +53 -0
  34. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graphservice.d.ts +14 -0
  35. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/index.d.ts +4 -0
  36. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/models.d.ts +61 -0
  37. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/servicewrapper.d.ts +92 -0
  38. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/servicewrapper.d.ts +24 -0
  39. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/settings/index.d.ts +2 -0
  40. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/settings/servicewrapper.d.ts +18 -0
  41. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/types/index.d.ts +1 -0
  42. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/types/models.d.ts +22 -0
  43. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/index.d.ts +3 -0
  44. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/models.d.ts +55 -0
  45. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/servicewrapper.d.ts +7 -0
  46. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/client.d.ts +6 -0
  47. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/index.d.ts +3 -0
  48. package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/models.d.ts +10 -0
  49. package/dist/bindings/github.com/omniviewdev/omniview/index.d.ts +3 -0
  50. package/dist/bindings/github.com/omniviewdev/omniview/internal/settings/index.d.ts +2 -0
  51. package/dist/bindings/github.com/omniviewdev/omniview/internal/settings/servicewrapper.d.ts +48 -0
  52. package/dist/bindings/github.com/omniviewdev/omniview/internal/telemetry/index.d.ts +2 -0
  53. package/dist/bindings/github.com/omniviewdev/omniview/internal/telemetry/telemetrybinding.d.ts +7 -0
  54. package/dist/bindings/github.com/omniviewdev/omniview/models.d.ts +38 -0
  55. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/config/index.d.ts +1 -0
  56. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/config/models.d.ts +101 -0
  57. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/types/index.d.ts +1 -0
  58. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/types/models.d.ts +199 -0
  59. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/exec/index.d.ts +1 -0
  60. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/exec/models.d.ts +79 -0
  61. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/logs/index.d.ts +1 -0
  62. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/logs/models.d.ts +133 -0
  63. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/metric/index.d.ts +1 -0
  64. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/metric/models.d.ts +207 -0
  65. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/networker/index.d.ts +2 -0
  66. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/networker/models.d.ts +96 -0
  67. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/resource/index.d.ts +2 -0
  68. package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/resource/models.d.ts +1199 -0
  69. package/dist/bindings/github.com/omniviewdev/plugin-sdk/settings/index.d.ts +2 -0
  70. package/dist/bindings/github.com/omniviewdev/plugin-sdk/settings/models.d.ts +169 -0
  71. package/dist/bindings/github.com/wailsapp/wails/v3/internal/eventcreate.d.ts +1 -0
  72. package/dist/bindings/time/index.d.ts +1 -0
  73. package/dist/bindings/time/models.d.ts +33 -0
  74. package/dist/calls-BmUnjINC.js +677 -0
  75. package/dist/calls-DZctVyoQ.cjs +1 -0
  76. package/dist/compat/legacyEnum.d.ts +10 -0
  77. package/dist/compat/resource.d.ts +4 -0
  78. package/dist/compat/types.d.ts +4 -0
  79. package/dist/context/plugins/PluginContext.d.ts +2 -2
  80. package/dist/events-BTiuwc-0.cjs +1 -0
  81. package/dist/events-DDTGFACO.js +371 -0
  82. package/dist/extensions/provider.d.ts +12 -6
  83. package/dist/extensions/registry.d.ts +37 -18
  84. package/dist/hooks/connection/useConnection.d.ts +5 -5
  85. package/dist/hooks/connection/useConnectionStatus.d.ts +7 -0
  86. package/dist/hooks/connection/useConnections.d.ts +4 -4
  87. package/dist/hooks/exec/useExecSession.d.ts +2 -2
  88. package/dist/hooks/logs/useLogSession.d.ts +1 -2
  89. package/dist/hooks/metric/useMetricProviders.d.ts +3 -3
  90. package/dist/hooks/metric/useMetricStream.d.ts +2 -2
  91. package/dist/hooks/metric/useResourceMetrics.d.ts +4 -3
  92. package/dist/hooks/networker/types.d.ts +3 -3
  93. package/dist/hooks/networker/usePortForwardSessions.d.ts +4 -4
  94. package/dist/hooks/networker/useResourcePortForwarder.d.ts +3 -4
  95. package/dist/hooks/resource/useEditorSchemas.d.ts +2 -2
  96. package/dist/hooks/resource/useEventBatcher.d.ts +3 -0
  97. package/dist/hooks/resource/useResource.d.ts +3 -4
  98. package/dist/hooks/resource/useResourceActions.d.ts +2 -3
  99. package/dist/hooks/resource/useResourceAreaComponent.d.ts +3 -3
  100. package/dist/hooks/resource/useResourceGroups.d.ts +6 -6
  101. package/dist/hooks/resource/useResourceMutations.d.ts +3 -4
  102. package/dist/hooks/resource/useResourceType.d.ts +1 -1
  103. package/dist/hooks/resource/useResourceTypes.d.ts +6 -6
  104. package/dist/hooks/resource/useResources.d.ts +3 -4
  105. package/dist/index-D2mKAO8s.js +1069 -0
  106. package/dist/index-D_aIcqH0.cjs +6 -0
  107. package/dist/index.cjs +2 -2
  108. package/dist/index.js +1371 -1778
  109. package/dist/legacyEnum-DORXlU_y.js +13 -0
  110. package/dist/legacyEnum-DkV5yRdA.cjs +1 -0
  111. package/dist/models-B8OVRhdT.js +159 -0
  112. package/dist/models-BVKsY9u1.js +2285 -0
  113. package/dist/models-CExSuVU2.cjs +1 -0
  114. package/dist/models-DdAWPDgz.cjs +1 -0
  115. package/dist/models.cjs +1 -1
  116. package/dist/models.d.ts +27 -1
  117. package/dist/models.js +259 -2244
  118. package/dist/runtime.cjs +1 -1
  119. package/dist/runtime.d.ts +1 -1
  120. package/dist/runtime.js +198 -205
  121. package/dist/servicewrapper-BH5omp-N.js +708 -0
  122. package/dist/servicewrapper-dDhyC68C.cjs +1 -0
  123. package/dist/types/app.d.ts +1 -1
  124. package/dist/types/extensions.d.ts +107 -161
  125. package/dist/types/watch.d.ts +4 -5
  126. package/package.json +17 -9
  127. package/LICENSE +0 -661
  128. package/dist/Client-D4njqvNH.js +0 -632
  129. package/dist/Client-DHqavZ6d.cjs +0 -1
  130. package/dist/wailsjs/go/data/Client.d.ts +0 -10
  131. package/dist/wailsjs/go/devserver/DevServerManager.d.ts +0 -24
  132. package/dist/wailsjs/go/diagnostics/DiagnosticsClient.d.ts +0 -18
  133. package/dist/wailsjs/go/exec/Client.d.ts +0 -26
  134. package/dist/wailsjs/go/logs/Client.d.ts +0 -16
  135. package/dist/wailsjs/go/main/App.d.ts +0 -8
  136. package/dist/wailsjs/go/metric/Client.d.ts +0 -12
  137. package/dist/wailsjs/go/models.d.ts +0 -1060
  138. package/dist/wailsjs/go/networker/Client.d.ts +0 -14
  139. package/dist/wailsjs/go/plugin/pluginManager.d.ts +0 -52
  140. package/dist/wailsjs/go/pluginlog/Manager.d.ts +0 -18
  141. package/dist/wailsjs/go/resource/Client.d.ts +0 -90
  142. package/dist/wailsjs/go/settings/Client.d.ts +0 -14
  143. package/dist/wailsjs/go/settings/provider.d.ts +0 -46
  144. package/dist/wailsjs/go/ui/Client.d.ts +0 -6
  145. package/dist/wailsjs/go/utils/Client.d.ts +0 -2
  146. package/dist/wailsjs/runtime/runtime.d.ts +0 -249
@@ -0,0 +1,6 @@
1
+ "use strict";const f=typeof window<"u"&&typeof document<"u",oe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function F(e=21){const t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?crypto:null;if(t){const i=new Uint8Array(e);t.getRandomValues(i);let r="";for(let l=0;l<e;l++)r+=oe[i[l]&63];return r}let n="",o=e|0;for(;o--;)n+=oe[Math.random()*64|0];return n}var B;function ye(){return window.location.origin+"/wails/runtime"}const C=512*1024;class ce extends Error{constructor(t,n){super(t,n),this.name="RuntimeError"}}const P=Object.freeze({Call:0,Clipboard:1,Application:2,Events:3,ContextMenu:4,Dialog:5,Window:6,Screens:7,System:8,Browser:9,CancelCall:10,IOS:11,Android:12});let K=F(),Z=null;function A(e,t=""){return function(n,o=null){return Me(e,n,t,o)}}async function Me(e,t,n,o){var i,r;if(Z)return Z.call(e,t,n,o);let l=new URL(ye()),a={object:e,method:t};o!=null&&(a.args=o);let u={"x-wails-client-id":K,"Content-Type":"application/json"};n&&(u["x-wails-window-name"]=n);const g=JSON.stringify(a);let c;if(g.length>C?c=await _e(l,u,g):c=await fetch(l,{method:"POST",headers:u,body:g}),!c.ok){const p=c.headers.get("Content-Type");if(p!=null&&p.includes("application/json")){const h=await c.json();let m;switch(h.kind){case"ReferenceError":m=new ReferenceError(h.message);break;case"TypeError":m=new TypeError(h.message);break;case"RuntimeError":m=new ce(h.message);break;default:m=new Error(h.message)}throw m.cause=h.cause,m}throw new Error(await c.text())}return((r=(i=c.headers.get("Content-Type"))===null||i===void 0?void 0:i.indexOf("application/json"))!==null&&r!==void 0?r:-1)!==-1?c.json():c.text()}async function _e(e,t,n){const o=F(),i=new TextEncoder().encode(n),r=Math.ceil(i.length/C);for(let l=0;l<r-1;l++){const a=i.subarray(l*C,(l+1)*C),u=await fetch(e,{method:"POST",headers:Object.assign(Object.assign({},t),{"x-wails-chunk-id":o,"x-wails-chunk-index":String(l),"x-wails-chunk-total":String(r)}),body:a});if(!u.ok)throw new Error(await u.text())}return fetch(e,{method:"POST",headers:Object.assign(Object.assign({},t),{"x-wails-chunk-id":o,"x-wails-chunk-index":String(r-1),"x-wails-chunk-total":String(r)}),body:i.subarray((r-1)*C)})}const ie=f&&typeof((B=window.wails)===null||B===void 0?void 0:B.invokeAsync)=="function"?window.wails:null;if(ie){const e=new Map;window._wailsAndroidCallback=(t,n,o)=>{var i;const r=e.get(t);if(r){if(e.delete(t),o){r.reject(new Error(o));return}try{const l=JSON.parse(n??"{}");if(!l.ok){r.reject(new Error((i=l.error)!==null&&i!==void 0?i:"unknown runtime call error"));return}r.resolve("text"in l?l.text:l.data)}catch(l){r.reject(l)}}},Z={call(t,n,o,i){return new Promise((r,l)=>{const a=F();e.set(a,{resolve:r,reject:l});try{ie.invokeAsync(a,JSON.stringify({object:t,method:n,windowName:o,args:i??null,clientId:K}))}catch(u){e.delete(a),l(u)}})}}}const Q=A(P.System),Se=0,Ee=1,Te=2,N=function(){var e,t,n,o,i,r;try{if(!((t=(e=window.chrome)===null||e===void 0?void 0:e.webview)===null||t===void 0)&&t.postMessage)return window.chrome.webview.postMessage.bind(window.chrome.webview);if(!((i=(o=(n=window.webkit)===null||n===void 0?void 0:n.messageHandlers)===null||o===void 0?void 0:o.external)===null||i===void 0)&&i.postMessage)return window.webkit.messageHandlers.external.postMessage.bind(window.webkit.messageHandlers.external);if(!((r=window.wails)===null||r===void 0)&&r.invoke)return l=>window.wails.invoke(typeof l=="string"?l:JSON.stringify(l))}catch{}return console.warn(`
2
+ %c⚠️ Browser Environment Detected %c
3
+
4
+ %cOnly UI previews are available in the browser. For full functionality, please run the application in desktop mode.
5
+ More information at: https://v3.wails.io/learn/build/#using-a-browser-for-development
6
+ `,"background: #ffffff; color: #000000; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 2px solid #000000;","background: transparent;","color: #ffffff; font-style: italic; font-weight: bold;"),null}();function M(e){N==null||N(e)}function Ce(){return Q(Se)}async function De(){return Q(Te)}function ze(){return Q(Ee)}function I(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS)==="windows"}function ee(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS)==="linux"}function te(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS)==="darwin"}function fe(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS)==="ios"}function we(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS)==="android"}function Oe(){return fe()||we()}function Re(){return te()||I()||ee()}function xe(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.Arch)==="amd64"}function ke(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.Arch)==="arm"}function Le(){var e,t;return((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.Arch)==="arm64"}function he(){var e,t;return!!(!((t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0)&&t.Debug)}const Fe=Object.freeze(Object.defineProperty({__proto__:null,Capabilities:De,Environment:ze,IsAMD64:xe,IsARM:ke,IsARM64:Le,IsAndroid:we,IsDarkMode:Ce,IsDebug:he,IsDesktop:Re,IsIOS:fe,IsLinux:ee,IsMac:te,IsMobile:Oe,IsWindows:I,invoke:M},Symbol.toStringTag,{value:"Module"}));function Pe(){return new MouseEvent("mousedown").buttons===0}function Ae(){if(!EventTarget||!AbortSignal||!AbortController)return!1;let e=!0;const t=new EventTarget,n=new AbortController;return t.addEventListener("test",()=>{e=!1},{signal:n.signal}),n.abort(),t.dispatchEvent(new CustomEvent("test")),e}function me(e){var t;return e.target instanceof HTMLElement?e.target:!(e.target instanceof HTMLElement)&&e.target instanceof Node&&(t=e.target.parentElement)!==null&&t!==void 0?t:document.body}let ve=!1;f&&document.addEventListener("DOMContentLoaded",()=>{ve=!0});function pe(e){ve||document.readyState==="complete"?e():document.addEventListener("DOMContentLoaded",e)}f&&window.addEventListener("contextmenu",Be);const Ie=A(P.ContextMenu),He=0;function je(e,t,n,o){Ie(He,{id:e,x:t,y:n,data:o})}function Be(e){const t=me(e),n=window.getComputedStyle(t).getPropertyValue("--custom-contextmenu").trim();if(n){e.preventDefault();const o=window.getComputedStyle(t).getPropertyValue("--custom-contextmenu-data");je(n,e.clientX,e.clientY,o)}else Ne(e,t)}function Ne(e,t){if(he())return;switch(window.getComputedStyle(t).getPropertyValue("--default-contextmenu").trim()){case"show":return;case"hide":e.preventDefault();return}if(t.isContentEditable)return;const n=window.getSelection(),o=n&&n.toString().length>0;if(o)for(let i=0;i<n.rangeCount;i++){const l=n.getRangeAt(i).getClientRects();for(let a=0;a<l.length;a++){const u=l[a];if(document.elementFromPoint(u.left,u.top)===t)return}}(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(o||!t.readOnly&&!t.disabled)||e.preventDefault()}function D(e){try{return window._wails.flags[e]}catch(t){throw new Error("Unable to retrieve flag '"+e+"': "+t,{cause:t})}}const We=Object.freeze(Object.defineProperty({__proto__:null,GetFlag:D},Symbol.toStringTag,{value:"Module"}));let z=!1,O=!1,G=!1,E=!1,T=!1,y="",re="auto",_=0,x=!1;f&&(x=Pe(),window._wails=window._wails||{},window._wails.setResizable=e=>{G=e,G||(E=T=!1,w())});let J=!1;function Ue(){var e,t;const n=(t=(e=window._wails)===null||e===void 0?void 0:e.environment)===null||t===void 0?void 0:t.OS;if(n==="ios"||n==="android")return!0;const o=navigator.userAgent||navigator.vendor||window.opera||"";return/android|iphone|ipad|ipod|iemobile|wpdesktop/i.test(o)}function W(){if(!J&&!Ue()){window.addEventListener("mousedown",X,{capture:!0}),window.addEventListener("mousemove",X,{capture:!0}),window.addEventListener("mouseup",X,{capture:!0});for(const e of["click","contextmenu","dblclick"])window.addEventListener(e,Ve,{capture:!0});J=!0}}if(f){W(),document.addEventListener("DOMContentLoaded",W,{once:!0});let e=0;const t=window.setInterval(()=>{if(J){window.clearInterval(t);return}W(),++e>100&&window.clearInterval(t)},50)}function Ve(e){if(e.type==="dblclick"&&te()&&window===window.top&&ge(e)){e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),M("wails:drag:doubleclick");return}(O||T)&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault())}function ge(e){const t=me(e);return window.getComputedStyle(t).getPropertyValue("--wails-draggable").trim()==="drag"&&e.offsetX>=0&&e.offsetX<t.clientWidth&&e.offsetY>=0&&e.offsetY<t.clientHeight}const U=0,Xe=1,V=2;function X(e){let t,n=e.buttons;switch(e.type){case"mousedown":t=U,x||(n=_|1<<e.button);break;case"mouseup":t=Xe,x||(n=_&~(1<<e.button));break;default:t=V,x||(n=_);break}let o=_&~n,i=n&~_;_=n,t===U&&!(i&e.button)&&(o|=1<<e.button,i|=1<<e.button),(t!==V&&T||O&&(t===U||e.button!==0))&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault()),o&1&&Ze(),i&1&&Ye(e),t===V&&Je(e)}function Ye(e){if(z=!1,E=!1,!(!I()&&e.type==="mousedown"&&e.button===0&&e.detail!==1)){if(y){if(e.type!=="mousedown")return;E=!0;return}z=ge(e)}}function Ze(e){z=!1,O=!1,E=!1,T=!1}const Ge=Object.freeze({"se-resize":"nwse-resize","sw-resize":"nesw-resize","nw-resize":"nwse-resize","ne-resize":"nesw-resize","w-resize":"ew-resize","n-resize":"ns-resize","s-resize":"ns-resize","e-resize":"ew-resize"});function w(e){e?(y||(re=document.body.style.cursor),document.body.style.cursor=Ge[e]):!e&&y&&(document.body.style.cursor=re),y=e||""}function Je(e){if(E&&y?(T=!0,M("wails:resize:"+y)):z&&(O=!0,M("wails:drag")),O||T){z=E=!1;return}if(!G||!I()&&!(ee()&&D("frameless"))){y&&w();return}const t=D("system.resizeHandleHeight")||5,n=D("system.resizeHandleWidth")||5,o=D("resizeCornerExtra")||10,i=Math.max(0,window.innerWidth-document.documentElement.clientWidth),r=Math.max(0,window.innerHeight-document.documentElement.clientHeight),l=window.innerWidth-i,a=window.innerHeight-r,u=e.clientX<l&&l-e.clientX<n,g=e.clientX<n,c=e.clientY<t,p=e.clientY<a&&a-e.clientY<t,h=e.clientX<l&&l-e.clientX<n+o,m=e.clientX<n+o,H=e.clientY<t+o,j=e.clientY<a&&a-e.clientY<t+o;!m&&!H&&!j&&!h?w():h&&j?w("se-resize"):m&&j?w("sw-resize"):m&&H?w("nw-resize"):H&&h?w("ne-resize"):g?w("w-resize"):c?w("n-resize"):p?w("s-resize"):u?w("e-resize"):w()}const se="--wails-non-client-region",$e="wails:runtime-config-ready",qe=new Set(["caption","minimize","maximize","close"]);f&&(window._wails=window._wails||{});let $=!1,le="",Y=new Set,S,ae=!1;function de(e){const t=e.trim().toLowerCase();if(qe.has(t))return t}function Ke(e){if(!(e instanceof HTMLElement))return;const t=window.getComputedStyle(e),n=de(t.getPropertyValue(se));if(!n)return;const o=e.parentElement;if(o){const i=window.getComputedStyle(o);if(de(i.getPropertyValue(se))===n)return}return n}function Qe(e){const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"&&t.contentVisibility!=="hidden"}function et(e){if(!(e instanceof HTMLElement))return;const t=Ke(e);if(!t||!Qe(e))return;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return;const o=window.devicePixelRatio||1,i=Math.floor(n.left*o),r=Math.floor(n.top*o),l=Math.ceil(n.right*o),a=Math.ceil(n.bottom*o);if(!(l<=i||a<=r))return{kind:t,left:i,top:r,right:l,bottom:a}}function tt(){const e=[];if(document.documentElement&&e.push(document.documentElement),document.body){e.push(document.body);for(const t of document.body.querySelectorAll("*"))e.push(t)}return e}function nt(e){if(typeof ResizeObserver>"u")return;S??(S=new ResizeObserver(b));const t=new Set(e);for(const n of Y)t.has(n)||S.unobserve(n);for(const n of t)Y.has(n)||S.observe(n);Y=t}function ot(){$=!1;const e=tt(),t=[],n=[];for(const i of e){const r=et(i);r&&(t.push(r),n.push(i))}nt(n);const o=JSON.stringify({version:1,regions:t});o!==le&&(le=o,M("wails:non-client-region:"+o))}function b(){$||($=!0,window.requestAnimationFrame(ot))}function it(){var e,t;if(ae)return;ae=!0,b(),new MutationObserver(b).observe(document.documentElement,{attributes:!0,childList:!0,subtree:!0}),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),(e=window.visualViewport)===null||e===void 0||e.addEventListener("resize",b),(t=window.visualViewport)===null||t===void 0||t.addEventListener("scroll",b)}function ue(){var e,t;const n=(e=window._wails.environment)===null||e===void 0?void 0:e.OS;if(n===void 0)return!1;const o=(t=window._wails.flags)===null||t===void 0?void 0:t.nonClientRegionTracking;return n==="windows"&&o===!0&&pe(it),!0}f&&!ue()&&window.addEventListener($e,ue,{once:!0});function R(e){return e}function rt(e){return e??""}function st(e){return e===R?t=>t===null?[]:t:t=>{if(t===null)return[];for(let n=0;n<t.length;n++)t[n]=e(t[n]);return t}}function lt(e,t){return t===R?n=>n===null?{}:n:n=>{if(n===null)return{};for(const o in n)n[o]=t(n[o]);return n}}function at(e){return e===R?R:t=>t===null?null:e(t)}const dt={},ut="data-file-drop-target",v="file-drop-target-active";let d=null;const ct=0,ft=1,wt=2,ht=3,mt=4,vt=5,pt=6,gt=7,bt=8,yt=9,Mt=10,_t=11,St=12,Et=13,Tt=14,Ct=15,Dt=16,zt=17,Ot=18,Rt=19,xt=20,kt=21,Lt=22,Ft=23,Pt=24,At=25,It=26,Ht=27,jt=28,Bt=29,Nt=30,Wt=31,Ut=32,Vt=33,Xt=34,Yt=35,Zt=36,Gt=37,Jt=38,$t=39,qt=40,Kt=41,Qt=42,en=43,tn=44,nn=45,on=46,rn=47,sn=48,ln=49,an=50,dn=51,un=52;function k(e){return e?e.closest(`[${ut}]`):null}function cn(){var e,t,n,o;return((t=(e=window.chrome)===null||e===void 0?void 0:e.webview)===null||t===void 0?void 0:t.postMessageWithAdditionalObjects)==null?!1:((o=(n=window._wails)===null||n===void 0?void 0:n.flags)===null||o===void 0?void 0:o.enableFileDrop)===!0}function fn(e,t,n){var o,i;!((i=(o=window.chrome)===null||o===void 0?void 0:o.webview)===null||i===void 0)&&i.postMessageWithAdditionalObjects&&window.chrome.webview.postMessageWithAdditionalObjects(`file:drop:${e}:${t}`,n)}let ne=!1;function be(){ne=!1,d&&(d.classList.remove(v),d=null)}function wn(){var e,t;((t=(e=window._wails)===null||e===void 0?void 0:e.flags)===null||t===void 0?void 0:t.enableFileDrop)!==!1&&(ne=!0)}function hn(){be()}function mn(e,t){var n,o;if(!ne||((o=(n=window._wails)===null||n===void 0?void 0:n.flags)===null||o===void 0?void 0:o.enableFileDrop)===!1)return;const i=document.elementFromPoint(e,t),r=k(i);d&&d!==r&&d.classList.remove(v),r?(r.classList.add(v),d=r):d=null}const s=Symbol("caller");class L{constructor(t=""){this[s]=A(P.Window,t);for(const n of Object.getOwnPropertyNames(L.prototype))n!=="constructor"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this))}Get(t){return new L(t)}Position(){return this[s](ct)}Center(){return this[s](ft)}Close(){return this[s](wt)}DisableSizeConstraints(){return this[s](ht)}EnableSizeConstraints(){return this[s](mt)}Focus(){return this[s](vt)}ForceReload(){return this[s](pt)}Fullscreen(){return this[s](gt)}GetScreen(){return this[s](bt)}GetZoom(){return this[s](yt)}Height(){return this[s](Mt)}Hide(){return this[s](_t)}IsFocused(){return this[s](St)}IsFullscreen(){return this[s](Et)}IsMaximised(){return this[s](Tt)}IsMinimised(){return this[s](Ct)}Maximise(){return this[s](Dt)}Minimise(){return this[s](zt)}Name(){return this[s](Ot)}OpenDevTools(){return this[s](Rt)}RelativePosition(){return this[s](xt)}Reload(){return this[s](kt)}Resizable(){return this[s](Lt)}Restore(){return this[s](Ft)}SetPosition(t,n){return this[s](Pt,{x:t,y:n})}SetAlwaysOnTop(t){return this[s](At,{alwaysOnTop:t})}SetBackgroundColour(t,n,o,i){return this[s](It,{r:t,g:n,b:o,a:i})}SetFrameless(t){return this[s](Ht,{frameless:t})}SetFullscreenButtonEnabled(t){return this[s](jt,{enabled:t})}SetMaxSize(t,n){return this[s](Bt,{width:t,height:n})}SetMinSize(t,n){return this[s](Nt,{width:t,height:n})}SetRelativePosition(t,n){return this[s](Wt,{x:t,y:n})}SetResizable(t){return this[s](Ut,{resizable:t})}SetSize(t,n){return this[s](Vt,{width:t,height:n})}SetTitle(t){return this[s](Xt,{title:t})}SetZoom(t){return this[s](Yt,{zoom:t})}Show(){return this[s](Zt)}Size(){return this[s](Gt)}ToggleFullscreen(){return this[s](Jt)}ToggleMaximise(){return this[s]($t)}ToggleFrameless(){return this[s](qt)}UnFullscreen(){return this[s](Kt)}UnMaximise(){return this[s](Qt)}UnMinimise(){return this[s](en)}Width(){return this[s](tn)}Zoom(){return this[s](nn)}ZoomIn(){return this[s](on)}ZoomOut(){return this[s](rn)}ZoomReset(){return this[s](sn)}HandlePlatformFileDrop(t,n,o){var i,r;if(((r=(i=window._wails)===null||i===void 0?void 0:i.flags)===null||r===void 0?void 0:r.enableFileDrop)===!1)return;const l=document.elementFromPoint(n,o),a=k(l);if(!a)return;const u={id:a.id,classList:Array.from(a.classList),attributes:{}};for(let c=0;c<a.attributes.length;c++){const p=a.attributes[c];u.attributes[p.name]=p.value}const g={filenames:t,x:n,y:o,elementDetails:u};this[s](an,g),be()}SetScreen(t){return this[s](un,{screenID:t})}SnapAssist(){return this[s](ln)}Print(){return this[s](dn)}}const q=new L("");function vn(){const e=document.documentElement;let t=0;e.addEventListener("dragenter",n=>{var o,i,r;if(!(!((o=n.dataTransfer)===null||o===void 0)&&o.types.includes("Files")))return;if(n.preventDefault(),((r=(i=window._wails)===null||i===void 0?void 0:i.flags)===null||r===void 0?void 0:r.enableFileDrop)===!1){n.dataTransfer.dropEffect="none";return}t++;const l=document.elementFromPoint(n.clientX,n.clientY),a=k(l);d&&d!==a&&d.classList.remove(v),a?(a.classList.add(v),n.dataTransfer.dropEffect="copy",d=a):(n.dataTransfer.dropEffect="none",d=null)},!1),e.addEventListener("dragover",n=>{var o,i,r;if(!(!((o=n.dataTransfer)===null||o===void 0)&&o.types.includes("Files")))return;if(n.preventDefault(),((r=(i=window._wails)===null||i===void 0?void 0:i.flags)===null||r===void 0?void 0:r.enableFileDrop)===!1){n.dataTransfer.dropEffect="none";return}const l=document.elementFromPoint(n.clientX,n.clientY),a=k(l);d&&d!==a&&d.classList.remove(v),a?(a.classList.contains(v)||a.classList.add(v),n.dataTransfer.dropEffect="copy",d=a):(n.dataTransfer.dropEffect="none",d=null)},!1),e.addEventListener("dragleave",n=>{var o,i,r;!((o=n.dataTransfer)===null||o===void 0)&&o.types.includes("Files")&&(n.preventDefault(),((r=(i=window._wails)===null||i===void 0?void 0:i.flags)===null||r===void 0?void 0:r.enableFileDrop)!==!1&&n.relatedTarget!==null&&(t--,(t===0||d&&!d.contains(n.relatedTarget))&&(d&&(d.classList.remove(v),d=null),t=0)))},!1),e.addEventListener("drop",n=>{var o,i,r;if(!((o=n.dataTransfer)===null||o===void 0)&&o.types.includes("Files")&&(n.preventDefault(),((r=(i=window._wails)===null||i===void 0?void 0:i.flags)===null||r===void 0?void 0:r.enableFileDrop)!==!1&&(t=0,d&&(d.classList.remove(v),d=null),cn()))){const l=[];if(n.dataTransfer.items){for(const a of n.dataTransfer.items)if(a.kind==="file"){const u=a.getAsFile();u&&l.push(u)}}else if(n.dataTransfer.files)for(const a of n.dataTransfer.files)l.push(a);l.length>0&&fn(n.clientX,n.clientY,l)}},!1)}typeof window<"u"&&typeof document<"u"&&vn();f&&(window._wails=window._wails||{});f&&(window._wails.invoke=M,window._wails.clientId=K);f&&(window._wails.handlePlatformFileDrop=q.HandlePlatformFileDrop.bind(q));f&&(window._wails.handleDragEnter=wn,window._wails.handleDragLeave=hn,window._wails.handleDragOver=mn);f&&M("wails:runtime:ready");function pn(e){return fetch(e,{method:"HEAD"}).then(t=>{if(t.ok&&(t.headers.get("content-type")||"").toLowerCase().includes("javascript")){const o=document.createElement("script");o.src=e,document.head.appendChild(o)}}).catch(()=>{})}f&&pn("/wails/custom.js");exports.Any=R;exports.Array=st;exports.ByteSlice=rt;exports.Events=dt;exports.Map=lt;exports.Nullable=at;exports.RuntimeError=ce;exports.canAbortListeners=Ae;exports.flags=We;exports.hasDOM=f;exports.nanoid=F;exports.newRuntimeCaller=A;exports.objectNames=P;exports.system=Fe;exports.thisWindow=q;exports.whenReady=pe;
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Tt=Object.defineProperty;var Nt=(e,t,n)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Nt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),d=require("react"),Z=require("react-router-dom"),C=require("./Client-DHqavZ6d.cjs"),x=require("./models.cjs"),_=require("@tanstack/react-query"),kt=require("@omniviewdev/ui/feedback"),O=require("./runtime.cjs"),ue=d.createContext(void 0),k={PLUGIN_NOT_FOUND:"omniview:plugin/not-found",PLUGIN_NOT_LOADED:"omniview:plugin/not-loaded",PLUGIN_ALREADY_LOADED:"omniview:plugin/already-loaded",PLUGIN_INSTALL_FAILED:"omniview:plugin/install-failed",PLUGIN_LOAD_FAILED:"omniview:plugin/load-failed",PLUGIN_BUILD_FAILED:"omniview:plugin/build-failed",SETTINGS_MISSING_CONFIG:"omniview:settings/missing-config",SETTINGS_INVALID_CONFIG:"omniview:settings/invalid-config",RESOURCE_NOT_FOUND:"omniview:resource/not-found",RESOURCE_FORBIDDEN:"omniview:resource/forbidden",RESOURCE_UNAUTHORIZED:"omniview:resource/unauthorized",RESOURCE_CONFLICT:"omniview:resource/conflict",RESOURCE_TIMEOUT:"omniview:resource/timeout",CONNECTION_NOT_FOUND:"omniview:connection/not-found",CONNECTION_FAILED:"omniview:connection/failed",RESOURCE_CONNECTION_ERROR:"omniview:resource/connection-error",RESOURCE_CERTIFICATE_ERROR:"omniview:resource/certificate-error",SESSION_NOT_FOUND:"omniview:session/not-found",SESSION_FAILED:"omniview:session/failed",CANCELLED:"omniview:cancelled",INTERNAL:"omniview:internal",VALIDATION:"omniview:validation",NOT_IMPLEMENTED:"omniview:not-implemented"};function Mt(e){switch(e){case"NOT_FOUND":return{typeUri:k.RESOURCE_NOT_FOUND,status:404};case"FORBIDDEN":return{typeUri:k.RESOURCE_FORBIDDEN,status:403};case"UNAUTHORIZED":return{typeUri:k.RESOURCE_UNAUTHORIZED,status:401};case"CONFLICT":case"ALREADY_EXISTS":return{typeUri:k.RESOURCE_CONFLICT,status:409};case"TIMEOUT":return{typeUri:k.RESOURCE_TIMEOUT,status:408};case"CONNECTION_ERROR":return{typeUri:k.RESOURCE_CONNECTION_ERROR,status:503};case"CERTIFICATE_ERROR":return{typeUri:k.RESOURCE_CERTIFICATE_ERROR,status:502};default:return{typeUri:k.INTERNAL,status:500}}}function $(e){if(e==null)return{type:k.INTERNAL,title:"Unknown error",status:500,detail:"An unknown error occurred."};let t;if(typeof e=="string"?t=e:e instanceof Error?t=e.message:t=String(e),t.startsWith("{"))try{const n=JSON.parse(t);if(typeof n.type=="string"&&typeof n.title=="string"&&typeof n.status=="number"&&typeof n.detail=="string")return n;if(typeof n.code=="string"&&typeof n.title=="string"&&typeof n.message=="string"){const{typeUri:r,status:s}=Mt(n.code);return{type:r,title:n.title,status:s,detail:n.message,suggestions:Array.isArray(n.suggestions)?n.suggestions:void 0}}}catch{}return{type:k.INTERNAL,title:"Error",status:500,detail:t}}function Fe(e){return e==null?!1:(typeof e=="string"?e:e instanceof Error?e.message:String(e))==="cancelled"?!0:$(e).type===k.CANCELLED}function et(e){switch(e.type){case"navigate":return{label:e.label,onClick:()=>{window.location.hash=e.target??""}};case"open-url":return{label:e.label,onClick:()=>{window.open(e.target,"_blank")}};case"copy":return{label:e.label,onClick:()=>{navigator.clipboard.writeText(e.target??"")}};case"retry":return{label:e.label,onClick:()=>{}};default:return{label:e.label,onClick:()=>{}}}}function tt(e,t){var s,o;const n=[e.detail,...((s=e.suggestions)==null?void 0:s.map(i=>`• ${i}`))??[]].join(`
2
- `);return{message:t||(e.title!=="Error"?e.title:"Operation failed"),status:"error",details:n,actions:(o=e.actions)==null?void 0:o.map(et)}}function G(e,t,n){if(Fe(t))return;const r=$(t);e(tt(r,n))}function I(e,t){return n=>{if(Fe(n))return;const r=$(n);e(tt(r,r.title!=="Error"?r.title:t))}}function Lt(e){const{children:t,pluginId:n}=e,[r,s]=d.useState({}),[o,i]=d.useState(new x.config.PluginMeta),[a,u]=d.useState(!1),[l,c]=d.useState(null);console.debug("[PluginContextProvider] render",{pluginId:n,metaLoaded:a,metaError:!!l});const m=()=>{n===void 0||n===""||(console.debug(`[PluginContextProvider] fetching settings for "${n}"`),C.PluginValues(n).then(f=>{console.debug(`[PluginContextProvider] settings loaded for "${n}"`,Object.keys(f)),s(f)}).catch(f=>{const g=$(f);console.error(`[PluginContextProvider] error fetching settings for "${n}":`,g.detail)}))},p=()=>{if(n===void 0||n===""){console.debug("[PluginContextProvider] skipping meta fetch — empty pluginId");return}console.debug(`[PluginContextProvider] fetching meta for "${n}"`),c(null),C.GetPluginMeta(n).then(f=>{console.debug(`[PluginContextProvider] meta loaded for "${n}"`,{name:f==null?void 0:f.name,version:f==null?void 0:f.version}),i(f),u(!0)}).catch(f=>{const g=$(f);console.error(`[PluginContextProvider] error fetching meta for "${n}":`,g.detail),c(g.detail),u(!1)})};return d.useEffect(()=>{console.debug(`[PluginContextProvider] useEffect — pluginId changed to "${n}"`),m(),p()},[n]),l?R.jsx("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",padding:24},children:R.jsxs("div",{style:{maxWidth:480,width:"100%",border:"1px solid #7F1D1D",borderRadius:8,backgroundColor:"#1C1917",padding:20,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[R.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[R.jsx("circle",{cx:"12",cy:"12",r:"10"}),R.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),R.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),R.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#FECACA"},children:"Plugin failed to load"})]}),R.jsx("p",{style:{fontSize:13,color:"#A1A1AA",margin:"0 0 16px"},children:l}),R.jsx("button",{onClick:()=>p(),style:{background:"transparent",color:"#F87171",border:"1px solid #7F1D1D",borderRadius:6,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer"},children:"Retry"})]})}):a?R.jsx(ue.Provider,{value:{pluginId:n,settings:r,meta:o},children:t}):R.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center"},children:[R.jsx("div",{style:{width:24,height:24,border:"2px solid #3F3F46",borderTopColor:"#A1A1AA",borderRadius:"50%",animation:"plugin-spin 0.8s linear infinite"}}),R.jsx("style",{children:"@keyframes plugin-spin { to { transform: rotate(360deg); } }"})]})}function le(){const e=d.useContext(ue);if(!e)throw new Error("usePluginContext must be used within a PluginContextProvider");return e}function $t(){return le().settings}const Ae=d.createContext(void 0),Ut=({children:e})=>{const[t,n]=d.useState({}),r=()=>{C.Values().then(o=>{console.log("Fetched settings:",o),n(o)}).catch(o=>{console.error("Error fetching settings:",o)})};d.useEffect(()=>{r()},[]);const s=()=>{r()};return R.jsx(Ae.Provider,{value:{settings:t,reload:s},children:e})},nt={height:32,focused:0,tabs:[],createTab:()=>{},createTabs:()=>{},updateTab:()=>{},focusTab:()=>{},reorderTab:()=>{},closeTab:()=>{},closeTabs:()=>{},resizeDrawer:()=>{},closeDrawer:()=>{},fullscreenDrawer:()=>{}},rt=d.createContext(nt),st=d.createContext(void 0),ot=d.createContext(void 0),Te=d.createContext(void 0),qt=3e4,jt=({children:e})=>{const[t,n]=d.useState([]),r=d.useCallback(a=>{n(u=>[a,...u])},[]),s=d.useCallback((a,u)=>{n(l=>l.map(c=>c.id===a?{...c,...u}:c))},[]),o=d.useCallback(a=>{n(u=>u.filter(l=>l.id!==a))},[]);d.useEffect(()=>{const a=[];for(const u of t)if(u.status==="completed"||u.status==="error"){const l=Date.now()-(u.completedAt??u.startedAt),c=Math.max(0,qt-l);a.push(setTimeout(()=>o(u.id),c))}return()=>a.forEach(clearTimeout)},[t,o]);const i=d.useMemo(()=>({operations:t,addOperation:r,updateOperation:s,removeOperation:o}),[t,r,s,o]);return R.jsx(Te.Provider,{value:i,children:e})};var we=function(e,t){return we=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},we(e,t)};function Qt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");we(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var _e="Invariant Violation",Ge=Object.setPrototypeOf,Gt=Ge===void 0?function(e,t){return e.__proto__=t,e}:Ge,Kt=function(e){Qt(t,e);function t(n){n===void 0&&(n=_e);var r=e.call(this,typeof n=="number"?_e+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=_e,Gt(r,t.prototype),r}return t}(Error);function be(e,t){if(!e)throw new Kt(t)}var it=["debug","log","warn","error","silent"],zt=it.indexOf("log");function re(e){return function(){if(it.indexOf(e)>=zt){var t=console[e]||console.log;return t.apply(console,arguments)}}}(function(e){e.debug=re("debug"),e.log=re("log"),e.warn=re("warn"),e.error=re("error")})(be||(be={}));const at=d.createContext(void 0),Ne=()=>d.useContext(at),Wt=e=>{const t=Ne();return t==null?void 0:t.getExtensionPoint(e)},Bt=e=>{const t=Ne(),n=t==null?void 0:t.getExtensionPoint(e);return n?n.provide({getCacheKey:()=>e}):[]},Ht=({registry:e,children:t})=>{const n=d.useRef(e);return d.useEffect(()=>{be(n.current===e,"You can't change the extension registry after it has been rendered")},[e]),R.jsx(at.Provider,{value:n.current,children:d.Children.only(t)})},Ke=e=>{if(!e||typeof e!="string")throw new TypeError(`extensionName is required to be a string and can't be: "${e}" (${typeof e})`);return e.trim()};class ct{constructor(t){L(this,"_settings");L(this,"_extensions",new Map);L(this,"_lookupCache",new Map);L(this,"_matchCache",new Map);L(this,"_matcher");const{matcher:n,...r}=t;this._settings=r,this._matcher=t.matcher}settings(){return this._settings}register(t){if(this._extensions.get(t.id))throw new Error(`Resource sidebar view with id ${t.id} already exists`);const n={...t,registeredAt:new Date,updatedAt:new Date,enabled:!0};this._extensions.set(t.id,n);const r=Array.from(this._matchCache.keys());for(const s of r)s.startsWith(t.plugin)&&this._matchCache.delete(s)}unregister(t){this._extensions.delete(t)}get(t){var n;return(n=this._extensions.get(t))==null?void 0:n.component}list(){return Array.from(this._extensions.values())}generateMatchCacheKey(t){return`${t.plugin}/${t.id}`}calculateMatches(t){if(!this._matcher)return Array.from(this._extensions.values());const n=[];for(const r of this._extensions.values()){const s=this.generateMatchCacheKey(r),o=this._matchCache.has(s);if(o&&this._matchCache.get(s)){n.push(r);continue}this._matcher(t,r)?(this._matchCache.set(s,!0),n.push(r)):o||this._matchCache.set(s,!1)}return n}preload(t){const n=this.calculateMatches(t),r=t.getCacheKey();this._lookupCache.set(r,n.map(s=>s.id))}provide(t){if(this._settings.disabled)return[];if(this._settings.mode==="single"){const o=this._extensions.get(this._settings.selected);return o?[o.component]:[]}const n=t.getCacheKey();let r=this._lookupCache.get(n);if(r){let o=r.map(i=>this._extensions.get(i)).filter(i=>!!i).map(i=>i.component);return this._settings.order&&(o=this.reorderComponents(o,r,this._settings.order)),o}r=this.calculateMatches(t).map(o=>o.id),this._lookupCache.set(n,r);let s=r.map(o=>this._extensions.get(o)).filter(o=>!!o).map(o=>o.component);return this._settings.order&&(s=this.reorderComponents(s,r,this._settings.order)),s}reorderComponents(t,n,r){const s=new Map(n.map((o,i)=>[o,t[i]]));return r.map(o=>s.get(o)).filter(o=>!!o)}reorder(t){const n=t.map(i=>this._extensions.get(i)).filter(i=>!!i),r=Array.from(this._extensions.values()).filter(i=>!t.includes(i.id)),s=[...n,...r];this._extensions.clear(),s.forEach(i=>this._extensions.set(i.id,i));const o=Array.from(this._lookupCache.keys());for(const i of o){const a=this._lookupCache.get(i);if(!a)continue;const u=a.filter(l=>t.includes(l));this._lookupCache.set(i,u)}}clearLookupCache(){this._lookupCache.clear()}clearMatchCache(){this._matchCache.clear()}clearAllCaches(){this.clearLookupCache(),this.clearMatchCache()}}class Yt{constructor({initialStores:t}){L(this,"store",{});t.forEach(n=>{this.addExtensionPoint(n)})}addExtensionPoint(t){let n=Ke(t.id);if(console.log("validated",n),console.log("store",this.store),this.store[n]){console.warn(`Extension point ${n} already exists. Not adding again.`);return}this.store[n]=new ct(t)}getExtensionPoint(t){return t=Ke(t),this.store[t]}listExtensionPointIds(){return Object.keys(this.store)}listExtensionPoints(){return Object.values(this.store).map(t=>t.settings())}}const ut=d.createContext(void 0),Jt={default:"info",info:"info",success:"success",warning:"warning",error:"error"},Vt=({children:e})=>{const{push:t}=kt.useNotificationStack(),[n,r]=d.useState([]),s=i=>{r(a=>[...a,i])},o=(i,a,u)=>{const l=typeof i=="object";let c="",m="info",p,f=5e3,g;if(l){if(c=i.message,i.showOnce){if(n.includes(c))return;s(c)}m=i.status,p=i.details,f=i.autoHideDuration??5e3,g=i.actions}else c=i,m=a,p=u;t({severity:Jt[m]??"info",title:c,message:p,timeout:f,actions:g})};return R.jsx(ut.Provider,{value:{showSnackbar:o},children:e})},M=()=>{const e=d.useContext(ut);if(e===void 0)throw new Error("useCustomSnackbar must be used within a CustomSnackbarProvider");return e};function D(e){const t=d.useContext(ue),n=(t==null?void 0:t.pluginId)??e;if(!n)throw new Error("pluginID must be provided either via PluginContext or as an explicit parameter");return n}const Xt=({pluginID:e,connectionID:t})=>{const n=D(e),r=_.useQueryClient(),{showSnackbar:s}=M(),o=[n,"connection","detail",t],{mutateAsync:i}=_.useMutation({mutationFn:async()=>C.StartConnection(n,t),onSuccess(m){r.setQueryData(o,m),r.invalidateQueries({queryKey:["EDITOR_SCHEMAS",n,t]})},onError:I(s,"Failed to start connection")}),{mutateAsync:a}=_.useMutation({mutationFn:async()=>C.StopConnection(n,t),onSuccess(m){r.setQueryData(o,m)},onError:I(s,"Failed to stop connection")}),{mutateAsync:u}=_.useMutation({mutationFn:async m=>C.UpdateConnection(n,m),onSuccess(m,{name:p}){s({message:`Connection ${p} successfully updated`,status:"success"}),r.setQueryData(o,c),r.setQueriesData({queryKey:[n,"connection","list"]},f=>f==null?void 0:f.map(g=>g.id===t?m:g))},onError:I(s,"Failed to update connection")}),{mutateAsync:l}=_.useMutation({mutationFn:async()=>C.RemoveConnection(n,t),onSuccess(){s({message:"Connection successfully removed",status:"success"}),r.setQueryData(o,void 0),r.setQueriesData({queryKey:[n,"connection","list"]},m=>m==null?void 0:m.filter(p=>p.id!==t))},onError:I(s,"Failed to remove connection")}),c=_.useQuery({queryKey:o,queryFn:async()=>C.GetConnection(n,t)});return{connection:c,startConnection:i,stopConnection:a,updateConnection:u,deleteConnection:l}},lt=e=>[e,"connection","list"],Zt=({plugin:e})=>{const t=D(e),n=_.useQueryClient(),{showSnackbar:r}=M(),s=lt(t),{mutateAsync:o}=_.useMutation({mutationFn:async l=>C.StartConnectionWatch(t,l.id),onError:I(r,"Failed to start connection watch")}),{mutateAsync:i}=_.useMutation({mutationFn:async l=>C.StopConnectionWatch(t,l.id),onError:I(r,"Failed to stop connection watch")}),a=d.useCallback(l=>{console.log("got update to connections",l),n.setQueryData(s,l)},[]);return d.useEffect(()=>{const l=O.EventsOn(`${t}/connection/sync`,a);return()=>{l()}},[]),{connections:_.useQuery({queryKey:s,queryFn:async()=>{try{return await C.ListConnections(t)}catch(l){console.log(l),I(r,"Failed to load connections")(l)}return[]},staleTime:3e4,placeholderData:_.keepPreviousData}),startWatch:o,stopWatch:i}},en=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"connection","namespaces",t];return{namespaces:_.useQuery({queryKey:r,queryFn:async()=>C.GetConnectionNamespaces(n,t)})}},b=x.resource.WatchState,tn=x.resource.SyncPolicy;function ve(e){const t=Object.values(e.states),n=t.length;let r=0,s=0,o=0,i=0;for(const c of t)c===b.SYNCED&&r++,(c===b.ERROR||c===b.FAILED)&&s++,c===b.FORBIDDEN&&o++,c===b.SKIPPED&&i++;const a=n-i,u=t.filter(c=>c===b.SYNCED||c===b.ERROR||c===b.STOPPED||c===b.FAILED||c===b.FORBIDDEN).length,l=a>0?u/a:0;return{pluginID:e.pluginID,connectionID:e.connectionID,totalResources:n,watchedTotal:a,syncedCount:r,errorCount:s,forbiddenCount:o,skippedCount:i,doneCount:u,progress:l}}function oe(e){return e.watchedTotal>0&&e.doneCount>=e.watchedTotal}function dt(e){return e.some(t=>!oe(t))}function ft(e){const t=e.reduce((r,s)=>r+s.watchedTotal,0);return t===0?0:e.reduce((r,s)=>r+s.doneCount,0)/t}function ke(e){return`${e.pluginId}/${e.connection}`}function pt(e,t){const n=ke(t);e.has(n)||e.set(n,{states:{},pluginID:t.pluginId,connectionID:t.connection});const r=e.get(n);return r.states[t.resourceKey]=t.state,r}function nn(){const[e,t]=d.useState(new Set),[n,r]=d.useState({}),[s,o]=d.useState(new Map),i=d.useRef(new Map);d.useEffect(()=>{C.GetAllConnectionStates().then(h=>{if(!h)return;const E={},y=new Set,w=new Map;for(const[S,v]of Object.entries(h)){E[S]=v.map(F=>F.connection);for(const F of v){if(!F.started)continue;const P=`${S}/${F.connection.id}`;y.add(P);const U={pluginID:S,connectionID:F.connection.id,states:{}};if(F.resources)for(const[me,X]of Object.entries(F.resources))U.states[me]=X;i.current.set(P,U),w.set(P,ve(U))}}r(E),t(y),o(w)}).catch(()=>{})},[]),d.useEffect(()=>O.EventsOn("connection/status",E=>{const y=`${E.pluginID}/${E.connectionID}`;E.status==="DISCONNECTED"?(t(w=>{const S=new Set(w);return S.delete(y),S}),o(w=>{const S=new Map(w);return S.delete(y),S}),i.current.delete(y)):t(w=>{const S=new Set(w);return S.add(y),S}),C.ListAllConnections().then(w=>{w&&r(w)}).catch(()=>{})}),[]);const a=d.useCallback(h=>{const E=ke(h);t(S=>{if(S.has(E))return S;const v=new Set(S);return v.add(E),v});const y=pt(i.current,h),w=ve(y);o(S=>{const v=new Map(S);return v.set(E,w),v})},[]);d.useEffect(()=>O.EventsOn("watch/STATE",a),[a]);const u=d.useCallback(async(h,E)=>{await C.StopConnection(h,E)},[]),l=d.useCallback(async(h,E)=>{await C.StartConnectionWatch(h,E)},[]),c=[];for(const h of e){const[E,y]=h.split("/",2),S=(n[E]??[]).find(U=>U.id===y),v=s.get(h),F=v!=null&&!oe(v),P=v!=null&&v.errorCount>0;c.push({pluginID:E,connectionID:y,name:(S==null?void 0:S.name)??y,avatar:(S==null?void 0:S.avatar)??"",isStarted:!0,sync:v,isSyncing:F,hasErrors:P})}const m=new Map;for(const h of c){const E=m.get(h.pluginID)??[];E.push(h),m.set(h.pluginID,E)}const p=Array.from(s.values()),f=c.filter(h=>h.isSyncing),g=c.filter(h=>h.hasErrors);return{entries:c,grouped:m,connectedCount:c.length,syncingCount:f.length,errorCount:g.length,hasSyncing:dt(p),aggregateProgress:ft(p),disconnect:u,retryWatch:l}}function rn(e,t){return window.go.data.Client.Get(e,t)}function sn(e,t,n){return window.go.data.Client.Set(e,t,n)}function on(e,t,n){const r=D(e),s=_.useQueryClient(),o=[r,"data",t],i=_.useQuery({queryKey:o,queryFn:async()=>{const u=await rn(r,t);return u??n}}),a=_.useMutation({mutationFn:async u=>{await sn(r,t,u)},onMutate:async u=>{await s.cancelQueries({queryKey:o});const l=s.getQueryData(o);return s.setQueryData(o,u),{previous:l}},onError:(u,l,c)=>{(c==null?void 0:c.previous)!==void 0&&s.setQueryData(o,c.previous)},onSettled:()=>{s.invalidateQueries({queryKey:o})}});return{data:i.data??n,update:async u=>{await a.mutateAsync(u)},isLoading:i.isLoading}}const an=()=>{const e=d.useContext(st);if(!e)throw new Error("useRightDrawer must be used within a RightDrawerProvider");return e},Me=()=>{const e=d.useContext(rt);if(e===void 0)throw new Error("useBottomDrawer must be used within a BottomDrawerProvider");return e},cn=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=M(),{createTab:r,updateTab:s}=Me();return{createSession:_.useMutation({mutationFn:async({connectionID:i,icon:a,label:u,opts:l})=>{const c=`pending-${crypto.randomUUID()}`;r({id:c,title:u??"Connecting...",variant:"terminal",icon:a??"LuSquareTerminal",properties:{status:"connecting",pluginID:t,connectionID:i,opts:{...l}}});const m=x.exec.SessionOptions.createFrom({command:["/bin/bash"],tty:!0,...l});try{const p=await C.CreateSession(t,i,m);s({id:c},{id:p.id,title:u??`Session ${p.id.substring(0,8)}`,properties:{status:"connected",pluginID:t,connectionID:i,opts:{...l}}})}catch(p){const f=$(p);s({id:c},{properties:{status:"error",error:f.detail,pluginID:t,connectionID:i,opts:{...l}}}),G(n,p,"Failed to start session")}}}).mutateAsync}},un=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=M(),{createTab:r}=Me(),s=_.useMutation({mutationFn:async({connectionID:i,resourceKey:a,resourceID:u,resourceData:l,icon:c,label:m,target:p,follow:f=!0,tailLines:g=1e3,params:h})=>{const E=x.logs.CreateSessionOptions.createFrom({resource_key:a,resource_id:u,resource_data:l,options:x.logs.LogSessionOptions.createFrom({target:p??"",follow:f,include_previous:!1,include_timestamps:!0,tail_lines:g,since_seconds:0,limit_bytes:0,include_source_events:!0,params:h??{}})}),y=await C.CreateSession$1(t,i,E);return r({id:y.id,title:m??`Logs ${y.id.substring(0,8)}`,variant:"logs",icon:c??"LuLogs"}),y},onError:I(n,"Failed to start log session")}),o=_.useMutation({mutationFn:async i=>{await C.CloseSession(i)},onError:I(n,"Failed to close log session")});return{createLogSession:s.mutateAsync,closeLogSession:o.mutateAsync}},ln=()=>_.useQuery({queryKey:["metric","providers"],queryFn:C.GetProviders,staleTime:3e4}),yt=e=>_.useQuery({queryKey:["metric","providers",e],queryFn:()=>C.GetProvidersForResource(e),enabled:!!e,staleTime:3e4}),dn=e=>{var E,y;const{connectionID:t,resourceKey:n,resourceID:r,resourceNamespace:s="",resourceData:o={},metricIDs:i=[],shape:a=0,timeRange:u,refreshInterval:l=0,enabled:c=!0}=e,{data:m,isLoading:p}=yt(n),f=m??[],g=u?Math.max(Math.floor((u.end.getTime()-u.start.getTime())/250),15e3)*1e6:0,h=_.useQuery({queryKey:["metric","query",t,n,r,s,i,a,(E=u==null?void 0:u.start)==null?void 0:E.getTime(),(y=u==null?void 0:u.end)==null?void 0:y.getTime()],queryFn:()=>C.QueryAll(t,n,r,s,o,i,a,(u==null?void 0:u.start)??new Date(0),(u==null?void 0:u.end)??new Date(0),g),enabled:c&&!!t&&!!n&&(n.startsWith("cluster::")||!!r)&&f.length>0,refetchInterval:l>0?l:void 0,staleTime:5e3,placeholderData:_.keepPreviousData});return{data:h.data??void 0,providers:f,isLoading:p||h.isLoading,error:h.error,refetch:h.refetch}},fn=e=>{const{pluginID:t,connectionID:n,resourceKey:r,resourceID:s,resourceNamespace:o="",resourceData:i={},metricIDs:a=[],interval:u=1e4,enabled:l=!0}=e,c=D(t),[m,p]=d.useState(null),[f,g]=d.useState(null),[h,E]=d.useState(!1),[y,w]=d.useState(null),S=d.useRef(null),v=d.useCallback(async()=>{if(!(!l||!c||!n||!r||!s))try{const P=await C.Subscribe(c,n,{resource_key:r,resource_id:s,resource_namespace:o,resource_data:i,metric_ids:a,interval:u*1e6});g(P),E(!0),w(null);const U=O.EventsOn(`core/metrics/data/${P}`,X=>{try{const q=JSON.parse(X);q.results&&p(q.results)}catch(q){console.error("Failed to parse metric stream data:",q)}}),me=O.EventsOn(`core/metrics/error/${P}`,X=>{try{const q=JSON.parse(X);w(q.error||"Unknown error")}catch{w("Failed to parse metric stream error")}});S.current=()=>{U(),me()}}catch(P){w(P instanceof Error?P.message:String(P))}},[c,n,r,s,o,a,u,l]),F=d.useCallback(async()=>{if(f)try{await C.Unsubscribe(f)}catch(P){console.error("Failed to unsubscribe:",P)}S.current&&(S.current(),S.current=null),g(null),E(!1)},[f]);return d.useEffect(()=>()=>{f&&C.Unsubscribe(f).catch(console.error),S.current&&S.current()},[f]),{data:m,subscriptionID:f,isStreaming:h,error:y,start:v,stop:F}},Q=["networker","portforward","all-sessions"];function pn(){const{showSnackbar:e}=M(),t=_.useQueryClient(),n=_.useQuery({queryKey:[...Q],queryFn:async()=>C.ListAllPortForwardSessions().catch(o=>{if($(o).detail.includes("not found"))return[];throw o}),retry:!1});d.useEffect(()=>{const o=O.EventsOn("core/networker/portforward/created",()=>{t.invalidateQueries({queryKey:[...Q]})}),i=O.EventsOn("core/networker/portforward/closed",()=>{t.invalidateQueries({queryKey:[...Q]})});return()=>{o(),i()}},[t]);const r=n.data??[],s=_.useMutation({mutationFn:async o=>C.ClosePortForwardSession(o),onError:I(e,"Failed to close port forwarding session"),onSuccess:async()=>{await t.invalidateQueries({queryKey:[...Q]})}});return{sessions:n,activeSessions:r,closeSession:s.mutateAsync,openInBrowser:o=>O.BrowserOpenURL(`http://localhost:${o}`)}}function yn({pluginID:e,connectionID:t,resourceID:n}){const r=D(e),s=["networker","portforward","sessions",r,t,n],{showSnackbar:o}=M(),i=_.useQueryClient(),a=_.useQuery({queryKey:s,queryFn:async()=>C.FindPortForwardSessions(r,t,x.networker.FindPortForwardSessionRequest.createFrom({resource_id:n,connection_id:t})).catch(c=>{const m=$(c);return m.detail.includes("not found")?[]:(o({message:"Failed to fetch port forward sessions",status:"error",details:m.detail}),[])}),retry:!1}),u=_.useMutation({mutationFn:async({opts:c})=>{const m=x.networker.PortForwardSessionOptions.createFrom({local_port:c.localPort||0,remote_port:c.remotePort,protocol:c.protocol||"TCP",connection_type:"RESOURCE",connection:{resource_data:c.resource,connection_id:t,plugin_id:r,resource_id:c.resourceId,resource_key:c.resourceKey},labels:c.labels??{},params:c.parameters??{}}),p=await C.StartResourcePortForwardingSession(r,t,m);return c.openInBrowser&&O.BrowserOpenURL(`http://localhost:${p.local_port}`),p},onError:I(o,"Failed to start port forwarding session"),onSuccess:async()=>{await Promise.all([i.invalidateQueries({queryKey:s}),i.invalidateQueries({queryKey:[...Q]})])}}),l=_.useMutation({mutationFn:async({opts:c})=>C.ClosePortForwardSession(c.sessionID),onError:I(o,"Failed to close port forwarding session"),onSuccess:async()=>{await Promise.all([i.invalidateQueries({queryKey:s}),i.invalidateQueries({queryKey:[...Q]})])}});return{sessions:a,forward:u.mutateAsync,close:l.mutateAsync}}const hn=()=>{const e=d.useContext(ot);if(!e)throw new Error("useConfirmationModal must be used within a ConfirmationModalProvider");return e},gn=({pluginID:e,connectionID:t,resourceKey:n,resourceID:r,namespace:s=""})=>{const o=D(e),i=_.useQueryClient(),{showSnackbar:a}=M(),u=["RESOURCE",o,t,n,r,s],{mutateAsync:l}=_.useMutation({mutationFn:async p=>C.Update(o,t,n,x.resource.ClientUpdateInput.createFrom({input:p.input,id:r,namespace:s})),onSuccess:async()=>{a(`Resource ${r} updated`,"success"),await i.invalidateQueries({queryKey:u})},onError:I(a,`Failed to update resource ${r}`)}),{mutateAsync:c}=_.useMutation({mutationFn:async(p={})=>C.Delete(o,t,n,x.resource.DeleteInput.createFrom({id:r,namespace:s,gracePeriodSeconds:p.gracePeriodSeconds})),onSuccess:async()=>{a(`Resource ${r} deleted`,"success"),await i.invalidateQueries({queryKey:u})},onError:I(a,`Failed to delete resource ${r}`)});return{resource:_.useQuery({queryKey:u,queryFn:async()=>C.Get(o,t,n,x.resource.GetInput.createFrom({id:r,namespace:s})),retry:!1}),update:l,remove:c}},mn=e=>{const t=["component",e.plugin,e.resource,e.area];return{component:_.useQuery({queryKey:t,queryFn:async()=>C.GetResourceAreaComponent(e)})}},_n=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"resource_groups","list"];return{groups:_.useQuery({queryKey:r,queryFn:async()=>C.GetResourceGroups(n,t),retry:!1})}},Cn=({pluginID:e,connectionID:t,searches:n})=>{const r=D(e),s=i=>[r,t,i.key,i.namespaces,"list"];return _.useQueries({queries:n.map(i=>({queryKey:s(i),queryFn:async()=>C.List(r,t,i.key,x.resource.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:i.namespaces})).then(a=>(console.log(a.result),a.result&&i.postFilter?Object.values(a.result).filter(i.postFilter):Object.values(a.result||{}))),retry:!1}))})},En=({pluginID:e,resourceKey:t})=>{const n=D(e),r=[n,"resources",t];return{resourceType:_.useQuery({queryKey:r,queryFn:async()=>C.GetResourceType(n,t),retry:!1})}},Sn=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"resources","list"];return{types:_.useQuery({queryKey:r,queryFn:async()=>C.GetResourceTypes(n,t),retry:!1})}};var ht=Symbol.for("immer-nothing"),ze=Symbol.for("immer-draftable"),T=Symbol.for("immer-state"),wn=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function A(e,...t){if(process.env.NODE_ENV!=="production"){const n=wn[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Y=Object.getPrototypeOf;function J(e){return!!e&&!!e[T]}function K(e){var t;return e?gt(e)||Array.isArray(e)||!!e[ze]||!!((t=e.constructor)!=null&&t[ze])||fe(e)||pe(e):!1}var bn=Object.prototype.constructor.toString();function gt(e){if(!e||typeof e!="object")return!1;const t=Y(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===bn}function ie(e,t){de(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function de(e){const t=e[T];return t?t.type_:Array.isArray(e)?1:fe(e)?2:pe(e)?3:0}function Pe(e,t){return de(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function mt(e,t,n){const r=de(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function vn(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function fe(e){return e instanceof Map}function pe(e){return e instanceof Set}function j(e){return e.copy_||e.base_}function Re(e,t){if(fe(e))return new Map(e);if(pe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=gt(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[T];let s=Reflect.ownKeys(r);for(let o=0;o<s.length;o++){const i=s[o],a=r[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Y(e),r)}else{const r=Y(e);if(r!==null&&n)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function Le(e,t=!1){return ye(e)||J(e)||!K(e)||(de(e)>1&&(e.set=e.add=e.clear=e.delete=Pn),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Le(r,!0))),e}function Pn(){A(2)}function ye(e){return Object.isFrozen(e)}var Rn={};function z(e){const t=Rn[e];return t||A(0,e),t}var ee;function _t(){return ee}function Dn(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function We(e,t){t&&(z("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function De(e){Oe(e),e.drafts_.forEach(On),e.drafts_=null}function Oe(e){e===ee&&(ee=e.parent_)}function Be(e){return ee=Dn(ee,e)}function On(e){const t=e[T];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function He(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[T].modified_&&(De(t),A(4)),K(e)&&(e=ae(t,e),t.parent_||ce(t,e)),t.patches_&&z("Patches").generateReplacementPatches_(n[T].base_,e,t.patches_,t.inversePatches_)):e=ae(t,n,[]),De(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ht?e:void 0}function ae(e,t,n){if(ye(t))return t;const r=t[T];if(!r)return ie(t,(s,o)=>Ye(e,r,t,s,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return ce(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let o=s,i=!1;r.type_===3&&(o=new Set(s),s.clear(),i=!0),ie(o,(a,u)=>Ye(e,r,s,a,u,n,i)),ce(e,s,!1),n&&e.patches_&&z("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Ye(e,t,n,r,s,o,i){if(process.env.NODE_ENV!=="production"&&s===n&&A(5),J(s)){const a=o&&t&&t.type_!==3&&!Pe(t.assigned_,r)?o.concat(r):void 0,u=ae(e,s,a);if(mt(n,r,u),J(u))e.canAutoFreeze_=!1;else return}else i&&n.add(s);if(K(s)&&!ye(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ae(e,s),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&ce(e,s)}}function ce(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Le(t,n)}function xn(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:_t(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,o=$e;n&&(s=[r],o=te);const{revoke:i,proxy:a}=Proxy.revocable(s,o);return r.draft_=a,r.revoke_=i,a}var $e={get(e,t){if(t===T)return e;const n=j(e);if(!Pe(n,t))return In(e,n,t);const r=n[t];return e.finalized_||!K(r)?r:r===Ce(e.base_,t)?(Ee(e),e.copy_[t]=Ie(r,e)):r},has(e,t){return t in j(e)},ownKeys(e){return Reflect.ownKeys(j(e))},set(e,t,n){const r=Ct(j(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const s=Ce(j(e),t),o=s==null?void 0:s[T];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(vn(n,s)&&(n!==void 0||Pe(e.base_,t)))return!0;Ee(e),xe(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ce(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ee(e),xe(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=j(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){A(11)},getPrototypeOf(e){return Y(e.base_)},setPrototypeOf(){A(12)}},te={};ie($e,(e,t)=>{te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});te.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&A(13),te.set.call(this,e,t,void 0)};te.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&A(14),$e.set.call(this,e[0],t,n,e[0])};function Ce(e,t){const n=e[T];return(n?j(n):e)[t]}function In(e,t,n){var s;const r=Ct(t,n);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function Ct(e,t){if(!(t in e))return;let n=Y(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Y(n)}}function xe(e){e.modified_||(e.modified_=!0,e.parent_&&xe(e.parent_))}function Ee(e){e.copy_||(e.copy_=Re(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const i=this;return function(u=o,...l){return i.produce(u,c=>n.call(this,c,...l))}}typeof n!="function"&&A(6),r!==void 0&&typeof r!="function"&&A(7);let s;if(K(t)){const o=Be(this),i=Ie(t,void 0);let a=!0;try{s=n(i),a=!1}finally{a?De(o):Oe(o)}return We(o,r),He(s,o)}else if(!t||typeof t!="object"){if(s=n(t),s===void 0&&(s=t),s===ht&&(s=void 0),this.autoFreeze_&&Le(s,!0),r){const o=[],i=[];z("Patches").generateReplacementPatches_(t,s,o,i),r(o,i)}return s}else A(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...a)=>this.produceWithPatches(i,u=>t(u,...a));let r,s;return[this.produce(t,n,(i,a)=>{r=i,s=a}),r,s]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){K(e)||A(8),J(e)&&(e=An(e));const t=Be(this),n=Ie(e,void 0);return n[T].isManual_=!0,Oe(t),n}finishDraft(e,t){const n=e&&e[T];(!n||!n.isManual_)&&A(9);const{scope_:r}=n;return We(r,t),He(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const s=t[n];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}n>-1&&(t=t.slice(n+1));const r=z("Patches").applyPatches_;return J(e)?r(e,t):this.produce(e,s=>r(s,t))}};function Ie(e,t){const n=fe(e)?z("MapSet").proxyMap_(e,t):pe(e)?z("MapSet").proxySet_(e,t):xn(e,t);return(t?t.scope_:_t()).drafts_.push(n),n}function An(e){return J(e)||A(10,e),Et(e)}function Et(e){if(!K(e)||ye(e))return e;const t=e[T];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Re(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Re(e,!0);return ie(n,(r,s)=>{mt(n,r,Et(s))}),t&&(t.finalized_=!1),n}var N=new Fn,St=N.produce;N.produceWithPatches.bind(N);N.setAutoFreeze.bind(N);N.setUseStrictShallowCopy.bind(N);N.applyPatches.bind(N);N.createDraft.bind(N);N.finishDraft.bind(N);var se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nn="Expected a function",wt="__lodash_hash_undefined__",kn="[object Function]",Mn="[object GeneratorFunction]",Ln="[object Symbol]",$n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Un=/^\w*$/,qn=/^\./,jn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qn=/[\\^$.*+?()[\]{}|]/g,Gn=/\\(\\)?/g,Kn=/^\[object .+?Constructor\]$/,zn=typeof se=="object"&&se&&se.Object===Object&&se,Wn=typeof self=="object"&&self&&self.Object===Object&&self,Ue=zn||Wn||Function("return this")();function Bn(e,t){return e==null?void 0:e[t]}function Hn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Yn=Array.prototype,Jn=Function.prototype,bt=Object.prototype,Se=Ue["__core-js_shared__"],Je=function(){var e=/[^.]+$/.exec(Se&&Se.keys&&Se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),vt=Jn.toString,qe=bt.hasOwnProperty,Pt=bt.toString,Vn=RegExp("^"+vt.call(qe).replace(Qn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ve=Ue.Symbol,Xn=Yn.splice,Zn=Rt(Ue,"Map"),ne=Rt(Object,"create"),Xe=Ve?Ve.prototype:void 0,Ze=Xe?Xe.toString:void 0;function W(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function er(){this.__data__=ne?ne(null):{}}function tr(e){return this.has(e)&&delete this.__data__[e]}function nr(e){var t=this.__data__;if(ne){var n=t[e];return n===wt?void 0:n}return qe.call(t,e)?t[e]:void 0}function rr(e){var t=this.__data__;return ne?t[e]!==void 0:qe.call(t,e)}function sr(e,t){var n=this.__data__;return n[e]=ne&&t===void 0?wt:t,this}W.prototype.clear=er;W.prototype.delete=tr;W.prototype.get=nr;W.prototype.has=rr;W.prototype.set=sr;function V(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function or(){this.__data__=[]}function ir(e){var t=this.__data__,n=he(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Xn.call(t,n,1),!0}function ar(e){var t=this.__data__,n=he(t,e);return n<0?void 0:t[n][1]}function cr(e){return he(this.__data__,e)>-1}function ur(e,t){var n=this.__data__,r=he(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}V.prototype.clear=or;V.prototype.delete=ir;V.prototype.get=ar;V.prototype.has=cr;V.prototype.set=ur;function B(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function lr(){this.__data__={hash:new W,map:new(Zn||V),string:new W}}function dr(e){return ge(this,e).delete(e)}function fr(e){return ge(this,e).get(e)}function pr(e){return ge(this,e).has(e)}function yr(e,t){return ge(this,e).set(e,t),this}B.prototype.clear=lr;B.prototype.delete=dr;B.prototype.get=fr;B.prototype.has=pr;B.prototype.set=yr;function he(e,t){for(var n=e.length;n--;)if(Pr(e[n][0],t))return n;return-1}function hr(e,t){t=Cr(t,e)?[t]:_r(t);for(var n=0,r=t.length;e!=null&&n<r;)e=e[br(t[n++])];return n&&n==r?e:void 0}function gr(e){if(!Ot(e)||Sr(e))return!1;var t=Rr(e)||Hn(e)?Vn:Kn;return t.test(vr(e))}function mr(e){if(typeof e=="string")return e;if(Qe(e))return Ze?Ze.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _r(e){return Dt(e)?e:wr(e)}function ge(e,t){var n=e.__data__;return Er(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Rt(e,t){var n=Bn(e,t);return gr(n)?n:void 0}function Cr(e,t){if(Dt(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Qe(e)?!0:Un.test(e)||!$n.test(e)||t!=null&&e in Object(t)}function Er(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Sr(e){return!!Je&&Je in e}var wr=je(function(e){e=Or(e);var t=[];return qn.test(e)&&t.push(""),e.replace(jn,function(n,r,s,o){t.push(s?o.replace(Gn,"$1"):r||n)}),t});function br(e){if(typeof e=="string"||Qe(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function vr(e){if(e!=null){try{return vt.call(e)}catch{}try{return e+""}catch{}}return""}function je(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Nn);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],o=n.cache;if(o.has(s))return o.get(s);var i=e.apply(this,r);return n.cache=o.set(s,i),i};return n.cache=new(je.Cache||B),n}je.Cache=B;function Pr(e,t){return e===t||e!==e&&t!==t}var Dt=Array.isArray;function Rr(e){var t=Ot(e)?Pt.call(e):"";return t==kn||t==Mn}function Ot(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Dr(e){return!!e&&typeof e=="object"}function Qe(e){return typeof e=="symbol"||Dr(e)&&Pt.call(e)==Ln}function Or(e){return e==null?"":mr(e)}function xr(e,t,n){var r=e==null?void 0:hr(e,t);return r===void 0?n:r}var Ir=xr;const H=Tn(Ir);function xt(e,t,n){return St(e??{result:[],success:!0,totalCount:0},s=>{for(const o of t)switch(o.type){case"ADD":{s.result.findIndex(a=>H(o.payload.data,n)===H(a,n))===-1&&s.result.push(o.payload.data);break}case"UPDATE":{const i=s.result.findIndex(a=>H(o.payload.data,n)===H(a,n));i!==-1&&(s.result[i]=o.payload.data);break}case"DELETE":{const i=s.result.findIndex(a=>H(o.payload.data,n)===H(a,n));i!==-1&&s.result.splice(i,1);break}}})}function It(e,t,n,r,s,o){const i=(o==null?void 0:o.syncWindowMs)??500,a=d.useRef([]),u=d.useRef(null),l=d.useRef(null),c=d.useRef(s);c.current=s;const m=d.useCallback(()=>{const f=a.current;if(a.current=[],u.current=null,l.current=null,!(f.length===0||!r)){e.setQueryData(t,g=>xt(g,f,r));for(const g of f)(g.type==="ADD"||g.type==="UPDATE")&&e.setQueryData(n(g.payload.id,g.payload.namespace),{result:g.payload.data})}},[e,t,n,r]),p=d.useCallback(f=>{a.current.push(f),!(u.current!==null||l.current!==null)&&(c.current===1?u.current=setTimeout(m,i):l.current=requestAnimationFrame(m))},[m,i]);return d.useEffect(()=>()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)},[]),p}const Fr=({pluginID:e,connectionID:t,resourceKey:n,idAccessor:r,namespaces:s})=>{const o=D(e),i=_.useQueryClient(),{showSnackbar:a}=M(),u=d.useMemo(()=>s??[],[s]),l=d.useMemo(()=>[o,t,n,u,"list"],[o,t,n,u]),c=d.useCallback((E,y)=>[o,t,n,y,E],[o,t,n]),{mutateAsync:m}=_.useMutation({mutationFn:async E=>C.Create(o,t,n,x.resource.ClientCreateInput.createFrom({input:E.input,namespace:E.namespace??(u.length===1?u[0]:"")})),onSuccess:async E=>{var v;const y=E.result;let w="";(v=y==null?void 0:y.metadata)!=null&&v.name?w=y.metadata.name:y!=null&&y.id?w=y.id:y!=null&&y.name?w=y.name:y!=null&&y.ID?w=y.ID:y!=null&&y.Name&&(w=y.Name);const S=w?`Resource ${w} created`:"Resource created";a(S,"success"),await i.invalidateQueries({queryKey:l})},onError:I(a,"Failed to create resource")}),p=_.useQuery({queryKey:l,queryFn:async()=>C.List(o,t,n,x.resource.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:u})),placeholderData:(E,y)=>E,retry:!1}),[f,g]=d.useState(b.IDLE);d.useEffect(()=>O.EventsOn(`${o}/${t}/watch/STATE`,y=>{y.resourceKey===n&&g(y.state)}),[o,t,n]);const h=It(i,l,c,r,f);return d.useEffect(()=>{if(!r)return;C.SubscribeResource(o,t,n);const E=O.EventsOn(`${o}/${t}/${n}/ADD`,S=>h({type:"ADD",payload:S})),y=O.EventsOn(`${o}/${t}/${n}/UPDATE`,S=>h({type:"UPDATE",payload:S})),w=O.EventsOn(`${o}/${t}/${n}/DELETE`,S=>h({type:"DELETE",payload:S}));return()=>{E(),y(),w(),C.UnsubscribeResource(o,t,n)}},[o,t,n,h]),{resources:p,create:m,watchState:f,isSyncing:f===b.SYNCING,isSynced:f===b.SYNCED,watchError:f===b.ERROR}},Ar=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=M(),r=_.useMutation({mutationFn:async({opts:i,input:a})=>C.Create(t,i.connectionID,i.resourceKey,x.resource.ClientCreateInput.createFrom({input:a.input,namespace:a.namespace??i.namespace??""})),onSuccess:(i,{opts:a})=>{n(`Resource ${a.resourceID} created`,"success")},onError(i,{opts:a}){G(n,i,`Failed to create resource ${a.resourceID}`)}}),s=_.useMutation({mutationFn:async({opts:i,input:a})=>C.Update(t,i.connectionID,i.resourceKey,x.resource.ClientUpdateInput.createFrom({input:a.input,id:i.resourceID,namespace:i.namespace??""})),onSuccess:(i,{opts:a})=>{n(`Resource ${a.resourceID} updated`,"success")},onError(i,{opts:a}){G(n,i,`Failed to update resource ${a.resourceID}`)}}),o=_.useMutation({mutationFn:async({opts:i,input:a})=>C.Delete(t,i.connectionID,i.resourceKey,x.resource.DeleteInput.createFrom({id:i.resourceID,namespace:i.namespace??"",gracePeriodSeconds:a.gracePeriodSeconds})),onSuccess:(i,{opts:a})=>{n(`Resource ${a.resourceID} deleted`,"success")},onError(i,{opts:a}){G(n,i,`Failed to delete resource ${a.resourceID}`)}});return{create:r.mutateAsync,update:s.mutateAsync,remove:o.mutateAsync}},Tr=({pluginID:e,connectionID:t,resourceKey:n,enabled:r=!0})=>{const s=D(e),o=_.useQuery({queryKey:["RESOURCE_ACTIONS",s,t,n],queryFn:()=>C.GetActions(s,t,n),enabled:r&&!!s&&!!t&&!!n,staleTime:5*60*1e3});return{actions:o.data??[],isLoading:o.isLoading,error:o.error}},Nr=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),s=_.useQueryClient(),{showSnackbar:o}=M(),i=_.useMutation({mutationFn:async({actionID:a,id:u="",namespace:l="",params:c={}})=>C.ExecuteAction(r,t,n,a,x.resource.ActionInput.createFrom({id:u,namespace:l,params:c})),onSuccess:a=>{a.message&&o(a.message,"success"),s.invalidateQueries({queryKey:["RESOURCES",r,t,n]})},onError:(a,u)=>{G(o,a,`Failed to execute action "${u.actionID}"`)}});return{executeAction:i.mutateAsync,isExecuting:i.isPending,error:i.error}},kr=({pluginID:e,connectionID:t,enabled:n=!0})=>{const r=D(e),s=_.useQuery({queryKey:["EDITOR_SCHEMAS",r,t],queryFn:()=>C.GetEditorSchemas(r,t),enabled:n&&!!r&&!!t,staleTime:10*60*1e3,retry:1});return{schemas:s.data??[],isLoading:s.isLoading,error:s.error,refetch:s.refetch}},Mr=({pluginID:e,connectionID:t,enabled:n=!0})=>{const r=D(e),s=_.useQueryClient(),o=[r,t,"watch-state"],i=d.useRef([]),a=d.useRef(!1),u=d.useCallback(p=>{s.setQueryData(o,f=>f&&St(f,g=>{g.resources[p.resourceKey]=p.state,g.resourceCounts[p.resourceKey]=p.resourceCount;let h=0,E=0;for(const y of Object.values(g.resources))y===b.SYNCED&&h++,(y===b.ERROR||y===b.FAILED)&&E++;g.syncedCount=h,g.errorCount=E}))},[s,r,t]),l=_.useQuery({queryKey:o,queryFn:async()=>{const p=await C.GetWatchState(r,t),f={};let g=0,h=0;for(const[y,w]of Object.entries(p.resources??{}))f[y]=w,w===b.SYNCED&&g++,w===b.ERROR&&h++;const E={};for(const[y,w]of Object.entries(p.resourceCounts??{}))E[y]=w;return{connection:p.connectionId,resources:f,resourceCounts:E,totalResources:Object.keys(f).length,syncedCount:g,errorCount:h}},enabled:n&&!!r&&!!t,refetchInterval:p=>{const f=p.state.data;if(!f||f.totalResources===0)return 3e3;let g=0;for(const h of Object.values(f.resources))(h===b.SYNCED||h===b.ERROR||h===b.STOPPED||h===b.FAILED||h===b.FORBIDDEN||h===b.SKIPPED)&&g++;return g>=f.totalResources?!1:3e3}});d.useEffect(()=>{if(!l.data||a.current)return;a.current=!0;const p=i.current;i.current=[];for(const f of p)u(f)},[l.data,u]),d.useEffect(()=>{if(!n||!r||!t)return;a.current=!1,i.current=[];const p=O.EventsOn(`${r}/${t}/watch/STATE`,f=>{a.current?u(f):i.current.push(f)});return()=>{p(),a.current=!1,i.current=[]}},[r,t,n,u]);const c=l.data;let m=0;if(c!=null&&c.resources)for(const p of Object.values(c.resources))(p===b.SYNCED||p===b.ERROR||p===b.STOPPED||p===b.FAILED||p===b.FORBIDDEN||p===b.SKIPPED)&&m++;return{summary:l,getResourceState:p=>c==null?void 0:c.resources[p],isFullySynced:c?c.totalResources>0&&m===c.totalResources:!1,syncProgress:c&&c.totalResources>0?m/c.totalResources:0,errorCount:(c==null?void 0:c.errorCount)??0}},Lr=()=>{const[e,t]=d.useState(new Map),n=d.useRef(new Map),r=d.useRef(new Map),s=d.useCallback(l=>{const c=ke(l),m=pt(n.current,l),p=ve(m);if(t(f=>{const g=new Map(f);return g.set(c,p),g}),r.current.has(c)&&(clearTimeout(r.current.get(c)),r.current.delete(c)),oe(p)){const f=setTimeout(()=>{t(g=>{const h=new Map(g);return h.delete(c),h}),n.current.delete(c),r.current.delete(c)},5e3);r.current.set(c,f)}},[]);d.useEffect(()=>{const l=O.EventsOn("watch/STATE",s);return()=>{l();for(const c of r.current.values())clearTimeout(c)}},[s]);const o=Array.from(e.values()),i=dt(o),a=o.find(l=>!oe(l))??o[0]??null,u=ft(o);return{syncs:o,hasSyncing:i,primarySync:a,aggregateProgress:u}},Ft=()=>{const e=d.useContext(Te);if(!e)throw new Error("useOperations must be used within an OperationsProvider");return e},$r=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),{showSnackbar:s}=M(),{addOperation:o,updateOperation:i}=Ft(),a=d.useRef([]);return d.useEffect(()=>()=>{a.current.forEach(l=>l())},[]),{startStreamAction:d.useCallback(async({actionID:l,id:c,namespace:m,label:p,params:f={}})=>{try{const g=await C.StreamAction(r,t,n,l,x.resource.ActionInput.createFrom({id:c,namespace:m,params:f}));o({id:g,label:p,resourceKey:n,resourceName:c,namespace:m,connectionID:t,status:"running",startedAt:Date.now()});const h=`action/stream/${g}`,E=O.EventsOn(h,y=>{var w,S,v,F;switch(y.type){case"progress":{const P=y.data??{};i(g,{message:P.message,progress:P.ready!==void 0&&P.desired!==void 0?{ready:P.ready,desired:P.desired}:void 0});break}case"complete":i(g,{status:"completed",message:((w=y.data)==null?void 0:w.message)??"Completed",completedAt:Date.now()}),s(((S=y.data)==null?void 0:S.message)??p+" completed","success"),O.EventsOff(h);break;case"error":i(g,{status:"error",message:((v=y.data)==null?void 0:v.message)??"Failed",completedAt:Date.now()}),s(((F=y.data)==null?void 0:F.message)??p+" failed","error"),O.EventsOff(h);break}});return a.current.push(()=>{E(),O.EventsOff(h)}),g}catch(g){throw G(s,g,`Failed to start "${l}"`),g}},[r,t,n,o,i,s])}},Ur=()=>{const e=d.useContext(Ae);if(!e)throw new Error("useSettings must be used within a SettingsProvider");return e},qr=({to:e,withinContext:t,...n})=>{const{pluginId:r}=le();r||console.error("Link used outside of a plugin context");const s=`/_plugin/${r}${e.startsWith("/")?"":"/"}${e}`;return d.useMemo(()=>R.jsx(Z.Link,{style:{textDecoration:"none",color:"inherit"},...n,to:s}),[n,s])};function jr(){const e=Z.useNavigate(),t=Z.useLocation(),{pluginId:n}=le();n||console.error("usePluginRouter used outside of a plugin context");const r=`/_plugin/${n}`,s=t.pathname.startsWith(r)?t.pathname.slice(r.length)||"/":t.pathname,o=d.useCallback((i,a)=>{const{...u}=a??{};i.startsWith("/")?e(`${r}${i}`,u):e(i,u)},[e,r]);return d.useMemo(()=>({location:t,navigate:o,pluginPath:s}),[t,o,s])}class Qr{}class Gr{constructor(){L(this,"_extensions");L(this,"root");L(this,"pages");L(this,"_routes")}get extensions(){return this._extensions||[]}get Routes(){var t;if(!this._routes&&this.root)return[{path:"",index:!0,Component:this.root}];if(!((t=this._routes)!=null&&t.length))throw new Error("cannot use plugin without a root page or router");return this._routes}get Window(){if(!this._routes&&this.root)return R.jsx(this.root,{});const t=Z.createMemoryRouter(this._routes||[]);return R.jsx(Z.RouterProvider,{router:t})}registerExtensionPoints(t){return this._extensions=t||[],this}setRootPage(t){return this.root=t,this}withPage(t,n){return this.pages||(this.pages={}),this.pages[t]?(console.warn("Cannot register page with the same name. Please use a different name."),this):(this.pages[t]=n,this)}withRoutes(t){return this._routes=t,this}}var At=(e=>(e.MISSING_MANIFEST="MISSING_MANIFEST",e.MISSING_PLUGIN="MISSING_PLUGIN",e.MISSING_ENTRYPOINT="MISSING_ENTRYPOINT",e))(At||{});const Kr=e=>{const t=e.split("::");return t.length===1?{group:"core",version:"",kind:t[0]}:{group:t[0]||"core",version:t[1]||"",kind:t[2]||t[0]}},zr=e=>!e||e==="core"?"Core":e.charAt(0).toUpperCase()+e.slice(1);exports.ALL_SESSIONS_KEY=Q;exports.BottomDrawerContext=rt;exports.ConfirmationModalContext=ot;exports.ErrorTypes=k;exports.ExtensionPointRegistry=Yt;exports.ExtensionPointStore=ct;exports.ExtensionProvider=Ht;exports.Link=qr;exports.OperationsContext=Te;exports.OperationsProvider=jt;exports.PluginContext=ue;exports.PluginContextProvider=Lt;exports.PluginErrorCode=At;exports.PluginWindow=Gr;exports.PluginWindowRootProps=Qr;exports.RightDrawerContext=st;exports.SettingsContext=Ae;exports.SettingsProvider=Ut;exports.SnackbarProvider=Vt;exports.SyncPolicy=tn;exports.WatchState=b;exports.actionToSnackbar=et;exports.applyBatch=xt;exports.connectionListQueryKey=lt;exports.createErrorHandler=I;exports.defaultState=nt;exports.formatGroup=zr;exports.isCancelledError=Fe;exports.parseAppError=$;exports.parseResourceKey=Kr;exports.showAppError=G;exports.useActiveSyncs=Lr;exports.useBottomDrawer=Me;exports.useConfirmationModal=hn;exports.useConnection=Xt;exports.useConnectionNamespaces=en;exports.useConnectionStatus=nn;exports.useConnections=Zt;exports.useEditorSchemas=kr;exports.useEventBatcher=It;exports.useExec=cn;exports.useExecuteAction=Nr;exports.useExtensionPoint=Wt;exports.useExtensionPointComponents=Bt;exports.useExtensionRegistry=Ne;exports.useLogs=un;exports.useMetricProviders=ln;exports.useMetricProvidersForResource=yt;exports.useMetricStream=fn;exports.useOperations=Ft;exports.usePluginContext=le;exports.usePluginData=on;exports.usePluginRouter=jr;exports.usePluginSettings=$t;exports.usePortForwardSessions=pn;exports.useResolvedPluginId=D;exports.useResource=gn;exports.useResourceActions=Tr;exports.useResourceAreaComponent=mn;exports.useResourceGroups=_n;exports.useResourceMetrics=dn;exports.useResourceMutations=Ar;exports.useResourcePortForwarder=yn;exports.useResourceSearch=Cn;exports.useResourceType=En;exports.useResourceTypes=Sn;exports.useResources=Fr;exports.useRightDrawer=an;exports.useSettings=Ur;exports.useSnackbar=M;exports.useStreamAction=$r;exports.useWatchState=Mr;
1
+ "use strict";var Ze=Object.defineProperty;var Xe=(t,e,n)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>Xe(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),l=require("react"),B=require("react-router-dom"),g=require("./servicewrapper-dDhyC68C.cjs"),A=require("./models-DdAWPDgz.cjs"),S=require("@tanstack/react-query"),Ve=require("@omniviewdev/base-ui");require("./index-D_aIcqH0.cjs");const D=require("./events-BTiuwc-0.cjs"),et=require("./legacyEnum-DkV5yRdA.cjs"),X=l.createContext(void 0),U={PLUGIN_NOT_FOUND:"omniview:plugin/not-found",PLUGIN_NOT_LOADED:"omniview:plugin/not-loaded",PLUGIN_ALREADY_LOADED:"omniview:plugin/already-loaded",PLUGIN_INSTALL_FAILED:"omniview:plugin/install-failed",PLUGIN_LOAD_FAILED:"omniview:plugin/load-failed",PLUGIN_BUILD_FAILED:"omniview:plugin/build-failed",SETTINGS_MISSING_CONFIG:"omniview:settings/missing-config",SETTINGS_INVALID_CONFIG:"omniview:settings/invalid-config",RESOURCE_NOT_FOUND:"omniview:resource/not-found",RESOURCE_FORBIDDEN:"omniview:resource/forbidden",RESOURCE_UNAUTHORIZED:"omniview:resource/unauthorized",RESOURCE_CONFLICT:"omniview:resource/conflict",RESOURCE_TIMEOUT:"omniview:resource/timeout",CONNECTION_NOT_FOUND:"omniview:connection/not-found",CONNECTION_FAILED:"omniview:connection/failed",RESOURCE_CONNECTION_ERROR:"omniview:resource/connection-error",RESOURCE_CERTIFICATE_ERROR:"omniview:resource/certificate-error",SESSION_NOT_FOUND:"omniview:session/not-found",SESSION_FAILED:"omniview:session/failed",CANCELLED:"omniview:cancelled",INTERNAL:"omniview:internal",VALIDATION:"omniview:validation",NOT_IMPLEMENTED:"omniview:not-implemented"};function tt(t){switch(t){case"NOT_FOUND":return{typeUri:U.RESOURCE_NOT_FOUND,status:404};case"FORBIDDEN":return{typeUri:U.RESOURCE_FORBIDDEN,status:403};case"UNAUTHORIZED":return{typeUri:U.RESOURCE_UNAUTHORIZED,status:401};case"CONFLICT":case"ALREADY_EXISTS":return{typeUri:U.RESOURCE_CONFLICT,status:409};case"TIMEOUT":return{typeUri:U.RESOURCE_TIMEOUT,status:408};case"CONNECTION_ERROR":return{typeUri:U.RESOURCE_CONNECTION_ERROR,status:503};case"CERTIFICATE_ERROR":return{typeUri:U.RESOURCE_CERTIFICATE_ERROR,status:502};default:return{typeUri:U.INTERNAL,status:500}}}function q(t){if(t==null)return{type:U.INTERNAL,title:"Unknown error",status:500,detail:"An unknown error occurred."};let e;if(typeof t=="string"?e=t:t instanceof Error?e=t.message:e=String(t),e.startsWith("{"))try{const n=JSON.parse(e);if(typeof n.type=="string"&&typeof n.title=="string"&&typeof n.status=="number"&&typeof n.detail=="string")return n;if(typeof n.code=="string"&&typeof n.title=="string"&&typeof n.message=="string"){const{typeUri:r,status:s}=tt(n.code);return{type:r,title:n.title,status:s,detail:n.message,suggestions:Array.isArray(n.suggestions)?n.suggestions:void 0}}}catch{}return{type:U.INTERNAL,title:"Error",status:500,detail:e}}function ue(t){return t==null?!1:(typeof t=="string"?t:t instanceof Error?t.message:String(t))==="cancelled"?!0:q(t).type===U.CANCELLED}function ve(t){switch(t.type){case"navigate":return{label:t.label,onClick:()=>{window.location.hash=t.target??""}};case"open-url":return{label:t.label,onClick:()=>{window.open(t.target,"_blank")}};case"copy":return{label:t.label,onClick:()=>{navigator.clipboard.writeText(t.target??"")}};case"retry":return{label:t.label,onClick:()=>{}};default:return{label:t.label,onClick:()=>{}}}}function be(t,e){var s,i;const n=[t.detail,...((s=t.suggestions)==null?void 0:s.map(o=>`• ${o}`))??[]].join(`
2
+ `);return{message:e||(t.title!=="Error"?t.title:"Operation failed"),status:"error",details:n,actions:(i=t.actions)==null?void 0:i.map(ve)}}function Q(t,e,n){if(ue(e))return;const r=q(e);t(be(r,n))}function N(t,e){return n=>{if(ue(n))return;const r=q(n);t(be(r,r.title!=="Error"?r.title:e))}}function nt(t){const{children:e,pluginId:n}=t,[r,s]=l.useState({}),[i,o]=l.useState(new A.PluginMeta),[a,c]=l.useState(!1),[d,u]=l.useState(null);console.debug("[PluginContextProvider] render",{pluginId:n,metaLoaded:a,metaError:!!d});const h=()=>{n===void 0||n===""||(console.debug(`[PluginContextProvider] fetching settings for "${n}"`),g.PluginValues(n).then(f=>{console.debug(`[PluginContextProvider] settings loaded for "${n}"`,Object.keys(f)),s(f)}).catch(f=>{const y=q(f);console.error(`[PluginContextProvider] error fetching settings for "${n}":`,y.detail)}))},p=()=>{if(n===void 0||n===""){console.debug("[PluginContextProvider] skipping meta fetch — empty pluginId");return}console.debug(`[PluginContextProvider] fetching meta for "${n}"`),u(null),g.GetPluginMeta(n).then(f=>{console.debug(`[PluginContextProvider] meta loaded for "${n}"`,{name:f==null?void 0:f.name,version:f==null?void 0:f.version}),o(f),c(!0)}).catch(f=>{const y=q(f);console.error(`[PluginContextProvider] error fetching meta for "${n}":`,y.detail),u(y.detail),c(!1)})};return l.useEffect(()=>{console.debug(`[PluginContextProvider] useEffect — pluginId changed to "${n}"`),h(),p()},[n]),d?O.jsx("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",padding:24},children:O.jsxs("div",{style:{maxWidth:480,width:"100%",border:"1px solid #7F1D1D",borderRadius:8,backgroundColor:"#1C1917",padding:20,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[O.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[O.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[O.jsx("circle",{cx:"12",cy:"12",r:"10"}),O.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),O.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),O.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#FECACA"},children:"Plugin failed to load"})]}),O.jsx("p",{style:{fontSize:13,color:"#A1A1AA",margin:"0 0 16px"},children:d}),O.jsx("button",{onClick:()=>p(),style:{background:"transparent",color:"#F87171",border:"1px solid #7F1D1D",borderRadius:6,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer"},children:"Retry"})]})}):a?O.jsx(X.Provider,{value:{pluginId:n,settings:r,meta:i},children:e}):O.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center"},children:[O.jsx("div",{style:{width:24,height:24,border:"2px solid #3F3F46",borderTopColor:"#A1A1AA",borderRadius:"50%",animation:"plugin-spin 0.8s linear infinite"}}),O.jsx("style",{children:"@keyframes plugin-spin { to { transform: rotate(360deg); } }"})]})}function V(){const t=l.useContext(X);if(!t)throw new Error("usePluginContext must be used within a PluginContextProvider");return t}function rt(){return V().settings}const le=l.createContext(void 0),st=({children:t})=>{const[e,n]=l.useState({}),r=()=>{g.Values().then(i=>{console.log("Fetched settings:",i),n(i)}).catch(i=>{console.error("Error fetching settings:",i)})};l.useEffect(()=>{r()},[]);const s=()=>{r()};return O.jsx(le.Provider,{value:{settings:e,reload:s},children:t})},Re={height:32,focused:0,tabs:[],createTab:()=>{},createTabs:()=>{},updateTab:()=>{},focusTab:()=>{},reorderTab:()=>{},closeTab:()=>{},closeTabs:()=>{},resizeDrawer:()=>{},closeDrawer:()=>{},fullscreenDrawer:()=>{}},xe=l.createContext(Re),Pe=l.createContext(void 0),Ie=l.createContext(void 0),de=l.createContext(void 0),ot=3e4,it=({children:t})=>{const[e,n]=l.useState([]),r=l.useCallback(a=>{n(c=>[a,...c])},[]),s=l.useCallback((a,c)=>{n(d=>d.map(u=>u.id===a?{...u,...c}:u))},[]),i=l.useCallback(a=>{n(c=>c.filter(d=>d.id!==a))},[]);l.useEffect(()=>{const a=[];for(const c of e)if(c.status==="completed"||c.status==="error"){const d=Date.now()-(c.completedAt??c.startedAt),u=Math.max(0,ot-d);a.push(setTimeout(()=>i(c.id),u))}return()=>a.forEach(clearTimeout)},[e,i]);const o=l.useMemo(()=>({operations:e,addOperation:r,updateOperation:s,removeOperation:i}),[e,r,s,i]);return O.jsx(de.Provider,{value:o,children:t})};var ie=function(t,e){return ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},ie(t,e)};function at(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ie(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var re="Invariant Violation",Se=Object.setPrototypeOf,ct=Se===void 0?function(t,e){return t.__proto__=e,t}:Se,ut=function(t){at(e,t);function e(n){n===void 0&&(n=re);var r=t.call(this,typeof n=="number"?re+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=re,ct(r,e.prototype),r}return e}(Error);function ae(t,e){if(!t)throw new ut(e)}var Fe=["debug","log","warn","error","silent"],lt=Fe.indexOf("log");function z(t){return function(){if(Fe.indexOf(t)>=lt){var e=console[t]||console.log;return e.apply(console,arguments)}}}(function(t){t.debug=z("debug"),t.log=z("log"),t.warn=z("warn"),t.error=z("error")})(ae||(ae={}));const Oe=l.createContext(void 0),De=()=>l.useContext(Oe);function dt(t){const e=De(),n=l.useRef(null),r=e==null?void 0:e.getExtensionPoint(t),s=l.useCallback(o=>{const a=[];return e&&a.push(e.subscribe(o)),r&&a.push(r.subscribe(o)),()=>{for(const c of a)c()}},[e,t,r]),i=l.useCallback(()=>{const o=e==null?void 0:e.getExtensionPoint(t);if(!o){if(n.current&&n.current.store===void 0)return n.current.sentinel;const d={};return n.current={store:void 0,version:-1,sentinel:d},d}const a=n.current;if(a&&a.store===o&&a.version===o.version)return a.sentinel;const c={};return n.current={store:o,version:o.version,sentinel:c},c},[e,t]);return l.useSyncExternalStore(s,i),e==null?void 0:e.getExtensionPoint(t)}const ft=({registry:t,children:e})=>{const n=l.useRef(t);return ae(n.current===t,"You can't change the extension registry after it has been rendered"),O.jsx(Oe.Provider,{value:n.current,children:e})},se=t=>{if(!t||typeof t!="string")throw new TypeError(`extensionName is required to be a string and can't be: "${t}" (${typeof t})`);return t.trim()};class Te{constructor(e){M(this,"id");M(this,"mode");M(this,"_pluginId");M(this,"_version",0);M(this,"_contributions",new Map);M(this,"_lookupCache",new Map);M(this,"_matcher");M(this,"_select");M(this,"_listeners",new Set);this.id=e.id,this.mode=e.mode??"multiple",this._pluginId=e.pluginId,this._matcher=e.matcher,this._select=e.select}get pluginId(){return this._pluginId}get version(){return this._version}register(e){if(this._contributions.has(e.id))throw new Error(`Contribution with id "${e.id}" already exists in extension point "${this.id}"`);this._contributions.set(e.id,e),this._invalidateCache(),this._notify()}unregister(e){this._contributions.delete(e)&&(this._invalidateCache(),this._notify())}provide(e){return this._getMatched(e).map(r=>r.value)}list(e){return this._getMatched(e)}listAll(){return Array.from(this._contributions.values())}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}removeContributionsByPlugin(e){let n=!1;for(const[r,s]of this._contributions)s.plugin===e&&(this._contributions.delete(r),n=!0);n&&(this._invalidateCache(),this._notify())}_getMatched(e){const n=this._getCacheKey(e);if(n!=null){const s=this._lookupCache.get(n);if(s){const i=s.map(o=>this._contributions.get(o)).filter(o=>o!=null);return this._applyMode(i,e)}}let r=this._sortDeterministic(Array.from(this._contributions.values()));return this._matcher&&e!==void 0&&(r=r.filter(s=>this._matcher(s,e))),n!=null&&this._lookupCache.set(n,r.map(s=>s.id)),this._applyMode(r,e)}_applyMode(e,n){if(this.mode==="single"){if(this._select){const r=this._select(e,n);return r?[r]:[]}return e.length>0?[e[0]]:[]}return e}_sortDeterministic(e){return[...e].sort((n,r)=>{const s=n.plugin.localeCompare(r.plugin);return s!==0?s:n.id.localeCompare(r.id)})}_getCacheKey(e){if(e!=null&&typeof e=="object"&&"getCacheKey"in e){const n=e.getCacheKey;if(typeof n=="function")return n()}}_invalidateCache(){this._lookupCache.clear()}_notify(){this._version++;for(const e of this._listeners)e()}}class pt{constructor(e){M(this,"_stores",new Map);M(this,"_storeUnsubs",new Map);M(this,"_listeners",new Set);if(e!=null&&e.initialStores)for(const n of e.initialStores)this.addExtensionPoint(n)}addExtensionPoint(e){const n=se(e.id);if(this._stores.has(n)){const s=this._stores.get(n);throw new Error(`Extension point "${n}" already exists (owned by "${s.pluginId??"unknown"}")`)}const r=new Te({...e,id:n});this._stores.set(n,r),this._storeUnsubs.set(n,r.subscribe(()=>this._notify())),this._notify()}getExtensionPoint(e){const n=se(e);return this._stores.get(n)}hasExtensionPoint(e){const n=se(e);return this._stores.has(n)}listExtensionPoints(){return Array.from(this._stores.keys())}removeExtensionPoints(e){var r;let n=!1;for(const[s,i]of this._stores)i.pluginId===e&&((r=this._storeUnsubs.get(s))==null||r(),this._storeUnsubs.delete(s),this._stores.delete(s),n=!0);n&&this._notify()}removeContributions(e){for(const n of this._stores.values())n.removeContributionsByPlugin(e);this._notify()}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_notify(){for(const e of this._listeners)e()}}const Ae=l.createContext(void 0),yt={default:"info",info:"info",success:"success",warning:"warning",error:"danger"},ht=({children:t})=>{const{toast:e}=Ve.useToast(),[n,r]=l.useState([]),s=o=>{r(a=>[...a,o])},i=(o,a,c)=>{const d=typeof o=="object";let u="",h="info",p,f=5e3,y;if(d){if(u=o.message,o.showOnce){if(n.includes(u))return;s(u)}h=o.status,p=o.details,f=o.autoHideDuration??5e3,y=o.actions}else u=o,h=a,p=c;e(p??u,{severity:yt[h]??"info",title:p?u:void 0,duration:f,action:y==null?void 0:y[0]})};return O.jsx(Ae.Provider,{value:{showSnackbar:i},children:t})},$=()=>{const t=l.useContext(Ae);if(t===void 0)throw new Error("useCustomSnackbar must be used within a CustomSnackbarProvider");return t};function T(t){const e=l.useContext(X),n=(e==null?void 0:e.pluginId)??t;if(!n)throw new Error("pluginID must be provided either via PluginContext or as an explicit parameter");return n}const gt=({pluginID:t,connectionID:e})=>{const n=T(t),r=S.useQueryClient(),{showSnackbar:s}=$(),i=[n,"connection","detail",e],{mutateAsync:o}=S.useMutation({mutationFn:async()=>g.StartConnection(n,e),onSuccess(h){r.setQueryData(i,h),r.invalidateQueries({queryKey:["EDITOR_SCHEMAS",n,e]})},onError:N(s,"Failed to start connection")}),{mutateAsync:a}=S.useMutation({mutationFn:async()=>g.StopConnection(n,e),onSuccess(h){r.setQueryData(i,h)},onError:N(s,"Failed to stop connection")}),{mutateAsync:c}=S.useMutation({mutationFn:async h=>g.UpdateConnection(n,h),onSuccess(h,{name:p}){s({message:`Connection ${p} successfully updated`,status:"success"}),r.setQueryData(i,h),r.setQueriesData({queryKey:[n,"connection","list"]},f=>f==null?void 0:f.map(y=>y.id===e?h:y))},onError:N(s,"Failed to update connection")}),{mutateAsync:d}=S.useMutation({mutationFn:async()=>g.RemoveConnection(n,e),onSuccess(){s({message:"Connection successfully removed",status:"success"}),r.setQueryData(i,void 0),r.setQueriesData({queryKey:[n,"connection","list"]},h=>h==null?void 0:h.filter(p=>p.id!==e))},onError:N(s,"Failed to remove connection")});return{connection:S.useQuery({queryKey:i,queryFn:async()=>g.GetConnection(n,e)}),startConnection:o,stopConnection:a,updateConnection:c,deleteConnection:d}},Me=t=>[t,"connection","list"],mt=({plugin:t})=>{const e=T(t),n=S.useQueryClient(),{showSnackbar:r}=$(),s=Me(e),{mutateAsync:i}=S.useMutation({mutationFn:async d=>g.StartConnectionWatch(e,d.id),onError:N(r,"Failed to start connection watch")}),{mutateAsync:o}=S.useMutation({mutationFn:async d=>g.StopConnectionWatch(e,d.id),onError:N(r,"Failed to stop connection watch")}),a=l.useCallback(d=>{const u=d.data;console.log("got update to connections",u),n.setQueryData(s,u)},[n,s]);return l.useEffect(()=>{const d=D.On(`${e}/connection/sync`,a);return()=>{d()}},[e,a]),{connections:S.useQuery({queryKey:s,queryFn:async()=>{try{return await g.ListConnections(e)}catch(d){console.log(d),N(r,"Failed to load connections")(d)}return[]},staleTime:3e4,placeholderData:S.keepPreviousData}),startWatch:i,stopWatch:o}},St=({pluginID:t,connectionID:e})=>{const n=T(t),r=[n,"connection","namespaces",e];return{namespaces:S.useQuery({queryKey:r,queryFn:async()=>g.GetConnectionNamespaces(n,e)})}},I=et.withLegacyNames(A.WatchState,"WatchState");function ce(t){const e=Object.values(t.states),n=e.length;let r=0,s=0,i=0,o=0;for(const u of e)u===I.WatchStateSynced&&r++,(u===I.WatchStateError||u===I.WatchStateFailed)&&s++,u===I.WatchStateForbidden&&i++,u===I.WatchStateSkipped&&o++;const a=n-o,c=e.filter(u=>u===I.WatchStateSynced||u===I.WatchStateError||u===I.WatchStateStopped||u===I.WatchStateFailed||u===I.WatchStateForbidden).length,d=a>0?c/a:0;return{pluginID:t.pluginID,connectionID:t.connectionID,totalResources:n,watchedTotal:a,syncedCount:r,errorCount:s,forbiddenCount:i,skippedCount:o,doneCount:c,progress:d}}function Z(t){return t.watchedTotal>0&&t.doneCount>=t.watchedTotal}function Ne(t){return t.some(e=>!Z(e))}function ke(t){const e=t.reduce((r,s)=>r+s.watchedTotal,0);return e===0?0:t.reduce((r,s)=>r+s.doneCount,0)/e}function fe(t){return`${t.pluginId}/${t.connection}`}function Le(t,e){const n=fe(e);t.has(n)||t.set(n,{states:{},pluginID:e.pluginId,connectionID:e.connection});const r=t.get(n);return r.states[e.resourceKey]=e.state,r}function Ct(){const[t,e]=l.useState(new Set),[n,r]=l.useState({}),[s,i]=l.useState(new Map),o=l.useRef(new Map),[a,c]=l.useState(new Map);l.useEffect(()=>{const m=D.On("plugin/crash_recovery_failed",P=>{const v=P.data,w=v==null?void 0:v.pluginID;w&&c(b=>{const F=new Map(b);return F.set(w,v.error??"Crash recovery failed"),F})}),x=D.On("plugin/recovered",P=>{const v=P.data,w=v==null?void 0:v.pluginID;w&&c(b=>{if(!b.has(w))return b;const F=new Map(b);return F.delete(w),F})});return()=>{m(),x()}},[]),l.useEffect(()=>{g.GetAllConnectionStates().then(m=>{if(!m)return;const x={},P=new Set,v=new Map;for(const[w,b]of Object.entries(m))if(b){x[w]=b.map(F=>F.connection);for(const F of b){if(!F.started)continue;const L=`${w}/${F.connection.id}`;P.add(L);const k={pluginID:w,connectionID:F.connection.id,states:{}};if(F.resources)for(const[ne,Je]of Object.entries(F.resources))k.states[ne]=Je;o.current.set(L,k),v.set(L,ce(k))}}r(x),e(P),i(v)}).catch(()=>{})},[]),l.useEffect(()=>D.On("connection/status",x=>{const P=x.data,v=`${P.pluginID}/${P.connectionID}`;P.status==="DISCONNECTED"?(e(w=>{const b=new Set(w);return b.delete(v),b}),i(w=>{const b=new Map(w);return b.delete(v),b}),o.current.delete(v)):e(w=>{const b=new Set(w);return b.add(v),b}),g.ListAllConnections().then(w=>{if(!w)return;const b={};for(const[F,L]of Object.entries(w))L!=null&&(b[F]=L);r(b)}).catch(()=>{})}),[]);const d=l.useCallback(m=>{const x=m.data,P=fe(x);e(b=>{if(b.has(P))return b;const F=new Set(b);return F.add(P),F});const v=Le(o.current,x),w=ce(v);i(b=>{const F=new Map(b);return F.set(P,w),F})},[]);l.useEffect(()=>D.On("watch/STATE",d),[d]);const u=l.useCallback(async(m,x)=>{await g.StopConnection(m,x)},[]),h=l.useCallback(async(m,x)=>{await g.StartConnectionWatch(m,x)},[]),p=l.useCallback(async m=>{const x=a.get(m);c(P=>{if(!P.has(m))return P;const v=new Map(P);return v.delete(m),v});try{await g.RetryFailedPlugin(m)}catch(P){throw c(v=>{const w=new Map(v);return w.set(m,x??"Reload failed"),w}),P}},[a]),f=[];for(const m of t){const[x,P]=m.split("/",2),w=(n[x]??[]).find(ne=>ne.id===P),b=s.get(m),F=b!=null&&!Z(b),L=b!=null&&b.errorCount>0,k=a.get(x);f.push({pluginID:x,connectionID:P,name:(w==null?void 0:w.name)??P,avatar:(w==null?void 0:w.avatar)??"",isStarted:!0,sync:b,isSyncing:F,hasErrors:L||k!=null,pluginFailed:k!=null,pluginError:k})}const y=new Map;for(const m of f){const x=y.get(m.pluginID)??[];x.push(m),y.set(m.pluginID,x)}const _=Array.from(s.values()),R=f.filter(m=>m.isSyncing),C=f.filter(m=>m.hasErrors),E=f.filter(m=>m.pluginFailed);return{entries:f,grouped:y,connectedCount:f.length,syncingCount:R.length,errorCount:C.length,failedCount:E.length,hasSyncing:Ne(_),aggregateProgress:ke(_),disconnect:u,retryWatch:h,retryPlugin:p}}function Et(t,e){return e===null?t===null:Array.isArray(e)?Array.isArray(t):typeof e=="object"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t==typeof e}function wt(t,e,n){const r=T(t),s=S.useQueryClient(),i=[r,"data",e],o=S.useQuery({queryKey:i,queryFn:async()=>{const c=await g.Get(r,e);return c==null?n:Et(c,n)?c:(console.warn(`[usePluginData] stored value for "${e}" has unexpected type (expected ${Array.isArray(n)?"array":typeof n}, got ${Array.isArray(c)?"array":typeof c}). Using default.`),n)}}),a=S.useMutation({mutationFn:async c=>{await g.Set(r,e,c)},onMutate:async c=>{await s.cancelQueries({queryKey:i});const d=s.getQueryData(i);return s.setQueryData(i,c),{previous:d}},onError:(c,d,u)=>{(u==null?void 0:u.previous)!==void 0&&s.setQueryData(i,u.previous)},onSettled:()=>{s.invalidateQueries({queryKey:i})}});return{data:o.data??n,update:async c=>{await a.mutateAsync(c)},isLoading:o.isLoading}}const _t=()=>{const t=l.useContext(Pe);if(!t)throw new Error("useRightDrawer must be used within a RightDrawerProvider");return t},pe=()=>{const t=l.useContext(xe);if(t===void 0)throw new Error("useBottomDrawer must be used within a BottomDrawerProvider");return t},vt=({pluginID:t})=>{const e=T(t),{showSnackbar:n}=$(),{createTab:r,updateTab:s}=pe();return{createSession:S.useMutation({mutationFn:async({connectionID:o,icon:a,label:c,opts:d})=>{const u=`pending-${crypto.randomUUID()}`;r({id:u,title:c??"Connecting...",variant:"terminal",icon:a??"LuSquareTerminal",properties:{status:"connecting",pluginID:e,connectionID:o,opts:{...d}}});const h=A.SessionOptions.createFrom({command:["/bin/bash"],tty:!0,...d});try{const p=await g.CreateSession(e,o,h);if(!p)throw new Error("Failed to create session: null response");s({id:u},{id:p.id,title:c??`Session ${p.id.substring(0,8)}`,properties:{status:"connected",pluginID:e,connectionID:o,opts:{...d}}})}catch(p){const f=q(p);s({id:u},{properties:{status:"error",error:f.detail,pluginID:e,connectionID:o,opts:{...d}}}),Q(n,p,"Failed to start session")}}}).mutateAsync}},bt=({pluginID:t})=>{const e=T(t),{showSnackbar:n}=$(),{createTab:r}=pe(),s=S.useMutation({mutationFn:async({connectionID:o,resourceKey:a,resourceID:c,resourceData:d,icon:u,label:h,target:p,follow:f=!0,tailLines:y=1e3,params:_})=>{const R=A.CreateSessionOptions.createFrom({resource_key:a,resource_id:c,resource_data:d,options:A.LogSessionOptions.createFrom({target:p??"",follow:f,include_previous:!1,include_timestamps:!0,tail_lines:y,since_seconds:0,limit_bytes:0,include_source_events:!0,params:_??{}})}),C=await g.CreateSession$1(e,o,R);if(!C)throw new Error("Failed to create log session: null response");return r({id:C.id,title:h??`Logs ${C.id.substring(0,8)}`,variant:"logs",icon:u??"LuLogs"}),C},onError:N(n,"Failed to start log session")}),i=S.useMutation({mutationFn:async o=>{await g.CloseSession(o)},onError:N(n,"Failed to close log session")});return{createLogSession:s.mutateAsync,closeLogSession:i.mutateAsync}},Rt=()=>S.useQuery({queryKey:["metric","providers"],queryFn:g.GetProviders,staleTime:3e4}),Ue=t=>S.useQuery({queryKey:["metric","providers",t],queryFn:()=>g.GetProvidersForResource(t),enabled:!!t,staleTime:3e4}),xt=t=>{var R,C;const{connectionID:e,resourceKey:n,resourceID:r,resourceNamespace:s="",resourceData:i={},metricIDs:o=[],shape:a=0,timeRange:c,refreshInterval:d=0,enabled:u=!0}=t,{data:h,isLoading:p}=Ue(n),f=h??[],y=c?Math.max(Math.floor((c.end.getTime()-c.start.getTime())/250),15e3)*1e6:0,_=S.useQuery({queryKey:["metric","query",e,n,r,s,o,a,(R=c==null?void 0:c.start)==null?void 0:R.getTime(),(C=c==null?void 0:c.end)==null?void 0:C.getTime()],queryFn:async()=>{const E=await g.QueryAll(e,n,r,s,i,o,a,((c==null?void 0:c.start)??new Date(0)).toISOString(),((c==null?void 0:c.end)??new Date(0)).toISOString(),y),m={};for(const[x,P]of Object.entries(E))P!=null&&(m[x]=P);return m},enabled:u&&!!e&&!!n&&(n.startsWith("cluster::")||!!r)&&f.length>0,refetchInterval:d>0?d:void 0,staleTime:5e3,placeholderData:S.keepPreviousData});return{data:_.data??void 0,providers:f,isLoading:p||_.isLoading,error:_.error,refetch:_.refetch}},Pt=t=>{const{pluginID:e,connectionID:n,resourceKey:r,resourceID:s,resourceNamespace:i="",resourceData:o={},metricIDs:a=[],interval:c=1e4,enabled:d=!0}=t,u=T(e),[h,p]=l.useState(null),[f,y]=l.useState(null),[_,R]=l.useState(!1),[C,E]=l.useState(null),m=l.useRef(null),x=l.useCallback(async()=>{if(!(!d||!u||!n||!r||!s))try{const v=await g.Subscribe(u,n,{resource_key:r,resource_id:s,resource_namespace:i,resource_data:o,metric_ids:a,interval:c*1e6});y(v),R(!0),E(null);const w=D.On(`core/metrics/data/${v}`,F=>{const L=F.data;try{const k=JSON.parse(L);k.results&&p(k.results)}catch(k){console.error("Failed to parse metric stream data:",k)}}),b=D.On(`core/metrics/error/${v}`,F=>{const L=F.data;try{const k=JSON.parse(L);E(k.error||"Unknown error")}catch{E("Failed to parse metric stream error")}});m.current=()=>{w(),b()}}catch(v){E(v instanceof Error?v.message:String(v))}},[u,n,r,s,i,a,c,d]),P=l.useCallback(async()=>{if(f)try{await g.Unsubscribe(f)}catch(v){console.error("Failed to unsubscribe:",v)}m.current&&(m.current(),m.current=null),y(null),R(!1)},[f]);return l.useEffect(()=>()=>{f&&g.Unsubscribe(f).catch(console.error),m.current&&m.current()},[f]),{data:h,subscriptionID:f,isStreaming:_,error:C,start:x,stop:P}},j=["networker","portforward","all-sessions"];function It(){const{showSnackbar:t}=$(),e=S.useQueryClient(),n=S.useQuery({queryKey:[...j],queryFn:async()=>g.ListAllPortForwardSessions().catch(i=>{if(q(i).detail.includes("not found"))return[];throw i}),retry:!1});l.useEffect(()=>{const i=D.On("core/networker/portforward/created",()=>{e.invalidateQueries({queryKey:[...j]})}),o=D.On("core/networker/portforward/closed",()=>{e.invalidateQueries({queryKey:[...j]})});return()=>{i(),o()}},[e]);const r=n.data??[],s=S.useMutation({mutationFn:async i=>g.ClosePortForwardSession(i),onError:N(t,"Failed to close port forwarding session"),onSuccess:async()=>{await e.invalidateQueries({queryKey:[...j]})}});return{sessions:n,activeSessions:r,closeSession:s.mutateAsync,openInBrowser:i=>D.OpenURL(`http://localhost:${i}`)}}function Ft({pluginID:t,connectionID:e,resourceID:n}){const r=T(t),s=["networker","portforward","sessions",r,e,n],{showSnackbar:i}=$(),o=S.useQueryClient(),a=S.useQuery({queryKey:s,queryFn:async()=>g.FindPortForwardSessions(r,e,A.FindPortForwardSessionRequest.createFrom({resource_id:n,connection_id:e})).catch(u=>{const h=q(u);return h.detail.includes("not found")?[]:(i({message:"Failed to fetch port forward sessions",status:"error",details:h.detail}),[])}),retry:!1}),c=S.useMutation({mutationFn:async({opts:u})=>{const h=A.PortForwardSessionOptions.createFrom({local_port:u.localPort||0,remote_port:u.remotePort,protocol:u.protocol||"TCP",connection_type:"RESOURCE",connection:{resource_data:u.resource,connection_id:e,plugin_id:r,resource_id:u.resourceId,resource_key:u.resourceKey},labels:u.labels??{},params:u.parameters??{}}),p=await g.StartResourcePortForwardingSession(r,e,h);if(!p)throw new Error("Failed to start port forwarding: null response");return u.openInBrowser&&D.OpenURL(`http://localhost:${p.local_port}`),p},onError:N(i,"Failed to start port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...j]})])}}),d=S.useMutation({mutationFn:async({opts:u})=>g.ClosePortForwardSession(u.sessionID),onError:N(i,"Failed to close port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...j]})])}});return{sessions:a,forward:c.mutateAsync,close:d.mutateAsync}}const Ot=()=>{const t=l.useContext(Ie);if(!t)throw new Error("useConfirmationModal must be used within a ConfirmationModalProvider");return t},Dt=({pluginID:t,connectionID:e,resourceKey:n,resourceID:r,namespace:s=""})=>{const i=T(t),o=S.useQueryClient(),{showSnackbar:a}=$(),c=["RESOURCE",i,e,n,r,s],{mutateAsync:d}=S.useMutation({mutationFn:async p=>g.Update(i,e,n,A.UpdateInput.createFrom({input:p.input,id:r,namespace:s})),onSuccess:async()=>{a(`Resource ${r} updated`,"success"),await o.invalidateQueries({queryKey:c})},onError:N(a,`Failed to update resource ${r}`)}),{mutateAsync:u}=S.useMutation({mutationFn:async(p={})=>g.Delete(i,e,n,A.DeleteInput.createFrom({id:r,namespace:s,gracePeriodSeconds:p.gracePeriodSeconds})),onSuccess:async()=>{a(`Resource ${r} deleted`,"success"),await o.invalidateQueries({queryKey:c})},onError:N(a,`Failed to delete resource ${r}`)});return{resource:S.useQuery({queryKey:c,queryFn:async()=>g.Get$1(i,e,n,A.GetInput.createFrom({id:r,namespace:s})),retry:!1}),update:d,remove:u}},Tt=t=>{const e=["component",t.plugin,t.resource,t.area];return{component:S.useQuery({queryKey:e,queryFn:async()=>g.GetResourceAreaComponent(t)})}},At=({pluginID:t,connectionID:e})=>{const n=T(t),r=[n,"resource_groups","list"];return{groups:S.useQuery({queryKey:r,queryFn:async()=>g.GetResourceGroups(n,e),retry:!1})}},Mt=({pluginID:t,connectionID:e,searches:n})=>{const r=T(t),s=o=>[r,e,o.key,o.namespaces,"list"];return S.useQueries({queries:n.map(o=>({queryKey:s(o),queryFn:async()=>g.List(r,e,o.key,A.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:o.namespaces})).then(a=>a?(console.log(a.result),a.result&&o.postFilter?Object.values(a.result).filter(o.postFilter):Object.values(a.result||{})):[]),retry:!1}))})},Nt=({pluginID:t,resourceKey:e})=>{const n=T(t),r=[n,"resources",e];return{resourceType:S.useQuery({queryKey:r,queryFn:async()=>g.GetResourceType(n,e),retry:!1})}},kt=({pluginID:t,connectionID:e})=>{const n=T(t),r=[n,"resources","list",e];return{types:S.useQuery({queryKey:r,queryFn:async()=>g.GetResourceTypes(n,e),retry:!1})}};var Y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ut="Expected a function",$e="__lodash_hash_undefined__",$t="[object Function]",qt="[object GeneratorFunction]",jt="[object Symbol]",Qt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Wt=/^\w*$/,Gt=/^\./,Kt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Bt=/[\\^$.*+?()[\]{}|]/g,Ht=/\\(\\)?/g,zt=/^\[object .+?Constructor\]$/,Yt=typeof Y=="object"&&Y&&Y.Object===Object&&Y,Jt=typeof self=="object"&&self&&self.Object===Object&&self,ye=Yt||Jt||Function("return this")();function Zt(t,e){return t==null?void 0:t[e]}function Xt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}var Vt=Array.prototype,en=Function.prototype,qe=Object.prototype,oe=ye["__core-js_shared__"],Ce=function(){var t=/[^.]+$/.exec(oe&&oe.keys&&oe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),je=en.toString,he=qe.hasOwnProperty,Qe=qe.toString,tn=RegExp("^"+je.call(he).replace(Bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ee=ye.Symbol,nn=Vt.splice,rn=We(ye,"Map"),H=We(Object,"create"),we=Ee?Ee.prototype:void 0,_e=we?we.toString:void 0;function W(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function sn(){this.__data__=H?H(null):{}}function on(t){return this.has(t)&&delete this.__data__[t]}function an(t){var e=this.__data__;if(H){var n=e[t];return n===$e?void 0:n}return he.call(e,t)?e[t]:void 0}function cn(t){var e=this.__data__;return H?e[t]!==void 0:he.call(e,t)}function un(t,e){var n=this.__data__;return n[t]=H&&e===void 0?$e:e,this}W.prototype.clear=sn;W.prototype.delete=on;W.prototype.get=an;W.prototype.has=cn;W.prototype.set=un;function K(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ln(){this.__data__=[]}function dn(t){var e=this.__data__,n=ee(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():nn.call(e,n,1),!0}function fn(t){var e=this.__data__,n=ee(e,t);return n<0?void 0:e[n][1]}function pn(t){return ee(this.__data__,t)>-1}function yn(t,e){var n=this.__data__,r=ee(n,t);return r<0?n.push([t,e]):n[r][1]=e,this}K.prototype.clear=ln;K.prototype.delete=dn;K.prototype.get=fn;K.prototype.has=pn;K.prototype.set=yn;function G(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function hn(){this.__data__={hash:new W,map:new(rn||K),string:new W}}function gn(t){return te(this,t).delete(t)}function mn(t){return te(this,t).get(t)}function Sn(t){return te(this,t).has(t)}function Cn(t,e){return te(this,t).set(t,e),this}G.prototype.clear=hn;G.prototype.delete=gn;G.prototype.get=mn;G.prototype.has=Sn;G.prototype.set=Cn;function ee(t,e){for(var n=t.length;n--;)if(On(t[n][0],e))return n;return-1}function En(t,e){e=bn(e,t)?[e]:vn(e);for(var n=0,r=e.length;t!=null&&n<r;)t=t[In(e[n++])];return n&&n==r?t:void 0}function wn(t){if(!Ke(t)||xn(t))return!1;var e=Dn(t)||Xt(t)?tn:zt;return e.test(Fn(t))}function _n(t){if(typeof t=="string")return t;if(me(t))return _e?_e.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function vn(t){return Ge(t)?t:Pn(t)}function te(t,e){var n=t.__data__;return Rn(e)?n[typeof e=="string"?"string":"hash"]:n.map}function We(t,e){var n=Zt(t,e);return wn(n)?n:void 0}function bn(t,e){if(Ge(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||me(t)?!0:Wt.test(t)||!Qt.test(t)||e!=null&&t in Object(e)}function Rn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function xn(t){return!!Ce&&Ce in t}var Pn=ge(function(t){t=An(t);var e=[];return Gt.test(t)&&e.push(""),t.replace(Kt,function(n,r,s,i){e.push(s?i.replace(Ht,"$1"):r||n)}),e});function In(t){if(typeof t=="string"||me(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Fn(t){if(t!=null){try{return je.call(t)}catch{}try{return t+""}catch{}}return""}function ge(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(Ut);var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=t.apply(this,r);return n.cache=i.set(s,o),o};return n.cache=new(ge.Cache||G),n}ge.Cache=G;function On(t,e){return t===e||t!==t&&e!==e}var Ge=Array.isArray;function Dn(t){var e=Ke(t)?Qe.call(t):"";return e==$t||e==qt}function Ke(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Tn(t){return!!t&&typeof t=="object"}function me(t){return typeof t=="symbol"||Tn(t)&&Qe.call(t)==jt}function An(t){return t==null?"":_n(t)}function Mn(t,e,n){var r=t==null?void 0:En(t,e);return r===void 0?n:r}var Nn=Mn;const J=Lt(Nn);function Be(t,e,n){const r=t??{result:[],success:!0,totalCount:0},s=[...r.result??[]];for(const i of e){const o=J(i.payload.data,n);switch(i.type){case"ADD":{s.findIndex(c=>J(c,n)===o)===-1&&s.push(i.payload.data);break}case"UPDATE":{const a=s.findIndex(c=>J(c,n)===o);a!==-1&&(s[a]=i.payload.data);break}case"DELETE":{const a=s.findIndex(c=>J(c,n)===o);a!==-1&&s.splice(a,1);break}}}return{...r,result:s}}function He(t,e,n,r,s,i){const o=(i==null?void 0:i.syncWindowMs)??500,a=l.useRef([]),c=l.useRef(null),d=l.useRef(null),u=l.useRef(s);u.current=s;const h=l.useCallback(()=>{const f=a.current;if(a.current=[],c.current=null,d.current=null,!(f.length===0||!r)){t.setQueryData(e,y=>Be(y,f,r));for(const y of f)(y.type==="ADD"||y.type==="UPDATE")&&t.setQueryData(n(y.payload.id,y.payload.namespace),{result:y.payload.data})}},[t,e,n,r]),p=l.useCallback(f=>{a.current.push(f),!(c.current!==null||d.current!==null)&&(u.current===1?c.current=setTimeout(h,o):d.current=requestAnimationFrame(h))},[h,o]);return l.useEffect(()=>()=>{c.current!==null&&(clearTimeout(c.current),c.current=null),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)},[]),p}const kn=({pluginID:t,connectionID:e,resourceKey:n,idAccessor:r,namespaces:s})=>{const i=T(t),o=S.useQueryClient(),{showSnackbar:a}=$(),c=l.useMemo(()=>s??[],[s]),d=l.useMemo(()=>[i,e,n,c,"list"],[i,e,n,c]),u=l.useCallback((R,C)=>[i,e,n,C,R],[i,e,n]),{mutateAsync:h}=S.useMutation({mutationFn:async R=>g.Create(i,e,n,A.CreateInput.createFrom({input:R.input,namespace:R.namespace??(c.length===1?c[0]:"")})),onSuccess:async R=>{var x;const C=R==null?void 0:R.result;let E="";(x=C==null?void 0:C.metadata)!=null&&x.name?E=C.metadata.name:C!=null&&C.id?E=C.id:C!=null&&C.name?E=C.name:C!=null&&C.ID?E=C.ID:C!=null&&C.Name&&(E=C.Name);const m=E?`Resource ${E} created`:"Resource created";a(m,"success"),await o.invalidateQueries({queryKey:d})},onError:N(a,"Failed to create resource")}),p=S.useQuery({queryKey:d,queryFn:async()=>g.List(i,e,n,A.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:c})),placeholderData:(R,C)=>R,retry:!1}),[f,y]=l.useState(I.WatchStateIdle);l.useEffect(()=>D.On(`${i}/${e}/watch/STATE`,C=>{const E=C.data;E.resourceKey===n&&y(E.state)}),[i,e,n]);const _=He(o,d,u,r,f);return l.useEffect(()=>{if(!r)return;g.SubscribeResource(i,e,n);const R=D.On(`${i}/${e}/${n}/ADD`,m=>_({type:"ADD",payload:m.data})),C=D.On(`${i}/${e}/${n}/UPDATE`,m=>_({type:"UPDATE",payload:m.data})),E=D.On(`${i}/${e}/${n}/DELETE`,m=>_({type:"DELETE",payload:m.data}));return()=>{R(),C(),E(),g.UnsubscribeResource(i,e,n)}},[i,e,n,_]),{resources:p,create:h,watchState:f,isSyncing:f===I.WatchStateSyncing,isSynced:f===I.WatchStateSynced,watchError:f===I.WatchStateError}},Ln=({pluginID:t})=>{const e=T(t),{showSnackbar:n}=$(),r=S.useMutation({mutationFn:async({opts:o,input:a})=>g.Create(e,o.connectionID,o.resourceKey,A.CreateInput.createFrom({input:a.input,namespace:a.namespace??o.namespace??""})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} created`,"success")},onError(o,{opts:a}){Q(n,o,`Failed to create resource ${a.resourceID}`)}}),s=S.useMutation({mutationFn:async({opts:o,input:a})=>g.Update(e,o.connectionID,o.resourceKey,A.UpdateInput.createFrom({input:a.input,id:o.resourceID,namespace:o.namespace??""})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} updated`,"success")},onError(o,{opts:a}){Q(n,o,`Failed to update resource ${a.resourceID}`)}}),i=S.useMutation({mutationFn:async({opts:o,input:a})=>g.Delete(e,o.connectionID,o.resourceKey,A.DeleteInput.createFrom({id:o.resourceID,namespace:o.namespace??"",gracePeriodSeconds:a.gracePeriodSeconds})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} deleted`,"success")},onError(o,{opts:a}){Q(n,o,`Failed to delete resource ${a.resourceID}`)}});return{create:r.mutateAsync,update:s.mutateAsync,remove:i.mutateAsync}},Un=({pluginID:t,connectionID:e,resourceKey:n,enabled:r=!0})=>{const s=T(t),i=S.useQuery({queryKey:["RESOURCE_ACTIONS",s,e,n],queryFn:()=>g.GetActions(s,e,n),enabled:r&&!!s&&!!e&&!!n,staleTime:5*60*1e3});return{actions:i.data??[],isLoading:i.isLoading,error:i.error}},$n=({pluginID:t,connectionID:e,resourceKey:n})=>{const r=T(t),s=S.useQueryClient(),{showSnackbar:i}=$(),o=S.useMutation({mutationFn:async({actionID:a,id:c="",namespace:d="",params:u={}})=>g.ExecuteAction(r,e,n,a,A.ActionInput.createFrom({id:c,namespace:d,params:u})),onSuccess:a=>{a!=null&&a.message&&i(a.message,"success"),s.invalidateQueries({queryKey:["RESOURCES",r,e,n]})},onError:(a,c)=>{Q(i,a,`Failed to execute action "${c.actionID}"`)}});return{executeAction:o.mutateAsync,isExecuting:o.isPending,error:o.error}},qn=({pluginID:t,connectionID:e,enabled:n=!0})=>{const r=T(t),s=S.useQuery({queryKey:["EDITOR_SCHEMAS",r,e],queryFn:()=>g.GetEditorSchemas(r,e),enabled:n&&!!r&&!!e,staleTime:10*60*1e3,retry:1});return{schemas:s.data??[],isLoading:s.isLoading,error:s.error,refetch:s.refetch}},jn=({pluginID:t,connectionID:e,enabled:n=!0})=>{const r=T(t),s=S.useQueryClient(),i=[r,e,"watch-state"],o=l.useRef([]),a=l.useRef(!1),c=l.useCallback(p=>{s.setQueryData(i,f=>{if(!f)return f;const y={...f.resources,[p.resourceKey]:p.state},_={...f.resourceCounts,[p.resourceKey]:p.resourceCount};let R=0,C=0;for(const E of Object.values(y))E===I.WatchStateSynced&&R++,(E===I.WatchStateError||E===I.WatchStateFailed)&&C++;return{...f,resources:y,resourceCounts:_,totalResources:Object.keys(y).length,syncedCount:R,errorCount:C}})},[s,r,e]),d=S.useQuery({queryKey:i,queryFn:async()=>{const p=await g.GetWatchState(r,e);if(!p)throw new Error("Failed to get watch state: null response");const f={};let y=0,_=0;for(const[C,E]of Object.entries(p.resources??{}))E!=null&&(f[C]=E,E===I.WatchStateSynced&&y++,E===I.WatchStateError&&_++);const R={};for(const[C,E]of Object.entries(p.resourceCounts??{}))E!=null&&(R[C]=E);return{connection:p.connectionId,resources:f,resourceCounts:R,totalResources:Object.keys(f).length,syncedCount:y,errorCount:_}},enabled:n&&!!r&&!!e,refetchInterval:p=>{const f=p.state.data;if(!f||f.totalResources===0)return 3e3;let y=0;for(const _ of Object.values(f.resources))(_===I.WatchStateSynced||_===I.WatchStateError||_===I.WatchStateStopped||_===I.WatchStateFailed||_===I.WatchStateForbidden||_===I.WatchStateSkipped)&&y++;return y>=f.totalResources?!1:3e3}});l.useEffect(()=>{if(!d.data||a.current)return;a.current=!0;const p=o.current;o.current=[];for(const f of p)c(f)},[d.data,c]),l.useEffect(()=>{if(!n||!r||!e)return;a.current=!1,o.current=[];const p=D.On(`${r}/${e}/watch/STATE`,f=>{const y=f.data;a.current?c(y):o.current.push(y)});return()=>{p(),a.current=!1,o.current=[]}},[r,e,n,c]);const u=d.data;let h=0;if(u!=null&&u.resources)for(const p of Object.values(u.resources))(p===I.WatchStateSynced||p===I.WatchStateError||p===I.WatchStateStopped||p===I.WatchStateFailed||p===I.WatchStateForbidden||p===I.WatchStateSkipped)&&h++;return{summary:d,getResourceState:p=>u==null?void 0:u.resources[p],isFullySynced:u?u.totalResources>0&&h===u.totalResources:!1,syncProgress:u&&u.totalResources>0?h/u.totalResources:0,errorCount:(u==null?void 0:u.errorCount)??0}},Qn=()=>{const[t,e]=l.useState(new Map),n=l.useRef(new Map),r=l.useRef(new Map),s=l.useCallback(d=>{const u=d.data,h=fe(u),p=Le(n.current,u),f=ce(p);if(e(y=>{const _=new Map(y);return _.set(h,f),_}),r.current.has(h)&&(clearTimeout(r.current.get(h)),r.current.delete(h)),Z(f)){const y=setTimeout(()=>{e(_=>{const R=new Map(_);return R.delete(h),R}),n.current.delete(h),r.current.delete(h)},5e3);r.current.set(h,y)}},[]);l.useEffect(()=>{const d=D.On("watch/STATE",s);return()=>{d();for(const u of r.current.values())clearTimeout(u)}},[s]);const i=Array.from(t.values()),o=Ne(i),a=i.find(d=>!Z(d))??i[0]??null,c=ke(i);return{syncs:i,hasSyncing:o,primarySync:a,aggregateProgress:c}},ze=()=>{const t=l.useContext(de);if(!t)throw new Error("useOperations must be used within an OperationsProvider");return t},Wn=({pluginID:t,connectionID:e,resourceKey:n})=>{const r=T(t),{showSnackbar:s}=$(),{addOperation:i,updateOperation:o}=ze(),a=l.useRef([]);return l.useEffect(()=>()=>{a.current.forEach(d=>d())},[]),{startStreamAction:l.useCallback(async({actionID:d,id:u,namespace:h,label:p,params:f={}})=>{try{const y=await g.StreamAction(r,e,n,d,A.ActionInput.createFrom({id:u,namespace:h,params:f}));i({id:y,label:p,resourceKey:n,resourceName:u,namespace:h,connectionID:e,status:"running",startedAt:Date.now()});const _=`action/stream/${y}`,R=D.On(_,C=>{var m,x,P,v;const E=C.data;switch(E.type){case"progress":{const w=E.data??{};o(y,{message:w.message,progress:w.ready!==void 0&&w.desired!==void 0?{ready:w.ready,desired:w.desired}:void 0});break}case"complete":o(y,{status:"completed",message:((m=E.data)==null?void 0:m.message)??"Completed",completedAt:Date.now()}),s(((x=E.data)==null?void 0:x.message)??p+" completed","success"),D.Off(_);break;case"error":o(y,{status:"error",message:((P=E.data)==null?void 0:P.message)??"Failed",completedAt:Date.now()}),s(((v=E.data)==null?void 0:v.message)??p+" failed","error"),D.Off(_);break}});return a.current.push(()=>{R(),D.Off(_)}),y}catch(y){throw Q(s,y,`Failed to start "${d}"`),y}},[r,e,n,i,o,s])}},Gn=()=>{const t=l.useContext(le);if(!t)throw new Error("useSettings must be used within a SettingsProvider");return t},Kn=({to:t,withinContext:e,...n})=>{const{pluginId:r}=V();r||console.error("Link used outside of a plugin context");const s=`/_plugin/${r}${t.startsWith("/")?"":"/"}${t}`;return l.useMemo(()=>O.jsx(B.Link,{style:{textDecoration:"none",color:"inherit"},...n,to:s}),[n,s])};function Bn(){const t=B.useNavigate(),e=B.useLocation(),{pluginId:n}=V();n||console.error("usePluginRouter used outside of a plugin context");const r=`/_plugin/${n}`,s=e.pathname.startsWith(r)?e.pathname.slice(r.length)||"/":e.pathname,i=l.useCallback((o,a)=>{const{...c}=a??{};o.startsWith("/")?t(`${r}${o}`,c):t(o,c)},[t,r]);return l.useMemo(()=>({location:e,navigate:i,pluginPath:s}),[e,i,s])}class Hn{}class zn{constructor(){M(this,"_extensions");M(this,"root");M(this,"pages");M(this,"_routes")}get extensions(){return this._extensions||[]}get Routes(){var e;if(!this._routes&&this.root)return[{path:"",index:!0,Component:this.root}];if(!((e=this._routes)!=null&&e.length))throw new Error("cannot use plugin without a root page or router");return this._routes}get Window(){if(!this._routes&&this.root)return O.jsx(this.root,{});const e=B.createMemoryRouter(this._routes||[]);return O.jsx(B.RouterProvider,{router:e})}registerExtensionPoints(e){return this._extensions=e||[],this}setRootPage(e){return this.root=e,this}withPage(e,n){return this.pages||(this.pages={}),this.pages[e]?(console.warn("Cannot register page with the same name. Please use a different name."),this):(this.pages[e]=n,this)}withRoutes(e){return this._routes=e,this}}var Ye=(t=>(t.MISSING_MANIFEST="MISSING_MANIFEST",t.MISSING_PLUGIN="MISSING_PLUGIN",t.MISSING_ENTRYPOINT="MISSING_ENTRYPOINT",t))(Ye||{});const Yn=t=>{const e=t.split("::");return e.length===1?{group:"core",version:"",kind:e[0]}:{group:e[0]||"core",version:e[1]||"",kind:e[2]||e[0]}},Jn=t=>!t||t==="core"?"Core":t.charAt(0).toUpperCase()+t.slice(1);exports.ALL_SESSIONS_KEY=j;exports.BottomDrawerContext=xe;exports.ConfirmationModalContext=Ie;exports.ErrorTypes=U;exports.ExtensionPointRegistry=pt;exports.ExtensionPointStore=Te;exports.ExtensionProvider=ft;exports.Link=Kn;exports.OperationsContext=de;exports.OperationsProvider=it;exports.PluginContext=X;exports.PluginContextProvider=nt;exports.PluginErrorCode=Ye;exports.PluginWindow=zn;exports.PluginWindowRootProps=Hn;exports.RightDrawerContext=Pe;exports.SettingsContext=le;exports.SettingsProvider=st;exports.SnackbarProvider=ht;exports.WatchState=I;exports.actionToSnackbar=ve;exports.applyBatch=Be;exports.connectionListQueryKey=Me;exports.createErrorHandler=N;exports.defaultState=Re;exports.formatGroup=Jn;exports.isCancelledError=ue;exports.parseAppError=q;exports.parseResourceKey=Yn;exports.showAppError=Q;exports.useActiveSyncs=Qn;exports.useBottomDrawer=pe;exports.useConfirmationModal=Ot;exports.useConnection=gt;exports.useConnectionNamespaces=St;exports.useConnectionStatus=Ct;exports.useConnections=mt;exports.useEditorSchemas=qn;exports.useEventBatcher=He;exports.useExec=vt;exports.useExecuteAction=$n;exports.useExtensionPoint=dt;exports.useExtensionRegistry=De;exports.useLogs=bt;exports.useMetricProviders=Rt;exports.useMetricProvidersForResource=Ue;exports.useMetricStream=Pt;exports.useOperations=ze;exports.usePluginContext=V;exports.usePluginData=wt;exports.usePluginRouter=Bn;exports.usePluginSettings=rt;exports.usePortForwardSessions=It;exports.useResolvedPluginId=T;exports.useResource=Dt;exports.useResourceActions=Un;exports.useResourceAreaComponent=Tt;exports.useResourceGroups=At;exports.useResourceMetrics=xt;exports.useResourceMutations=Ln;exports.useResourcePortForwarder=Ft;exports.useResourceSearch=Mt;exports.useResourceType=Nt;exports.useResourceTypes=kt;exports.useResources=kn;exports.useRightDrawer=_t;exports.useSettings=Gn;exports.useSnackbar=$;exports.useStreamAction=Wn;exports.useWatchState=jn;