@omniviewdev/runtime 0.3.0 → 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.
- package/dist/api.cjs +1 -1
- package/dist/api.d.ts +15 -14
- package/dist/api.js +110 -125
- package/dist/bindings/encoding/json/index.d.ts +1 -0
- package/dist/bindings/encoding/json/models.d.ts +6 -0
- package/dist/bindings/github.com/omniviewdev/omniview/appservice.d.ts +18 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/diagnostics/diagnosticsclient.d.ts +51 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/diagnostics/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/data/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/data/servicewrapper.d.ts +5 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/models.d.ts +132 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/devserver/servicewrapper.d.ts +12 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/exec/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/exec/servicewrapper.d.ts +22 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/lifecycle/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/lifecycle/models.d.ts +29 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/logs/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/logs/servicewrapper.d.ts +11 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/models.d.ts +39 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/metric/servicewrapper.d.ts +16 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/models.d.ts +72 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/networker/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/networker/servicewrapper.d.ts +11 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/models.d.ts +24 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/pluginlog/servicewrapper.d.ts +7 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/registry/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/registry/models.d.ts +94 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graph/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graph/models.d.ts +53 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/graphservice.d.ts +14 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/index.d.ts +4 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/models.d.ts +61 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/servicewrapper.d.ts +92 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/servicewrapper.d.ts +24 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/settings/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/settings/servicewrapper.d.ts +18 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/types/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/types/models.d.ts +22 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/models.d.ts +55 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/ui/servicewrapper.d.ts +7 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/client.d.ts +6 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/utils/models.d.ts +10 -0
- package/dist/bindings/github.com/omniviewdev/omniview/index.d.ts +3 -0
- package/dist/bindings/github.com/omniviewdev/omniview/internal/settings/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/internal/settings/servicewrapper.d.ts +48 -0
- package/dist/bindings/github.com/omniviewdev/omniview/internal/telemetry/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/omniview/internal/telemetry/telemetrybinding.d.ts +7 -0
- package/dist/bindings/github.com/omniviewdev/omniview/models.d.ts +38 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/config/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/config/models.d.ts +101 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/types/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/types/models.d.ts +199 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/exec/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/exec/models.d.ts +79 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/logs/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/logs/models.d.ts +133 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/metric/index.d.ts +1 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/metric/models.d.ts +207 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/networker/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/networker/models.d.ts +96 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/resource/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/pkg/v1/resource/models.d.ts +1199 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/settings/index.d.ts +2 -0
- package/dist/bindings/github.com/omniviewdev/plugin-sdk/settings/models.d.ts +169 -0
- package/dist/bindings/github.com/wailsapp/wails/v3/internal/eventcreate.d.ts +1 -0
- package/dist/bindings/time/index.d.ts +1 -0
- package/dist/bindings/time/models.d.ts +33 -0
- package/dist/calls-BmUnjINC.js +677 -0
- package/dist/calls-DZctVyoQ.cjs +1 -0
- package/dist/compat/legacyEnum.d.ts +10 -0
- package/dist/compat/resource.d.ts +4 -0
- package/dist/compat/types.d.ts +4 -0
- package/dist/context/plugins/PluginContext.d.ts +2 -2
- package/dist/events-BTiuwc-0.cjs +1 -0
- package/dist/events-DDTGFACO.js +371 -0
- package/dist/hooks/connection/useConnection.d.ts +5 -5
- package/dist/hooks/connection/useConnectionStatus.d.ts +7 -0
- package/dist/hooks/connection/useConnections.d.ts +4 -4
- package/dist/hooks/exec/useExecSession.d.ts +2 -2
- package/dist/hooks/logs/useLogSession.d.ts +1 -2
- package/dist/hooks/metric/useMetricProviders.d.ts +3 -3
- package/dist/hooks/metric/useMetricStream.d.ts +2 -2
- package/dist/hooks/metric/useResourceMetrics.d.ts +4 -3
- package/dist/hooks/networker/types.d.ts +3 -3
- package/dist/hooks/networker/usePortForwardSessions.d.ts +4 -4
- package/dist/hooks/networker/useResourcePortForwarder.d.ts +3 -4
- package/dist/hooks/resource/useEditorSchemas.d.ts +2 -2
- package/dist/hooks/resource/useEventBatcher.d.ts +3 -0
- package/dist/hooks/resource/useResource.d.ts +3 -4
- package/dist/hooks/resource/useResourceActions.d.ts +2 -3
- package/dist/hooks/resource/useResourceAreaComponent.d.ts +3 -3
- package/dist/hooks/resource/useResourceGroups.d.ts +6 -6
- package/dist/hooks/resource/useResourceMutations.d.ts +3 -4
- package/dist/hooks/resource/useResourceType.d.ts +1 -1
- package/dist/hooks/resource/useResourceTypes.d.ts +6 -6
- package/dist/hooks/resource/useResources.d.ts +3 -4
- package/dist/index-D2mKAO8s.js +1069 -0
- package/dist/index-D_aIcqH0.cjs +6 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1192 -1600
- package/dist/legacyEnum-DORXlU_y.js +13 -0
- package/dist/legacyEnum-DkV5yRdA.cjs +1 -0
- package/dist/models-B8OVRhdT.js +159 -0
- package/dist/models-BVKsY9u1.js +2285 -0
- package/dist/models-CExSuVU2.cjs +1 -0
- package/dist/models-DdAWPDgz.cjs +1 -0
- package/dist/models.cjs +1 -1
- package/dist/models.d.ts +27 -1
- package/dist/models.js +259 -2244
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +198 -205
- package/dist/servicewrapper-BH5omp-N.js +708 -0
- package/dist/servicewrapper-dDhyC68C.cjs +1 -0
- package/dist/types/watch.d.ts +4 -5
- package/package.json +17 -13
- package/LICENSE +0 -661
- package/dist/Client-07zrOerN.js +0 -636
- package/dist/Client-CLvQWnuz.cjs +0 -1
- package/dist/wailsjs/go/data/Client.d.ts +0 -10
- package/dist/wailsjs/go/devserver/DevServerManager.d.ts +0 -24
- package/dist/wailsjs/go/diagnostics/DiagnosticsClient.d.ts +0 -18
- package/dist/wailsjs/go/exec/Client.d.ts +0 -26
- package/dist/wailsjs/go/logs/Client.d.ts +0 -16
- package/dist/wailsjs/go/main/App.d.ts +0 -8
- package/dist/wailsjs/go/metric/Client.d.ts +0 -12
- package/dist/wailsjs/go/models.d.ts +0 -1060
- package/dist/wailsjs/go/networker/Client.d.ts +0 -14
- package/dist/wailsjs/go/plugin/pluginManager.d.ts +0 -52
- package/dist/wailsjs/go/pluginlog/Manager.d.ts +0 -18
- package/dist/wailsjs/go/resource/Client.d.ts +0 -90
- package/dist/wailsjs/go/settings/Client.d.ts +0 -14
- package/dist/wailsjs/go/settings/provider.d.ts +0 -48
- package/dist/wailsjs/go/ui/Client.d.ts +0 -6
- package/dist/wailsjs/go/utils/Client.d.ts +0 -2
- 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
|
|
2
|
-
`);return{message:t||(e.title!=="Error"?e.title:"Operation failed"),status:"error",details:n,actions:(i=e.actions)==null?void 0:i.map(Ze)}}function G(e,t,n){if(Ae(t))return;const r=$(t);e(et(r,n))}function x(e,t){return n=>{if(Ae(n))return;const r=$(n);e(et(r,r.title!=="Error"?r.title:t))}}function Lt(e){const{children:t,pluginId:n}=e,[r,s]=l.useState({}),[i,o]=l.useState(new I.config.PluginMeta),[a,u]=l.useState(!1),[d,c]=l.useState(null);console.debug("[PluginContextProvider] render",{pluginId:n,metaLoaded:a,metaError:!!d});const m=()=>{n===void 0||n===""||(console.debug(`[PluginContextProvider] fetching settings for "${n}"`),E.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),E.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),u(!0)}).catch(f=>{const g=$(f);console.error(`[PluginContextProvider] error fetching meta for "${n}":`,g.detail),c(g.detail),u(!1)})};return l.useEffect(()=>{console.debug(`[PluginContextProvider] useEffect — pluginId changed to "${n}"`),m(),p()},[n]),d?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:d}),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:i},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=l.useContext(ue);if(!e)throw new Error("usePluginContext must be used within a PluginContextProvider");return e}function $t(){return le().settings}const Te=l.createContext(void 0),Ut=({children:e})=>{const[t,n]=l.useState({}),r=()=>{E.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 R.jsx(Te.Provider,{value:{settings:t,reload:s},children:e})},tt={height:32,focused:0,tabs:[],createTab:()=>{},createTabs:()=>{},updateTab:()=>{},focusTab:()=>{},reorderTab:()=>{},closeTab:()=>{},closeTabs:()=>{},resizeDrawer:()=>{},closeDrawer:()=>{},fullscreenDrawer:()=>{}},nt=l.createContext(tt),rt=l.createContext(void 0),st=l.createContext(void 0),Ne=l.createContext(void 0),qt=3e4,jt=({children:e})=>{const[t,n]=l.useState([]),r=l.useCallback(a=>{n(u=>[a,...u])},[]),s=l.useCallback((a,u)=>{n(d=>d.map(c=>c.id===a?{...c,...u}:c))},[]),i=l.useCallback(a=>{n(u=>u.filter(d=>d.id!==a))},[]);l.useEffect(()=>{const a=[];for(const u of t)if(u.status==="completed"||u.status==="error"){const d=Date.now()-(u.completedAt??u.startedAt),c=Math.max(0,qt-d);a.push(setTimeout(()=>i(u.id),c))}return()=>a.forEach(clearTimeout)},[t,i]);const o=l.useMemo(()=>({operations:t,addOperation:r,updateOperation:s,removeOperation:i}),[t,r,s,i]);return R.jsx(Ne.Provider,{value:o,children:e})};var be=function(e,t){return be=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])},be(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");be(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,zt=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 ve(e,t){if(!e)throw new zt(t)}var ot=["debug","log","warn","error","silent"],Kt=ot.indexOf("log");function re(e){return function(){if(ot.indexOf(e)>=Kt){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")})(ve||(ve={}));const it=l.createContext(void 0),at=()=>l.useContext(it);function Wt(e){const t=at(),n=l.useRef(null),r=t==null?void 0:t.getExtensionPoint(e),s=l.useCallback(o=>{const a=[];return t&&a.push(t.subscribe(o)),r&&a.push(r.subscribe(o)),()=>{for(const u of a)u()}},[t,e,r]),i=l.useCallback(()=>{const o=t==null?void 0:t.getExtensionPoint(e);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 u={};return n.current={store:o,version:o.version,sentinel:u},u},[t,e]);return l.useSyncExternalStore(s,i),t==null?void 0:t.getExtensionPoint(e)}const Bt=({registry:e,children:t})=>{const n=l.useRef(e);return ve(n.current===e,"You can't change the extension registry after it has been rendered"),R.jsx(it.Provider,{value:n.current,children:t})},Ee=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){F(this,"id");F(this,"mode");F(this,"_pluginId");F(this,"_version",0);F(this,"_contributions",new Map);F(this,"_lookupCache",new Map);F(this,"_matcher");F(this,"_select");F(this,"_listeners",new Set);this.id=t.id,this.mode=t.mode??"multiple",this._pluginId=t.pluginId,this._matcher=t.matcher,this._select=t.select}get pluginId(){return this._pluginId}get version(){return this._version}register(t){if(this._contributions.has(t.id))throw new Error(`Contribution with id "${t.id}" already exists in extension point "${this.id}"`);this._contributions.set(t.id,t),this._invalidateCache(),this._notify()}unregister(t){this._contributions.delete(t)&&(this._invalidateCache(),this._notify())}provide(t){return this._getMatched(t).map(r=>r.value)}list(t){return this._getMatched(t)}listAll(){return Array.from(this._contributions.values())}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}removeContributionsByPlugin(t){let n=!1;for(const[r,s]of this._contributions)s.plugin===t&&(this._contributions.delete(r),n=!0);n&&(this._invalidateCache(),this._notify())}_getMatched(t){const n=this._getCacheKey(t);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,t)}}let r=this._sortDeterministic(Array.from(this._contributions.values()));return this._matcher&&t!==void 0&&(r=r.filter(s=>this._matcher(s,t))),n!=null&&this._lookupCache.set(n,r.map(s=>s.id)),this._applyMode(r,t)}_applyMode(t,n){if(this.mode==="single"){if(this._select){const r=this._select(t,n);return r?[r]:[]}return t.length>0?[t[0]]:[]}return t}_sortDeterministic(t){return[...t].sort((n,r)=>{const s=n.plugin.localeCompare(r.plugin);return s!==0?s:n.id.localeCompare(r.id)})}_getCacheKey(t){if(t!=null&&typeof t=="object"&&"getCacheKey"in t){const n=t.getCacheKey;if(typeof n=="function")return n()}}_invalidateCache(){this._lookupCache.clear()}_notify(){this._version++;for(const t of this._listeners)t()}}class Ht{constructor(t){F(this,"_stores",new Map);F(this,"_storeUnsubs",new Map);F(this,"_listeners",new Set);if(t!=null&&t.initialStores)for(const n of t.initialStores)this.addExtensionPoint(n)}addExtensionPoint(t){const n=Ee(t.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 ct({...t,id:n});this._stores.set(n,r),this._storeUnsubs.set(n,r.subscribe(()=>this._notify())),this._notify()}getExtensionPoint(t){const n=Ee(t);return this._stores.get(n)}hasExtensionPoint(t){const n=Ee(t);return this._stores.has(n)}listExtensionPoints(){return Array.from(this._stores.keys())}removeExtensionPoints(t){var r;let n=!1;for(const[s,i]of this._stores)i.pluginId===t&&((r=this._storeUnsubs.get(s))==null||r(),this._storeUnsubs.delete(s),this._stores.delete(s),n=!0);n&&this._notify()}removeContributions(t){for(const n of this._stores.values())n.removeContributionsByPlugin(t);this._notify()}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_notify(){for(const t of this._listeners)t()}}const ut=l.createContext(void 0),Yt={default:"info",info:"info",success:"success",warning:"warning",error:"error"},Jt=({children:e})=>{const{push:t}=Mt.useNotificationStack(),[n,r]=l.useState([]),s=o=>{r(a=>[...a,o])},i=(o,a,u)=>{const d=typeof o=="object";let c="",m="info",p,f=5e3,g;if(d){if(c=o.message,o.showOnce){if(n.includes(c))return;s(c)}m=o.status,p=o.details,f=o.autoHideDuration??5e3,g=o.actions}else c=o,m=a,p=u;t({severity:Yt[m]??"info",title:c,message:p,timeout:f,actions:g})};return R.jsx(ut.Provider,{value:{showSnackbar:i},children:e})},L=()=>{const e=l.useContext(ut);if(e===void 0)throw new Error("useCustomSnackbar must be used within a CustomSnackbarProvider");return e};function D(e){const t=l.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 Vt=({pluginID:e,connectionID:t})=>{const n=D(e),r=_.useQueryClient(),{showSnackbar:s}=L(),i=[n,"connection","detail",t],{mutateAsync:o}=_.useMutation({mutationFn:async()=>E.StartConnection(n,t),onSuccess(m){r.setQueryData(i,m),r.invalidateQueries({queryKey:["EDITOR_SCHEMAS",n,t]})},onError:x(s,"Failed to start connection")}),{mutateAsync:a}=_.useMutation({mutationFn:async()=>E.StopConnection(n,t),onSuccess(m){r.setQueryData(i,m)},onError:x(s,"Failed to stop connection")}),{mutateAsync:u}=_.useMutation({mutationFn:async m=>E.UpdateConnection(n,m),onSuccess(m,{name:p}){s({message:`Connection ${p} successfully updated`,status:"success"}),r.setQueryData(i,c),r.setQueriesData({queryKey:[n,"connection","list"]},f=>f==null?void 0:f.map(g=>g.id===t?m:g))},onError:x(s,"Failed to update connection")}),{mutateAsync:d}=_.useMutation({mutationFn:async()=>E.RemoveConnection(n,t),onSuccess(){s({message:"Connection successfully removed",status:"success"}),r.setQueryData(i,void 0),r.setQueriesData({queryKey:[n,"connection","list"]},m=>m==null?void 0:m.filter(p=>p.id!==t))},onError:x(s,"Failed to remove connection")}),c=_.useQuery({queryKey:i,queryFn:async()=>E.GetConnection(n,t)});return{connection:c,startConnection:o,stopConnection:a,updateConnection:u,deleteConnection:d}},lt=e=>[e,"connection","list"],Xt=({plugin:e})=>{const t=D(e),n=_.useQueryClient(),{showSnackbar:r}=L(),s=lt(t),{mutateAsync:i}=_.useMutation({mutationFn:async d=>E.StartConnectionWatch(t,d.id),onError:x(r,"Failed to start connection watch")}),{mutateAsync:o}=_.useMutation({mutationFn:async d=>E.StopConnectionWatch(t,d.id),onError:x(r,"Failed to stop connection watch")}),a=l.useCallback(d=>{console.log("got update to connections",d),n.setQueryData(s,d)},[]);return l.useEffect(()=>{const d=O.EventsOn(`${t}/connection/sync`,a);return()=>{d()}},[]),{connections:_.useQuery({queryKey:s,queryFn:async()=>{try{return await E.ListConnections(t)}catch(d){console.log(d),x(r,"Failed to load connections")(d)}return[]},staleTime:3e4,placeholderData:_.keepPreviousData}),startWatch:i,stopWatch:o}},Zt=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"connection","namespaces",t];return{namespaces:_.useQuery({queryKey:r,queryFn:async()=>E.GetConnectionNamespaces(n,t)})}},b=I.resource.WatchState,en=I.resource.SyncPolicy;function Pe(e){const t=Object.values(e.states),n=t.length;let r=0,s=0,i=0,o=0;for(const c of t)c===b.SYNCED&&r++,(c===b.ERROR||c===b.FAILED)&&s++,c===b.FORBIDDEN&&i++,c===b.SKIPPED&&o++;const a=n-o,u=t.filter(c=>c===b.SYNCED||c===b.ERROR||c===b.STOPPED||c===b.FAILED||c===b.FORBIDDEN).length,d=a>0?u/a:0;return{pluginID:e.pluginID,connectionID:e.connectionID,totalResources:n,watchedTotal:a,syncedCount:r,errorCount:s,forbiddenCount:i,skippedCount:o,doneCount:u,progress:d}}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 Me(e){return`${e.pluginId}/${e.connection}`}function pt(e,t){const n=Me(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 tn(){const[e,t]=l.useState(new Set),[n,r]=l.useState({}),[s,i]=l.useState(new Map),o=l.useRef(new Map);l.useEffect(()=>{E.GetAllConnectionStates().then(h=>{if(!h)return;const S={},y=new Set,w=new Map;for(const[C,v]of Object.entries(h)){S[C]=v.map(A=>A.connection);for(const A of v){if(!A.started)continue;const P=`${C}/${A.connection.id}`;y.add(P);const U={pluginID:C,connectionID:A.connection.id,states:{}};if(A.resources)for(const[me,X]of Object.entries(A.resources))U.states[me]=X;o.current.set(P,U),w.set(P,Pe(U))}}r(S),t(y),i(w)}).catch(()=>{})},[]),l.useEffect(()=>O.EventsOn("connection/status",S=>{const y=`${S.pluginID}/${S.connectionID}`;S.status==="DISCONNECTED"?(t(w=>{const C=new Set(w);return C.delete(y),C}),i(w=>{const C=new Map(w);return C.delete(y),C}),o.current.delete(y)):t(w=>{const C=new Set(w);return C.add(y),C}),E.ListAllConnections().then(w=>{w&&r(w)}).catch(()=>{})}),[]);const a=l.useCallback(h=>{const S=Me(h);t(C=>{if(C.has(S))return C;const v=new Set(C);return v.add(S),v});const y=pt(o.current,h),w=Pe(y);i(C=>{const v=new Map(C);return v.set(S,w),v})},[]);l.useEffect(()=>O.EventsOn("watch/STATE",a),[a]);const u=l.useCallback(async(h,S)=>{await E.StopConnection(h,S)},[]),d=l.useCallback(async(h,S)=>{await E.StartConnectionWatch(h,S)},[]),c=[];for(const h of e){const[S,y]=h.split("/",2),C=(n[S]??[]).find(U=>U.id===y),v=s.get(h),A=v!=null&&!oe(v),P=v!=null&&v.errorCount>0;c.push({pluginID:S,connectionID:y,name:(C==null?void 0:C.name)??y,avatar:(C==null?void 0:C.avatar)??"",isStarted:!0,sync:v,isSyncing:A,hasErrors:P})}const m=new Map;for(const h of c){const S=m.get(h.pluginID)??[];S.push(h),m.set(h.pluginID,S)}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:d}}function nn(e,t){return window.go.data.Client.Get(e,t)}function rn(e,t,n){return window.go.data.Client.Set(e,t,n)}function sn(e,t,n){const r=D(e),s=_.useQueryClient(),i=[r,"data",t],o=_.useQuery({queryKey:i,queryFn:async()=>{const u=await nn(r,t);return u??n}}),a=_.useMutation({mutationFn:async u=>{await rn(r,t,u)},onMutate:async u=>{await s.cancelQueries({queryKey:i});const d=s.getQueryData(i);return s.setQueryData(i,u),{previous:d}},onError:(u,d,c)=>{(c==null?void 0:c.previous)!==void 0&&s.setQueryData(i,c.previous)},onSettled:()=>{s.invalidateQueries({queryKey:i})}});return{data:o.data??n,update:async u=>{await a.mutateAsync(u)},isLoading:o.isLoading}}const on=()=>{const e=l.useContext(rt);if(!e)throw new Error("useRightDrawer must be used within a RightDrawerProvider");return e},ke=()=>{const e=l.useContext(nt);if(e===void 0)throw new Error("useBottomDrawer must be used within a BottomDrawerProvider");return e},an=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=L(),{createTab:r,updateTab:s}=ke();return{createSession:_.useMutation({mutationFn:async({connectionID:o,icon:a,label:u,opts:d})=>{const c=`pending-${crypto.randomUUID()}`;r({id:c,title:u??"Connecting...",variant:"terminal",icon:a??"LuSquareTerminal",properties:{status:"connecting",pluginID:t,connectionID:o,opts:{...d}}});const m=I.exec.SessionOptions.createFrom({command:["/bin/bash"],tty:!0,...d});try{const p=await E.CreateSession(t,o,m);s({id:c},{id:p.id,title:u??`Session ${p.id.substring(0,8)}`,properties:{status:"connected",pluginID:t,connectionID:o,opts:{...d}}})}catch(p){const f=$(p);s({id:c},{properties:{status:"error",error:f.detail,pluginID:t,connectionID:o,opts:{...d}}}),G(n,p,"Failed to start session")}}}).mutateAsync}},cn=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=L(),{createTab:r}=ke(),s=_.useMutation({mutationFn:async({connectionID:o,resourceKey:a,resourceID:u,resourceData:d,icon:c,label:m,target:p,follow:f=!0,tailLines:g=1e3,params:h})=>{const S=I.logs.CreateSessionOptions.createFrom({resource_key:a,resource_id:u,resource_data:d,options:I.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 E.CreateSession$1(t,o,S);return r({id:y.id,title:m??`Logs ${y.id.substring(0,8)}`,variant:"logs",icon:c??"LuLogs"}),y},onError:x(n,"Failed to start log session")}),i=_.useMutation({mutationFn:async o=>{await E.CloseSession(o)},onError:x(n,"Failed to close log session")});return{createLogSession:s.mutateAsync,closeLogSession:i.mutateAsync}},un=()=>_.useQuery({queryKey:["metric","providers"],queryFn:E.GetProviders,staleTime:3e4}),yt=e=>_.useQuery({queryKey:["metric","providers",e],queryFn:()=>E.GetProvidersForResource(e),enabled:!!e,staleTime:3e4}),ln=e=>{var S,y;const{connectionID:t,resourceKey:n,resourceID:r,resourceNamespace:s="",resourceData:i={},metricIDs:o=[],shape:a=0,timeRange:u,refreshInterval:d=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,o,a,(S=u==null?void 0:u.start)==null?void 0:S.getTime(),(y=u==null?void 0:u.end)==null?void 0:y.getTime()],queryFn:()=>E.QueryAll(t,n,r,s,i,o,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:d>0?d:void 0,staleTime:5e3,placeholderData:_.keepPreviousData});return{data:h.data??void 0,providers:f,isLoading:p||h.isLoading,error:h.error,refetch:h.refetch}},dn=e=>{const{pluginID:t,connectionID:n,resourceKey:r,resourceID:s,resourceNamespace:i="",resourceData:o={},metricIDs:a=[],interval:u=1e4,enabled:d=!0}=e,c=D(t),[m,p]=l.useState(null),[f,g]=l.useState(null),[h,S]=l.useState(!1),[y,w]=l.useState(null),C=l.useRef(null),v=l.useCallback(async()=>{if(!(!d||!c||!n||!r||!s))try{const P=await E.Subscribe(c,n,{resource_key:r,resource_id:s,resource_namespace:i,resource_data:o,metric_ids:a,interval:u*1e6});g(P),S(!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")}});C.current=()=>{U(),me()}}catch(P){w(P instanceof Error?P.message:String(P))}},[c,n,r,s,i,a,u,d]),A=l.useCallback(async()=>{if(f)try{await E.Unsubscribe(f)}catch(P){console.error("Failed to unsubscribe:",P)}C.current&&(C.current(),C.current=null),g(null),S(!1)},[f]);return l.useEffect(()=>()=>{f&&E.Unsubscribe(f).catch(console.error),C.current&&C.current()},[f]),{data:m,subscriptionID:f,isStreaming:h,error:y,start:v,stop:A}},Q=["networker","portforward","all-sessions"];function fn(){const{showSnackbar:e}=L(),t=_.useQueryClient(),n=_.useQuery({queryKey:[...Q],queryFn:async()=>E.ListAllPortForwardSessions().catch(i=>{if($(i).detail.includes("not found"))return[];throw i}),retry:!1});l.useEffect(()=>{const i=O.EventsOn("core/networker/portforward/created",()=>{t.invalidateQueries({queryKey:[...Q]})}),o=O.EventsOn("core/networker/portforward/closed",()=>{t.invalidateQueries({queryKey:[...Q]})});return()=>{i(),o()}},[t]);const r=n.data??[],s=_.useMutation({mutationFn:async i=>E.ClosePortForwardSession(i),onError:x(e,"Failed to close port forwarding session"),onSuccess:async()=>{await t.invalidateQueries({queryKey:[...Q]})}});return{sessions:n,activeSessions:r,closeSession:s.mutateAsync,openInBrowser:i=>O.BrowserOpenURL(`http://localhost:${i}`)}}function pn({pluginID:e,connectionID:t,resourceID:n}){const r=D(e),s=["networker","portforward","sessions",r,t,n],{showSnackbar:i}=L(),o=_.useQueryClient(),a=_.useQuery({queryKey:s,queryFn:async()=>E.FindPortForwardSessions(r,t,I.networker.FindPortForwardSessionRequest.createFrom({resource_id:n,connection_id:t})).catch(c=>{const m=$(c);return m.detail.includes("not found")?[]:(i({message:"Failed to fetch port forward sessions",status:"error",details:m.detail}),[])}),retry:!1}),u=_.useMutation({mutationFn:async({opts:c})=>{const m=I.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 E.StartResourcePortForwardingSession(r,t,m);return c.openInBrowser&&O.BrowserOpenURL(`http://localhost:${p.local_port}`),p},onError:x(i,"Failed to start port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...Q]})])}}),d=_.useMutation({mutationFn:async({opts:c})=>E.ClosePortForwardSession(c.sessionID),onError:x(i,"Failed to close port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...Q]})])}});return{sessions:a,forward:u.mutateAsync,close:d.mutateAsync}}const yn=()=>{const e=l.useContext(st);if(!e)throw new Error("useConfirmationModal must be used within a ConfirmationModalProvider");return e},hn=({pluginID:e,connectionID:t,resourceKey:n,resourceID:r,namespace:s=""})=>{const i=D(e),o=_.useQueryClient(),{showSnackbar:a}=L(),u=["RESOURCE",i,t,n,r,s],{mutateAsync:d}=_.useMutation({mutationFn:async p=>E.Update(i,t,n,I.resource.ClientUpdateInput.createFrom({input:p.input,id:r,namespace:s})),onSuccess:async()=>{a(`Resource ${r} updated`,"success"),await o.invalidateQueries({queryKey:u})},onError:x(a,`Failed to update resource ${r}`)}),{mutateAsync:c}=_.useMutation({mutationFn:async(p={})=>E.Delete(i,t,n,I.resource.DeleteInput.createFrom({id:r,namespace:s,gracePeriodSeconds:p.gracePeriodSeconds})),onSuccess:async()=>{a(`Resource ${r} deleted`,"success"),await o.invalidateQueries({queryKey:u})},onError:x(a,`Failed to delete resource ${r}`)});return{resource:_.useQuery({queryKey:u,queryFn:async()=>E.Get(i,t,n,I.resource.GetInput.createFrom({id:r,namespace:s})),retry:!1}),update:d,remove:c}},gn=e=>{const t=["component",e.plugin,e.resource,e.area];return{component:_.useQuery({queryKey:t,queryFn:async()=>E.GetResourceAreaComponent(e)})}},mn=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"resource_groups","list"];return{groups:_.useQuery({queryKey:r,queryFn:async()=>E.GetResourceGroups(n,t),retry:!1})}},_n=({pluginID:e,connectionID:t,searches:n})=>{const r=D(e),s=o=>[r,t,o.key,o.namespaces,"list"];return _.useQueries({queries:n.map(o=>({queryKey:s(o),queryFn:async()=>E.List(r,t,o.key,I.resource.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:o.namespaces})).then(a=>(console.log(a.result),a.result&&o.postFilter?Object.values(a.result).filter(o.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()=>E.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()=>E.GetResourceTypes(n,t),retry:!1})}};var ht=Symbol.for("immer-nothing"),ze=Symbol.for("immer-draftable"),N=Symbol.for("immer-state"),Cn=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 T(e,...t){if(process.env.NODE_ENV!=="production"){const n=Cn[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[N]}function z(e){var t;return e?gt(e)||Array.isArray(e)||!!e[ze]||!!((t=e.constructor)!=null&&t[ze])||fe(e)||pe(e):!1}var wn=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)===wn}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[N];return t?t.type_:Array.isArray(e)?1:fe(e)?2:pe(e)?3:0}function Re(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 bn(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 De(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[N];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){const o=s[i],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}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)||!z(e)||(de(e)>1&&(e.set=e.add=e.clear=e.delete=vn),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Le(r,!0))),e}function vn(){T(2)}function ye(e){return Object.isFrozen(e)}var Pn={};function K(e){const t=Pn[e];return t||T(0,e),t}var ee;function _t(){return ee}function Rn(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ke(e,t){t&&(K("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Oe(e){Ie(e),e.drafts_.forEach(Dn),e.drafts_=null}function Ie(e){e===ee&&(ee=e.parent_)}function We(e){return ee=Rn(ee,e)}function Dn(e){const t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Be(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[N].modified_&&(Oe(t),T(4)),z(e)&&(e=ae(t,e),t.parent_||ce(t,e)),t.patches_&&K("Patches").generateReplacementPatches_(n[N].base_,e,t.patches_,t.inversePatches_)):e=ae(t,n,[]),Oe(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[N];if(!r)return ie(t,(s,i)=>He(e,r,t,s,i,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 i=s,o=!1;r.type_===3&&(i=new Set(s),s.clear(),o=!0),ie(i,(a,u)=>He(e,r,s,a,u,n,o)),ce(e,s,!1),n&&e.patches_&&K("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function He(e,t,n,r,s,i,o){if(process.env.NODE_ENV!=="production"&&s===n&&T(5),J(s)){const a=i&&t&&t.type_!==3&&!Re(t.assigned_,r)?i.concat(r):void 0,u=ae(e,s,a);if(mt(n,r,u),J(u))e.canAutoFreeze_=!1;else return}else o&&n.add(s);if(z(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 On(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,i=$e;n&&(s=[r],i=te);const{revoke:o,proxy:a}=Proxy.revocable(s,i);return r.draft_=a,r.revoke_=o,a}var $e={get(e,t){if(t===N)return e;const n=j(e);if(!Re(n,t))return In(e,n,t);const r=n[t];return e.finalized_||!z(r)?r:r===Se(e.base_,t)?(Ce(e),e.copy_[t]=xe(r,e)):r},has(e,t){return t in j(e)},ownKeys(e){return Reflect.ownKeys(j(e))},set(e,t,n){const r=Et(j(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const s=Se(j(e),t),i=s==null?void 0:s[N];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(bn(n,s)&&(n!==void 0||Re(e.base_,t)))return!0;Ce(e),Fe(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 Se(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ce(e),Fe(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(){T(11)},getPrototypeOf(e){return Y(e.base_)},setPrototypeOf(){T(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))&&T(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))&&T(14),$e.set.call(this,e[0],t,n,e[0])};function Se(e,t){const n=e[N];return(n?j(n):e)[t]}function In(e,t,n){var s;const r=Et(t,n);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function Et(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 Fe(e){e.modified_||(e.modified_=!0,e.parent_&&Fe(e.parent_))}function Ce(e){e.copy_||(e.copy_=De(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 i=n;n=t;const o=this;return function(u=i,...d){return o.produce(u,c=>n.call(this,c,...d))}}typeof n!="function"&&T(6),r!==void 0&&typeof r!="function"&&T(7);let s;if(z(t)){const i=We(this),o=xe(t,void 0);let a=!0;try{s=n(o),a=!1}finally{a?Oe(i):Ie(i)}return Ke(i,r),Be(s,i)}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 i=[],o=[];K("Patches").generateReplacementPatches_(t,s,i,o),r(i,o)}return s}else T(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,u=>t(u,...a));let r,s;return[this.produce(t,n,(o,a)=>{r=o,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){z(e)||T(8),J(e)&&(e=xn(e));const t=We(this),n=xe(e,void 0);return n[N].isManual_=!0,Ie(t),n}finishDraft(e,t){const n=e&&e[N];(!n||!n.isManual_)&&T(9);const{scope_:r}=n;return Ke(r,t),Be(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=K("Patches").applyPatches_;return J(e)?r(e,t):this.produce(e,s=>r(s,t))}};function xe(e,t){const n=fe(e)?K("MapSet").proxyMap_(e,t):pe(e)?K("MapSet").proxySet_(e,t):On(e,t);return(t?t.scope_:_t()).drafts_.push(n),n}function xn(e){return J(e)||T(10,e),St(e)}function St(e){if(!z(e)||ye(e))return e;const t=e[N];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=De(e,t.scope_.immer_.useStrictShallowCopy_)}else n=De(e,!0);return ie(n,(r,s)=>{mt(n,r,St(s))}),t&&(t.finalized_=!1),n}var M=new Fn,Ct=M.produce;M.produceWithPatches.bind(M);M.setAutoFreeze.bind(M);M.setUseStrictShallowCopy.bind(M);M.applyPatches.bind(M);M.createDraft.bind(M);M.finishDraft.bind(M);var se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function An(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Tn="Expected a function",wt="__lodash_hash_undefined__",Nn="[object Function]",Mn="[object GeneratorFunction]",kn="[object Symbol]",Ln=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$n=/^\w*$/,Un=/^\./,qn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,jn=/[\\^$.*+?()[\]{}|]/g,Qn=/\\(\\)?/g,Gn=/^\[object .+?Constructor\]$/,zn=typeof se=="object"&&se&&se.Object===Object&&se,Kn=typeof self=="object"&&self&&self.Object===Object&&self,Ue=zn||Kn||Function("return this")();function Wn(e,t){return e==null?void 0:e[t]}function Bn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Hn=Array.prototype,Yn=Function.prototype,bt=Object.prototype,we=Ue["__core-js_shared__"],Ye=function(){var e=/[^.]+$/.exec(we&&we.keys&&we.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),vt=Yn.toString,qe=bt.hasOwnProperty,Pt=bt.toString,Jn=RegExp("^"+vt.call(qe).replace(jn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Je=Ue.Symbol,Vn=Hn.splice,Xn=Rt(Ue,"Map"),ne=Rt(Object,"create"),Ve=Je?Je.prototype:void 0,Xe=Ve?Ve.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 Zn(){this.__data__=ne?ne(null):{}}function er(e){return this.has(e)&&delete this.__data__[e]}function tr(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 nr(e){var t=this.__data__;return ne?t[e]!==void 0:qe.call(t,e)}function rr(e,t){var n=this.__data__;return n[e]=ne&&t===void 0?wt:t,this}W.prototype.clear=Zn;W.prototype.delete=er;W.prototype.get=tr;W.prototype.has=nr;W.prototype.set=rr;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 sr(){this.__data__=[]}function or(e){var t=this.__data__,n=he(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Vn.call(t,n,1),!0}function ir(e){var t=this.__data__,n=he(t,e);return n<0?void 0:t[n][1]}function ar(e){return he(this.__data__,e)>-1}function cr(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=sr;V.prototype.delete=or;V.prototype.get=ir;V.prototype.has=ar;V.prototype.set=cr;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 ur(){this.__data__={hash:new W,map:new(Xn||V),string:new W}}function lr(e){return ge(this,e).delete(e)}function dr(e){return ge(this,e).get(e)}function fr(e){return ge(this,e).has(e)}function pr(e,t){return ge(this,e).set(e,t),this}B.prototype.clear=ur;B.prototype.delete=lr;B.prototype.get=dr;B.prototype.has=fr;B.prototype.set=pr;function he(e,t){for(var n=e.length;n--;)if(vr(e[n][0],t))return n;return-1}function yr(e,t){t=_r(t,e)?[t]:mr(t);for(var n=0,r=t.length;e!=null&&n<r;)e=e[wr(t[n++])];return n&&n==r?e:void 0}function hr(e){if(!Ot(e)||Sr(e))return!1;var t=Pr(e)||Bn(e)?Jn:Gn;return t.test(br(e))}function gr(e){if(typeof e=="string")return e;if(Qe(e))return Xe?Xe.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function mr(e){return Dt(e)?e:Cr(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=Wn(e,t);return hr(n)?n:void 0}function _r(e,t){if(Dt(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Qe(e)?!0:$n.test(e)||!Ln.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!!Ye&&Ye in e}var Cr=je(function(e){e=Dr(e);var t=[];return Un.test(e)&&t.push(""),e.replace(qn,function(n,r,s,i){t.push(s?i.replace(Qn,"$1"):r||n)}),t});function wr(e){if(typeof e=="string"||Qe(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function br(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(Tn);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o),o};return n.cache=new(je.Cache||B),n}je.Cache=B;function vr(e,t){return e===t||e!==e&&t!==t}var Dt=Array.isArray;function Pr(e){var t=Ot(e)?Pt.call(e):"";return t==Nn||t==Mn}function Ot(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Rr(e){return!!e&&typeof e=="object"}function Qe(e){return typeof e=="symbol"||Rr(e)&&Pt.call(e)==kn}function Dr(e){return e==null?"":gr(e)}function Or(e,t,n){var r=e==null?void 0:yr(e,t);return r===void 0?n:r}var Ir=Or;const H=An(Ir);function It(e,t,n){return Ct(e??{result:[],success:!0,totalCount:0},s=>{for(const i of t)switch(i.type){case"ADD":{s.result.findIndex(a=>H(i.payload.data,n)===H(a,n))===-1&&s.result.push(i.payload.data);break}case"UPDATE":{const o=s.result.findIndex(a=>H(i.payload.data,n)===H(a,n));o!==-1&&(s.result[o]=i.payload.data);break}case"DELETE":{const o=s.result.findIndex(a=>H(i.payload.data,n)===H(a,n));o!==-1&&s.result.splice(o,1);break}}})}function Ft(e,t,n,r,s,i){const o=(i==null?void 0:i.syncWindowMs)??500,a=l.useRef([]),u=l.useRef(null),d=l.useRef(null),c=l.useRef(s);c.current=s;const m=l.useCallback(()=>{const f=a.current;if(a.current=[],u.current=null,d.current=null,!(f.length===0||!r)){e.setQueryData(t,g=>It(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=l.useCallback(f=>{a.current.push(f),!(u.current!==null||d.current!==null)&&(c.current===1?u.current=setTimeout(m,o):d.current=requestAnimationFrame(m))},[m,o]);return l.useEffect(()=>()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)},[]),p}const Fr=({pluginID:e,connectionID:t,resourceKey:n,idAccessor:r,namespaces:s})=>{const i=D(e),o=_.useQueryClient(),{showSnackbar:a}=L(),u=l.useMemo(()=>s??[],[s]),d=l.useMemo(()=>[i,t,n,u,"list"],[i,t,n,u]),c=l.useCallback((S,y)=>[i,t,n,y,S],[i,t,n]),{mutateAsync:m}=_.useMutation({mutationFn:async S=>E.Create(i,t,n,I.resource.ClientCreateInput.createFrom({input:S.input,namespace:S.namespace??(u.length===1?u[0]:"")})),onSuccess:async S=>{var v;const y=S.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 C=w?`Resource ${w} created`:"Resource created";a(C,"success"),await o.invalidateQueries({queryKey:d})},onError:x(a,"Failed to create resource")}),p=_.useQuery({queryKey:d,queryFn:async()=>E.List(i,t,n,I.resource.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:u})),placeholderData:(S,y)=>S,retry:!1}),[f,g]=l.useState(b.IDLE);l.useEffect(()=>O.EventsOn(`${i}/${t}/watch/STATE`,y=>{y.resourceKey===n&&g(y.state)}),[i,t,n]);const h=Ft(o,d,c,r,f);return l.useEffect(()=>{if(!r)return;E.SubscribeResource(i,t,n);const S=O.EventsOn(`${i}/${t}/${n}/ADD`,C=>h({type:"ADD",payload:C})),y=O.EventsOn(`${i}/${t}/${n}/UPDATE`,C=>h({type:"UPDATE",payload:C})),w=O.EventsOn(`${i}/${t}/${n}/DELETE`,C=>h({type:"DELETE",payload:C}));return()=>{S(),y(),w(),E.UnsubscribeResource(i,t,n)}},[i,t,n,h]),{resources:p,create:m,watchState:f,isSyncing:f===b.SYNCING,isSynced:f===b.SYNCED,watchError:f===b.ERROR}},xr=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=L(),r=_.useMutation({mutationFn:async({opts:o,input:a})=>E.Create(t,o.connectionID,o.resourceKey,I.resource.ClientCreateInput.createFrom({input:a.input,namespace:a.namespace??o.namespace??""})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} created`,"success")},onError(o,{opts:a}){G(n,o,`Failed to create resource ${a.resourceID}`)}}),s=_.useMutation({mutationFn:async({opts:o,input:a})=>E.Update(t,o.connectionID,o.resourceKey,I.resource.ClientUpdateInput.createFrom({input:a.input,id:o.resourceID,namespace:o.namespace??""})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} updated`,"success")},onError(o,{opts:a}){G(n,o,`Failed to update resource ${a.resourceID}`)}}),i=_.useMutation({mutationFn:async({opts:o,input:a})=>E.Delete(t,o.connectionID,o.resourceKey,I.resource.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}){G(n,o,`Failed to delete resource ${a.resourceID}`)}});return{create:r.mutateAsync,update:s.mutateAsync,remove:i.mutateAsync}},Ar=({pluginID:e,connectionID:t,resourceKey:n,enabled:r=!0})=>{const s=D(e),i=_.useQuery({queryKey:["RESOURCE_ACTIONS",s,t,n],queryFn:()=>E.GetActions(s,t,n),enabled:r&&!!s&&!!t&&!!n,staleTime:5*60*1e3});return{actions:i.data??[],isLoading:i.isLoading,error:i.error}},Tr=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),s=_.useQueryClient(),{showSnackbar:i}=L(),o=_.useMutation({mutationFn:async({actionID:a,id:u="",namespace:d="",params:c={}})=>E.ExecuteAction(r,t,n,a,I.resource.ActionInput.createFrom({id:u,namespace:d,params:c})),onSuccess:a=>{a.message&&i(a.message,"success"),s.invalidateQueries({queryKey:["RESOURCES",r,t,n]})},onError:(a,u)=>{G(i,a,`Failed to execute action "${u.actionID}"`)}});return{executeAction:o.mutateAsync,isExecuting:o.isPending,error:o.error}},Nr=({pluginID:e,connectionID:t,enabled:n=!0})=>{const r=D(e),s=_.useQuery({queryKey:["EDITOR_SCHEMAS",r,t],queryFn:()=>E.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(),i=[r,t,"watch-state"],o=l.useRef([]),a=l.useRef(!1),u=l.useCallback(p=>{s.setQueryData(i,f=>f&&Ct(f,g=>{g.resources[p.resourceKey]=p.state,g.resourceCounts[p.resourceKey]=p.resourceCount;let h=0,S=0;for(const y of Object.values(g.resources))y===b.SYNCED&&h++,(y===b.ERROR||y===b.FAILED)&&S++;g.syncedCount=h,g.errorCount=S}))},[s,r,t]),d=_.useQuery({queryKey:i,queryFn:async()=>{const p=await E.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 S={};for(const[y,w]of Object.entries(p.resourceCounts??{}))S[y]=w;return{connection:p.connectionId,resources:f,resourceCounts:S,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}});l.useEffect(()=>{if(!d.data||a.current)return;a.current=!0;const p=o.current;o.current=[];for(const f of p)u(f)},[d.data,u]),l.useEffect(()=>{if(!n||!r||!t)return;a.current=!1,o.current=[];const p=O.EventsOn(`${r}/${t}/watch/STATE`,f=>{a.current?u(f):o.current.push(f)});return()=>{p(),a.current=!1,o.current=[]}},[r,t,n,u]);const c=d.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:d,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}},kr=()=>{const[e,t]=l.useState(new Map),n=l.useRef(new Map),r=l.useRef(new Map),s=l.useCallback(d=>{const c=Me(d),m=pt(n.current,d),p=Pe(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)}},[]);l.useEffect(()=>{const d=O.EventsOn("watch/STATE",s);return()=>{d();for(const c of r.current.values())clearTimeout(c)}},[s]);const i=Array.from(e.values()),o=dt(i),a=i.find(d=>!oe(d))??i[0]??null,u=ft(i);return{syncs:i,hasSyncing:o,primarySync:a,aggregateProgress:u}},xt=()=>{const e=l.useContext(Ne);if(!e)throw new Error("useOperations must be used within an OperationsProvider");return e},Lr=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),{showSnackbar:s}=L(),{addOperation:i,updateOperation:o}=xt(),a=l.useRef([]);return l.useEffect(()=>()=>{a.current.forEach(d=>d())},[]),{startStreamAction:l.useCallback(async({actionID:d,id:c,namespace:m,label:p,params:f={}})=>{try{const g=await E.StreamAction(r,t,n,d,I.resource.ActionInput.createFrom({id:c,namespace:m,params:f}));i({id:g,label:p,resourceKey:n,resourceName:c,namespace:m,connectionID:t,status:"running",startedAt:Date.now()});const h=`action/stream/${g}`,S=O.EventsOn(h,y=>{var w,C,v,A;switch(y.type){case"progress":{const P=y.data??{};o(g,{message:P.message,progress:P.ready!==void 0&&P.desired!==void 0?{ready:P.ready,desired:P.desired}:void 0});break}case"complete":o(g,{status:"completed",message:((w=y.data)==null?void 0:w.message)??"Completed",completedAt:Date.now()}),s(((C=y.data)==null?void 0:C.message)??p+" completed","success"),O.EventsOff(h);break;case"error":o(g,{status:"error",message:((v=y.data)==null?void 0:v.message)??"Failed",completedAt:Date.now()}),s(((A=y.data)==null?void 0:A.message)??p+" failed","error"),O.EventsOff(h);break}});return a.current.push(()=>{S(),O.EventsOff(h)}),g}catch(g){throw G(s,g,`Failed to start "${d}"`),g}},[r,t,n,i,o,s])}},$r=()=>{const e=l.useContext(Te);if(!e)throw new Error("useSettings must be used within a SettingsProvider");return e},Ur=({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 l.useMemo(()=>R.jsx(Z.Link,{style:{textDecoration:"none",color:"inherit"},...n,to:s}),[n,s])};function qr(){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,i=l.useCallback((o,a)=>{const{...u}=a??{};o.startsWith("/")?e(`${r}${o}`,u):e(o,u)},[e,r]);return l.useMemo(()=>({location:t,navigate:i,pluginPath:s}),[t,i,s])}class jr{}class Qr{constructor(){F(this,"_extensions");F(this,"root");F(this,"pages");F(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 Gr=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=nt;exports.ConfirmationModalContext=st;exports.ErrorTypes=k;exports.ExtensionPointRegistry=Ht;exports.ExtensionPointStore=ct;exports.ExtensionProvider=Bt;exports.Link=Ur;exports.OperationsContext=Ne;exports.OperationsProvider=jt;exports.PluginContext=ue;exports.PluginContextProvider=Lt;exports.PluginErrorCode=At;exports.PluginWindow=Qr;exports.PluginWindowRootProps=jr;exports.RightDrawerContext=rt;exports.SettingsContext=Te;exports.SettingsProvider=Ut;exports.SnackbarProvider=Jt;exports.SyncPolicy=en;exports.WatchState=b;exports.actionToSnackbar=Ze;exports.applyBatch=It;exports.connectionListQueryKey=lt;exports.createErrorHandler=x;exports.defaultState=tt;exports.formatGroup=zr;exports.isCancelledError=Ae;exports.parseAppError=$;exports.parseResourceKey=Gr;exports.showAppError=G;exports.useActiveSyncs=kr;exports.useBottomDrawer=ke;exports.useConfirmationModal=yn;exports.useConnection=Vt;exports.useConnectionNamespaces=Zt;exports.useConnectionStatus=tn;exports.useConnections=Xt;exports.useEditorSchemas=Nr;exports.useEventBatcher=Ft;exports.useExec=an;exports.useExecuteAction=Tr;exports.useExtensionPoint=Wt;exports.useExtensionRegistry=at;exports.useLogs=cn;exports.useMetricProviders=un;exports.useMetricProvidersForResource=yt;exports.useMetricStream=dn;exports.useOperations=xt;exports.usePluginContext=le;exports.usePluginData=sn;exports.usePluginRouter=qr;exports.usePluginSettings=$t;exports.usePortForwardSessions=fn;exports.useResolvedPluginId=D;exports.useResource=hn;exports.useResourceActions=Ar;exports.useResourceAreaComponent=gn;exports.useResourceGroups=mn;exports.useResourceMetrics=ln;exports.useResourceMutations=xr;exports.useResourcePortForwarder=pn;exports.useResourceSearch=_n;exports.useResourceType=En;exports.useResourceTypes=Sn;exports.useResources=Fr;exports.useRightDrawer=on;exports.useSettings=$r;exports.useSnackbar=L;exports.useStreamAction=Lr;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;
|