@omniviewdev/runtime 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -1
- package/dist/api.d.ts +16 -14
- package/dist/api.js +111 -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 +99 -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/graphservice-CRRwkBcy.cjs +1 -0
- package/dist/graphservice-CXr8ZCEY.js +726 -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/index.d.ts +2 -0
- package/dist/hooks/resource/useDependencyTree.d.ts +41 -0
- package/dist/hooks/resource/useEditorSchemas.d.ts +2 -2
- package/dist/hooks/resource/useEventBatcher.d.ts +3 -0
- package/dist/hooks/resource/useRelatedResources.d.ts +82 -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 +1281 -1599
- package/dist/legacyEnum-DORXlU_y.js +13 -0
- package/dist/legacyEnum-DkV5yRdA.cjs +1 -0
- package/dist/models-BoBl5Kgj.js +159 -0
- package/dist/models-BvR5jdms.js +2358 -0
- package/dist/models-CHycLCM0.cjs +1 -0
- package/dist/models-DOdc96z9.cjs +1 -0
- package/dist/models.cjs +1 -1
- package/dist/models.d.ts +28 -1
- package/dist/models.js +263 -2244
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +198 -205
- 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 Xe=Object.defineProperty;var Ve=(t,e,n)=>e in t?Xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>Ve(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react/jsx-runtime"),d=require("react"),B=require("react-router-dom"),h=require("./graphservice-CRRwkBcy.cjs"),A=require("./models-CHycLCM0.cjs"),S=require("@tanstack/react-query"),et=require("@omniviewdev/base-ui");require("./index-D_aIcqH0.cjs");const T=require("./events-BTiuwc-0.cjs"),tt=require("./legacyEnum-DkV5yRdA.cjs"),X=d.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 nt(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 $(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}=nt(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:$(t).type===U.CANCELLED}function be(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 ve(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(be)}}function j(t,e,n){if(ue(e))return;const r=$(e);t(ve(r,n))}function N(t,e){return n=>{if(ue(n))return;const r=$(n);t(ve(r,r.title!=="Error"?r.title:e))}}function rt(t){const{children:e,pluginId:n}=t,[r,s]=d.useState({}),[i,o]=d.useState(new A.PluginMeta),[a,c]=d.useState(!1),[l,u]=d.useState(null);console.debug("[PluginContextProvider] render",{pluginId:n,metaLoaded:a,metaError:!!l});const g=()=>{n===void 0||n===""||(console.debug(`[PluginContextProvider] fetching settings for "${n}"`),h.PluginValues(n).then(f=>{console.debug(`[PluginContextProvider] settings loaded for "${n}"`,Object.keys(f)),s(f)}).catch(f=>{const y=$(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),h.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=$(f);console.error(`[PluginContextProvider] error fetching meta for "${n}":`,y.detail),u(y.detail),c(!1)})};return d.useEffect(()=>{console.debug(`[PluginContextProvider] useEffect — pluginId changed to "${n}"`),g(),p()},[n]),l?D.jsx("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",padding:24},children:D.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:[D.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[D.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[D.jsx("circle",{cx:"12",cy:"12",r:"10"}),D.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),D.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),D.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#FECACA"},children:"Plugin failed to load"})]}),D.jsx("p",{style:{fontSize:13,color:"#A1A1AA",margin:"0 0 16px"},children:l}),D.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?D.jsx(X.Provider,{value:{pluginId:n,settings:r,meta:i},children:e}):D.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center"},children:[D.jsx("div",{style:{width:24,height:24,border:"2px solid #3F3F46",borderTopColor:"#A1A1AA",borderRadius:"50%",animation:"plugin-spin 0.8s linear infinite"}}),D.jsx("style",{children:"@keyframes plugin-spin { to { transform: rotate(360deg); } }"})]})}function V(){const t=d.useContext(X);if(!t)throw new Error("usePluginContext must be used within a PluginContextProvider");return t}function st(){return V().settings}const le=d.createContext(void 0),ot=({children:t})=>{const[e,n]=d.useState({}),r=()=>{h.Values().then(i=>{console.log("Fetched settings:",i),n(i)}).catch(i=>{console.error("Error fetching settings:",i)})};d.useEffect(()=>{r()},[]);const s=()=>{r()};return D.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=d.createContext(Re),Fe=d.createContext(void 0),Pe=d.createContext(void 0),de=d.createContext(void 0),it=3e4,at=({children:t})=>{const[e,n]=d.useState([]),r=d.useCallback(a=>{n(c=>[a,...c])},[]),s=d.useCallback((a,c)=>{n(l=>l.map(u=>u.id===a?{...u,...c}:u))},[]),i=d.useCallback(a=>{n(c=>c.filter(l=>l.id!==a))},[]);d.useEffect(()=>{const a=[];for(const c of e)if(c.status==="completed"||c.status==="error"){const l=Date.now()-(c.completedAt??c.startedAt),u=Math.max(0,it-l);a.push(setTimeout(()=>i(c.id),u))}return()=>a.forEach(clearTimeout)},[e,i]);const o=d.useMemo(()=>({operations:e,addOperation:r,updateOperation:s,removeOperation:i}),[e,r,s,i]);return D.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 ct(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,ut=Se===void 0?function(t,e){return t.__proto__=e,t}:Se,lt=function(t){ct(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,ut(r,e.prototype),r}return e}(Error);function ae(t,e){if(!t)throw new lt(e)}var Ie=["debug","log","warn","error","silent"],dt=Ie.indexOf("log");function z(t){return function(){if(Ie.indexOf(t)>=dt){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=d.createContext(void 0),De=()=>d.useContext(Oe);function ft(t){const e=De(),n=d.useRef(null),r=e==null?void 0:e.getExtensionPoint(t),s=d.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=d.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 l={};return n.current={store:void 0,version:-1,sentinel:l},l}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 d.useSyncExternalStore(s,i),e==null?void 0:e.getExtensionPoint(t)}const pt=({registry:t,children:e})=>{const n=d.useRef(t);return ae(n.current===t,"You can't change the extension registry after it has been rendered"),D.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 yt{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=d.createContext(void 0),gt={default:"info",info:"info",success:"success",warning:"warning",error:"danger"},ht=({children:t})=>{const{toast:e}=et.useToast(),[n,r]=d.useState([]),s=o=>{r(a=>[...a,o])},i=(o,a,c)=>{const l=typeof o=="object";let u="",g="info",p,f=5e3,y;if(l){if(u=o.message,o.showOnce){if(n.includes(u))return;s(u)}g=o.status,p=o.details,f=o.autoHideDuration??5e3,y=o.actions}else u=o,g=a,p=c;e(p??u,{severity:gt[g]??"info",title:p?u:void 0,duration:f,action:y==null?void 0:y[0]})};return D.jsx(Ae.Provider,{value:{showSnackbar:i},children:t})},q=()=>{const t=d.useContext(Ae);if(t===void 0)throw new Error("useCustomSnackbar must be used within a CustomSnackbarProvider");return t};function O(t){const e=d.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 mt=({pluginID:t,connectionID:e})=>{const n=O(t),r=S.useQueryClient(),{showSnackbar:s}=q(),i=[n,"connection","detail",e],{mutateAsync:o}=S.useMutation({mutationFn:async()=>h.StartConnection(n,e),onSuccess(g){r.setQueryData(i,g),r.invalidateQueries({queryKey:["EDITOR_SCHEMAS",n,e]})},onError:N(s,"Failed to start connection")}),{mutateAsync:a}=S.useMutation({mutationFn:async()=>h.StopConnection(n,e),onSuccess(g){r.setQueryData(i,g)},onError:N(s,"Failed to stop connection")}),{mutateAsync:c}=S.useMutation({mutationFn:async g=>h.UpdateConnection(n,g),onSuccess(g,{name:p}){s({message:`Connection ${p} successfully updated`,status:"success"}),r.setQueryData(i,g),r.setQueriesData({queryKey:[n,"connection","list"]},f=>f==null?void 0:f.map(y=>y.id===e?g:y))},onError:N(s,"Failed to update connection")}),{mutateAsync:l}=S.useMutation({mutationFn:async()=>h.RemoveConnection(n,e),onSuccess(){s({message:"Connection successfully removed",status:"success"}),r.setQueryData(i,void 0),r.setQueriesData({queryKey:[n,"connection","list"]},g=>g==null?void 0:g.filter(p=>p.id!==e))},onError:N(s,"Failed to remove connection")});return{connection:S.useQuery({queryKey:i,queryFn:async()=>h.GetConnection(n,e)}),startConnection:o,stopConnection:a,updateConnection:c,deleteConnection:l}},Me=t=>[t,"connection","list"],St=({plugin:t})=>{const e=O(t),n=S.useQueryClient(),{showSnackbar:r}=q(),s=Me(e),{mutateAsync:i}=S.useMutation({mutationFn:async l=>h.StartConnectionWatch(e,l.id),onError:N(r,"Failed to start connection watch")}),{mutateAsync:o}=S.useMutation({mutationFn:async l=>h.StopConnectionWatch(e,l.id),onError:N(r,"Failed to stop connection watch")}),a=d.useCallback(l=>{const u=l.data;console.log("got update to connections",u),n.setQueryData(s,u)},[n,s]);return d.useEffect(()=>{const l=T.On(`${e}/connection/sync`,a);return()=>{l()}},[e,a]),{connections:S.useQuery({queryKey:s,queryFn:async()=>{try{return await h.ListConnections(e)}catch(l){console.log(l),N(r,"Failed to load connections")(l)}return[]},staleTime:3e4,placeholderData:S.keepPreviousData}),startWatch:i,stopWatch:o}},Et=({pluginID:t,connectionID:e})=>{const n=O(t),r=[n,"connection","namespaces",e];return{namespaces:S.useQuery({queryKey:r,queryFn:async()=>h.GetConnectionNamespaces(n,e)})}},P=tt.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===P.WatchStateSynced&&r++,(u===P.WatchStateError||u===P.WatchStateFailed)&&s++,u===P.WatchStateForbidden&&i++,u===P.WatchStateSkipped&&o++;const a=n-o,c=e.filter(u=>u===P.WatchStateSynced||u===P.WatchStateError||u===P.WatchStateStopped||u===P.WatchStateFailed||u===P.WatchStateForbidden).length,l=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:l}}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]=d.useState(new Set),[n,r]=d.useState({}),[s,i]=d.useState(new Map),o=d.useRef(new Map),[a,c]=d.useState(new Map);d.useEffect(()=>{const m=T.On("plugin/crash_recovery_failed",F=>{const b=F.data,_=b==null?void 0:b.pluginID;_&&c(v=>{const I=new Map(v);return I.set(_,b.error??"Crash recovery failed"),I})}),x=T.On("plugin/recovered",F=>{const b=F.data,_=b==null?void 0:b.pluginID;_&&c(v=>{if(!v.has(_))return v;const I=new Map(v);return I.delete(_),I})});return()=>{m(),x()}},[]),d.useEffect(()=>{h.GetAllConnectionStates().then(m=>{if(!m)return;const x={},F=new Set,b=new Map;for(const[_,v]of Object.entries(m))if(v){x[_]=v.map(I=>I.connection);for(const I of v){if(!I.started)continue;const L=`${_}/${I.connection.id}`;F.add(L);const k={pluginID:_,connectionID:I.connection.id,states:{}};if(I.resources)for(const[ne,Ze]of Object.entries(I.resources))k.states[ne]=Ze;o.current.set(L,k),b.set(L,ce(k))}}r(x),e(F),i(b)}).catch(()=>{})},[]),d.useEffect(()=>T.On("connection/status",x=>{const F=x.data,b=`${F.pluginID}/${F.connectionID}`;F.status==="DISCONNECTED"?(e(_=>{const v=new Set(_);return v.delete(b),v}),i(_=>{const v=new Map(_);return v.delete(b),v}),o.current.delete(b)):e(_=>{const v=new Set(_);return v.add(b),v}),h.ListAllConnections().then(_=>{if(!_)return;const v={};for(const[I,L]of Object.entries(_))L!=null&&(v[I]=L);r(v)}).catch(()=>{})}),[]);const l=d.useCallback(m=>{const x=m.data,F=fe(x);e(v=>{if(v.has(F))return v;const I=new Set(v);return I.add(F),I});const b=Le(o.current,x),_=ce(b);i(v=>{const I=new Map(v);return I.set(F,_),I})},[]);d.useEffect(()=>T.On("watch/STATE",l),[l]);const u=d.useCallback(async(m,x)=>{await h.StopConnection(m,x)},[]),g=d.useCallback(async(m,x)=>{await h.StartConnectionWatch(m,x)},[]),p=d.useCallback(async m=>{const x=a.get(m);c(F=>{if(!F.has(m))return F;const b=new Map(F);return b.delete(m),b});try{await h.RetryFailedPlugin(m)}catch(F){throw c(b=>{const _=new Map(b);return _.set(m,x??"Reload failed"),_}),F}},[a]),f=[];for(const m of t){const[x,F]=m.split("/",2),_=(n[x]??[]).find(ne=>ne.id===F),v=s.get(m),I=v!=null&&!Z(v),L=v!=null&&v.errorCount>0,k=a.get(x);f.push({pluginID:x,connectionID:F,name:(_==null?void 0:_.name)??F,avatar:(_==null?void 0:_.avatar)??"",isStarted:!0,sync:v,isSyncing:I,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 w=Array.from(s.values()),R=f.filter(m=>m.isSyncing),E=f.filter(m=>m.hasErrors),C=f.filter(m=>m.pluginFailed);return{entries:f,grouped:y,connectedCount:f.length,syncingCount:R.length,errorCount:E.length,failedCount:C.length,hasSyncing:Ne(w),aggregateProgress:ke(w),disconnect:u,retryWatch:g,retryPlugin:p}}function _t(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=O(t),s=S.useQueryClient(),i=[r,"data",e],o=S.useQuery({queryKey:i,queryFn:async()=>{const c=await h.Get(r,e);return c==null?n:_t(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 h.Set(r,e,c)},onMutate:async c=>{await s.cancelQueries({queryKey:i});const l=s.getQueryData(i);return s.setQueryData(i,c),{previous:l}},onError:(c,l,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 bt=()=>{const t=d.useContext(Fe);if(!t)throw new Error("useRightDrawer must be used within a RightDrawerProvider");return t},pe=()=>{const t=d.useContext(xe);if(t===void 0)throw new Error("useBottomDrawer must be used within a BottomDrawerProvider");return t},vt=({pluginID:t})=>{const e=O(t),{showSnackbar:n}=q(),{createTab:r,updateTab:s}=pe();return{createSession:S.useMutation({mutationFn:async({connectionID:o,icon:a,label:c,opts:l})=>{const u=`pending-${crypto.randomUUID()}`;r({id:u,title:c??"Connecting...",variant:"terminal",icon:a??"LuSquareTerminal",properties:{status:"connecting",pluginID:e,connectionID:o,opts:{...l}}});const g=A.SessionOptions.createFrom({command:["/bin/bash"],tty:!0,...l});try{const p=await h.CreateSession(e,o,g);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:{...l}}})}catch(p){const f=$(p);s({id:u},{properties:{status:"error",error:f.detail,pluginID:e,connectionID:o,opts:{...l}}}),j(n,p,"Failed to start session")}}}).mutateAsync}},Rt=({pluginID:t})=>{const e=O(t),{showSnackbar:n}=q(),{createTab:r}=pe(),s=S.useMutation({mutationFn:async({connectionID:o,resourceKey:a,resourceID:c,resourceData:l,icon:u,label:g,target:p,follow:f=!0,tailLines:y=1e3,params:w})=>{const R=A.CreateSessionOptions.createFrom({resource_key:a,resource_id:c,resource_data:l,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:w??{}})}),E=await h.CreateSession$1(e,o,R);if(!E)throw new Error("Failed to create log session: null response");return r({id:E.id,title:g??`Logs ${E.id.substring(0,8)}`,variant:"logs",icon:u??"LuLogs"}),E},onError:N(n,"Failed to start log session")}),i=S.useMutation({mutationFn:async o=>{await h.CloseSession(o)},onError:N(n,"Failed to close log session")});return{createLogSession:s.mutateAsync,closeLogSession:i.mutateAsync}},xt=()=>S.useQuery({queryKey:["metric","providers"],queryFn:h.GetProviders,staleTime:3e4}),Ue=t=>S.useQuery({queryKey:["metric","providers",t],queryFn:()=>h.GetProvidersForResource(t),enabled:!!t,staleTime:3e4}),Ft=t=>{var R,E;const{connectionID:e,resourceKey:n,resourceID:r,resourceNamespace:s="",resourceData:i={},metricIDs:o=[],shape:a=0,timeRange:c,refreshInterval:l=0,enabled:u=!0}=t,{data:g,isLoading:p}=Ue(n),f=g??[],y=c?Math.max(Math.floor((c.end.getTime()-c.start.getTime())/250),15e3)*1e6:0,w=S.useQuery({queryKey:["metric","query",e,n,r,s,o,a,(R=c==null?void 0:c.start)==null?void 0:R.getTime(),(E=c==null?void 0:c.end)==null?void 0:E.getTime()],queryFn:async()=>{const C=await h.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,F]of Object.entries(C))F!=null&&(m[x]=F);return m},enabled:u&&!!e&&!!n&&(n.startsWith("cluster::")||!!r)&&f.length>0,refetchInterval:l>0?l:void 0,staleTime:5e3,placeholderData:S.keepPreviousData});return{data:w.data??void 0,providers:f,isLoading:p||w.isLoading,error:w.error,refetch:w.refetch}},Pt=t=>{const{pluginID:e,connectionID:n,resourceKey:r,resourceID:s,resourceNamespace:i="",resourceData:o={},metricIDs:a=[],interval:c=1e4,enabled:l=!0}=t,u=O(e),[g,p]=d.useState(null),[f,y]=d.useState(null),[w,R]=d.useState(!1),[E,C]=d.useState(null),m=d.useRef(null),x=d.useCallback(async()=>{if(!(!l||!u||!n||!r||!s))try{const b=await h.Subscribe(u,n,{resource_key:r,resource_id:s,resource_namespace:i,resource_data:o,metric_ids:a,interval:c*1e6});y(b),R(!0),C(null);const _=T.On(`core/metrics/data/${b}`,I=>{const L=I.data;try{const k=JSON.parse(L);k.results&&p(k.results)}catch(k){console.error("Failed to parse metric stream data:",k)}}),v=T.On(`core/metrics/error/${b}`,I=>{const L=I.data;try{const k=JSON.parse(L);C(k.error||"Unknown error")}catch{C("Failed to parse metric stream error")}});m.current=()=>{_(),v()}}catch(b){C(b instanceof Error?b.message:String(b))}},[u,n,r,s,i,a,c,l]),F=d.useCallback(async()=>{if(f)try{await h.Unsubscribe(f)}catch(b){console.error("Failed to unsubscribe:",b)}m.current&&(m.current(),m.current=null),y(null),R(!1)},[f]);return d.useEffect(()=>()=>{f&&h.Unsubscribe(f).catch(console.error),m.current&&m.current()},[f]),{data:g,subscriptionID:f,isStreaming:w,error:E,start:x,stop:F}},Q=["networker","portforward","all-sessions"];function It(){const{showSnackbar:t}=q(),e=S.useQueryClient(),n=S.useQuery({queryKey:[...Q],queryFn:async()=>h.ListAllPortForwardSessions().catch(i=>{if($(i).detail.includes("not found"))return[];throw i}),retry:!1});d.useEffect(()=>{const i=T.On("core/networker/portforward/created",()=>{e.invalidateQueries({queryKey:[...Q]})}),o=T.On("core/networker/portforward/closed",()=>{e.invalidateQueries({queryKey:[...Q]})});return()=>{i(),o()}},[e]);const r=n.data??[],s=S.useMutation({mutationFn:async i=>h.ClosePortForwardSession(i),onError:N(t,"Failed to close port forwarding session"),onSuccess:async()=>{await e.invalidateQueries({queryKey:[...Q]})}});return{sessions:n,activeSessions:r,closeSession:s.mutateAsync,openInBrowser:i=>T.OpenURL(`http://localhost:${i}`)}}function Ot({pluginID:t,connectionID:e,resourceID:n}){const r=O(t),s=["networker","portforward","sessions",r,e,n],{showSnackbar:i}=q(),o=S.useQueryClient(),a=S.useQuery({queryKey:s,queryFn:async()=>h.FindPortForwardSessions(r,e,A.FindPortForwardSessionRequest.createFrom({resource_id:n,connection_id:e})).catch(u=>{const g=$(u);return g.detail.includes("not found")?[]:(i({message:"Failed to fetch port forward sessions",status:"error",details:g.detail}),[])}),retry:!1}),c=S.useMutation({mutationFn:async({opts:u})=>{const g=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 h.StartResourcePortForwardingSession(r,e,g);if(!p)throw new Error("Failed to start port forwarding: null response");return u.openInBrowser&&T.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:[...Q]})])}}),l=S.useMutation({mutationFn:async({opts:u})=>h.ClosePortForwardSession(u.sessionID),onError:N(i,"Failed to close port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...Q]})])}});return{sessions:a,forward:c.mutateAsync,close:l.mutateAsync}}const Dt=()=>{const t=d.useContext(Pe);if(!t)throw new Error("useConfirmationModal must be used within a ConfirmationModalProvider");return t},Tt=({pluginID:t,connectionID:e,resourceKey:n,resourceID:r,namespace:s=""})=>{const i=O(t),o=S.useQueryClient(),{showSnackbar:a}=q(),c=["RESOURCE",i,e,n,r,s],{mutateAsync:l}=S.useMutation({mutationFn:async p=>h.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={})=>h.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()=>h.Get$1(i,e,n,A.GetInput.createFrom({id:r,namespace:s})),retry:!1}),update:l,remove:u}},At=t=>{const e=["component",t.plugin,t.resource,t.area];return{component:S.useQuery({queryKey:e,queryFn:async()=>h.GetResourceAreaComponent(t)})}},Mt=({pluginID:t,connectionID:e})=>{const n=O(t),r=[n,"resource_groups","list"];return{groups:S.useQuery({queryKey:r,queryFn:async()=>h.GetResourceGroups(n,e),retry:!1})}},Nt=({pluginID:t,connectionID:e,searches:n})=>{const r=O(t),s=o=>[r,e,o.key,o.namespaces,"list"];return S.useQueries({queries:n.map(o=>({queryKey:s(o),queryFn:async()=>h.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}))})},kt=({pluginID:t,resourceKey:e})=>{const n=O(t),r=[n,"resources",e];return{resourceType:S.useQuery({queryKey:r,queryFn:async()=>h.GetResourceType(n,e),retry:!1})}},Lt=({pluginID:t,connectionID:e})=>{const n=O(t),r=[n,"resources","list",e];return{types:S.useQuery({queryKey:r,queryFn:async()=>h.GetResourceTypes(n,e),retry:!1})}};var Y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ut(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qt="Expected a function",qe="__lodash_hash_undefined__",$t="[object Function]",Qt="[object GeneratorFunction]",jt="[object Symbol]",Wt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gt=/^\w*$/,Kt=/^\./,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ht=/[\\^$.*+?()[\]{}|]/g,zt=/\\(\\)?/g,Yt=/^\[object .+?Constructor\]$/,Jt=typeof Y=="object"&&Y&&Y.Object===Object&&Y,Zt=typeof self=="object"&&self&&self.Object===Object&&self,ye=Jt||Zt||Function("return this")();function Xt(t,e){return t==null?void 0:t[e]}function Vt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}var en=Array.prototype,tn=Function.prototype,$e=Object.prototype,oe=ye["__core-js_shared__"],Ee=function(){var t=/[^.]+$/.exec(oe&&oe.keys&&oe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Qe=tn.toString,ge=$e.hasOwnProperty,je=$e.toString,nn=RegExp("^"+Qe.call(ge).replace(Ht,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ce=ye.Symbol,rn=en.splice,sn=We(ye,"Map"),H=We(Object,"create"),_e=Ce?Ce.prototype:void 0,we=_e?_e.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 on(){this.__data__=H?H(null):{}}function an(t){return this.has(t)&&delete this.__data__[t]}function cn(t){var e=this.__data__;if(H){var n=e[t];return n===qe?void 0:n}return ge.call(e,t)?e[t]:void 0}function un(t){var e=this.__data__;return H?e[t]!==void 0:ge.call(e,t)}function ln(t,e){var n=this.__data__;return n[t]=H&&e===void 0?qe:e,this}W.prototype.clear=on;W.prototype.delete=an;W.prototype.get=cn;W.prototype.has=un;W.prototype.set=ln;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 dn(){this.__data__=[]}function fn(t){var e=this.__data__,n=ee(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():rn.call(e,n,1),!0}function pn(t){var e=this.__data__,n=ee(e,t);return n<0?void 0:e[n][1]}function yn(t){return ee(this.__data__,t)>-1}function gn(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=dn;K.prototype.delete=fn;K.prototype.get=pn;K.prototype.has=yn;K.prototype.set=gn;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(sn||K),string:new W}}function mn(t){return te(this,t).delete(t)}function Sn(t){return te(this,t).get(t)}function En(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=mn;G.prototype.get=Sn;G.prototype.has=En;G.prototype.set=Cn;function ee(t,e){for(var n=t.length;n--;)if(Dn(t[n][0],e))return n;return-1}function _n(t,e){e=Rn(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)||Fn(t))return!1;var e=Tn(t)||Vt(t)?nn:Yt;return e.test(On(t))}function bn(t){if(typeof t=="string")return t;if(me(t))return we?we.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 xn(e)?n[typeof e=="string"?"string":"hash"]:n.map}function We(t,e){var n=Xt(t,e);return wn(n)?n:void 0}function Rn(t,e){if(Ge(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||me(t)?!0:Gt.test(t)||!Wt.test(t)||e!=null&&t in Object(e)}function xn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Fn(t){return!!Ee&&Ee in t}var Pn=he(function(t){t=Mn(t);var e=[];return Kt.test(t)&&e.push(""),t.replace(Bt,function(n,r,s,i){e.push(s?i.replace(zt,"$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 On(t){if(t!=null){try{return Qe.call(t)}catch{}try{return t+""}catch{}}return""}function he(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(qt);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(he.Cache||G),n}he.Cache=G;function Dn(t,e){return t===e||t!==t&&e!==e}var Ge=Array.isArray;function Tn(t){var e=Ke(t)?je.call(t):"";return e==$t||e==Qt}function Ke(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function An(t){return!!t&&typeof t=="object"}function me(t){return typeof t=="symbol"||An(t)&&je.call(t)==jt}function Mn(t){return t==null?"":bn(t)}function Nn(t,e,n){var r=t==null?void 0:_n(t,e);return r===void 0?n:r}var kn=Nn;const J=Ut(kn);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=d.useRef([]),c=d.useRef(null),l=d.useRef(null),u=d.useRef(s);u.current=s;const g=d.useCallback(()=>{const f=a.current;if(a.current=[],c.current=null,l.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=d.useCallback(f=>{a.current.push(f),!(c.current!==null||l.current!==null)&&(u.current===1?c.current=setTimeout(g,o):l.current=requestAnimationFrame(g))},[g,o]);return d.useEffect(()=>()=>{c.current!==null&&(clearTimeout(c.current),c.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)},[]),p}const Ln=({pluginID:t,connectionID:e,resourceKey:n,idAccessor:r,namespaces:s})=>{const i=O(t),o=S.useQueryClient(),{showSnackbar:a}=q(),c=d.useMemo(()=>s??[],[s]),l=d.useMemo(()=>[i,e,n,c,"list"],[i,e,n,c]),u=d.useCallback((R,E)=>[i,e,n,E,R],[i,e,n]),{mutateAsync:g}=S.useMutation({mutationFn:async R=>h.Create(i,e,n,A.CreateInput.createFrom({input:R.input,namespace:R.namespace??(c.length===1?c[0]:"")})),onSuccess:async R=>{var x;const E=R==null?void 0:R.result;let C="";(x=E==null?void 0:E.metadata)!=null&&x.name?C=E.metadata.name:E!=null&&E.id?C=E.id:E!=null&&E.name?C=E.name:E!=null&&E.ID?C=E.ID:E!=null&&E.Name&&(C=E.Name);const m=C?`Resource ${C} created`:"Resource created";a(m,"success"),await o.invalidateQueries({queryKey:l})},onError:N(a,"Failed to create resource")}),p=S.useQuery({queryKey:l,queryFn:async()=>h.List(i,e,n,A.ListInput.createFrom({order:[{field:"name",descending:!1}],pagination:{page:1,pageSize:200},namespaces:c})),placeholderData:(R,E)=>R,retry:!1}),[f,y]=d.useState(P.WatchStateIdle);d.useEffect(()=>T.On(`${i}/${e}/watch/STATE`,E=>{const C=E.data;C.resourceKey===n&&y(C.state)}),[i,e,n]);const w=He(o,l,u,r,f);return d.useEffect(()=>{if(!r)return;h.SubscribeResource(i,e,n);const R=T.On(`${i}/${e}/${n}/ADD`,m=>w({type:"ADD",payload:m.data})),E=T.On(`${i}/${e}/${n}/UPDATE`,m=>w({type:"UPDATE",payload:m.data})),C=T.On(`${i}/${e}/${n}/DELETE`,m=>w({type:"DELETE",payload:m.data}));return()=>{R(),E(),C(),h.UnsubscribeResource(i,e,n)}},[i,e,n,w]),{resources:p,create:g,watchState:f,isSyncing:f===P.WatchStateSyncing,isSynced:f===P.WatchStateSynced,watchError:f===P.WatchStateError}},Un=({pluginID:t})=>{const e=O(t),{showSnackbar:n}=q(),r=S.useMutation({mutationFn:async({opts:o,input:a})=>h.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}){j(n,o,`Failed to create resource ${a.resourceID}`)}}),s=S.useMutation({mutationFn:async({opts:o,input:a})=>h.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}){j(n,o,`Failed to update resource ${a.resourceID}`)}}),i=S.useMutation({mutationFn:async({opts:o,input:a})=>h.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}){j(n,o,`Failed to delete resource ${a.resourceID}`)}});return{create:r.mutateAsync,update:s.mutateAsync,remove:i.mutateAsync}},qn=({pluginID:t,connectionID:e,resourceKey:n,enabled:r=!0})=>{const s=O(t),i=S.useQuery({queryKey:["RESOURCE_ACTIONS",s,e,n],queryFn:()=>h.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=O(t),s=S.useQueryClient(),{showSnackbar:i}=q(),o=S.useMutation({mutationFn:async({actionID:a,id:c="",namespace:l="",params:u={}})=>h.ExecuteAction(r,e,n,a,A.ActionInput.createFrom({id:c,namespace:l,params:u})),onSuccess:a=>{a!=null&&a.message&&i(a.message,"success"),s.invalidateQueries({queryKey:["RESOURCES",r,e,n]})},onError:(a,c)=>{j(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=O(t),s=S.useQuery({queryKey:["EDITOR_SCHEMAS",r,e],queryFn:()=>h.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=O(t),s=S.useQueryClient(),i=[r,e,"watch-state"],o=d.useRef([]),a=d.useRef(!1),c=d.useCallback(p=>{s.setQueryData(i,f=>{if(!f)return f;const y={...f.resources,[p.resourceKey]:p.state},w={...f.resourceCounts,[p.resourceKey]:p.resourceCount};let R=0,E=0;for(const C of Object.values(y))C===P.WatchStateSynced&&R++,(C===P.WatchStateError||C===P.WatchStateFailed)&&E++;return{...f,resources:y,resourceCounts:w,totalResources:Object.keys(y).length,syncedCount:R,errorCount:E}})},[s,r,e]),l=S.useQuery({queryKey:i,queryFn:async()=>{const p=await h.GetWatchState(r,e);if(!p)throw new Error("Failed to get watch state: null response");const f={};let y=0,w=0;for(const[E,C]of Object.entries(p.resources??{}))C!=null&&(f[E]=C,C===P.WatchStateSynced&&y++,C===P.WatchStateError&&w++);const R={};for(const[E,C]of Object.entries(p.resourceCounts??{}))C!=null&&(R[E]=C);return{connection:p.connectionId,resources:f,resourceCounts:R,totalResources:Object.keys(f).length,syncedCount:y,errorCount:w}},enabled:n&&!!r&&!!e,refetchInterval:p=>{const f=p.state.data;if(!f||f.totalResources===0)return 3e3;let y=0;for(const w of Object.values(f.resources))(w===P.WatchStateSynced||w===P.WatchStateError||w===P.WatchStateStopped||w===P.WatchStateFailed||w===P.WatchStateForbidden||w===P.WatchStateSkipped)&&y++;return y>=f.totalResources?!1:3e3}});d.useEffect(()=>{if(!l.data||a.current)return;a.current=!0;const p=o.current;o.current=[];for(const f of p)c(f)},[l.data,c]),d.useEffect(()=>{if(!n||!r||!e)return;a.current=!1,o.current=[];const p=T.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=l.data;let g=0;if(u!=null&&u.resources)for(const p of Object.values(u.resources))(p===P.WatchStateSynced||p===P.WatchStateError||p===P.WatchStateStopped||p===P.WatchStateFailed||p===P.WatchStateForbidden||p===P.WatchStateSkipped)&&g++;return{summary:l,getResourceState:p=>u==null?void 0:u.resources[p],isFullySynced:u?u.totalResources>0&&g===u.totalResources:!1,syncProgress:u&&u.totalResources>0?g/u.totalResources:0,errorCount:(u==null?void 0:u.errorCount)??0}},Wn=()=>{const[t,e]=d.useState(new Map),n=d.useRef(new Map),r=d.useRef(new Map),s=d.useCallback(l=>{const u=l.data,g=fe(u),p=Le(n.current,u),f=ce(p);if(e(y=>{const w=new Map(y);return w.set(g,f),w}),r.current.has(g)&&(clearTimeout(r.current.get(g)),r.current.delete(g)),Z(f)){const y=setTimeout(()=>{e(w=>{const R=new Map(w);return R.delete(g),R}),n.current.delete(g),r.current.delete(g)},5e3);r.current.set(g,y)}},[]);d.useEffect(()=>{const l=T.On("watch/STATE",s);return()=>{l();for(const u of r.current.values())clearTimeout(u)}},[s]);const i=Array.from(t.values()),o=Ne(i),a=i.find(l=>!Z(l))??i[0]??null,c=ke(i);return{syncs:i,hasSyncing:o,primarySync:a,aggregateProgress:c}},ze=()=>{const t=d.useContext(de);if(!t)throw new Error("useOperations must be used within an OperationsProvider");return t},Gn=({pluginID:t,connectionID:e,resourceKey:n})=>{const r=O(t),{showSnackbar:s}=q(),{addOperation:i,updateOperation:o}=ze(),a=d.useRef([]);return d.useEffect(()=>()=>{a.current.forEach(l=>l())},[]),{startStreamAction:d.useCallback(async({actionID:l,id:u,namespace:g,label:p,params:f={}})=>{try{const y=await h.StreamAction(r,e,n,l,A.ActionInput.createFrom({id:u,namespace:g,params:f}));i({id:y,label:p,resourceKey:n,resourceName:u,namespace:g,connectionID:e,status:"running",startedAt:Date.now()});const w=`action/stream/${y}`,R=T.On(w,E=>{var m,x,F,b;const C=E.data;switch(C.type){case"progress":{const _=C.data??{};o(y,{message:_.message,progress:_.ready!==void 0&&_.desired!==void 0?{ready:_.ready,desired:_.desired}:void 0});break}case"complete":o(y,{status:"completed",message:((m=C.data)==null?void 0:m.message)??"Completed",completedAt:Date.now()}),s(((x=C.data)==null?void 0:x.message)??p+" completed","success"),T.Off(w);break;case"error":o(y,{status:"error",message:((F=C.data)==null?void 0:F.message)??"Failed",completedAt:Date.now()}),s(((b=C.data)==null?void 0:b.message)??p+" failed","error"),T.Off(w);break}});return a.current.push(()=>{R(),T.Off(w)}),y}catch(y){throw j(s,y,`Failed to start "${l}"`),y}},[r,e,n,i,o,s])}},Kn=1e4,Bn={owns:{outgoing:"Owns",incoming:"Owned by"},runs_on:{outgoing:"Runs on",incoming:"Running here"},uses:{outgoing:"Uses",incoming:"Used by"},exposes:{outgoing:"Exposes",incoming:"Exposed by"},manages:{outgoing:"Manages",incoming:"Managed by"},member_of:{outgoing:"Member of",incoming:"Members"},selects:{outgoing:"Selects",incoming:"Selected by"}};function Hn(t,e){const n=Bn[t];if(n)return n[e];const r=t.replace(/_/g," ");return e==="outgoing"?r:`${r} (incoming)`}function zn(t,e){return t.pluginId===e.pluginId&&t.connectionId===e.connectionId&&t.resourceKey===e.resourceKey&&t.id===e.id&&(t.namespace??"")===(e.namespace??"")}function Ye(t,e){return e.map(n=>{const r=zn(n.source,t);return{resource:r?n.target:n.source,type:n.type,direction:r?"outgoing":"incoming",label:n.label}})}const Yn=({pluginID:t,connectionID:e,resourceKey:n,resourceID:r,namespace:s="",direction:i="both",relationshipType:o,enabled:a=!0,refetchInterval:c=Kn})=>{const l=O(t),u=S.useQuery({queryKey:["RESOURCE_RELATED",l,e,n,s,r,i,o??null],queryFn:async()=>h.GetRelated(l,e,n,s,r,i,o??null),enabled:a&&!!l&&!!e&&!!n&&!!r,refetchInterval:c}),g={pluginId:l,connectionId:e,resourceKey:n,id:r,namespace:s},p=u.data??[];return{related:Ye(g,p),edges:p,isLoading:u.isLoading,isFetching:u.isFetching,error:u.error,refetch:u.refetch}},Jn=({pluginID:t,connectionID:e,resourceKey:n,resourceID:r,namespace:s="",maxDepth:i=3,enabled:o=!0,refetchInterval:a=1e4})=>{const c=O(t),l=S.useQuery({queryKey:["RESOURCE_DEPENDENCY_TREE",c,e,n,s,r,i],queryFn:async()=>h.GetDependencyTree(c,e,n,s,r,i),enabled:o&&!!c&&!!e&&!!n&&!!r,refetchInterval:a});return{tree:l.data??null,isLoading:l.isLoading,isFetching:l.isFetching,error:l.error,refetch:l.refetch}},Zn=()=>{const t=d.useContext(le);if(!t)throw new Error("useSettings must be used within a SettingsProvider");return t},Xn=({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 d.useMemo(()=>D.jsx(B.Link,{style:{textDecoration:"none",color:"inherit"},...n,to:s}),[n,s])};function Vn(){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=d.useCallback((o,a)=>{const{...c}=a??{};o.startsWith("/")?t(`${r}${o}`,c):t(o,c)},[t,r]);return d.useMemo(()=>({location:e,navigate:i,pluginPath:s}),[e,i,s])}class er{}class tr{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 D.jsx(this.root,{});const e=B.createMemoryRouter(this._routes||[]);return D.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 Je=(t=>(t.MISSING_MANIFEST="MISSING_MANIFEST",t.MISSING_PLUGIN="MISSING_PLUGIN",t.MISSING_ENTRYPOINT="MISSING_ENTRYPOINT",t))(Je||{});const nr=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]}},rr=t=>!t||t==="core"?"Core":t.charAt(0).toUpperCase()+t.slice(1);exports.ALL_SESSIONS_KEY=Q;exports.BottomDrawerContext=xe;exports.ConfirmationModalContext=Pe;exports.ErrorTypes=U;exports.ExtensionPointRegistry=yt;exports.ExtensionPointStore=Te;exports.ExtensionProvider=pt;exports.Link=Xn;exports.OperationsContext=de;exports.OperationsProvider=at;exports.PluginContext=X;exports.PluginContextProvider=rt;exports.PluginErrorCode=Je;exports.PluginWindow=tr;exports.PluginWindowRootProps=er;exports.RightDrawerContext=Fe;exports.SettingsContext=le;exports.SettingsProvider=ot;exports.SnackbarProvider=ht;exports.WatchState=P;exports.actionToSnackbar=be;exports.applyBatch=Be;exports.connectionListQueryKey=Me;exports.createErrorHandler=N;exports.defaultState=Re;exports.formatGroup=rr;exports.isCancelledError=ue;exports.parseAppError=$;exports.parseResourceKey=nr;exports.relationshipLabel=Hn;exports.showAppError=j;exports.toRelatedResources=Ye;exports.useActiveSyncs=Wn;exports.useBottomDrawer=pe;exports.useConfirmationModal=Dt;exports.useConnection=mt;exports.useConnectionNamespaces=Et;exports.useConnectionStatus=Ct;exports.useConnections=St;exports.useDependencyTree=Jn;exports.useEditorSchemas=Qn;exports.useEventBatcher=He;exports.useExec=vt;exports.useExecuteAction=$n;exports.useExtensionPoint=ft;exports.useExtensionRegistry=De;exports.useLogs=Rt;exports.useMetricProviders=xt;exports.useMetricProvidersForResource=Ue;exports.useMetricStream=Pt;exports.useOperations=ze;exports.usePluginContext=V;exports.usePluginData=wt;exports.usePluginRouter=Vn;exports.usePluginSettings=st;exports.usePortForwardSessions=It;exports.useRelatedResources=Yn;exports.useResolvedPluginId=O;exports.useResource=Tt;exports.useResourceActions=qn;exports.useResourceAreaComponent=At;exports.useResourceGroups=Mt;exports.useResourceMetrics=Ft;exports.useResourceMutations=Un;exports.useResourcePortForwarder=Ot;exports.useResourceSearch=Nt;exports.useResourceType=kt;exports.useResourceTypes=Lt;exports.useResources=Ln;exports.useRightDrawer=bt;exports.useSettings=Zn;exports.useSnackbar=q;exports.useStreamAction=Gn;exports.useWatchState=jn;
|