@perses-dev/splunk-plugin 0.2.0-beta.2 → 0.2.0-beta.3
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/__mf/js/{Splunk.98b2d5ad.js → Splunk.45c32f8a.js} +5 -5
- package/__mf/js/async/{121.cd990f2a.js → 121.7e1a0048.js} +2 -2
- package/__mf/js/async/{562.faedd192.js → 181.9e3df2c2.js} +2 -2
- package/__mf/js/async/{230.28ff3a01.js → 230.c390fc88.js} +1 -1
- package/__mf/js/async/{392.54d1105e.js → 392.dca74a49.js} +2 -2
- package/__mf/js/async/{43.c13dea67.js → 43.4cc39135.js} +2 -2
- package/__mf/js/async/{470.39364cc9.js → 470.4281575d.js} +2 -2
- package/__mf/js/async/{496.5533cf13.js → 496.28020072.js} +1 -1
- package/__mf/js/async/55.ba1a49d4.js +102 -0
- package/__mf/js/async/{181.45639ce7.js → 562.502b501d.js} +2 -2
- package/__mf/js/async/67.6b764531.js +53 -0
- package/__mf/js/async/{77.d9722d64.js → 77.44971754.js} +1 -1
- package/__mf/js/async/{788.e519d52f.js → 788.6ba539bc.js} +6 -6
- package/__mf/js/async/{873.84546c86.js → 873.1dce08b9.js} +1 -1
- package/__mf/js/async/{882.0bb195b0.js → 882.5fe2864d.js} +1 -1
- package/__mf/js/async/{941.049134e9.js → 941.a97f0fe0.js} +2 -2
- package/__mf/js/async/{963.4c102cc8.js → 963.9daceafd.js} +1 -1
- package/__mf/js/async/{967.49cac6cc.js → 967.b5ca912b.js} +1 -1
- package/__mf/js/async/{978.1b184143.js → 978.0bd5fc1b.js} +1 -1
- package/__mf/js/async/{982.8181aade.js → 982.533ef158.js} +2 -2
- package/__mf/js/async/{__federation_expose_SplunkDatasource.5b9ca25b.js → __federation_expose_SplunkDatasource.e019e371.js} +2 -2
- package/__mf/js/async/{__federation_expose_SplunkLogQuery.5e35f21f.js → __federation_expose_SplunkLogQuery.ecc1449e.js} +2 -2
- package/__mf/js/async/{__federation_expose_SplunkTimeSeriesQuery.62f3d6f2.js → __federation_expose_SplunkTimeSeriesQuery.50f80d8b.js} +2 -2
- package/__mf/js/async/{lib-router.02ac6b0e.js → lib-router.82be452e.js} +2 -2
- package/__mf/js/{main.4223bafa.js → main.8245bf2c.js} +5 -5
- package/lib/queries/constants.d.ts.map +1 -1
- package/mf-manifest.json +56 -56
- package/mf-stats.json +56 -56
- package/package.json +4 -4
- package/__mf/js/async/874.496bb61a.js +0 -4
- package/__mf/js/async/879.ab41564d.js +0 -102
- /package/__mf/js/async/{121.cd990f2a.js.LICENSE.txt → 121.7e1a0048.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{181.45639ce7.js.LICENSE.txt → 181.9e3df2c2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.54d1105e.js.LICENSE.txt → 392.dca74a49.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{43.c13dea67.js.LICENSE.txt → 43.4cc39135.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.39364cc9.js.LICENSE.txt → 470.4281575d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{562.faedd192.js.LICENSE.txt → 562.502b501d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{874.496bb61a.js.LICENSE.txt → 67.6b764531.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{788.e519d52f.js.LICENSE.txt → 788.6ba539bc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.049134e9.js.LICENSE.txt → 941.a97f0fe0.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{982.8181aade.js.LICENSE.txt → 982.533ef158.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_SplunkDatasource.5b9ca25b.js.LICENSE.txt → __federation_expose_SplunkDatasource.e019e371.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_SplunkLogQuery.5e35f21f.js.LICENSE.txt → __federation_expose_SplunkLogQuery.ecc1449e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_SplunkTimeSeriesQuery.62f3d6f2.js.LICENSE.txt → __federation_expose_SplunkTimeSeriesQuery.50f80d8b.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.02ac6b0e.js.LICENSE.txt → lib-router.82be452e.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! For license information please see 67.6b764531.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_Splunk_0_2_0_beta_3=self.chunk_Splunk_0_2_0_beta_3||[]).push([["67"],{4178(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z","Alert")},46001(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z","ArrowDown")},65168(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z","ArrowUp")},3908(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z","Check")},42514(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M19,3H14.82C14.4,1.84 13.3,1 12,1C10.7,1 9.6,1.84 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M7,7H17V5H19V19H5V5H7V7Z","ClipboardOutline")},10871(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z","Cog")},54042(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z","Download")},50894(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M12,19.58V19.58C10.4,19.58 8.89,18.96 7.76,17.83C6.62,16.69 6,15.19 6,13.58C6,12 6.62,10.47 7.76,9.34L12,5.1M17.66,7.93L12,2.27V2.27L6.34,7.93C3.22,11.05 3.22,16.12 6.34,19.24C7.9,20.8 9.95,21.58 12,21.58C14.05,21.58 16.1,20.8 17.66,19.24C20.78,16.12 20.78,11.05 17.66,7.93Z","InvertColors")},15810(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z","Link")},70002(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M17 22V20H20V17H22V20.5C22 20.89 21.84 21.24 21.54 21.54C21.24 21.84 20.89 22 20.5 22H17M7 22H3.5C3.11 22 2.76 21.84 2.46 21.54C2.16 21.24 2 20.89 2 20.5V17H4V20H7V22M17 2H20.5C20.89 2 21.24 2.16 21.54 2.46C21.84 2.76 22 3.11 22 3.5V7H20V4H17V2M7 2V4H4V7H2V3.5C2 3.11 2.16 2.76 2.46 2.46C2.76 2.16 3.11 2 3.5 2H7M10.5 6C13 6 15 8 15 10.5C15 11.38 14.75 12.2 14.31 12.9L17.57 16.16L16.16 17.57L12.9 14.31C12.2 14.75 11.38 15 10.5 15C8 15 6 13 6 10.5C6 8 8 6 10.5 6M10.5 8C9.12 8 8 9.12 8 10.5C8 11.88 9.12 13 10.5 13C11.88 13 13 11.88 13 10.5C13 9.12 11.88 8 10.5 8Z","MagnifyScan")},42524(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M19,13H5V11H19V13Z","Minus")},84864(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M7,13H17V11H7","MinusCircleOutline")},10571(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z","OpenInNew")},4918(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M14,19H18V5H14M6,19H10V5H6V19Z","Pause")},49603(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z","Pencil")},63808(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M8,5.14V19.14L19,12.14L8,5.14Z","Play")},86138(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,7H11V11H7V13H11V17H13V13H17V11H13V7Z","PlusCircleOutline")},74987(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z","Refresh")},24483(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M2 12C2 16.97 6.03 21 11 21C13.39 21 15.68 20.06 17.4 18.4L15.9 16.9C14.63 18.25 12.86 19 11 19C4.76 19 1.64 11.46 6.05 7.05C10.46 2.64 18 5.77 18 12H15L19 16H19.1L23 12H20C20 7.03 15.97 3 11 3C6.03 3 2 7.03 2 12Z","Reload")},82920(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M17.5 15.5C17.5 16.61 16.61 17.5 15.5 17.5S13.5 16.61 13.5 15.5 14.4 13.5 15.5 13.5 17.5 14.4 17.5 15.5M8.5 13.5C7.4 13.5 6.5 14.4 6.5 15.5S7.4 17.5 8.5 17.5 10.5 16.61 10.5 15.5 9.61 13.5 8.5 13.5M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16Z","RobotOutline")},22996(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M2,21L23,12L2,3V10L17,12L2,14V21Z","Send")},22182(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M18,18H6V6H18V18Z","Stop")},70645(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M12,18A6,6 0 0,1 6,12C6,11 6.25,10.03 6.7,9.2L5.24,7.74C4.46,8.97 4,10.43 4,12A8,8 0 0,0 12,20V23L16,19L12,15M12,4V1L8,5L12,9V6A6,6 0 0,1 18,12C18,13 17.75,13.97 17.3,14.8L18.76,16.26C19.54,15.03 20,13.57 20,12A8,8 0 0,0 12,4Z","Sync")},4150(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z","TrashCan")},27683(e,t,r){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=(0,((n=r(1448))&&n.__esModule?n:{default:n}).default)("M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z","Upload")},79524(e,t,r){let n=Symbol("SemVer ANY");class i{static get ANY(){return n}constructor(e,t){if(t=s(t),e instanceof i)if(!!t.loose===e.loose)return e;else e=e.value;u("comparator",e=e.trim().split(/\s+/).join(" "),t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===n?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(e){let t=this.options.loose?a[o.COMPARATORLOOSE]:a[o.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(u("Comparator.test",e,this.options.loose),this.semver===n||e===n)return!0;if("string"==typeof e)try{e=new c(e,this.options)}catch(e){return!1}return l(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof i))throw TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=s(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||l(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||l(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">"))}}e.exports=i;let s=r(57095),{safeRe:a,t:o}=r(86850),l=r(23811),u=r(79796),c=r(37944),d=r(68395)},68395(e,t,r){let n=/\s+/g;class i{constructor(e,t){if(t=a(t),e instanceof i)if(!!t.loose===e.loose&&!!t.includePrerelease===e.includePrerelease)return e;else return new i(e.raw,t);if(e instanceof o)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(n," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!b(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1){for(const e of this.set)if(1===e.length&&x(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(y,"");let t=((this.options.includePrerelease&&g)|(this.options.loose&&v))+":"+e,r=s.get(t);if(r)return r;let n=this.options.loose,i=n?c[p.HYPHENRANGELOOSE]:c[p.HYPHENRANGE];l("hyphen replace",e=e.replace(i,T(this.options.includePrerelease))),l("comparator trim",e=e.replace(c[p.COMPARATORTRIM],h)),l("tilde trim",e=e.replace(c[p.TILDETRIM],f)),l("caret trim",e=e.replace(c[p.CARETTRIM],m));let a=e.split(" ").map(e=>_(e,this.options)).join(" ").split(/\s+/).map(e=>P(e,this.options));n&&(a=a.filter(e=>(l("loose invalid filter",e,this.options),!!e.match(c[p.COMPARATORLOOSE])))),l("range list",a);let u=new Map;for(let e of a.map(e=>new o(e,this.options))){if(b(e))return[e];u.set(e.value,e)}u.size>1&&u.has("")&&u.delete("");let d=[...u.values()];return s.set(t,d),d}intersects(e,t){if(!(e instanceof i))throw TypeError("a Range is required");return this.set.some(r=>A(r,t)&&e.set.some(e=>A(e,t)&&r.every(r=>e.every(e=>r.intersects(e,t)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if($(this.set[t],e,this.options))return!0;return!1}}e.exports=i;let s=new(r(51158)),a=r(57095),o=r(79524),l=r(79796),u=r(37944),{safeRe:c,src:d,t:p,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:m}=r(86850),{FLAG_INCLUDE_PRERELEASE:g,FLAG_LOOSE:v}=r(59630),y=RegExp(d[p.BUILD],"g"),b=e=>"<0.0.0-0"===e.value,x=e=>""===e.value,A=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();for(;r&&n.length;)r=n.every(e=>i.intersects(e,t)),i=n.pop();return r},_=(e,t)=>(l("comp",e=e.replace(c[p.BUILD],""),t),l("caret",e=E(e,t)),l("tildes",e=w(e,t)),l("xrange",e=S(e,t)),l("stars",e=R(e,t)),e),j=e=>!e||"x"===e.toLowerCase()||"*"===e,w=(e,t)=>e.trim().split(/\s+/).map(e=>C(e,t)).join(" "),C=(e,t)=>{let r=t.loose?c[p.TILDELOOSE]:c[p.TILDE],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,s,a)=>{let o;return l("tilde",e,t,r,i,s,a),j(r)?o="":j(i)?o=`>=${r}.0.0${n} <${+r+1}.0.0-0`:j(s)?o=`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:a?(l("replaceTilde pr",a),o=`>=${r}.${i}.${s}-${a} <${r}.${+i+1}.0-0`):o=`>=${r}.${i}.${s} <${r}.${+i+1}.0-0`,l("tilde return",o),o})},E=(e,t)=>e.trim().split(/\s+/).map(e=>O(e,t)).join(" "),O=(e,t)=>{l("caret",e,t);let r=t.loose?c[p.CARETLOOSE]:c[p.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,s,a)=>{let o;return l("caret",e,t,r,i,s,a),j(r)?o="":j(i)?o=`>=${r}.0.0${n} <${+r+1}.0.0-0`:j(s)?o="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(l("replaceCaret pr",a),o="0"===r?"0"===i?`>=${r}.${i}.${s}-${a} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s}-${a} <${+r+1}.0.0-0`):(l("no pr"),o="0"===r?"0"===i?`>=${r}.${i}.${s} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s} <${+r+1}.0.0-0`),l("caret return",o),o})},S=(e,t)=>(l("replaceXRanges",e,t),e.split(/\s+/).map(e=>k(e,t)).join(" ")),k=(e,t)=>{e=e.trim();let r=t.loose?c[p.XRANGELOOSE]:c[p.XRANGE];return e.replace(r,(r,n,i,s,a,o)=>{let u,c,d;if(l("xRange",e,r,n,i,s,a,o),u=i,c=s,d=a,j(u)&&!j(c)||j(c)&&d&&!j(d))return e;let p=j(i),h=p||j(s),f=h||j(a);return"="===n&&f&&(n=""),o=t.includePrerelease?"-0":"",p?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&f?(h&&(s=0),a=0,">"===n?(n=">=",h?(i=+i+1,s=0):s=+s+1,a=0):"<="===n&&(n="<",h?i=+i+1:s=+s+1),"<"===n&&(o="-0"),r=`${n+i}.${s}.${a}${o}`):h?r=`>=${i}.0.0${o} <${+i+1}.0.0-0`:f&&(r=`>=${i}.${s}.0${o} <${i}.${+s+1}.0-0`),l("xRange return",r),r})},R=(e,t)=>(l("replaceStars",e,t),e.trim().replace(c[p.STAR],"")),P=(e,t)=>(l("replaceGTE0",e,t),e.trim().replace(c[t.includePrerelease?p.GTE0PRE:p.GTE0],"")),T=e=>(t,r,n,i,s,a,o,l,u,c,d,p)=>(r=j(n)?"":j(i)?`>=${n}.0.0${e?"-0":""}`:j(s)?`>=${n}.${i}.0${e?"-0":""}`:a?`>=${r}`:`>=${r}${e?"-0":""}`,l=j(u)?"":j(c)?`<${+u+1}.0.0-0`:j(d)?`<${u}.${+c+1}.0-0`:p?`<=${u}.${c}.${d}-${p}`:e?`<${u}.${c}.${+d+1}-0`:`<=${l}`,`${r} ${l}`.trim()),$=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(l(e[r].semver),e[r].semver!==o.ANY&&e[r].semver.prerelease.length>0){let n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0}},37944(e,t,r){let n=r(79796),{MAX_LENGTH:i,MAX_SAFE_INTEGER:s}=r(59630),{safeRe:a,t:o}=r(86850),l=r(57095),{compareIdentifiers:u}=r(14031);class c{constructor(e,t){if(t=l(t),e instanceof c)if(!!t.loose===e.loose&&!!t.includePrerelease===e.includePrerelease)return e;else e=e.version;else if("string"!=typeof e)throw TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>i)throw TypeError(`version is longer than ${i} characters`);n("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const r=e.trim().match(t.loose?a[o.LOOSE]:a[o.FULL]);if(!r)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>s||this.major<0)throw TypeError("Invalid major version");if(this.minor>s||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>s||this.patch<0)throw TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<s)return t}return e}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(n("SemVer.compare",this.version,this.options,e),!(e instanceof c)){if("string"==typeof e&&e===this.version)return 0;e=new c(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return(e instanceof c||(e=new c(e,this.options)),this.major<e.major)?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:+(this.patch>e.patch)}comparePre(e){if(e instanceof c||(e=new c(e,this.options)),this.prerelease.length&&!e.prerelease.length)return -1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],i=e.prerelease[t];if(n("prerelease compare",t,r,i),void 0===r&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===r)return -1;else if(r===i)continue;else return u(r,i)}while(++t)}compareBuild(e){e instanceof c||(e=new c(e,this.options));let t=0;do{let r=this.build[t],i=e.build[t];if(n("build compare",t,r,i),void 0===r&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===r)return -1;else if(r===i)continue;else return u(r,i)}while(++t)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw Error("invalid increment argument: identifier is empty");if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(0!==this.minor||0!==this.patch||0===this.prerelease.length)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(0!==this.patch||0===this.prerelease.length)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{let e=+!!Number(r);if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),((e,t)=>{let r=t.split(".");if(r.length>e.length)return!1;for(let t=0;t<r.length;t++)if(0!==u(e[t],r[t]))return!1;return!0})(this.prerelease,t)?isNaN(this.prerelease[t.split(".").length])&&(this.prerelease=n):this.prerelease=n}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=c},37994(e,t,r){let n=r(15860);e.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null}},23811(e,t,r){let n=r(36909),i=r(97659),s=r(60144),a=r(82077),o=r(30599),l=r(17092);e.exports=(e,t,r,u)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return n(e,r,u);case"!=":return i(e,r,u);case">":return s(e,r,u);case">=":return a(e,r,u);case"<":return o(e,r,u);case"<=":return l(e,r,u);default:throw TypeError(`Invalid operator: ${t}`)}}},45334(e,t,r){let n=r(37944),i=r(15860),{safeRe:s,t:a}=r(86850);e.exports=(e,t)=>{if(e instanceof n)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){let n,i=t.includePrerelease?s[a.COERCERTLFULL]:s[a.COERCERTL];for(;(n=i.exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&n.index+n[0].length===r.index+r[0].length||(r=n),i.lastIndex=n.index+n[1].length+n[2].length;i.lastIndex=-1}else r=e.match(t.includePrerelease?s[a.COERCEFULL]:s[a.COERCE]);if(null===r)return null;let o=r[2],l=r[3]||"0",u=r[4]||"0",c=t.includePrerelease&&r[5]?`-${r[5]}`:"",d=t.includePrerelease&&r[6]?`+${r[6]}`:"";return i(`${o}.${l}.${u}${c}${d}`,t)}},2801(e,t,r){let n=r(37944);e.exports=(e,t,r)=>{let i=new n(e,r),s=new n(t,r);return i.compare(s)||i.compareBuild(s)}},97023(e,t,r){let n=r(55380);e.exports=(e,t)=>n(e,t,!0)},55380(e,t,r){let n=r(37944);e.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))},80660(e,t,r){let n=r(15860);e.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),s=r.compare(i);if(0===s)return null;let a=s>0,o=a?r:i,l=a?i:r,u=!!o.prerelease.length;if(l.prerelease.length&&!u){if(!l.patch&&!l.minor)return"major";if(0===l.compareMain(o))return l.minor&&!l.patch?"minor":"patch"}let c=u?"pre":"";return r.major!==i.major?c+"major":r.minor!==i.minor?c+"minor":r.patch!==i.patch?c+"patch":"prerelease"}},36909(e,t,r){let n=r(55380);e.exports=(e,t,r)=>0===n(e,t,r)},60144(e,t,r){let n=r(55380);e.exports=(e,t,r)=>n(e,t,r)>0},82077(e,t,r){let n=r(55380);e.exports=(e,t,r)=>n(e,t,r)>=0},35955(e,t,r){let n=r(37944);e.exports=(e,t,r,i,s)=>{"string"==typeof r&&(s=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,s).version}catch(e){return null}}},30599(e,t,r){let n=r(55380);e.exports=(e,t,r)=>0>n(e,t,r)},17092(e,t,r){let n=r(55380);e.exports=(e,t,r)=>0>=n(e,t,r)},82966(e,t,r){let n=r(37944);e.exports=(e,t)=>new n(e,t).major},65986(e,t,r){let n=r(37944);e.exports=(e,t)=>new n(e,t).minor},97659(e,t,r){let n=r(55380);e.exports=(e,t,r)=>0!==n(e,t,r)},15860(e,t,r){let n=r(37944);e.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}},71617(e,t,r){let n=r(37944);e.exports=(e,t)=>new n(e,t).patch},59613(e,t,r){let n=r(15860);e.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}},22862(e,t,r){let n=r(55380);e.exports=(e,t,r)=>n(t,e,r)},36033(e,t,r){let n=r(2801);e.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))},81722(e,t,r){let n=r(68395);e.exports=(e,t,r)=>{try{t=new n(t,r)}catch(e){return!1}return t.test(e)}},90603(e,t,r){let n=r(2801);e.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))},33773(e,t,r){let n=r(15860),i=r(59630),s=r(37944),a=e=>e.startsWith("pre");e.exports=(e,t,r)=>{let o,l;if(!i.RELEASE_TYPES.includes(t))return null;let u=(o=e,l=r,n(o instanceof s?o.version:o,l));return u&&((e,t)=>{if(a(t))return e.version;switch(e.prerelease=[],t){case"major":e.minor=0,e.patch=0;break;case"minor":e.patch=0}return e.format()})(u,t)}},87645(e,t,r){let n=r(15860);e.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}},98449(e,t,r){let n=r(86850),i=r(59630),s=r(37944),a=r(14031),o=r(15860),l=r(87645),u=r(37994),c=r(35955),d=r(80660),p=r(82966),h=r(65986),f=r(71617),m=r(59613),g=r(55380),v=r(22862),y=r(97023),b=r(2801),x=r(90603),A=r(36033),_=r(60144),j=r(30599),w=r(36909),C=r(97659),E=r(82077),O=r(17092),S=r(23811),k=r(45334),R=r(33773),P=r(79524),T=r(68395),$=r(81722),I=r(10651),M=r(47840),z=r(7930),L=r(3489),V=r(17494),N=r(45463),F=r(67871),D=r(74266),q=r(81112);e.exports={parse:o,valid:l,clean:u,inc:c,diff:d,major:p,minor:h,patch:f,prerelease:m,compare:g,rcompare:v,compareLoose:y,compareBuild:b,sort:x,rsort:A,gt:_,lt:j,eq:w,neq:C,gte:E,lte:O,cmp:S,coerce:k,truncate:R,Comparator:P,Range:T,satisfies:$,toComparators:I,maxSatisfying:M,minSatisfying:z,minVersion:L,validRange:V,outside:N,gtr:F,ltr:D,intersects:q,simplifyRange:r(61465),subset:r(19252),SemVer:s,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},59630(e){e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||0x1fffffffffffff,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},79796(e){e.exports="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{}},14031(e){let t=/^[0-9]+$/,r=(e,r)=>{if("number"==typeof e&&"number"==typeof r)return e===r?0:e<r?-1:1;let n=t.test(e),i=t.test(r);return n&&i&&(e*=1,r*=1),e===r?0:n&&!i?-1:i&&!n?1:e<r?-1:1};e.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}},51158(e){e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(void 0!==t)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},57095(e){let t=Object.freeze({loose:!0}),r=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:r},86850(e,t,r){let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:s}=r(59630),a=r(79796),o=(t=e.exports={}).re=[],l=t.safeRe=[],u=t.src=[],c=t.safeSrc=[],d=t.t={},p=0,h="[a-zA-Z0-9-]",f=[["\\s",1],["\\d",s],[h,i]],m=(e,t,r)=>{let n=(e=>{for(let[t,r]of f)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=p++;a(e,i,t),d[e]=i,u[i]=t,c[i]=n,o[i]=new RegExp(t,r?"g":void 0),l[i]=new RegExp(n,r?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${h}*`),m("MAINVERSION",`(${u[d.NUMERICIDENTIFIER]})\\.(${u[d.NUMERICIDENTIFIER]})\\.(${u[d.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[d.NUMERICIDENTIFIERLOOSE]})\\.(${u[d.NUMERICIDENTIFIERLOOSE]})\\.(${u[d.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[d.NONNUMERICIDENTIFIER]}|${u[d.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[d.NONNUMERICIDENTIFIER]}|${u[d.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[d.PRERELEASEIDENTIFIER]}(?:\\.${u[d.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[d.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${h}+`),m("BUILD",`(?:\\+(${u[d.BUILDIDENTIFIER]}(?:\\.${u[d.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[d.MAINVERSION]}${u[d.PRERELEASE]}?${u[d.BUILD]}?`),m("FULL",`^${u[d.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[d.MAINVERSIONLOOSE]}${u[d.PRERELEASELOOSE]}?${u[d.BUILD]}?`),m("LOOSE",`^${u[d.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[d.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[d.XRANGEIDENTIFIER]})(?:\\.(${u[d.XRANGEIDENTIFIER]})(?:\\.(${u[d.XRANGEIDENTIFIER]})(?:${u[d.PRERELEASE]})?${u[d.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[d.XRANGEIDENTIFIERLOOSE]})(?:${u[d.PRERELEASELOOSE]})?${u[d.BUILD]}?)?)?`),m("XRANGE",`^${u[d.GTLT]}\\s*${u[d.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[d.GTLT]}\\s*${u[d.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),m("COERCE",`${u[d.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[d.COERCEPLAIN]+`(?:${u[d.PRERELEASE]})?`+`(?:${u[d.BUILD]})?`+"(?:$|[^\\d])"),m("COERCERTL",u[d.COERCE],!0),m("COERCERTLFULL",u[d.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[d.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${u[d.LONETILDE]}${u[d.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[d.LONETILDE]}${u[d.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[d.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${u[d.LONECARET]}${u[d.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[d.LONECARET]}${u[d.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[d.GTLT]}\\s*(${u[d.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[d.GTLT]}\\s*(${u[d.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[d.GTLT]}\\s*(${u[d.LOOSEPLAIN]}|${u[d.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[d.XRANGEPLAIN]})\\s+-\\s+(${u[d.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[d.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},67871(e,t,r){let n=r(45463);e.exports=(e,t,r)=>n(e,t,">",r)},81112(e,t,r){let n=r(68395);e.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))},74266(e,t,r){let n=r(45463);e.exports=(e,t,r)=>n(e,t,"<",r)},47840(e,t,r){let n=r(37944),i=r(68395);e.exports=(e,t,r)=>{let s=null,a=null,o=null;try{o=new i(t,r)}catch(e){return null}return e.forEach(e=>{o.test(e)&&(!s||-1===a.compare(e))&&(a=new n(s=e,r))}),s}},7930(e,t,r){let n=r(37944),i=r(68395);e.exports=(e,t,r)=>{let s=null,a=null,o=null;try{o=new i(t,r)}catch(e){return null}return e.forEach(e=>{o.test(e)&&(!s||1===a.compare(e))&&(a=new n(s=e,r))}),s}},3489(e,t,r){let n=r(37944),i=r(68395),s=r(60144);e.exports=(e,t)=>{e=new i(e,t);let r=new n("0.0.0");if(e.test(r)||(r=new n("0.0.0-0"),e.test(r)))return r;r=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],a=null;i.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":(!a||s(t,a))&&(a=t);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),a&&(!r||s(r,a))&&(r=a)}return r&&e.test(r)?r:null}},45463(e,t,r){let n=r(37944),i=r(79524),{ANY:s}=i,a=r(68395),o=r(81722),l=r(60144),u=r(30599),c=r(17092),d=r(82077);e.exports=(e,t,r,p)=>{let h,f,m,g,v;switch(e=new n(e,p),t=new a(t,p),r){case">":h=l,f=c,m=u,g=">",v=">=";break;case"<":h=u,f=d,m=l,g="<",v="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(o(e,t,p))return!1;for(let r=0;r<t.set.length;++r){let n=t.set[r],a=null,o=null;if(n.forEach(e=>{e.semver===s&&(e=new i(">=0.0.0")),a=a||e,o=o||e,h(e.semver,a.semver,p)?a=e:m(e.semver,o.semver,p)&&(o=e)}),a.operator===g||a.operator===v||(!o.operator||o.operator===g)&&f(e,o.semver)||o.operator===v&&m(e,o.semver))return!1}return!0}},61465(e,t,r){let n=r(81722),i=r(55380);e.exports=(e,t,r)=>{let s=[],a=null,o=null,l=e.sort((e,t)=>i(e,t,r));for(let e of l)n(e,t,r)?(o=e,a||(a=e)):(o&&s.push([a,o]),o=null,a=null);a&&s.push([a,null]);let u=[];for(let[e,t]of s)e===t?u.push(e):t||e!==l[0]?t?e===l[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");let c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},19252(e,t,r){let n=r(68395),i=r(79524),{ANY:s}=i,a=r(81722),o=r(55380),l=[new i(">=0.0.0-0")],u=[new i(">=0.0.0")],c=(e,t,r)=>{let n,i,c,h,f,m,g;if(e===t)return!0;if(1===e.length&&e[0].semver===s)if(1===t.length&&t[0].semver===s)return!0;else e=r.includePrerelease?l:u;if(1===t.length&&t[0].semver===s)if(r.includePrerelease)return!0;else t=u;let v=new Set;for(let t of e)">"===t.operator||">="===t.operator?n=d(n,t,r):"<"===t.operator||"<="===t.operator?i=p(i,t,r):v.add(t.semver);if(v.size>1)return null;if(n&&i&&((c=o(n.semver,i.semver,r))>0||0===c&&(">="!==n.operator||"<="!==i.operator)))return null;for(let e of v){if(n&&!a(e,String(n),r)||i&&!a(e,String(i),r))return null;for(let n of t)if(!a(e,String(n),r))return!1;return!0}let y=!!i&&!r.includePrerelease&&!!i.semver.prerelease.length&&i.semver,b=!!n&&!r.includePrerelease&&!!n.semver.prerelease.length&&n.semver;for(let e of(y&&1===y.prerelease.length&&"<"===i.operator&&0===y.prerelease[0]&&(y=!1),t)){if(g=g||">"===e.operator||">="===e.operator,m=m||"<"===e.operator||"<="===e.operator,n){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if((h=d(n,e,r))===e&&h!==n)return!1}else if(">="===n.operator&&!e.test(n.semver))return!1}if(i){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),"<"===e.operator||"<="===e.operator){if((f=p(i,e,r))===e&&f!==i)return!1}else if("<="===i.operator&&!e.test(i.semver))return!1}if(!e.operator&&(i||n)&&0!==c)return!1}return(!n||!m||!!i||0===c)&&(!i||!g||!!n||0===c)&&!b&&!y&&!0},d=(e,t,r)=>{if(!e)return t;let n=o(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},p=(e,t,r)=>{if(!e)return t;let n=o(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;e:for(let n of e.set){for(let e of t.set){let t=c(n,e,r);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}},10651(e,t,r){let n=r(68395);e.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "))},17494(e,t,r){let n=r(68395);e.exports=(e,t)=>{try{return new n(e,t).range||"*"}catch(e){return null}}},32473(e,t,r){var n=r(70451),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=n.useState,a=n.useEffect,o=n.useLayoutEffect,l=n.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!i(e,r)}catch(e){return!0}}var c="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),n=s({inst:{value:r,getSnapshot:t}}),i=n[0].inst,c=n[1];return o(function(){i.value=r,i.getSnapshot=t,u(i)&&c({inst:i})},[e,r,t]),a(function(){return u(i)&&c({inst:i}),e(function(){u(i)&&c({inst:i})})},[e]),l(r),r};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c},43676(e,t,r){e.exports=r(32473)},18019(e,t,r){r.r(t),r.d(t,{zodResolver:()=>d});var n=r(79215);let i=(e,t,r)=>{if(e&&"reportValidity"in e){let i=(0,n.get)(r,t);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},s=(e,t)=>{for(let r in t.fields){let n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?i(n.ref,r,e):n&&n.refs&&n.refs.forEach(t=>i(t,r,e))}},a=(e,t)=>{t.shouldUseNativeValidation&&s(e,t);let r={};for(let i in e){let s=(0,n.get)(t.fields,i),a=Object.assign(e[i]||{},{ref:s&&s.refs?s.refs[0]:s&&s.ref});if(o(t.names||Object.keys(e),i)){let e=Object.assign({},(0,n.get)(r,i));(0,n.set)(e,"root",a),(0,n.set)(r,i,e)}else(0,n.set)(r,i,a)}return r},o=(e,t)=>{let r=l(t).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(e=>l(e).match(`^${r}\\.\\d+`))};function l(e){return e.replace(/\[(\d+)]/g,".$1").replace(/[[\]]/g,"")}function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}function c(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function d(e,t,r){if(void 0===r&&(r={}),"_zod"in e&&"object"==typeof e._zod)return function(i,o,l){try{return Promise.resolve(c(function(){function n(e){return l.shouldUseNativeValidation&&s({},l),{errors:{},values:r.raw?Object.assign({},i):e}}return"sync"===r.mode?n(e.parse(i,t)):Promise.resolve(e.parseAsync(i,t)).then(n)},function(e){var t;if(!(null==e||null==(t=e._zod)||null==(t=t.traits)||!t.has("$ZodError")))return{values:{},errors:a(function(e,t){for(var r=Object.create(null);e.length;)!function(){var i=e[0],s=i.code,a=i.message,o=i.path.join(".");if(!r[o])if("invalid_union"===i.code&&i.errors.length>0){var l,c,d=i.errors.reduce(function(e,t){return t.length<e.length?t:e})[0];r[o]={message:null!=(l=null==d?void 0:d.message)?l:a,type:null!=(c=null==d?void 0:d.code)?c:s}}else r[o]={message:a,type:s};if("invalid_union"===i.code&&i.errors.forEach(function(t){return t.forEach(function(t){return e.push(u({},t,{path:[].concat(i.path,t.path)}))})}),t){var p=r[o].types,h=p&&p[i.code];r[o]=(0,n.appendErrors)(o,t,r,s,h?[].concat(h,i.message):i.message)}e.shift()}();return r}(e.issues,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)};throw e}))}catch(e){return Promise.reject(e)}};if("_def"in e&&"object"==typeof e._def)return function(i,o,l){try{return Promise.resolve(c(function(){return Promise.resolve(e["sync"===r.mode?"parse":"parseAsync"](i,t)).then(function(e){return l.shouldUseNativeValidation&&s({},l),{errors:{},values:r.raw?Object.assign({},i):e}})},function(e){if(Array.isArray(null==e?void 0:e.issues))return{values:{},errors:a(function(e,t){for(var r=Object.create(null);e.length;){var i=e[0],s=i.code,a=i.message,o=i.path.join(".");if(!r[o])if("unionErrors"in i){var l,u,c=i.unionErrors.reduce(function(e,t){return t.errors.length<e.errors.length?t:e}).errors[0];r[o]={message:null!=(l=null==c?void 0:c.message)?l:a,type:null!=(u=null==c?void 0:c.code)?u:s}}else r[o]={message:a,type:s};if("unionErrors"in i&&i.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var d=r[o].types,p=d&&d[i.code];r[o]=(0,n.appendErrors)(o,t,r,s,p?[].concat(p,i.message):i.message)}e.shift()}return r}(e.errors,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)};throw e}))}catch(e){return Promise.reject(e)}};throw Error("Invalid input: not a Zod schema")}},65152(e,t,r){async function n(...e){let t=await globalThis.fetch(...e);if(!1===t.ok){let e=t.headers.get("content-type");if(e?.includes("application/json")){let e=await t.clone().json();if(e.error)throw new a(e.error,t.status);if(e.message)throw new a(e.message,t.status)}let r=await t.clone().text();if(r)throw new a(r,t.status);throw new s(t)}return t}async function i(...e){let t=await n(...e);if(!t.ok)throw new s(t);return await t.json()}r.d(t,{hd:()=>n,x6:()=>i});class s extends Error{status;constructor(e){super(`${e.status} ${e.statusText}`),this.status=e.status,Object.setPrototypeOf(this,s.prototype)}}class a extends Error{status;constructor(e,t){super(e),this.status=t,Object.setPrototypeOf(this,a.prototype)}}},64846(e,t,r){let n,i,s,a,o,l,u,c,d,p,h,f,m,g,v,y,b,x,A;r.r(t),r.d(t,{useDisableAutoRefreshSetting:()=>aZ,DEFAULT_CALCULATION:()=>"last",usePluginBuiltinVariableDefinitions:()=>s1,DatasourceSelect:()=>oj,SILENCES_QUERY_KEY:()=>uA,useAnnotationData:()=>on,useTimeZoneParams:()=>cG,transformQueryResults:()=>uN,TimeRangeContext:()=>aW,DEFAULT_ANNOTATION_COLOR:()=>ai,ValidationProvider:()=>iJ,VariableEditorForm:()=>cy,VariablePreview:()=>ch,TOOLTIP_TEXT:()=>u7,ANNOTATION_KEY:()=>ot,useVariableValues:()=>a6,CALCULATIONS_CONFIG:()=>oc,useDatasourceClient:()=>aT,DatasourceEditorForm:()=>ov,parseVariables:()=>z.parseVariables,DEFAULT_REFRESH_INTERVAL_OPTIONS:()=>aL,formatLegendName:()=>da,useUsageMetrics:()=>uz,TimeRangeProvider:()=>aX,VariableContext:()=>a3,refreshIntervalQueryConfig:()=>cQ,defaultQueryName:()=>us,useBuiltinVariableContext:()=>a2,useUsageMetricsContext:()=>uM,useAlertsQueries:()=>um,getPluginModuleCompoundKey:()=>u5,useListPluginMetadata:()=>s0,datasourceSelectValueToSelector:()=>ok,decodeTimeRangeValue:()=>cD,ACTION_ICONS:()=>lq,PluginEditor:()=>an,getCalculations:()=>od,ItemSelectionActionsEditor:()=>lH,PluginKindSelect:()=>s2,PluginRegistryContext:()=>sG,escapeCsvValue:()=>dd,buildPanelEditorSchema:()=>iW,TimeRangeSettingsContext:()=>aN,DEFAULT_REPEAT_ALIGNMENT:()=>lW,PluginLoaderComponent:()=>d9,calculateVolumeInterval:()=>cA,TimeRangeProviderWithQueryParams:()=>cJ,executeAction:()=>c9,useListDatasourceSelectItems:()=>aP,useProfileQueries:()=>ux,DataQueriesProvider:()=>uU,JSON_QUERY_KEY:()=>ug,PROFILE_QUERY_KEY:()=>ub,PanelSpecEditor:()=>u2,filterVariableList:()=>ct,getActiveTimeSeriesQueries:()=>uk,useAllVariableValues:()=>a8,dynamicImportPluginLoader:()=>c_,useDataQueries:()=>uq,usePlugin:()=>sX,useTimeRangeSettingsContext:()=>aF,useBuiltinVariableDefinitions:()=>a5,useTimeSeriesQueries:()=>uE,TimeRangeProviderBasic:()=>cX,VariableStoreStateMap:()=>a9,formatTimestampISO:()=>dc,useInitialRefreshInterval:()=>cW,useSuggestedStepMs:()=>aJ,VariableListPreview:()=>cf,optionValueToSelector:()=>oO,getCalculation:()=>op,usePluginRegistry:()=>sJ,sanitizeFilename:()=>du,useEvent:()=>at,usePluginRuntime:()=>d4,LayoutEditor:()=>lX,getVariableDefinitionFromState:()=>cd,useReplaceVariablesInString:()=>oe,DatasourceStoreContext:()=>ak,useValidationSchemas:()=>iG,LEGEND_POSITIONS_CONFIG:()=>l4,replaceVariablesInString:()=>a7,selectorToOptionValue:()=>oE,DEFAULT_MAX_PER_ROW:()=>4,usePlugins:()=>sY,TimeRangeParam:()=>cq,useTimeRangeContext:()=>aK,DatasourceName:()=>ow,PluginRegistry:()=>u3,BuiltinVariableContext:()=>a1,OptionsEditorRadios:()=>ln,parseVariablesAndFormat:()=>z.parseVariablesAndFormat,UsageMetricsProvider:()=>uV,validateLegendSpec:()=>l6,registerHostSharedModules:()=>dX,PluginSpecEditor:()=>ae,TimeRangeControls:()=>ce,UsageMetricsContext:()=>uI,useDataQueriesContext:()=>uD,useSetRefreshIntervalParams:()=>cK,getInitialState:()=>cc,isTimeSeriesValueTuple:()=>cj,RepeatLayoutPreview:()=>lK,remotePluginLoader:()=>pt,useShowZoomRangeSetting:()=>aU,InterpolationFormat:()=>z.InterpolationFormat,generateQueryNames:()=>ua,DatasourceTestConnectionButton:()=>o$,useRouterContext:()=>c7,LEGEND_MODE_CONFIG:()=>l5,extractExportableData:()=>ds,useDatasource:()=>a$,RouterContext:()=>c8,ValidationSchemasContext:()=>iK,LinksEditor:()=>ut,TRACE_QUERY_KEY:()=>uR,MultiQueryEditor:()=>uc,TimeRangeSettingsProvider:()=>aB,useAutoRefreshIntervalsOptions:()=>aH,LEGEND_SIZE_CONFIG:()=>l9,useSilencesQueries:()=>u_,loadPlugin:()=>d2,useDatasourceSelectValueToSelector:()=>oR,OptionsEditorTabs:()=>uh,useListVariablePluginValues:()=>cs,useTimeRange:()=>aG,TIME_SERIES_QUERY_KEY:()=>uj,useBuiltinVariableValues:()=>a4,useJsonQueries:()=>uv,getVariableValuesKey:()=>co,HTTPSettingsEditor:()=>lu,exportDataAsCSV:()=>dp,legendValues:()=>l1,timeRangeQueryConfig:()=>cU,timeZoneQueryConfig:()=>cZ,useTimeSeriesQuery:()=>uC,CalculationSelector:()=>of,mockPluginRegistry:()=>dr,useShowCustomTimeRangeSetting:()=>aq,ALERTS_QUERY_KEY:()=>uf,useInitialTimeRange:()=>cH,LegendOptionsEditor:()=>ue,RouterProvider:()=>de,useDatasourceStore:()=>aR,MetricLabelInput:()=>cb,RepeatVariableEditor:()=>lJ,DataQueriesContext:()=>uF,LEGEND_VALUE_CONFIG:()=>l3,useTimeRangeOptionsSetting:()=>aQ,encodeTimeRangeValue:()=>cF,isExportableData:()=>di,panelEditorSchema:()=>iB,SORT_METHODS:()=>cu,VARIABLE_TYPES:()=>cl,isVariableDatasource:()=>oS,getMockPluginName:()=>dn,AnnotationEditorForm:()=>ol,replaceVariable:()=>z.replaceVariable,replaceVariables:()=>z.replaceVariables,useActiveTimeSeriesQueries:()=>uS,useAnnotations:()=>or,sanitizeColumnName:()=>dl,usePluginEditor:()=>ar,useTraceQueries:()=>uP,CalculationsMap:()=>ou,useTimeRangeParams:()=>cB,useResolveListVariableValues:()=>ca,ReactRouterProvider:()=>dt,useTimeRangeSettings:()=>aD,comparisonLegends:()=>l2,interpolate:()=>z.interpolate});var _,j,w,C,E={};r.r(E),r.d(E,{CancelledError:()=>s_,Hydrate:()=>dN,InfiniteQueryObserver:()=>dO,IsRestoringProvider:()=>sL,MutationCache:()=>d_,MutationObserver:()=>dS,QueriesObserver:()=>sW,Query:()=>dy,QueryCache:()=>db,QueryClient:()=>dE,QueryClientProvider:()=>U,QueryErrorResetBoundary:()=>sI,QueryObserver:()=>sC,defaultContext:()=>N,defaultShouldDehydrateMutation:()=>dk,defaultShouldDehydrateQuery:()=>dR,dehydrate:()=>dP,focusManager:()=>sv,hashQueryKey:()=>sn,hydrate:()=>dT,infiniteQueryOptions:()=>dL,isCancelledError:()=>sj,isError:()=>sd,isServer:()=>i1,matchQuery:()=>se,mutationOptions:()=>dq,notifyManager:()=>sm,onlineManager:()=>sb,parseFilterArgs:()=>i8,parseMutationArgs:()=>i6,parseMutationFilterArgs:()=>i7,parseQueryArgs:()=>i3,queryOptions:()=>dz,replaceEqualDeep:()=>ss,useHydrate:()=>dV,useInfiniteQuery:()=>dZ,useIsFetching:()=>dF,useIsMutating:()=>dD,useIsRestoring:()=>sz,useMutation:()=>dU,usePrefetchInfiniteQuery:()=>dB,usePrefetchQuery:()=>dH,useQueries:()=>sK,useQuery:()=>sB,useQueryClient:()=>q,useQueryErrorResetBoundary:()=>s$,useSuspenseInfiniteQuery:()=>dI,useSuspenseQueries:()=>dM,useSuspenseQuery:()=>d$});var O=r(62540),S=r(18019),k=r(74628),R=r(88091),P=r(66395),T=r(93648),$=r(315),I=r(47095),M=r(6227),z=r(35566),L=r(70451),V=r.n(L);let N=L.createContext(void 0),F=L.createContext(!1);function D(e,t){return e||(t&&"u">typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=N),window.ReactQueryClientContext):N)}let q=({context:e}={})=>{let t=L.useContext(D(e,L.useContext(F)));if(!t)throw Error("No QueryClient set, use QueryClientProvider to set one");return t},U=({client:e,children:t,context:r,contextSharing:n=!1})=>{L.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]);let i=D(r,n);return L.createElement(F.Provider,{value:!r&&n},L.createElement(i.Provider,{value:e},t))};var Q=r(50894),Z=r(79215);function H(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function B(e,t="|"){return e.map(e=>el(e)).join(t)}function W(e,t){return"bigint"==typeof t?t.toString():t}function K(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function G(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function J(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function X(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}let Y="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let et=K(()=>{if(ek.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function er(e){if(!1===ee(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==ee(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function en(e){return er(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ei=new Set(["string","number","symbol"]);function es(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ea(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function eo(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function el(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}let eu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ec(e,t,r,n="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let s=X(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t of Reflect.ownKeys(r)){if(!Object.prototype.hasOwnProperty.call(n,t))throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(let t of Reflect.ownKeys(n))i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return J(this,"shape",i),i},checks:[]});return ea(t,s)}function ed(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ep(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eh(e){return"string"==typeof e?e:e?.message}function ef(e,t,r){var n;for(let i=t;i<e.length;i++)(n=e[i]).schema??(n.schema=r)}function em(e,t,r){let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?e.schema??(e.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:eh(e.inst?._zod.def?.error?.(e))??eh(i?.(e))??eh(t?.error?.(e))??eh(r.customError?.(e))??eh(r.localeError?.(e))??"Invalid input",{inst:a,schema:o,continue:l,input:u,...c}=e;return c.path??(c.path=[]),c.message=s,t?.reportInput&&(c.input=u),c}let eg=/[\uD800-\uDBFF]/;function ev(e){let t=e.length;if(!eg.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(64512&e.charCodeAt(n))==55296&&(64512&e.charCodeAt(n+1))==56320&&(r--,n++);return r}function ey(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eb(...e){let[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}function ex(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}let eA=!1,e_={configurable:!0,get(){eA=!0}};function ej(e,t,r){let i=Object.getPrototypeOf(e._zod);if(t in i&&n!==e._zod){n=void 0;return}n=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,e_);let e=eA;eA=!1;try{let n=r(this);return eA?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n}),eA=eA||e,n}catch(r){throw delete this[t],eA=eA||e,r}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}let ew={value:void 0,enumerable:!1},eC="captureStackTrace"in Error?Error:null;function eE(e,t,r,n){function i(e){this.def=e,this.constr=u,this.traits=new Set}i.prototype={};let s=r&&new WeakSet;function a(n,a){if(!n._zod){ew.value=new i(a);try{Object.defineProperty(n,"_zod",ew)}finally{ew.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,a),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,i=e;for(;i&&i!==t;)i=Object.getPrototypeOf(i);let a=i??e;if(!s.has(a)){s.add(a);for(let e in r){let t=Object.getOwnPropertyDescriptor(r,e);t.get?Object.defineProperty(a,e,{...t,enumerable:!1}):function(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:ex(this,t,r.bind(this))},set(e){ex(this,t,e)}})}(a,e,t.value)}}}let o=u.prototype;for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&(e in n||(n[e]=o[e].bind(n)))}let o=n?.Parent??Object;class l extends o{}function u(e){let t=n?.Parent?function(e){let t=eC;if(t){let r=t.stackTraceLimit;if("number"==typeof r){try{t.stackTraceLimit=0}catch{return eC=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}(l):this;a(t,e);let r=t._zod.deferred;if(r){for(let e of r)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(u,"init",{value:a}),Object.defineProperty(u,Symbol.hasInstance,{value:t=>!!n?.Parent&&t instanceof n.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}class eO extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eS extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(w=globalThis).__zod_globalConfig??(w.__zod_globalConfig={});let ek=globalThis.__zod_globalConfig;function eR(e){return e&&Object.assign(ek,e),ek}class eP extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eT="~memo",e$=[];function eI(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let eM=new WeakMap,ez=[],eL={alloc(e,t,r){let n=i;if(!n)return r;i=void 0;let s={value:r,issues:null};return n.set(t.value,s),ez.push(s),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(e,r)=>{var n,i;let s;if("backward"!==r.direction&&(n=r,i=e.value,void 0!==(s=n[eT]?.backEdges)&&null!==i&&"object"==typeof i&&s.has(i)))throw new eP;return t(e,r)};e._zod.parse=r,e._zod.run===t&&(e._zod.run=r)})},attach(e){var t;let r,n,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,l)=>{let u;if(void 0===r&&!(r=function e(t,r){let n=eM.get(t);if(void 0!==n)return n;if(r.has(t))return!0;r.add(t);let i=!1,s=t=>{!i&&t?._zod&&e(t,r)&&(i=!0)},a=t._zod.def;switch(a.type){case"object":for(let e of Reflect.ownKeys(a.shape))s(a.shape[e]);s(a.catchall);break;case"array":s(a.element);break;case"tuple":for(let e of a.items)s(e);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(let e of a.options)s(e);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":s(t._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let r=t.value;if(r&&"object"==typeof r){if(r._zod)s(r);else if(Array.isArray(r))for(let e of r)s(e)}}}return r.delete(t),eM.set(t,i),i}(e,new Set)))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,l);let c=o.value;if(null===c||"object"!=typeof c)return t(o,l);let d=l[eT];if(d||(d={buckets:new Map,backEdges:void 0},l[eT]=d),n===l)u=s;else{var p;let t;(t=(p=d).buckets.get(e))||(t=new Map,p.buckets.set(e,t)),u=t,n=l,s=u}let h=u.get(c);if(h)return o.value=h.value,h.issues?h.issues.length&&o.issues.push(...eI(h.issues)):(o.memo=!0,d.backEdges??(d.backEdges=new Set),d.backEdges.add(h.value)),o;i=u;let f=ez.length,m=t(o,l);i=void 0;let g=ez.length>f?ez.pop():void 0;return m instanceof Promise?m.then(e=>(g&&(g.issues=e.issues.length?eI(e.issues):e$),e)):(g&&(g.issues=m.issues.length?eI(m.issues):e$),m)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}},eV=/^[cC][0-9a-z]{6,}$/,eN=/^[0-9a-z]+$/,eF=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,eD=/^[0-9a-vA-V]{20}$/,eq=/^[A-Za-z0-9]{27}$/,eU=/^[a-zA-Z0-9_-]{21}$/,eQ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eZ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,eH=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,eB=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eW=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,eK=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,eG=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,eJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eX=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,eY=/^[A-Za-z0-9_-]*$/,e0=/^https?$/,e1=/^\+[1-9]\d{6,14}$/,e2="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",e4=RegExp(`^${e2}$`);function e5(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let e9=/^-?\d+$/,e3=/^-?\d+(?:\.\d+)?$/,e6=/^(?:true|false)$/i,e8=/^[^A-Z]*$/,e7=/^[^a-z]*$/,te=eE("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tt=e=>{let t=e.value;return null!=t&&void 0!==t.length},tr={number:"number",bigint:"bigint",object:"date"},tn=eE("$ZodCheckLessThan",(e,t)=>{te.init(e,t);let r=tr[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:tr[typeof n.value]??r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ti=eE("$ZodCheckGreaterThan",(e,t)=>{te.init(e,t);let r=tr[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:tr[typeof n.value]??r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ts=eE("$ZodCheckMultipleOf",(e,t)=>{te.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{let n,i,s;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):0==(i=Math.round(n=r.value/t.value),s=4*Number.EPSILON*Math.max(Math.abs(n),1),Math.abs(n-i)<s?0:n-i))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ta=eE("$ZodCheckNumberFormat",(e,t)=>{te.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,s]=eu[t.format];e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=s,r&&(n.pattern=e9)}),e._zod.check=a=>{let o=a.value;if(r){if(!Number.isInteger(o))return void a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});if(!Number.isSafeInteger(o))return void(o>0?a.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}o<i&&a.issues.push({origin:"number",input:o,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),o>s&&a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),to=eE("$ZodCheckMaxLength",(e,t)=>{var r;te.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value,i=n.length;if(("string"==typeof n&&i>t.maximum?ev(n):i)<=t.maximum)return;let s=ey(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),tl=eE("$ZodCheckMinLength",(e,t)=>{var r;te.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value,i=n.length;if(("string"==typeof n&&i>=t.minimum&&i<2*t.minimum?ev(n):i)>=t.minimum)return;let s=ey(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),tu=eE("$ZodCheckLengthEquals",(e,t)=>{var r;te.init(e,t),(r=e._zod.def).when??(r.when=tt),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let n=r.value,i=n.length,s="string"==typeof n&&i>=t.length&&i<=2*t.length?ev(n):i;if(s===t.length)return;let a=ey(n),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),tc=eE("$ZodCheckStringFormat",(e,t)=>{var r,n;te.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),td=eE("$ZodCheckRegex",(e,t)=>{tc.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tp=eE("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e8),tc.init(e,t)}),th=eE("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=e7),tc.init(e,t)}),tf=eE("$ZodCheckIncludes",(e,t)=>{te.init(e,t);let r=es(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),tm=eE("$ZodCheckStartsWith",(e,t)=>{te.init(e,t);let r=RegExp(`^${es(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),tg=eE("$ZodCheckEndsWith",(e,t)=>{te.init(e,t);let r=RegExp(`.*${es(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),tv=eE("$ZodCheckOverwrite",(e,t)=>{te.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class ty{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
+
${t.join("\n")}
|
|
4
|
+
};`)(...Object.values(this.closed))}}let tb={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,W,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},tx={value:void 0,enumerable:!1},tA={value:void 0,enumerable:!1},t_=new WeakSet([Object.prototype,Error.prototype]),tj=(e,t)=>{e.name="$ZodError",tx.value=e._zod,Object.defineProperty(e,"_zod",tx),tA.value=t,Object.defineProperty(e,"issues",tA),tx.value=void 0,tA.value=void 0,Object.defineProperty(e,"message",tb);let r=Object.getPrototypeOf(e);t_.has(r)||(t_.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},tw=eE("$ZodError",tj),tC=eE("$ZodError",tj,void 0,{Parent:Error});function tE(e,t){return{callee:t?.callee??e,Err:t?.Err}}let tO=e=>{let t=(r,n,i,s)=>{let a=i?{...i,async:!1}:{async:!1},o=r._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new eO;if(o.issues.length){let r=new(s?.Err??e)(o.issues.map(e=>em(e,a,eR())));throw Y(r,s?.callee??t),r}return o.value};return t},tS=e=>{let t=async(r,n,i,s)=>{let a=i?{...i,async:!0}:{async:!0},o=r._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let r=new(s?.Err??e)(o.issues.map(e=>em(e,a,eR())));throw Y(r,s?.callee??t),r}return o.value};return t},tk=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new eO;return s.issues.length?{success:!1,error:new(e??tw)(s.issues.map(e=>em(e,i,eR())))}:{success:!0,data:s.value}},tR=tk(tC),tP=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>em(e,i,eR())))}:{success:!0,data:s.value}},tT=tP(tC),t$={major:4,minor:5,patch:4},tI=eE("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=t$;let n=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let t of i)for(let r of t._zod.onattach)r(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,r,n)=>{let i;if(t.memo)return t;let s=ed(t);for(let a of r){if(a._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(t)||!a._zod.def.when(t))continue}else if(s)continue;let r=t.issues.length,o=a._zod.check(t);if(o instanceof Promise&&n?.async===!1)throw new eO;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,t.issues.length!==r&&(ef(t.issues,r,e),s||(s=ed(t,r)))});else{if(t.issues.length===r)continue;ef(t.issues,r,e),s||(s=ed(t,r))}}return i?i.then(()=>t):t},r=(r,n,s)=>{if(ed(r))return r.aborted=!0,r;let a=t(n,i,s);if(a instanceof Promise){if(!1===s.async)throw new eO;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(n,s)=>{if(s.skipChecks)return e._zod.parse(n,s);if("backward"===s.direction){let t=e._zod.parse({value:n.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,n,s)):r(t,n,s)}let a=e._zod.parse(n,s);if(a instanceof Promise){if(!1===s.async)throw new eO;return a.then(e=>t(e,i,s))}return t(a,i,s)}}},{get"~standard"(){return ex(this,"~standard",tz(this),!1)},set"~standard"(value){ex(this,"~standard",value)}}),tM=e=>e.success?{value:e.data}:{issues:e.error?.issues};function tz(e){return{validate:t=>{try{return tM(tR(e,t))}catch(r){return tT(e,t).then(tM)}},vendor:"zod",version:1}}let tL=eE("$ZodString",(e,t)=>{var r;let n;tI.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=(r=e._zod.bag)?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*",RegExp(`^${n}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tV=eE("$ZodStringFormat",(e,t)=>{tc.init(e,t),tL.init(e,t)}),tN=eE("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=eZ),tV.init(e,t)}),tF=eE("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=eH(e))}else t.pattern??(t.pattern=eH());tV.init(e,t)}),tD=eE("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=eB),tV.init(e,t)}),tq=/[\t\n\r]/g,tU=eE("$ZodURL",(e,t)=>{tV.init(e,t),e._zod.check=r=>{try{var n,i;let s=r.value.trim(),a=function(e,t){if(!t.normalize&&t.protocol?.source===e0.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}(s,t);if(1===a)return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});if(2===a)return void r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});t.hostname&&((n=t.hostname).lastIndex=0,!n.test(a.hostname))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&((i=t.protocol).lastIndex=0,!i.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?a.href:s.replace(tq,"");return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),tQ=eE("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),tV.init(e,t)}),tZ=eE("$ZodNanoID",(e,t)=>{var r;if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=void 0===t.length?eU:(r=t.length,RegExp(`^[a-zA-Z0-9_-]{${r}}$`))),tV.init(e,t)}),tH=eE("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=eV),tV.init(e,t)}),tB=eE("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=eN),tV.init(e,t)}),tW=eE("$ZodULID",(e,t)=>{t.pattern??(t.pattern=eF),tV.init(e,t)}),tK=eE("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eD),tV.init(e,t)}),tG=eE("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=eq),tV.init(e,t)}),tJ=eE("$ZodISODateTime",(e,t)=>{let r,n,i;t.pattern??(r=["Z"],t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${e5({precision:t.precision,seconds:!0})}(?:${r.join("|")})`,i=t.local?`${n}|${e5({precision:t.precision})}`:n,t.pattern=RegExp(`^${e2}T(?:${i})$`)),tV.init(e,t),(t.local||-1===t.precision)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),tX=eE("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=e4),tV.init(e,t)}),tY=eE("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${e5(t)}$`)),tV.init(e,t)}),t0=eE("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=eQ),tV.init(e,t)}),t1=eE("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=eW),tV.init(e,t),e._zod.bag.format="ipv4"}),t2=/^[0-9a-fA-F:.]+$/;function t4(e){if(!t2.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}let t5=eE("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=eK),tV.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{t4(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),t9=eE("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eG),tV.init(e,t)}),t3=eE("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=eJ),tV.init(e,t),e._zod.check=r=>{!function(e){let t=e.split("/");if(2!==t.length)return!1;let[r,n]=t;if(!n)return!1;let i=Number(n);return`${i}`===n&&!(i<0)&&!(i>128)&&t4(r)}(r.value)&&r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function t6(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let t8=eE("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=eX),tV.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{t6(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),t7=eE("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=eY),tV.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!eY.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return t6(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),re=eE("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e1),tV.init(e,t)}),rt=eE("$ZodJWT",(e,t)=>{tV.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));if("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),rr=eE("$ZodNumber",(e,t)=>{tI.init(e,t),e._zod.pattern=e._zod.bag.pattern??e3,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;let s="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),r}}),rn=eE("$ZodNumberFormat",(e,t)=>{ta.init(e,t),rr.init(e,t)}),ri=eE("$ZodBoolean",(e,t)=>{tI.init(e,t),e._zod.pattern=e6,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),rs=eE("$ZodAny",(e,t)=>{tI.init(e,t),e._zod.parse=e=>e}),ra=eE("$ZodUnknown",(e,t)=>{tI.init(e,t),e._zod.parse=e=>e}),ro=eE("$ZodNever",(e,t)=>{tI.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function rl(e,t,r){e.issues.length&&t.issues.push(...ep(r,e.issues)),t.value[r]=e.value}let ru=eE("$ZodArray",(e,t)=>{tI.init(e,t);let r=ek.memoizer;r?.attach(e),e._zod.parse=(n,i)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),i):Array(s.length);let a=[];for(let e=0;e<s.length;e++){let r=s[e],o=t.element._zod.run({value:r,issues:[]},i);o instanceof Promise?a.push(o.then(t=>rl(t,n,e))):rl(o,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function rc(e,t,r,n,i,s){let a=r in n,o="optional"===s;if(a||!o||"optional"!==i){if(e.issues.length){if(void 0!==i&&o&&!a)return;t.issues.push(...ep(r,e.issues))}if(!a&&void 0===i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?a&&(t.value[r]=void 0):t.value[r]=e.value}}let rd=[];function rp(e){var t;let r=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:rd,s=i.length?[...r,...i]:r;for(let t of s)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Object.keys(t=e.shape).filter(e=>void 0!==t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,allKeys:s,symbolKeys:i,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(a)}}function rh(e,t,r,n,i,s){let a=[],o=i.keySet,l=i.catchall._zod,u=l.def.type,c=l.optin,d=l.optout;for(let i in t){if(o.has(i))continue;if("__proto__"===i){"never"===u&&a.push(i);continue}if("never"===u){a.push(i);continue}let s=l.run({value:t[i],issues:[]},n);s instanceof Promise?e.push(s.then(e=>rc(e,r,i,t,c,d))):rc(s,r,i,t,c,d)}return(a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length)?Promise.all(e).then(()=>r):r}let rf=new WeakMap,rm=eE("$ZodObject",(e,t)=>{let r;tI.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){let e=t.shape;rf.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),rf.set(t,r),r}})}let i=K(()=>rp(t));ej(e,"propValues",e=>{let t=e.def.shape,r={};for(let e in t){let n=t[e]._zod;if(n.values){for(let t of(Object.prototype.hasOwnProperty.call(r,e)||J(r,e,new Set),n.values))r[e].add(t);void 0!==n.optin&&r[e].add(void 0)}}return r});let s=t.catchall,a=ek.memoizer;a?.attach(e),e._zod.parse=(t,n)=>{r??(r=i.value);let o=t.value;if(!ee(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value=a?a.alloc(e,t,{},n):{};let l=[],u=r.shape;for(let e of r.allKeys){if("__proto__"===e)continue;let r=u[e],i=r._zod.optin,s=r._zod.optout,a=r._zod.run({value:o[e],issues:[]},n);a instanceof Promise?l.push(a.then(r=>rc(r,t,e,o,i,s))):rc(a,t,e,o,i,s)}return s?rh(l,o,t,n,i.value,e):l.length?Promise.all(l).then(()=>t):t}}),rg=eE("$ZodObjectJIT",(e,t)=>{let r,n;rm.init(e,t);let i=e._zod.parse,s=K(()=>rp(t)),a=ek.memoizer,o=!ek.jitless,l=o&&et.value,u=t.catchall;e._zod.parse=(c,d)=>{n??(n=s.value);let p=c.value;return ee(p)?o&&l&&d?.async===!1&&!0!==d.jitless?(r||(r=(t=>{let r=s.value,n=r.symbolKeys,i=new ty(["payload","ctx"],{shape:t,inst:e,memo:a,syms:n}),o=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,l=(e,t)=>`
|
|
5
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
|
+
const iss = ${e}.issues[i];
|
|
7
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
8
|
+
payload.issues.push(iss);
|
|
9
|
+
}`;i.write("const input = payload.value;");let u=Object.create(null),c=0;for(let e of r.allKeys)u[e]=`key_${c++}`;for(let e of(i.write(a?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};"),r.allKeys)){if("__proto__"===e)continue;let r=u[e],s="symbol"==typeof e?`syms[${n.indexOf(e)}]`:JSON.stringify(e),a=`${s} in input`,c=t[e],d=c?._zod?.optin,p=void 0!==d,h=c?._zod?.optout==="optional";if(i.write(`const ${r} = ${o(s)};`),p&&h){let e="optional"===d?`${r}_present`:`${r}.value !== undefined || ${r}_present`;i.write(`
|
|
10
|
+
const ${r}_present = ${a};
|
|
11
|
+
if (!${r}.issues.length || ${r}_present) {
|
|
12
|
+
if (${r}.issues.length) {${l(r,s)}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (${e}) {
|
|
16
|
+
newResult[${s}] = ${r}.value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
`)}else p?i.write(`
|
|
21
|
+
if (${r}.issues.length) {${l(r,s)}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (${r}.value === undefined) {
|
|
25
|
+
if (${a}) {
|
|
26
|
+
newResult[${s}] = undefined;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
newResult[${s}] = ${r}.value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
`):i.write(`
|
|
33
|
+
const ${r}_present = ${a};
|
|
34
|
+
if (${r}.issues.length) {${l(r,s)}
|
|
35
|
+
}
|
|
36
|
+
if (!${r}_present && !${r}.issues.length) {
|
|
37
|
+
payload.issues.push({
|
|
38
|
+
code: "invalid_type",
|
|
39
|
+
expected: "nonoptional",
|
|
40
|
+
input: undefined,
|
|
41
|
+
path: [${s}]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (${r}_present) {
|
|
46
|
+
newResult[${s}] = ${r}.value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
`)}return i.write("payload.value = newResult;"),i.write("return payload;"),i.compile()})(t.shape)),c=r(c,d),u)?rh([],p,c,d,n,e):c:i(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function rv(e,t,r,n){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let i=e.filter(e=>!ed(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>em(e,n,eR())))}),t)}let ry=eE("$ZodUnion",(e,t)=>{tI.init(e,t),ej(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),ej(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),ej(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),ej(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>G(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let s=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},i);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>rv(t,n,e,i)):rv(a,n,e,i)}}),rb=eE("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ry.init(e,t);let r=e._zod.parse;ej(e,"propValues",e=>{let t={};for(let r of e.def.options){let n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);for(let[e,r]of Object.entries(n))for(let n of(Object.prototype.hasOwnProperty.call(t,e)||J(t,e,new Set),r))t[e].add(n)}return t}),t.options.forEach((e,r)=>{let n=rf.get(e._zod.def);if(n&&!Object.prototype.hasOwnProperty.call(n,t.discriminator))throw Error(`Invalid discriminated union option at index "${r}"`)});let n=K(()=>{let e=t.options,r=new Map;for(let n of e){let e=n._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let t of e){if(r.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(i,s)=>{let a=i.value;if(!ee(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let o=n.value.get(a?.[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback||"backward"===s.direction?r(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),rx=eE("$ZodIntersection",(e,t)=>{tI.init(e,t),e._zod.parse=(e,r)=>{let n=e.value,i=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([t,r])=>rA(e,t,r)):rA(e,i,s)}});function rA(e,t,r){let n,i=new Map,s=new Map,a=(e,t)=>{let r;if("unrecognized_keys"!==e.code||e.path?.length)if("invalid_key"!==e.code||"record"!==e.origin||e.path?.length!==1)return!1;else{let t=String(e.path[0]);s.has(t)||s.set(t,e),r=[t]}else n??(n=e),r=e.keys;for(let e of r)i.has(e)||i.set(e,{}),i.get(e)[t]=!0;return!0};for(let r of t.issues)a(r,"l")||e.issues.push(r);for(let t of r.issues)a(t,"r")||e.issues.push(t);let o=[...i].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length){let t=n?o.filter(e=>n.keys.includes(e)):[];for(let r of(t.length&&e.issues.push({...n,keys:t}),o))!t.includes(r)&&s.has(r)&&e.issues.push(s.get(r))}let l=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(er(t)&&er(r)){let n=Object.keys(r),i=Object.keys(t).filter(e=>-1!==n.indexOf(e)),s={...t,...r};for(let n of(Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__,i)){if("__proto__"===n)continue;let i=e(t[n],r[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};s[n]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<t.length;i++){let s=e(t[i],r[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!l.valid){if(ed(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}let r_=eE("$ZodRecord",(e,t)=>{tI.init(e,t);let r=ek.memoizer;r?.attach(e),e._zod.parse=(n,i)=>{let s=n.value;if(!er(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o&&!t.partial){let l;n.value=r?r.alloc(e,n,{},i):{};let u=new Set;for(let r of o)if("string"==typeof r||"number"==typeof r||"symbol"==typeof r){if(u.add("number"==typeof r?r.toString():r),"__proto__"===r)continue;let o=t.keyType._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(o.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(e=>em(e,i,eR())),input:r,path:[r],inst:e});continue}let l=o.value;if("__proto__"===l)continue;let c=t.valueType._zod.run({value:s[r],issues:[]},i);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ep(r,e.issues)),n.value[l]=e.value})):(c.issues.length&&n.issues.push(...ep(r,c.issues)),n.value[l]=c.value)}for(let e in s)if(!u.has(e))if("loose"===t.mode){if("__proto__"===e)continue;n.value[e]=s[e]}else(l=l??[]).push(e);l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{let l;for(let u of(n.value=r?r.alloc(e,n,{},i):{},Reflect.ownKeys(s))){if("__proto__"===u||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let r=t.keyType._zod.run({value:u,issues:[]},i);if(r instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof u&&e3.test(u)&&r.issues.length){let e=t.keyType._zod.run({value:Number(u),issues:[]},i);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(r=e)}if(r.issues.length){"loose"===t.mode?n.value[u]=s[u]:o?(l=l??[]).push(u):n.issues.push({code:"invalid_key",origin:"record",issues:r.issues.map(e=>em(e,i,eR())),input:u,path:[u],inst:e});continue}let c=r.value;if("__proto__"===c)continue;let d=t.valueType._zod.run({value:s[u],issues:[]},i);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...ep(u,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...ep(u,d.issues)),n.value[c]=d.value)}l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}return a.length?Promise.all(a).then(()=>n):n}}),rj=eE("$ZodEnum",(e,t)=>{tI.init(e,t);let r=H(t.entries),n=new Set(r);e._zod.values=n;let i=r.filter(e=>ei.has(typeof e));e._zod.pattern=new RegExp(i.length?`^(${i.map(e=>es(e.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(t,i)=>{let s=t.value;return n.has(s)||t.issues.push({code:"invalid_value",values:r,input:s,inst:e}),t}}),rw=eE("$ZodLiteral",(e,t)=>{tI.init(e,t);let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(e=>"string"==typeof e?es(e):e?es(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(n,i)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),rC=eE("$ZodTransform",(e,t)=>{tI.init(e,t),e._zod.optin="optional",ek.memoizer?.guard(e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new eS(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(r.value=e,r));if(i instanceof Promise)throw new eO;return r.value=i,r}});function rE(e,t){return e.value=t.issues.length?void 0:t.value,e}let rO=eE("$ZodOptional",(e,t)=>{tI.init(e,t),ej(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",ej(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),ej(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${G(t.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let n=t.innerType._zod.run({value:e.value,issues:[]},r);return n instanceof Promise?n.then(t=>rE(e,t)):rE(e,n)}return t.innerType._zod.run(e,r)}}),rS=eE("$ZodExactOptional",(e,t)=>{rO.init(e,t),ej(e,"values",e=>e.def.innerType._zod.values),ej(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),rk=eE("$ZodNullable",(e,t)=>{tI.init(e,t),ej(e,"optin",e=>e.def.innerType._zod.optin),ej(e,"optout",e=>e.def.innerType._zod.optout),ej(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${G(t.source)}|null)$`):void 0}),ej(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),rR=eE("$ZodDefault",(e,t)=>{tI.init(e,t),e._zod.optin="defaulted",ej(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>rP(e,t)):rP(n,t)}});function rP(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rT=eE("$ZodPrefault",(e,t)=>{tI.init(e,t),e._zod.optin="defaulted",ej(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),r$=eE("$ZodNonOptional",(e,t)=>{tI.init(e,t),ej(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(t=>rI(t,e)):rI(i,e)}});function rI(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function rM(e,t,r,n){return t.issues.length?e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>em(e,n,eR()))},input:e.value}):(e.value=t.value,t.memo&&(e.memo=!0)),e}let rz=eE("$ZodCatch",(e,t)=>{tI.init(e,t),ej(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),ej(e,"optout",e=>e.def.innerType._zod.optout),ej(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let n=t.innerType._zod.run({value:e.value,issues:[]},r);return n instanceof Promise?n.then(n=>rM(e,n,t,r)):rM(e,n,t,r)}}),rL=eE("$ZodPipe",(e,t)=>{tI.init(e,t),ej(e,"values",e=>e.def.in._zod.values),ej(e,"optin",e=>e.def.in._zod.optin),ej(e,"optout",e=>e.def.out._zod.optout),ej(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let n=t.out._zod.run(e,r);return n instanceof Promise?n.then(e=>rV(e,t.in,r)):rV(n,t.in,r)}let n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>rV(e,t.out,r)):rV(n,t.out,r)}});function rV(e,t,r){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}let rN=eE("$ZodReadonly",(e,t)=>{tI.init(e,t),ej(e,"propValues",e=>e.def.innerType._zod.propValues),ej(e,"values",e=>e.def.innerType._zod.values),ej(e,"optin",e=>e.def.innerType?._zod?.optin),ej(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(rF):rF(n)}});function rF(e){return e.memo||(e.value=Object.freeze(e.value)),e}let rD=eE("$ZodCustom",(e,t)=>{te.init(e,t),tI.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(t=>rq(t,r,n,e));rq(i,r,n,e)}});function rq(e,t,r,n){if(!e){let e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(eb(e))}}(C=globalThis).__zod_globalRegistry??(C.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let rU=globalThis.__zod_globalRegistry;function rQ(e,t){return new tn({check:"less_than",...eo(t),value:e,inclusive:!1})}function rZ(e,t){return new tn({check:"less_than",...eo(t),value:e,inclusive:!0})}function rH(e,t){return new ti({check:"greater_than",...eo(t),value:e,inclusive:!1})}function rB(e,t){return new ti({check:"greater_than",...eo(t),value:e,inclusive:!0})}function rW(e,t){return new ts({check:"multiple_of",...eo(t),value:e})}function rK(e,t){return new to({check:"max_length",...eo(t),maximum:e})}function rG(e,t){return new tl({check:"min_length",...eo(t),minimum:e})}function rJ(e,t){return new tu({check:"length_equals",...eo(t),length:e})}function rX(e){return new tv({check:"overwrite",tx:e})}function rY(e,...t){for(let r of t)for(let t of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,t)&&J(e,t,r[t]);return e}function r0(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??rU,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function r1(e,t,r,n,i){let s="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:n.path,message:i}):t.unrepresentable;if("any"===s)return!1;if(void 0===s||"throw"===s)throw Error(i);return Object.assign(r,s),!0}function r2(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,n);else{let r=a.schema,s=t.processors[i.type];if(!s)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);s(e,t,r,n)}let s=e._zod.parent;s&&(a.ref||(a.ref=s),r2(s,t,n),t.seen.get(s).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&rY(a.schema,l),"input"===t.io&&function e(t,r){let n=r??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let i=t._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return e(i.element,n);if("set"===i.type)return e(i.valueType,n);if("lazy"===i.type)return e(i.getter(),n);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type||"catch"===i.type)return e(i.innerType,n);if("intersection"===i.type)return e(i.left,n)||e(i.right,n);if("record"===i.type||"map"===i.type)return e(i.keyType,n)||e(i.valueType,n);if("pipe"===i.type)return!!t._zod.traits.has("$ZodCodec")||e(i.in,n)||e(i.out,n);if("object"===i.type){for(let t in i.shape)if(e(i.shape[t],n))return!0;return!1}if("union"===i.type){for(let t of i.options)if(e(t,n))return!0;return!1}if("tuple"===i.type){for(let t of i.items)if(e(t,n))return!0;if(i.rest&&e(i.rest,n))return!0}return!1}(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function r4(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function r5(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=n.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(r,t[0])}}let i=t=>{if(t[1].schema.$ref)return;let n=t[1],{ref:i,defId:s}=(t=>{let n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(r)return{ref:i(r)};let s=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=s,{defId:s,ref:`${i("__shared")}#/${n}/${r4(s)}`}}let i=`#/${n}/`;if(t[1]===r&&!t[1].schema.id)return{ref:"#"};let s=t[1].schema.id??`__schema${e.counter++}`;return{defId:s,ref:i+r4(s)}})(t);n.def={...n.schema},s&&(n.defId=s);let a=n.schema;for(let e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
|
|
50
|
+
|
|
51
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let n=r[1];if(t===r[0]){i(r);continue}if(e.external){let n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){i(r);continue}}if(e.metadataRegistry.get(r[0])?.id||n.cycle||n.count>1&&"ref"===e.reused){i(r);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}let r9=new Set(["type","properties","required","additionalProperties"]),r3=["oneOf","anyOf"];function r6(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function r8(e){let t=[];for(let r of e){if("object"!=typeof r||"object"!==r.type)return null;for(let e in r)if(!r9.has(e))return null;t.push(r)}let r={},n=new Set;for(let e of t){for(let n in e.properties){if(Object.prototype.hasOwnProperty.call(r,n))continue;let e=[];for(let r of t){let t=r.properties?.[n]??r6(r);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}J(r,n,1===e.length?e[0]:r8(e)??{allOf:e})}for(let t of e.required??[])n.add(t)}let i={type:"object",properties:r};if(n.size&&(i.required=[...n]),t.every(e=>!1===e.additionalProperties))i.additionalProperties=!1;else{let e=[];for(let r of t){let t=r6(r);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function r7(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=t=>{let r=e.seen.get(t);if(null===r.ref)return;let i=r.def??r.schema,s={...i},a=r.ref;if(r.ref=null,a){n(a);let r=e.seen.get(a),o=r.schema;if(o.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(i.allOf=i.allOf??[],i.allOf.push(o)):rY(i,o),rY(i,s),t._zod.parent===a)for(let e in i)"$ref"!==e&&"allOf"!==e&&(e in s||delete i[e]);if(o.$ref&&r.def)for(let e in i)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(i[e])===JSON.stringify(r.def[e])&&delete i[e]}let o=t._zod.parent;if(o&&o!==a){n(o);let t=e.seen.get(o);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:r.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())n(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())!function e(t){let r=t.anyOf;if(!Array.isArray(r)||0===r.length||void 0!==t.type)return;let n=[];for(let t of r){if(!t||"object"!=typeof t)return;e(t);let r=Object.keys(t);if(1!==r.length||"type"!==r[0])return;let i=t.type;for(let e of Array.isArray(i)?i:[i]){if("string"!=typeof e)return;n.includes(e)||n.push(e)}}delete t.anyOf,t.type=1===n.length?n[0]:n}(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let r of e.seen.values())for(let e of[r.schema,r.def]){let r=e?.allOf;if(!Array.isArray(r))continue;let n=t.get(r);n?n.push(e):t.set(r,[e])}for(let r of e.intersections)for(let e of t.get(r)??[])!function(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of r9)if(t in e)return;let r=t.filter(e=>r3.some(t=>Array.isArray(e[t]))),n=null;if(r.length){let e=r[0],i=r3.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let s=t.filter(t=>t!==e),a=e[i].map(e=>r8([...s,e]));if(a.some(e=>!e))return;n={[i]:a}}else n=r8(t);n&&(delete e.allOf,rY(e,n))}(e)}}let i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(r)}rY(i,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;void 0!==s&&i.id===s&&delete i.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,J(a,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?i.$defs=a:i.definitions=a);try{let r=JSON.parse(JSON.stringify(i));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:ne(t,"input",e.processors),output:ne(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let ne=(e,t,r={})=>n=>{let{libraryOptions:i,target:s}=n??{},a=r0({...i??{},target:s,io:t,processors:r});return r2(e,a),r5(a,e),r7(a,e)},nt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function nr(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?nr(t.out):"catch"===t.type?nr(t.innerType):e._zod.optin}let nn=new WeakMap,ni=Symbol();function ns(e,t,r,n,i){let s=!1,a=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(s=!0,null));return s?(r1(t,r,n,i,"BigInt defaults cannot be represented in JSON Schema"),ni):JSON.parse(a)}let na=(e,t,r,n)=>{let i=e._zod.def;r2(i.innerType,t,n),t.seen.get(e).ref=i.innerType},no=new WeakSet([Object.prototype,Error.prototype]);function nl(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=r(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let nu=eE("ZodError",(e,t)=>{tw.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);no.has(r)||(no.add(r),nl(r,"format",e=>t=>(function(e,t=e=>e.message){let r={_errors:[]},n=(e,i=[])=>{for(let s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>n({issues:e},[...i,...s.path]));else if("invalid_key"===s.code)n({issues:s.issues},[...i,...s.path]);else if("invalid_element"===s.code)n({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(0===e.length)r._errors.push(t(s));else{let n=r,i=0;for(;i<e.length;){let r=e[i],a=i===e.length-1;if("_errors"===r){a&&n._errors.push(t(s)),i++;continue}Object.prototype.hasOwnProperty.call(n,r)||Object.defineProperty(n,r,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let o=n[r];a&&o._errors.push(t(s)),n=o,i++}}}};return n(e),r})(e,t)),nl(r,"flatten",e=>t=>(function(e,t=e=>e.message){let r={},n=[];for(let a of e.issues)if(a.path.length>0){var i,s;(i=a.path[0],s=()=>[],!Object.prototype.hasOwnProperty.call(r,i)&&("__proto__"===i?Object.defineProperty(r,i,{value:s(),writable:!0,enumerable:!0,configurable:!0}):r[i]=s()),r[i]).push(t(a))}else n.push(t(a));return{formErrors:n,fieldErrors:r}})(e,t)),nl(r,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,W,2)}),nl(r,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,W,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nc=tO(nu),nd=tS(nu),np=tk(nu),nh=tP(nu),nf=(l=tO(nu),u=(e,t,r,n)=>l(e,t,r?{...r,direction:"backward"}:{direction:"backward"},tE(u,n))),nm=(c=tO(nu),d=(e,t,r,n)=>c(e,t,r,tE(d,n))),ng=(p=tS(nu),h=async(e,t,r,n)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return await p(e,t,i,tE(h,n))}),nv=(f=tS(nu),m=async(e,t,r,n)=>await f(e,t,r,tE(m,n))),ny=(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return tk(nu)(e,t,n)},nb=(e,t,r)=>tk(nu)(e,t,r),nx=async(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return tP(nu)(e,t,n)},nA=async(e,t,r)=>tP(nu)(e,t,r);function n_(){ek.memoizer||eR({memoizer:eL})}let nj=eE("ZodType",(e,t)=>(ek.localeError||eR({localeError:(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function n(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return r=>{switch(r.code){case"invalid_type":{let e=n(r.expected),t=n(function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(r.input),r.input);return`Invalid input: expected ${e}, received ${t}`}case"invalid_value":if(1===r.values.length)return`Invalid input: expected ${el(r.values[0])}`;return`Invalid option: expected one of ${B(r.values,"|")}`;case"too_big":{let t=r.exact?"exactly ":r.inclusive?"<=":"<",n=e[r.origin]??null;if(n)return`Too big: expected ${r.origin??"value"} to have ${t}${r.maximum.toString()} ${n.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${t}${r.maximum.toString()}`}case"too_small":{let t=r.exact?"exactly ":r.inclusive?">=":">",n=e[r.origin]??null;if(n)return`Too small: expected ${r.origin} to have ${t}${r.minimum.toString()} ${n.unit}`;return`Too small: expected ${r.origin} to be ${t}${r.minimum.toString()}`}case"invalid_format":if("starts_with"===r.format)return`Invalid string: must start with "${r.prefix}"`;if("ends_with"===r.format)return`Invalid string: must end with "${r.suffix}"`;if("includes"===r.format)return`Invalid string: must include "${r.includes}"`;if("regex"===r.format)return`Invalid string: must match pattern ${r.pattern}`;return`Invalid ${t[r.format]??r.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${B(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":if(r.options&&Array.isArray(r.options)&&r.options.length>0){let e=r.options.map(e=>`'${e}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}if(!1===r.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}})()}),tI.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(X(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ea(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new iC({type:"custom",check:"custom",fn:e,...eo(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){var r;let n,i;return r=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(eb(e,t.value,n._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=t.value),e.inst??(e.inst=n),e.continue??(e.continue=!n._zod.def.abort),t.issues.push(eb(e)))},e(t.value,t)),(i=new te({check:"custom",...eo(t)}))._zod.check=r,n=i}(e,t))},overwrite(e){return this.check(rX(e))},optional(){return ih(this)},exactOptional(){var e;return e=this,new im({type:"optional",innerType:e})},nullable(){return iv(this)},nullish(){return ih(iv(this))},nonoptional(e){var t;return t=this,new ix({type:"nonoptional",innerType:t,...eo(e)})},array(){return n8(this)},or(e){return new it({type:"union",options:[this,e],...eo(void 0)})},and(e){var t;return t=this,new is({type:"intersection",left:t,right:e})},transform(e){return ij(this,new id({type:"transform",transform:e}))},default(e){var t,r;return t=this,r=e,new iy({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():en(r)}})},prefault(e){var t,r;return t=this,r=e,new ib({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():en(r)}})},catch(e){return function(e,t){let r;return new iA({type:"catch",innerType:e,catchValue:"function"==typeof t?t:((r=()=>t)["~constantCatch"]=!0,r)})}(this,e)},pipe(e){return ij(this,e)},readonly(){var e;return e=this,new iw({type:"readonly",innerType:e})},describe(e){let t=this.clone();return rU.add(t,{description:e}),t},meta(...e){if(0===e.length)return rU.get(this);let t=this.clone();return rU.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return ex(this,"~standard",{...tz(this),jsonSchema:{input:ne(this,"input"),output:ne(this,"output")}},!1)},set"~standard"(value){ex(this,"~standard",value)},parse:function e(t,r){return nc(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await nd(this,t,r,{callee:e})},safeParse(e,t){return np(this,e,t)},async safeParseAsync(e,t){return nh(this,e,t)},get spa(){return this?.safeParseAsync},set spa(value){ex(this,"spa",value)},encode:function e(t,r){return nf(this,t,r,{callee:e})},decode:function e(t,r){return nm(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await ng(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await nv(this,t,r,{callee:e})},safeEncode(e,t){return ny(this,e,t)},safeDecode(e,t){return nb(this,e,t)},async safeEncodeAsync(e,t){return nx(this,e,t)},async safeDecodeAsync(e,t){return nA(this,e,t)},toJSONSchema(e){return((e,t={})=>r=>{let n=r0({...r,processors:t});return r2(e,n),r5(n,e),r7(n,e)})(this,{})(e)},get description(){return rU.get(this)?.description},get _def(){return this._zod.def}}),nw=eE("_ZodString",(e,t)=>{tL.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{r.type="string";let{minimum:i,maximum:s,format:a,patterns:o,contentEncoding:l,laxFormat:u}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof s&&(r.maxLength=s),a&&(r.format=nt[a]??a,""===r.format&&delete r.format,("time"===a||u)&&delete r.format),l&&(r.contentEncoding=l),o&&o.size>0){let e=[...o];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,r,0);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null},{regex(...e){return this.check(function(e,t){return new td({check:"string_format",format:"regex",...eo(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new tf({check:"string_format",format:"includes",...eo(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new tm({check:"string_format",format:"starts_with",...eo(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new tg({check:"string_format",format:"ends_with",...eo(t),suffix:e})}(...e))},min(...e){return this.check(rG(...e))},max(...e){return this.check(rK(...e))},length(...e){return this.check(rJ(...e))},nonempty(...e){return this.check(rG(1,...e))},lowercase(e){return this.check(new tp({check:"string_format",format:"lowercase",...eo(e)}))},uppercase(e){return this.check(new th({check:"string_format",format:"uppercase",...eo(e)}))},trim(){return this.check(rX(e=>e.trim()))},normalize(...e){return this.check(function(e){return rX(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(rX(e=>e.toLowerCase()))},toUpperCase(){return this.check(rX(e=>e.toUpperCase()))},slugify(){return this.check(rX(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}}),nC=eE("ZodString",(e,t)=>{tL.init(e,t),nw.init(e,t)},{email(e){return this.check(new nT({type:"string",format:"email",check:"string_format",abort:!1,...eo(e)}))},url(e){return this.check(new nM({type:"string",format:"url",check:"string_format",abort:!1,...eo(e)}))},jwt(e){return this.check(new nG({type:"string",format:"jwt",check:"string_format",abort:!1,...eo(e)}))},emoji(e){return this.check(new nz({type:"string",format:"emoji",check:"string_format",abort:!1,...eo(e)}))},guid(e){return this.check(new n$({type:"string",format:"guid",check:"string_format",abort:!1,...eo(e)}))},uuid(e){return this.check(new nI({type:"string",format:"uuid",check:"string_format",abort:!1,...eo(e)}))},uuidv4(e){return this.check(new nI({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...eo(e)}))},uuidv6(e){return this.check(new nI({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...eo(e)}))},uuidv7(e){return this.check(new nI({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...eo(e)}))},nanoid(e){return this.check(new nL({type:"string",format:"nanoid",check:"string_format",abort:!1,...eo(e)}))},cuid(e){return this.check(new nV({type:"string",format:"cuid",check:"string_format",abort:!1,...eo(e)}))},cuid2(e){return this.check(new nN({type:"string",format:"cuid2",check:"string_format",abort:!1,...eo(e)}))},ulid(e){return this.check(new nF({type:"string",format:"ulid",check:"string_format",abort:!1,...eo(e)}))},base64(e){return this.check(new nB({type:"string",format:"base64",check:"string_format",abort:!1,...eo(e)}))},base64url(e){return this.check(new nW({type:"string",format:"base64url",check:"string_format",abort:!1,...eo(e)}))},xid(e){return this.check(new nD({type:"string",format:"xid",check:"string_format",abort:!1,...eo(e)}))},ksuid(e){return this.check(new nq({type:"string",format:"ksuid",check:"string_format",abort:!1,...eo(e)}))},ipv4(e){return this.check(new nU({type:"string",format:"ipv4",check:"string_format",abort:!1,...eo(e)}))},ipv6(e){return this.check(new nQ({type:"string",format:"ipv6",check:"string_format",abort:!1,...eo(e)}))},cidrv4(e){return this.check(new nZ({type:"string",format:"cidrv4",check:"string_format",abort:!1,...eo(e)}))},cidrv6(e){return this.check(new nH({type:"string",format:"cidrv6",check:"string_format",abort:!1,...eo(e)}))},e164(e){return this.check(new nK({type:"string",format:"e164",check:"string_format",abort:!1,...eo(e)}))},datetime(e){return this.check(new nS({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...eo(e)}))},date(e){return this.check(new nk({type:"string",format:"date",check:"string_format",...eo(e)}))},time(e){return this.check(new nR({type:"string",format:"time",check:"string_format",precision:null,...eo(e)}))},duration(e){return this.check(new nP({type:"string",format:"duration",check:"string_format",...eo(e)}))}});function nE(e){return new nC({type:"string",...eo(e)})}let nO=eE("ZodStringFormat",(e,t)=>{tV.init(e,t),nw.init(e,t)}),nS=eE("ZodISODateTime",(e,t)=>{tJ.init(e,t),nO.init(e,t)}),nk=eE("ZodISODate",(e,t)=>{tX.init(e,t),nO.init(e,t)}),nR=eE("ZodISOTime",(e,t)=>{tY.init(e,t),nO.init(e,t)}),nP=eE("ZodISODuration",(e,t)=>{t0.init(e,t),nO.init(e,t)}),nT=eE("ZodEmail",(e,t)=>{tD.init(e,t),nO.init(e,t)}),n$=eE("ZodGUID",(e,t)=>{tN.init(e,t),nO.init(e,t)}),nI=eE("ZodUUID",(e,t)=>{tF.init(e,t),nO.init(e,t)}),nM=eE("ZodURL",(e,t)=>{tU.init(e,t),nO.init(e,t)}),nz=eE("ZodEmoji",(e,t)=>{tQ.init(e,t),nO.init(e,t)}),nL=eE("ZodNanoID",(e,t)=>{tZ.init(e,t),nO.init(e,t)}),nV=eE("ZodCUID",(e,t)=>{tH.init(e,t),nO.init(e,t)}),nN=eE("ZodCUID2",(e,t)=>{tB.init(e,t),nO.init(e,t)}),nF=eE("ZodULID",(e,t)=>{tW.init(e,t),nO.init(e,t)}),nD=eE("ZodXID",(e,t)=>{tK.init(e,t),nO.init(e,t)}),nq=eE("ZodKSUID",(e,t)=>{tG.init(e,t),nO.init(e,t)}),nU=eE("ZodIPv4",(e,t)=>{t1.init(e,t),nO.init(e,t)}),nQ=eE("ZodIPv6",(e,t)=>{t5.init(e,t),nO.init(e,t)}),nZ=eE("ZodCIDRv4",(e,t)=>{t9.init(e,t),nO.init(e,t)}),nH=eE("ZodCIDRv6",(e,t)=>{t3.init(e,t),nO.init(e,t)}),nB=eE("ZodBase64",(e,t)=>{t8.init(e,t),nO.init(e,t)}),nW=eE("ZodBase64URL",(e,t)=>{t7.init(e,t),nO.init(e,t)}),nK=eE("ZodE164",(e,t)=>{re.init(e,t),nO.init(e,t)}),nG=eE("ZodJWT",(e,t)=>{rt.init(e,t),nO.init(e,t)}),nJ=eE("ZodNumber",(e,t)=>{rr.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let{minimum:i,maximum:s,format:a,multipleOf:o,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;"string"==typeof a&&a.includes("int")?r.type="integer":r.type="number";let c="number"==typeof u&&u>=(i??-1/0),d="number"==typeof l&&l<=(s??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;c?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:"number"==typeof i&&(r.minimum=i),d?p?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:"number"==typeof s&&(r.maximum=s),"number"==typeof o&&(Number.isFinite(o)&&0!==o?r.multipleOf=Math.abs(o):r1(e,t,r,n,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`))})(e,t,r,n);let r=e._zod.bag;e.minValue=Math.max(r.minimum??-1/0,r.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(r.maximum??1/0,r.exclusiveMaximum??1/0)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null},{gt(e,t){return this.check(rH(e,t))},gte(e,t){return this.check(rB(e,t))},min(e,t){return this.check(rB(e,t))},lt(e,t){return this.check(rQ(e,t))},lte(e,t){return this.check(rZ(e,t))},max(e,t){return this.check(rZ(e,t))},int(e){return this.check(n0(e))},safe(e){return this.check(n0(e))},positive(e){return this.check(rH(0,e))},nonnegative(e){return this.check(rB(0,e))},negative(e){return this.check(rQ(0,e))},nonpositive(e){return this.check(rZ(0,e))},multipleOf(e,t){return this.check(rW(e,t))},step(e,t){return this.check(rW(e,t))},finite(){return this}});function nX(e){return new nJ({type:"number",checks:[],...eo(e)})}let nY=eE("ZodNumberFormat",(e,t)=>{rn.init(e,t),nJ.init(e,t)});function n0(e){return new nY({type:"number",check:"number_format",abort:!1,format:"safeint",...eo(e)})}let n1=eE("ZodBoolean",(e,t)=>{ri.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{t.type="boolean"}});function n2(e){return new n1({type:"boolean",...eo(e)})}let n4=eE("ZodAny",(e,t)=>{rs.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}}),n5=eE("ZodUnknown",(e,t)=>{ra.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function n9(){return new n5({type:"unknown"})}let n3=eE("ZodNever",(e,t)=>{ro.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{t.not={}}}),n6=eE("ZodArray",(e,t)=>{n_(),ru.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(r.minItems=s),"number"==typeof a&&(r.maxItems=a),r.type="array",r.items=r2(i.element,t,{...n,path:[...n.path,"items"]})})(e,t,r,n),e.element=t.element},{min(e,t){return this.check(rG(e,t))},nonempty(e){return this.check(rG(1,e))},max(e,t){return this.check(rK(e,t))},length(e,t){return this.check(rJ(e,t))},unwrap(){return this.element}});function n8(e,t){return new n6({type:"array",element:e,...eo(t)})}let n7=eE("ZodObject",(e,t)=>{var r;let n,i;n_(),rg.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&r1(e,t,r,n,"Symbol keys cannot be represented in JSON Schema"))return;for(let e in r.type="object",r.properties={},s)J(r.properties,e,r2(s[e],t,{...n,path:[...n.path,"properties",e]}));let a=new Set([...new Set(Object.keys(s))].filter(e=>{let r=i.shape[e];return"input"===t.io?void 0===nr(r):void 0===r._zod.optout}));a.size>0&&(r.required=Array.from(a)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=r2(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)})(e,t,r,n),r="shape",(i=r in(n=Object.getPrototypeOf(e))?void 0:n)&&Object.defineProperty(i,r,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,r,e),e.value=(e=>e._zod.def.shape)(this),Object.defineProperty(this,r,e),e.value},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:!1,value:e})}})},{keyof(){return il(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:n9()})},loose(){return this.clone({...this._zod.def,catchall:n9()})},strict(){return this.clone({...this._zod.def,catchall:new n3({type:"never",...eo(void 0)})})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!er(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=X(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return J(this,"shape",r),r}});return ea(e,n)}(this,e)},safeExtend(e){var t=this;if(!er(e))throw Error("Invalid input to safeExtend: expected a plain object");let r=X(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e};return J(this,"shape",r),r}});return ea(t,r)},merge(e){var t=this;if(!e?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=X(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return J(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return ea(t,r)},pick(e){return function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=X(e._zod.def,{get shape(){let e={};for(let n of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(r.shape,n))throw Error(`Unrecognized key: "${String(n)}"`);t[n]&&J(e,n,r.shape[n])}return J(this,"shape",e),e},checks:[]});return ea(e,i)}(this,e)},omit(e){return function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=X(e._zod.def,{get shape(){let n={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(r.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete n[e]}return J(this,"shape",n),n},checks:[]});return ea(e,i)}(this,e)},partial(...e){return ec(ip,this,e[0])},exactPartial(...e){return ec(im,this,e[0],"exactPartial")},required(...e){var t,r;let n;return t=this,r=e[0],n=X(t._zod.def,{get shape(){let e=t._zod.def.shape,n={...e};if(r)for(let t of Reflect.ownKeys(r)){if(!Object.prototype.hasOwnProperty.call(n,t))throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&(n[t]=new ix({type:"nonoptional",innerType:e[t]}))}else for(let t of Reflect.ownKeys(e))n[t]=new ix({type:"nonoptional",innerType:e[t]});return J(this,"shape",n),n}}),ea(t,n)}});function ie(e,t){return new n7({type:"object",shape:e??{},...eo(t)})}let it=eE("ZodUnion",(e,t)=>{ry.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i,s,a;return s=!1===(i=e._zod.def).inclusive,a=i.options.map((e,r)=>r2(e,t,{...n,path:[...n.path,s?"oneOf":"anyOf",r]})),void(s?r.oneOf=a:r.anyOf=a)},e.options=t.options}),ir=eE("ZodDiscriminatedUnion",(e,t)=>{it.init(e,t),rb.init(e,t)});function ii(e,t,r){return new ir({type:"union",options:t,discriminator:e,...eo(r)})}let is=eE("ZodIntersection",(e,t)=>{rx.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i,s,a,o,l;return s=r2((i=e._zod.def).left,t,{...n,path:[...n.path,"allOf",0]}),a=r2(i.right,t,{...n,path:[...n.path,"allOf",1]}),void(r.allOf=l=[...(o=e=>"allOf"in e&&1===Object.keys(e).length)(s)?s.allOf:[s],...o(a)?a.allOf:[a]],t.intersections.push(l))}}),ia=eE("ZodRecord",(e,t)=>{n_(),r_.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=e._zod.def;r.type="object";let s=i.keyType,a=s._zod.bag,o=a?.patterns;if("loose"===i.mode&&o&&o.size>0){let e=r2(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});for(let t of(r.patternProperties={},o))J(r.patternProperties,t.source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){r.propertyNames=r2(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let s=nn.get(t);s||(s=[],nn.set(t,s),t.deferred.push(()=>(function(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let r=new Map;for(let n of nn.get(e)??[]){let i=e.seen.get(n),s=(i?.def??i?.schema)?.propertyNames;if(!s||!0===s||r.has(s))continue;let a=function e(t,r,n){if(r.$ref){if(n.has(r))return r;n.add(r);let i=t.get(r)?.def;if(!i)return r;let s=e(t,i,n);return s===i?r:s}for(let i of["anyOf","oneOf"]){let s=r[i];if(!Array.isArray(s))continue;let a=s.map(r=>e(t,r,n));a.some((e,t)=>e!==s[t])&&(r={...r,[i]:a})}let i=Array.isArray(r.type)?r.type:[r.type],s=!i.includes("string")&&i.some(e=>"number"===e||"integer"===e),a=r.enum??(void 0!==r.const?[r.const]:void 0);if(!s&&!a?.some(e=>"number"==typeof e))return r;let{minimum:o,maximum:l,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:d,format:p,id:h,...f}=r;return f.enum?f.enum=f.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof f.const&&(f.const=String(f.const)),s&&(f.type="string",a||(f.pattern=(i.includes("number")?e3:e9).source)),f}(t,s,new Set);a!==s&&r.set(s,a)}if(r.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&r.get(e.propertyNames);t&&(e.propertyNames=t)}})(t))),s.push(e)}r.additionalProperties=r2(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let l=s._zod.values,u="input"===t.io&&void 0!==nr(i.valueType);if(l&&!i.partial&&!u){let e=[...l].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e.map(String))}})(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType}),io=eE("ZodEnum",(e,t)=>{rj.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=H(e._zod.def.entries);if(0===i.length){r.not={};return}i.every(e=>"number"==typeof e)&&(r.type="number"),i.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=i})(e,0,r,0),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{let i={};for(let n of e)if(r.has(n))i[n]=t.entries[n];else throw Error(`Key ${n} not found in enum`);return new io({...t,checks:[],...eo(n),entries:i})},e.exclude=(e,n)=>{let i={...t.entries};for(let t of e)if(r.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new io({...t,checks:[],...eo(n),entries:i})}});function il(e,t){return new io({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...eo(t)})}let iu=eE("ZodLiteral",(e,t)=>{rw.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=e._zod.def;if(0===i.values.length){r.not={};return}let s=[];for(let a of i.values)if(void 0===a){if(r1(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof a){if(r1(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(0===s.length);else if(1===s.length){let e=s[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else s.every(e=>"number"==typeof e)&&(r.type="number"),s.every(e=>"string"==typeof e)&&(r.type="string"),s.every(e=>"boolean"==typeof e)&&(r.type="boolean"),s.every(e=>null===e)&&(r.type="null"),r.enum=s})(e,t,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ic(e,t){return new iu({type:"literal",values:Array.isArray(e)?e:[e],...eo(t)})}let id=eE("ZodTransform",(e,t)=>{n_(),rC.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{r1(e,t,r,n,"Transforms cannot be represented in JSON Schema")},e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new eS(e.constructor.name);r.addIssue=n=>{"string"==typeof n?r.issues.push(eb(n,r.value,t)):(n.fatal&&(n.continue=!1),n.code??(n.code="custom"),"input"in n||(n.input=r.value),n.inst??(n.inst=e),r.issues.push(eb(n)))};let i=t.transform(r.value,r);return i instanceof Promise?i.then(e=>(r.value=e,r)):(r.value=i,r)}}),ip=eE("ZodOptional",(e,t)=>{rO.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>na(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function ih(e){return new ip({type:"optional",innerType:e})}let im=eE("ZodExactOptional",(e,t)=>{rS.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>na(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),ig=eE("ZodNullable",(e,t)=>{rk.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i,s,a;return s=r2((i=e._zod.def).innerType,t,n),a=t.seen.get(e),void("openapi-3.0"===t.target?(a.ref=i.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}])},e.unwrap=()=>e._zod.def.innerType});function iv(e){return new ig({type:"nullable",innerType:e})}let iy=eE("ZodDefault",(e,t)=>{rR.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i,s;return r2((i=e._zod.def).innerType,t,n),t.seen.get(e).ref=i.innerType,void((s=ns(i.defaultValue,e,t,r,n))!==ni&&(r.default=s))},e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ib=eE("ZodPrefault",(e,t)=>{rT.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i=e._zod.def;if(r2(i.innerType,t,n),t.seen.get(e).ref=i.innerType,"input"!==t.io)return;let s=ns(i.defaultValue,e,t,r,n);s!==ni&&(r._prefault=s)})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),ix=eE("ZodNonOptional",(e,t)=>{r$.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i;r2((i=e._zod.def).innerType,t,n),t.seen.get(e).ref=i.innerType},e.unwrap=()=>e._zod.def.innerType}),iA=eE("ZodCatch",(e,t)=>{rz.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let i,s=e._zod.def;r2(s.innerType,t,n),t.seen.get(e).ref=s.innerType;try{i=s.catchValue(void 0)}catch{r1(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),i_=eE("ZodPipe",(e,t)=>{rL.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i,s,a;return s=(i=e._zod.def).in._zod.traits.has("$ZodTransform"),void(r2(a="input"===t.io?s?i.out:i.in:i.out,t,n),t.seen.get(e).ref=a)},e.in=t.in,e.out=t.out});function ij(e,t){return new i_({type:"pipe",in:e,out:t})}let iw=eE("ZodReadonly",(e,t)=>{rN.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{let i;r2((i=e._zod.def).innerType,t,n),t.seen.get(e).ref=i.innerType,r.readOnly=!0},e.unwrap=()=>e._zod.def.innerType}),iC=eE("ZodCustom",(e,t)=>{rD.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,n)=>{r1(e,t,r,n,"Custom types cannot be represented in JSON Schema")}}),iE=ie({name:nE().optional(),description:nE().optional()}),iO=ie({version:nE().optional(),registry:nE().optional()}),iS=ie({kind:nE().min(1,"Required"),metadata:iO.optional(),spec:(_=nE(),new ia((j=new n4({type:"any"}),j._zod)?{type:"record",keyType:_,valueType:j,...eo(void 0)}:{type:"record",keyType:nE(),valueType:_,...eo(j)}))}),ik=ie({display:iE.optional(),default:n2(),plugin:iS}),iR=nE().min(1,"Required").max(75,"Must be 75 or fewer characters long").regex(/^[a-zA-Z0-9_.-]+$/,"Must only contains alphanumerical characters and special characters _ . -"),iP=ie({name:iR}),iT=iP.extend({project:iR});ii("kind",[ie({kind:ic("Datasource"),metadata:iT,spec:ik}),ie({kind:ic("GlobalDatasource"),metadata:iP,spec:ik})]);let i$=ie({name:nE().min(1),spec:ik}),iI=ie({name:nE().optional(),description:nE().optional(),hidden:n2().optional()}),iM=ie({name:nE().min(1),display:iI.optional(),defaultValue:nE().or(n8(nE())).optional(),allowAllValue:n2(),allowMultiple:n2(),customAllValue:nE().optional(),capturingRegexp:nE().optional(),sort:il(["none","alphabetical-asc","alphabetical-desc","numerical-asc","numerical-desc","alphabetical-ci-asc","alphabetical-ci-desc"]).optional(),plugin:iS}),iz=ie({kind:ic("ListVariable"),spec:iM}),iL=ie({name:nE().min(1),display:iI.optional(),value:nE(),constant:n2().optional()}),iV=ii("kind",[ie({kind:ic("TextVariable"),spec:iL}),iz]),iN=ie({name:nE(),description:nE().optional(),hidden:n2().optional(),color:nE().optional()}),iF=ie({display:iN,plugin:iS}),iD=ie({name:nE().optional(),description:nE().optional()}),iq=ie({kind:nE().min(1),spec:ie({name:nE().optional(),plugin:iS})}),iU=ie({name:nE().optional(),url:nE().min(1),tooltip:nE().optional(),renderVariables:n2().optional(),targetBlank:n2().optional()}),iQ=ie({display:iD.optional(),plugin:iS,queries:n8(iq).optional(),links:n8(iU).optional(),annotations:n8(iF).optional()}),iZ=ie({kind:ic("Panel"),spec:iQ}),iH=ie({width:nX(),height:nX(),repeatVariable:ie({value:nE(),maxPer:nX().min(1).max(12).optional(),alignment:il(["horizontal","vertical"]).optional()}).optional()}).optional(),iB=ie({groupId:nX(),panelDefinition:iZ,layoutDefinition:iH});function iW(e){return ie({groupId:nX(),panelDefinition:ie({kind:ic("Panel"),spec:ie({display:iD.optional(),plugin:e,queries:n8(iq).optional(),links:n8(iU).optional(),annotations:n8(iF).optional()})}),layoutDefinition:iH})}let iK=(0,L.createContext)(void 0);function iG(){let e=(0,L.useContext)(iK);if(void 0===e)throw Error("No ValidationSchemasContext found. Did you forget a Provider?");return e}function iJ({children:e}){let[t,r]=(0,L.useState)(i$),[n,i]=(0,L.useState)(iB),[s,a]=(0,L.useState)(iV),[o,l]=(0,L.useState)(iF);return(0,O.jsx)(iK.Provider,{value:{datasourceEditorSchema:t,panelEditorSchema:n,variableEditorSchema:s,annotationEditorSchema:o,setDatasourceEditorSchemaPlugin:function(e){r(ie({name:nE().min(1),spec:ie({display:iE.optional(),default:n2(),plugin:e})}))},setPanelEditorSchemaPlugin:function(e){i(iW(e))},setVariableEditorSchemaPlugin:function(e){a(ii("kind",[ie({kind:ic("ListVariable"),spec:ie({name:nE().min(1),display:iI.optional(),defaultValue:nE().or(n8(nE())).optional(),allowAllValue:n2(),allowMultiple:n2(),customAllValue:nE().optional(),capturingRegexp:nE().optional(),sort:il(["none","alphabetical-asc","alphabetical-desc","numerical-asc","numerical-desc","alphabetical-ci-asc","alphabetical-ci-desc"]).optional(),plugin:e})}),ie({kind:ic("TextVariable"),spec:iL})]))},setAnnotationEditorSchemaPlugin:function(e){l(ie({display:iN,plugin:e}))}},children:e})}var iX=r(7013),iY=r(24483),i0=r(97653);let i1="u"<typeof window||"Deno"in window;function i2(){}function i4(e){return"number"==typeof e&&e>=0&&e!==1/0}function i5(e,t){return e.filter(e=>!t.includes(e))}function i9(e,t){return Math.max(e+(t||0)-Date.now(),0)}function i3(e,t,r){return sc(e)?"function"==typeof t?{...r,queryKey:e,queryFn:t}:{...t,queryKey:e}:e}function i6(e,t,r){return sc(e)?"function"==typeof t?{...r,mutationKey:e,mutationFn:t}:{...t,mutationKey:e}:"function"==typeof e?{...t,mutationFn:e}:{...e}}function i8(e,t,r){return sc(e)?[{...t,queryKey:e},r]:[e||{},t]}function i7(e,t,r){return sc(e)?[{...t,mutationKey:e},r]:[e||{},t]}function se(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:a,stale:o}=e;if(sc(a))if(n){if(t.queryHash!==sr(a,t.options))return!1}else{var l;if(l=t.queryKey,!si(l,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(void 0===i||i===t.state.fetchStatus)&&(!s||!!s(t))}function st(e,t){let{exact:r,fetching:n,predicate:i,mutationKey:s}=e;if(sc(s)){if(!t.options.mutationKey)return!1;if(r){if(sn(t.options.mutationKey)!==sn(s))return!1}else{var a;if(a=t.options.mutationKey,!si(a,s))return!1}}return("boolean"!=typeof n||"loading"===t.state.status===n)&&(!i||!!i(t))}function sr(e,t){return((null==t?void 0:t.queryKeyHashFn)||sn)(e)}function sn(e){return JSON.stringify(e,(e,t)=>sl(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function si(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&!Object.keys(t).some(r=>!si(e[r],t[r]))}function ss(e,t,r=0){if(e===t)return e;if(r>500)return t;let n=so(e)&&so(t);if(n||sl(e)&&sl(t)){let i=n?e.length:Object.keys(e).length,s=n?t:Object.keys(t),a=s.length,o=n?[]:{},l=0;for(let i=0;i<a;i++){let a=n?i:s[i];o[a]=ss(e[a],t[a],r+1),o[a]===e[a]&&l++}return i===a&&l===i?e:o}return t}function sa(e,t){if(e&&!t||t&&!e)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function so(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function sl(e){if(!su(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!su(r)&&!!r.hasOwnProperty("isPrototypeOf")}function su(e){return"[object Object]"===Object.prototype.toString.call(e)}function sc(e){return Array.isArray(e)}function sd(e){return e instanceof Error}function sp(e){return new Promise(t=>{setTimeout(t,e)})}function sh(e){sp(0).then(e)}function sf(e,t,r){return null!=r.isDataEqual&&r.isDataEqual(e,t)?e:"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?ss(e,t):t}let sm=(g=[],v=0,y=e=>{e()},b=e=>{e()},x=e=>{v?g.push(e):sh(()=>{y(e)})},A=()=>{let e=g;g=[],e.length&&sh(()=>{b(()=>{e.forEach(e=>{y(e)})})})},{batch:e=>{let t;v++;try{t=e()}finally{--v||A()}return t},batchCalls:e=>(...t)=>{x(()=>{e(...t)})},schedule:x,setNotifyFunction:e=>{y=e},setBatchNotifyFunction:e=>{b=e}});class sg{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){let t={listener:e};return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}let sv=new class extends sg{constructor(){super(),this.setup=e=>{if(!i1&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;null==(e=this.cleanup)||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.focused!==e&&(this.focused=e,this.onFocus())}onFocus(){this.listeners.forEach(({listener:e})=>{e()})}isFocused(){return"boolean"==typeof this.focused?this.focused:"u"<typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}},sy=["online","offline"],sb=new class extends sg{constructor(){super(),this.setup=e=>{if(!i1&&window.addEventListener){let t=()=>e();return sy.forEach(e=>{window.addEventListener(e,t,!1)}),()=>{sy.forEach(e=>{window.removeEventListener(e,t)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;null==(e=this.cleanup)||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e(e=>{"boolean"==typeof e?this.setOnline(e):this.onOnline()})}setOnline(e){this.online!==e&&(this.online=e,this.onOnline())}onOnline(){this.listeners.forEach(({listener:e})=>{e()})}isOnline(){return"boolean"==typeof this.online?this.online:"u"<typeof navigator||void 0===navigator.onLine||navigator.onLine}};function sx(e){return Math.min(1e3*2**e,3e4)}function sA(e){return(null!=e?e:"online")!=="online"||sb.isOnline()}class s_{constructor(e){this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent}}function sj(e){return e instanceof s_}function sw(e){let t,r,n,i=!1,s=0,a=!1,o=new Promise((e,t)=>{r=e,n=t}),l=()=>!sv.isFocused()||"always"!==e.networkMode&&!sb.isOnline(),u=n=>{a||(a=!0,null==e.onSuccess||e.onSuccess(n),null==t||t(),r(n))},c=r=>{a||(a=!0,null==e.onError||e.onError(r),null==t||t(),n(r))},d=()=>new Promise(r=>{t=e=>{let t=a||!l();return t&&r(e),t},null==e.onPause||e.onPause()}).then(()=>{t=void 0,a||null==e.onContinue||e.onContinue()}),p=()=>{let t;if(!a){try{t=e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(u).catch(t=>{var r,n;if(a)return;let o=null!=(r=e.retry)?r:3,u=null!=(n=e.retryDelay)?n:sx,h="function"==typeof u?u(s,t):u,f=!0===o||"number"==typeof o&&s<o||"function"==typeof o&&o(s,t);i||!f?c(t):(s++,null==e.onFail||e.onFail(s,t),sp(h).then(()=>{if(l())return d()}).then(()=>{i?c(t):p()}))})}};return sA(e.networkMode)?p():d().then(p),{promise:o,cancel:t=>{a||(c(new s_(t)),null==e.abort||e.abort())},continue:()=>(null==t?void 0:t())?o:Promise.resolve(),cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1}}}class sC extends sg{constructor(e,t){super(),this.client=e,this.options=t,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.currentQuery.addObserver(this),sE(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return sO(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return sO(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(e,t){let r=this.options,n=this.currentQuery;if(this.options=this.client.defaultQueryOptions(e),sa(r,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),this.updateQuery();let i=this.hasListeners();i&&sS(this.currentQuery,n,this.options,r)&&this.executeFetch(),this.updateResult(t),i&&(this.currentQuery!==n||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&this.updateStaleTimeout();let s=this.computeRefetchInterval();i&&(this.currentQuery!==n||this.options.enabled!==r.enabled||s!==this.currentRefetchInterval)&&this.updateRefetchInterval(s)}getOptimisticResult(e){var t,r,n;let i=this.client.getQueryCache().build(this.client,e),s=this.createResult(i,e);return t=this,r=s,(n=e).keepPreviousData||(void 0!==n.placeholderData?!r.isPlaceholderData:sa(t.getCurrentResult(),r))||(this.currentResult=s,this.currentResultOptions=this.options,this.currentResultState=this.currentQuery.state),s}getCurrentResult(){return this.currentResult}trackResult(e){let t={};return Object.keys(e).forEach(r=>{Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(r),e[r])})}),t}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:e,...t}={}){return this.fetch({...t,meta:{refetchPage:e}})}fetchOptimistic(e){let t=this.client.defaultQueryOptions(e),r=this.client.getQueryCache().build(this.client,t);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,t))}fetch(e){var t;return this.executeFetch({...e,cancelRefetch:null==(t=e.cancelRefetch)||t}).then(()=>(this.updateResult(),this.currentResult))}executeFetch(e){this.updateQuery();let t=this.currentQuery.fetch(this.options,e);return null!=e&&e.throwOnError||(t=t.catch(i2)),t}updateStaleTimeout(){if(this.clearStaleTimeout(),i1||this.currentResult.isStale||!i4(this.options.staleTime))return;let e=i9(this.currentResult.dataUpdatedAt,this.options.staleTime);this.staleTimeoutId=setTimeout(()=>{this.currentResult.isStale||this.updateResult()},e+1)}computeRefetchInterval(){var e;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(e=this.options.refetchInterval)&&e}updateRefetchInterval(e){this.clearRefetchInterval(),this.currentRefetchInterval=e,!i1&&!1!==this.options.enabled&&i4(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval(()=>{(this.options.refetchIntervalInBackground||sv.isFocused())&&this.executeFetch()},this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(e,t){let r,n=this.currentQuery,i=this.options,s=this.currentResult,a=this.currentResultState,o=this.currentResultOptions,l=e!==n,u=l?e.state:this.currentQueryInitialState,c=l?this.currentResult:this.previousQueryResult,{state:d}=e,{dataUpdatedAt:p,error:h,errorUpdatedAt:f,fetchStatus:m,status:g}=d,v=!1,y=!1;if(t._optimisticResults){let r=this.hasListeners(),s=!r&&sE(e,t),a=r&&sS(e,n,t,i);(s||a)&&(m=sA(e.options.networkMode)?"fetching":"paused",p||(g="loading")),"isRestoring"===t._optimisticResults&&(m="idle")}if(t.keepPreviousData&&!d.dataUpdatedAt&&null!=c&&c.isSuccess&&"error"!==g)r=c.data,p=c.dataUpdatedAt,g=c.status,v=!0;else if(t.select&&void 0!==d.data)if(s&&d.data===(null==a?void 0:a.data)&&t.select===this.selectFn)r=this.selectResult;else try{this.selectFn=t.select,r=t.select(d.data),r=sf(null==s?void 0:s.data,r,t),this.selectResult=r,this.selectError=null}catch(e){this.selectError=e}else r=d.data;if(void 0!==t.placeholderData&&void 0===r&&"loading"===g){let e;if(null!=s&&s.isPlaceholderData&&t.placeholderData===(null==o?void 0:o.placeholderData))e=s.data;else if(e="function"==typeof t.placeholderData?t.placeholderData():t.placeholderData,t.select&&void 0!==e)try{e=t.select(e),this.selectError=null}catch(e){this.selectError=e}void 0!==e&&(g="success",r=sf(null==s?void 0:s.data,e,t),y=!0)}this.selectError&&(h=this.selectError,r=this.selectResult,f=Date.now(),g="error");let b="fetching"===m,x="loading"===g,A="error"===g;return{status:g,fetchStatus:m,isLoading:x,isSuccess:"success"===g,isError:A,isInitialLoading:x&&b,data:r,dataUpdatedAt:p,error:h,errorUpdatedAt:f,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:b,isRefetching:b&&!x,isLoadingError:A&&0===d.dataUpdatedAt,isPaused:"paused"===m,isPlaceholderData:y,isPreviousData:v,isRefetchError:A&&0!==d.dataUpdatedAt,isStale:sk(e,t),refetch:this.refetch,remove:this.remove}}updateResult(e){let t=this.currentResult,r=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,sa(r,t))return;this.currentResult=r;let n={cache:!0},i=()=>{if(!t)return!0;let{notifyOnChangeProps:e}=this.options,r="function"==typeof e?e():e;if("all"===r||!r&&!this.trackedProps.size)return!0;let n=new Set(null!=r?r:this.trackedProps);return this.options.useErrorBoundary&&n.add("error"),Object.keys(this.currentResult).some(e=>this.currentResult[e]!==t[e]&&n.has(e))};(null==e?void 0:e.listeners)!==!1&&i()&&(n.listeners=!0),this.notify({...n,...e})}updateQuery(){let e=this.client.getQueryCache().build(this.client,this.options);if(e===this.currentQuery)return;let t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))}onQueryUpdate(e){let t={};"success"===e.type?t.onSuccess=!e.manual:"error"!==e.type||sj(e.error)||(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()}notify(e){sm.batch(()=>{var t,r,n,i,s,a,o,l;e.onSuccess?(null==(t=(r=this.options).onSuccess)||t.call(r,this.currentResult.data),null==(n=(i=this.options).onSettled)||n.call(i,this.currentResult.data,null)):e.onError&&(null==(s=(a=this.options).onError)||s.call(a,this.currentResult.error),null==(o=(l=this.options).onSettled)||o.call(l,void 0,this.currentResult.error)),e.listeners&&this.listeners.forEach(({listener:e})=>{e(this.currentResult)}),e.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})})}}function sE(e,t){return!1!==t.enabled&&!e.state.dataUpdatedAt&&("error"!==e.state.status||!1!==t.retryOnMount)||e.state.dataUpdatedAt>0&&sO(e,t,t.refetchOnMount)}function sO(e,t,r){if(!1!==t.enabled){let n="function"==typeof r?r(e):r;return"always"===n||!1!==n&&sk(e,t)}return!1}function sS(e,t,r,n){return!1!==r.enabled&&(e!==t||!1===n.enabled)&&(!r.suspense||"error"!==e.state.status)&&sk(e,r)}function sk(e,t){return e.isStaleByTime(t.staleTime)}let sR=r(43676).useSyncExternalStore;function sP(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}let sT=L.createContext(sP()),s$=()=>L.useContext(sT),sI=({children:e})=>{let[t]=L.useState(()=>sP());return L.createElement(sT.Provider,{value:t},"function"==typeof e?e(t):e)},sM=L.createContext(!1),sz=()=>L.useContext(sM),sL=sM.Provider;function sV(e,t){return"function"==typeof e?e(...t):!!e}let sN=(e,t)=>{(e.suspense||e.useErrorBoundary)&&!t.isReset()&&(e.retryOnMount=!1)},sF=e=>{L.useEffect(()=>{e.clearReset()},[e])},sD=({result:e,errorResetBoundary:t,useErrorBoundary:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&sV(r,[e.error,n]),sq=e=>{e.suspense&&("number"!=typeof e.staleTime&&(e.staleTime=1e3),"number"==typeof e.cacheTime&&(e.cacheTime=Math.max(e.cacheTime,1e3)))},sU=(e,t)=>e.isLoading&&e.isFetching&&!t,sQ=(e,t,r)=>(null==e?void 0:e.suspense)&&sU(t,r),sZ=(e,t,r)=>t.fetchOptimistic(e).then(({data:t})=>{null==e.onSuccess||e.onSuccess(t),null==e.onSettled||e.onSettled(t,null)}).catch(t=>{r.clearReset(),null==e.onError||e.onError(t),null==e.onSettled||e.onSettled(void 0,t)});function sH(e,t){let r=q({context:e.context}),n=sz(),i=s$(),s=r.defaultQueryOptions(e);s._optimisticResults=n?"isRestoring":"optimistic",s.onError&&(s.onError=sm.batchCalls(s.onError)),s.onSuccess&&(s.onSuccess=sm.batchCalls(s.onSuccess)),s.onSettled&&(s.onSettled=sm.batchCalls(s.onSettled)),sq(s),sN(s,i),sF(i);let[a]=L.useState(()=>new t(r,s)),o=a.getOptimisticResult(s);if(sR(L.useCallback(e=>{let t=n?()=>void 0:a.subscribe(sm.batchCalls(e));return a.updateResult(),t},[a,n]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),L.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),sQ(s,o,n))throw sZ(s,a,i);if(sD({result:o,errorResetBoundary:i,useErrorBoundary:s.useErrorBoundary,query:a.getCurrentQuery()}))throw o.error;return s.notifyOnChangeProps?o:a.trackResult(o)}function sB(e,t,r){return sH(i3(e,t,r),sC)}class sW extends sg{constructor(e,t){super(),this.client=e,this.queries=[],this.result=[],this.observers=[],this.observersMap={},t&&this.setQueries(t)}onSubscribe(){1===this.listeners.size&&this.observers.forEach(e=>{e.subscribe(t=>{this.onUpdate(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.observers.forEach(e=>{e.destroy()})}setQueries(e,t){this.queries=e,sm.batch(()=>{let e=this.observers,r=this.findMatchingObservers(this.queries);r.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions,t));let n=r.map(e=>e.observer),i=Object.fromEntries(n.map(e=>[e.options.queryHash,e])),s=n.map(e=>e.getCurrentResult()),a=n.some((t,r)=>t!==e[r]);e.length===n.length&&!a||(this.observers=n,this.observersMap=i,this.result=s,this.hasListeners()&&(i5(e,n).forEach(e=>{e.destroy()}),i5(n,e).forEach(e=>{e.subscribe(t=>{this.onUpdate(e,t)})}),this.notify()))})}getCurrentResult(){return this.result}getQueries(){return this.observers.map(e=>e.getCurrentQuery())}getObservers(){return this.observers}getOptimisticResult(e){return this.findMatchingObservers(e).map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions))}findMatchingObservers(e){let t=this.observers,r=new Map(t.map(e=>[e.options.queryHash,e])),n=e.map(e=>this.client.defaultQueryOptions(e)),i=n.flatMap(e=>{let t=r.get(e.queryHash);return null!=t?[{defaultedQueryOptions:e,observer:t}]:[]}),s=new Set(i.map(e=>e.defaultedQueryOptions.queryHash)),a=n.filter(e=>!s.has(e.queryHash)),o=new Set(i.map(e=>e.observer)),l=t.filter(e=>!o.has(e)),u=e=>{let t=this.client.defaultQueryOptions(e),r=this.observersMap[t.queryHash];return null!=r?r:new sC(this.client,t)},c=a.map((e,t)=>{if(e.keepPreviousData){let r=l[t];if(void 0!==r)return{defaultedQueryOptions:e,observer:r}}return{defaultedQueryOptions:e,observer:u(e)}});return i.concat(c).sort((e,t)=>n.indexOf(e.defaultedQueryOptions)-n.indexOf(t.defaultedQueryOptions))}onUpdate(e,t){let r=this.observers.indexOf(e);if(-1!==r){var n;let e;this.result=(n=this.result,(e=n.slice(0))[r]=t,e),this.notify()}}notify(){sm.batch(()=>{this.listeners.forEach(({listener:e})=>{e(this.result)})})}}function sK({queries:e,context:t}){let r=q({context:t}),n=sz(),i=s$(),s=L.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=n?"isRestoring":"optimistic",t}),[e,r,n]);s.forEach(e=>{sq(e),sN(e,i)}),sF(i);let[a]=L.useState(()=>new sW(r,s)),o=a.getOptimisticResult(s);sR(L.useCallback(e=>n?()=>void 0:a.subscribe(sm.batchCalls(e)),[a,n]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),L.useEffect(()=>{a.setQueries(s,{listeners:!1})},[s,a]);let l=o.some((e,t)=>sQ(s[t],e,n))?o.flatMap((e,t)=>{let r=s[t],o=a.getObservers()[t];if(r&&o)if(sQ(r,e,n))return sZ(r,o,i);else sU(e,n)&&sZ(r,o,i);return[]}):[];if(l.length>0)throw Promise.all(l);let u=a.getQueries(),c=o.find((e,t)=>{var r,n;return sD({result:e,errorResetBoundary:i,useErrorBoundary:null!=(r=null==(n=s[t])?void 0:n.useErrorBoundary)&&r,query:u[t]})});if(null!=c&&c.error)throw c.error;return o}let sG=(0,L.createContext)(void 0);function sJ(){let e=(0,L.useContext)(sG);if(void 0===e)throw Error("PluginRegistryContext not found. Did you forget a provider?");return e}function sX(e,t,r){r={...r,enabled:(r?.enabled??!0)&&void 0!==e&&""!==t};let{getPlugin:n}=sJ();return sB({queryKey:["getPlugin",e,t],queryFn:()=>n({kind:e,name:t}),...r})}function sY(e,t){let{getPlugin:r}=sJ(),n=[...new Set(t.map(e=>e.kind))],i=sK({queries:n.map(t=>({queryKey:["getPlugin",e,t],queryFn:()=>r({kind:e,name:t})}))});return t.map(e=>i[n.indexOf(e.kind)])}function s0(e,t){let{listPluginMetadata:r}=sJ();return sB({queryKey:["listPluginMetadata",e],queryFn:()=>r(e),...t})}function s1(){let{getPlugin:e,listPluginMetadata:t}=sJ();return sB({queryKey:["usePluginBuiltinVariableDefinitions"],queryFn:async()=>{let r=new Set((await t(["Datasource"])).map(e=>e.spec.name)),n=[];for(let t of r){let r=await e({kind:"Datasource",name:t});r.getBuiltinVariableDefinitions&&r.getBuiltinVariableDefinitions().forEach(e=>n.push(e))}return n}})}let s2=(0,L.forwardRef)((e,t)=>{let{pluginTypes:r,value:n,onChange:i,filteredQueryPlugins:s,...a}=e,{data:o,isLoading:l}=s0(r),u=(0,L.useMemo)(()=>s?.length?o?.filter(e=>s.includes(e.spec.name))?.toSorted((e,t)=>e.spec.display.name.localeCompare(t.spec.display.name)):o?.toSorted((e,t)=>e.spec.display.name.localeCompare(t.spec.display.name)),[o,s]),c=!n||l?"":s5(n),d=(0,L.useCallback)(e=>{if(""===e)return"";let t=s9(e);return u?.find(e=>e.kind===t.type&&e.spec.name===t.kind)?.spec.display.name},[u]);return(0,O.jsxs)(T.A,{select:!0,inputRef:t,...a,value:c,"aria-label":c,onChange:e=>{i?.(s9(e.target.value))},SelectProps:{renderValue:d},"data-testid":"plugin-kind-select",children:[l&&(0,O.jsx)(i0.A,{value:"",children:"Loading..."}),u?.map(e=>(0,O.jsx)(i0.A,{"data-testid":"option",value:s5({type:e.kind,kind:e.spec.name}),children:e.spec.display.name},e.kind+e.spec.name))]})});s2.displayName="PluginKindSelect";let s4="_____";function s5(e){return[e.type,e.kind].join(s4)}function s9(e){let t=e.split(s4),r=t[0],n=t[1];if(void 0===r||void 0===n)throw Error("Invalid optionValue string");return{type:r,kind:n}}var s3=r(25742);function s6(e){return"object"==typeof e&&null!==e}var s8=r(43945);function s7({plugin:e,pluginKind:t,value:r,testConnection:n,...i}){let s=e.healthCheckPath,a=(0,L.useMemo)(()=>{if(n&&s)return()=>{let e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n({default:!1,plugin:{kind:t,spec:s6(r)&&s6(r.proxy)&&"HTTPProxy"===r.proxy.kind&&s6(r.proxy.spec)&&"string"==typeof r.proxy.spec.url?(0,s8.produce)(r,t=>{let r=t.proxy.spec.allowedEndpoints??[];r.some(t=>t.endpointPattern===e&&"GET"===t.method)||(t.proxy.spec.allowedEndpoints=[...r,{endpointPattern:e,method:"GET"}])}):r}},s)}},[n,s,t,r]),{OptionsEditorComponent:o}=e;return o?(0,O.jsx)(o,{...i,value:r,testConnection:a}):null}function ae(e){let{pluginSelection:{type:t,kind:r},value:n,testConnection:i,...s}=e,{data:a,isLoading:o,error:l}=sX(t,r);if(l)return(0,O.jsx)(z.ErrorAlert,{error:l});if(o)return(0,O.jsx)($.A,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,O.jsx)(s3.A,{})});if(!a)throw Error(`Missing implementation for ${t} plugin with kind '${r}'`);if("Panel"===t)throw Error("This editor should not be used for panel type. Please use Panel Spec Editor instead.");if("Datasource"===t&&"createClient"in a)return(0,O.jsx)(s7,{plugin:a,pluginKind:r,value:n,testConnection:i,...s});let{OptionsEditorComponent:u}=a;return u?(0,O.jsx)(u,{...s,value:n}):null}function at(e){let t=(0,L.useRef)(e);return(0,L.useLayoutEffect)(()=>{t.current=e}),(0,L.useCallback)((...e)=>t.current(...e),[])}function ar(e){let{pluginTypes:t,value:r,onHideQueryEditorChange:n=()=>{}}=e,i=at(e.onChange),s=at(n),a=(0,L.useRef)({[r.selection.type]:{[r.selection.kind]:r.spec}}),o=at(()=>{let e=a.current[r.selection.type];void 0===e&&(e={},a.current[r.selection.type]=e),e[r.selection.kind]=r.spec}),l=(0,L.useRef)({[r.selection.kind]:!1}),{defaultPluginKinds:u}=sJ(),c=t[0],d=c?u?.[c]:void 0,p=c&&d?{type:c,kind:d}:void 0,h=!r.selection&&p?p:void 0,[f,m]=(0,L.useState)(h);(0,L.useEffect)(()=>{""===r.selection.kind&&(r.selection.kind=d||"")},[r.selection,d]);let{data:g,isFetching:v,error:y}=sX(f?.type,f?.kind||"");return(0,L.useEffect)(()=>{!f||void 0===g||v||(o(),i({selection:f,spec:g.createInitialOptions?g.createInitialOptions():{}}),"Panel"===f.type&&(l.current[f.kind]=!!g.hideQueryEditor,!!g.hideQueryEditor!==l.current[r.selection.kind]&&s(!!g.hideQueryEditor)),m(void 0))},[f,g,v,o,i,s,l,r.selection]),{pendingSelection:f,isLoading:v,error:y,onSelectionChange:e=>{let t=a.current[e.type]?.[e.kind];void 0!==t?(o(),i({selection:e,spec:t})):m(e),"Panel"===e.type&&void 0!==l.current[e.kind]&&l.current[r.selection.kind]!==l.current[e.kind]&&s(!!l.current[e.kind])},onSpecChange:e=>{i((0,s8.produce)(r,t=>{t.spec=e}))},rememberCurrentSpecState:o}}function an(e){let{value:t,withRunQueryButton:r=!0,pluginTypes:n,pluginKindLabel:i,onChange:s,isReadonly:a,onRunQuery:o,filteredQueryPlugins:l,testConnection:u,...c}=e,{pendingSelection:d,isLoading:p,error:h,onSelectionChange:f,onSpecChange:m}=ar(e),g=(0,L.useCallback)(e=>{m(e)},[m]);return(0,O.jsxs)(k.A,{...c,children:[(0,O.jsxs)(k.A,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:1,mb:1},children:[(0,O.jsx)(s2,{fullWidth:!1,sx:{minWidth:120},margin:"dense",label:i,pluginTypes:n,disabled:p,value:d||t.selection,slotProps:{input:{readOnly:a}},error:!!h,helperText:h?.message,onChange:f,filteredQueryPlugins:l}),r&&(0,O.jsx)(iX.A,{"data-testid":"run_query_button",variant:"contained",startIcon:(0,O.jsx)(iY,{}),onClick:o,disabled:p,children:"Run Query"})]}),(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:z.ErrorAlert,children:(0,O.jsx)(ae,{pluginSelection:t.selection,value:t.spec,onChange:g,isReadonly:a,testConnection:u})})]})}let ai="#FF6B6B";var as=r(11750),aa=r(81023),ao=r(77308),al=r(72052),au=r(11502),ac=r(29009),ad=r(46733);function ap(e){return(0,ad.Ay)("MuiCard",e)}(0,ac.A)("MuiCard",["root"]);let ah=(0,ao.A)(au.A,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})({overflow:"hidden"}),af=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiCard"}),{className:n,raised:i=!1,...s}=r,a={...r,raised:i},o=(e=>{let{classes:t}=e;return(0,aa.A)({root:["root"]},ap,t)})(a);return(0,O.jsx)(ah,{className:(0,as.A)(o.root,n),elevation:i?8:void 0,ref:t,ownerState:a,...s})});function am(e){return(0,ad.Ay)("MuiCardContent",e)}(0,ac.A)("MuiCardContent",["root"]);let ag=(0,ao.A)("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})({padding:16,"&:last-child":{paddingBottom:24}}),av=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiCardContent"}),{className:n,component:i="div",...s}=r,a={...r,component:i},o=(e=>{let{classes:t}=e;return(0,aa.A)({root:["root"]},am,t)})(a);return(0,O.jsx)(ag,{as:i,className:(0,as.A)(o.root,n),ownerState:a,ref:t,...s})});var ay=r(47601),ab=r(47599);function ax(e){return(0,ad.Ay)("MuiCardHeader",e)}let aA=(0,ac.A)("MuiCardHeader",["root","avatar","action","content","title","subheader"]);var a_=r(73397);let aj=(0,ao.A)("div",{name:"MuiCardHeader",slot:"Root",overridesResolver:(e,t)=>[{[`& .${aA.title}`]:t.title},{[`& .${aA.subheader}`]:t.subheader},t.root]})({display:"flex",alignItems:"center",padding:16}),aw=(0,ao.A)("div",{name:"MuiCardHeader",slot:"Avatar",overridesResolver:(e,t)=>t.avatar})({display:"flex",flex:"0 0 auto",marginRight:16}),aC=(0,ao.A)("div",{name:"MuiCardHeader",slot:"Action",overridesResolver:(e,t)=>t.action})({flex:"0 0 auto",alignSelf:"flex-start",marginTop:-4,marginRight:-8,marginBottom:-4}),aE=(0,ao.A)("div",{name:"MuiCardHeader",slot:"Content",overridesResolver:(e,t)=>t.content})({flex:"1 1 auto",[`.${ab.A.root}:where(& .${aA.title})`]:{display:"block"},[`.${ab.A.root}:where(& .${aA.subheader})`]:{display:"block"}}),aO=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiCardHeader"}),{action:n,avatar:i,component:s="div",disableTypography:a=!1,subheader:o,subheaderTypographyProps:l,title:u,titleTypographyProps:c,slots:d={},slotProps:p={},...h}=r,f={...r,component:s,disableTypography:a},m=(e=>{let{classes:t}=e;return(0,aa.A)({root:["root"],avatar:["avatar"],action:["action"],content:["content"],title:["title"],subheader:["subheader"]},ax,t)})(f),g={slots:d,slotProps:{title:c,subheader:l,...p}},v=u,[y,b]=(0,a_.A)("title",{className:m.title,elementType:R.A,externalForwardedProps:g,ownerState:f,additionalProps:{variant:i?"body2":"h5",component:"span"}});null==v||v.type===R.A||a||(v=(0,O.jsx)(y,{...b,children:v}));let x=o,[A,_]=(0,a_.A)("subheader",{className:m.subheader,elementType:R.A,externalForwardedProps:g,ownerState:f,additionalProps:{variant:i?"body2":"body1",color:"textSecondary",component:"span"}});null==x||x.type===R.A||a||(x=(0,O.jsx)(A,{..._,children:x}));let[j,w]=(0,a_.A)("root",{ref:t,className:m.root,elementType:aj,externalForwardedProps:{...g,...h,component:s},ownerState:f}),[C,E]=(0,a_.A)("avatar",{className:m.avatar,elementType:aw,externalForwardedProps:g,ownerState:f}),[S,k]=(0,a_.A)("content",{className:m.content,elementType:aE,externalForwardedProps:g,ownerState:f}),[P,T]=(0,a_.A)("action",{className:m.action,elementType:aC,externalForwardedProps:g,ownerState:f});return(0,O.jsxs)(j,{...w,children:[i&&(0,O.jsx)(C,{...E,children:i}),(0,O.jsxs)(S,{...k,children:[v,x]}),n&&(0,O.jsx)(P,{...T,children:n})]})});var aS=r(4178);let ak=(0,L.createContext)(void 0);function aR(){let e=(0,L.useContext)(ak);if(void 0===e)throw Error("No DatasourceStoreContext found. Did you forget a Provider?");return e}function aP(e,t){let{listDatasourceSelectItems:r}=aR();return sB({queryKey:["listDatasourceSelectItems",e,t],queryFn:()=>r(e)})}function aT(e){let t=aR();return sB({queryKey:["getDatasourceClient",e],queryFn:()=>t.getDatasourceClient(e)})}function a$(e){let t=aR();return sB({queryKey:["getDatasource",e],queryFn:()=>t.getDatasource(e)})}var aI=r(26124),aM=r(88685),az=r(88034);let aL=[{value:{pastDuration:"0s"},display:"Off"},{value:{pastDuration:"5s"},display:"5s"},{value:{pastDuration:"10s"},display:"10s"},{value:{pastDuration:"15s"},display:"15s"},{value:{pastDuration:"30s"},display:"30s"},{value:{pastDuration:"60s"},display:"1m"}],aV={showCustom:!0,showZoomButtons:!0,disableAutoRefresh:!1,autoRefreshIntervalOptions:aL,options:["5m","15m","30m","1h","6h","12h","24h","7d","14d"].map(e=>(0,z.buildRelativeTimeOption)(e))},aN=(0,L.createContext)(aV);function aF(){let e=(0,L.useContext)(aN);if(void 0===e)throw Error("No TimeRangeContext found. Did you forget a Provider?");return e}function aD(){return aF()}function aq(e){let t=aD().showCustom;return void 0!==e?e:t}function aU(e){let t=aD().showZoomButtons;return void 0!==e?e:t}function aQ(e){let t=aD().options;return void 0!==e?e:t}function aZ(e){let t=aD().disableAutoRefresh;return void 0!==e?e:t}function aH(e){let{autoRefreshIntervalOptions:t}=aD();return e?.length?e:t}function aB(e){let t=(0,L.useMemo)(()=>({showCustom:void 0===e.showCustom?aV.showCustom:e.showCustom,showZoomButtons:void 0===e.showZoomButtons?aV.showZoomButtons:e.showZoomButtons,disableAutoRefresh:void 0===e.disableAutoRefresh?aV.disableAutoRefresh:e.disableAutoRefresh,autoRefreshIntervalOptions:e.autoRefreshIntervalOptions?.length?e.autoRefreshIntervalOptions:aV.autoRefreshIntervalOptions,options:void 0===e.options?aV.options:e.options}),[e.showCustom,e.showZoomButtons,e.disableAutoRefresh,e.options,e.autoRefreshIntervalOptions]);return(0,O.jsx)(aN.Provider,{value:t,children:e.children})}let aW=(0,L.createContext)(void 0);function aK(){let e=(0,L.useContext)(aW);if(void 0===e)throw Error("No TimeRangeContext found. Did you forget a Provider?");return e}function aG(){return aK()}function aJ(e){let{absoluteTimeRange:t}=aG();return void 0===e?0:(0,aI.qU)(t,e)}function aX(e){let{timeRange:t,refreshInterval:r,children:n,setTimeRange:i,setRefreshInterval:s}=e,a=aZ(),o=q(),[l,u]=(0,L.useState)((0,aI.bB)(t)?(0,aI.b5)(t):t),c=(0,L.useCallback)(e=>{i(e),u((0,aI.bB)(e)?(0,aI.b5)(e):e)},[i]),d=(0,L.useCallback)(e=>{a||s(e)},[a,s]),p=(0,L.useCallback)(()=>{u((0,aI.bB)(t)?(0,aI.b5)(t):t),o.invalidateQueries({queryKey:["query"]}).finally(()=>o.removeQueries({queryKey:["query"],type:"inactive"})),o.invalidateQueries({queryKey:["variable"]}).finally(()=>o.removeQueries({queryKey:["variable"],type:"inactive"}))},[o,t]),h=(0,L.useCallback)(()=>{u((0,aI.bB)(t)?(0,aI.b5)(t):t),o.invalidateQueries({queryKey:["query"]}).finally(()=>{o.removeQueries({queryKey:["query"],type:"inactive"}),o.removeQueries({queryKey:["variable"],type:"inactive"})})},[o,t]),f=(0,L.useMemo)(()=>a?0:null!=r?(0,az.R)((0,aM.pW)(r)):0,[a,r]);(0,L.useEffect)(()=>{if(f>0){let e=setInterval(()=>{h()},f);return()=>clearInterval(e)}},[h,f]);let m=(0,L.useMemo)(()=>({timeRange:t,setTimeRange:c,absoluteTimeRange:l,refresh:p,refreshInterval:r,refreshIntervalInMs:f,setRefreshInterval:d}),[l,c,p,r,f,d,t]);return(0,O.jsx)(aW.Provider,{value:m,children:n})}function aY(e,t){return t?Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))):e}function a0(e){return Object.values(e).map(e=>JSON.stringify(e.value)).join(",")}let a1=(0,L.createContext)(void 0);function a2(){let e=(0,L.useContext)(a1);if(void 0===e)throw Error("No BuiltinVariableContext found. Did you forget a Provider?");return e}function a4(e){let{variables:t}=a2(),r=(0,L.useMemo)(()=>{let e={};for(let r of t)e[r.spec.name]={loading:!1,value:r.spec.value()};return e},[t]),n=(0,L.useMemo)(()=>{let t={};return e?.forEach(e=>{let n=r[e];n&&(t[e]=n)}),t},[e,r]);return void 0===e?r:n}function a5(){let{variables:e}=a2();return e}class a9{[s8.immerable]=!0;DEFAULT_LOCAL_SOURCE_NAME="";_state={};get(e){return this._sourceStatesOrEmpty(e.source)[e.name]}set(e,t){let r=this._sourceName(e.source);return this._state[r]||(this._state[r]={}),this._sourceStatesOrEmpty(e.source)[e.name]=t,t}has(e){return void 0!==this._sourceStatesOrEmpty(e.source)[e.name]}delete(e){let t=this.has(e),r=this._sourceName(e.source),n=this._state[r];return n&&delete n[e.name],Object.keys(n??{})?.length===0&&delete this._state[r],t}_sourceName(e){return e??this.DEFAULT_LOCAL_SOURCE_NAME}_sourceStatesOrEmpty(e){return this._state[this._sourceName(e)]??{}}}let a3=(0,L.createContext)(void 0);function a6(e){let{state:t}=function(){let e=(0,L.useContext)(a3);if(void 0===e)throw Error("No VariableContext found. Did you forget a Provider?");return e}(),r=(0,L.useMemo)(()=>{let r={};return e?.forEach(e=>{let n=t[e];n&&(r[e]=n)}),r},[t,e]);return void 0===e?t:r}function a8(e){let t=a6(e),r=a4(e);return(0,L.useMemo)(()=>({...t,...r}),[t,r])}function a7(e,t,r){let n={...t};for(let[e,t]of Object.entries(r??{}))n[e]={value:t,loading:!1};return(0,z.replaceVariables)(e,n)}function oe(e){let t=a8(e?(0,z.parseVariables)(e):[]);if(e)return(0,z.replaceVariables)(e,t)}let ot="Annotation";function or(e){let{getPlugin:t}=sJ(),r=function(){let{absoluteTimeRange:e}=aG();return{variableState:a8(),datasourceStore:aR(),absoluteTimeRange:e}}(),n=sY("Annotation",e.map(e=>({kind:e.plugin.kind})));return sK({queries:e.map((e,i)=>{let{queryEnabled:s,queryKey:a}=function({plugin:e,definition:t,context:r}){let{variableState:n,absoluteTimeRange:i}=r,s=e?.dependsOn?e.dependsOn(t.plugin.spec,r):{},a=s?.variables,o=[ot,t,i,a0(aY(n,a))],l=!1;return a&&(l=a.some(e=>n[e]?.loading)),{queryKey:o,queryEnabled:void 0!==e&&!l}}({context:r,definition:e,plugin:n[i]?.data}),o=e?.plugin?.kind;return{enabled:s,queryKey:a,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryFn:async({signal:n})=>{let i=await t({kind:ot,name:o});return await i.getAnnotationData(e.plugin.spec,r,n)}}})})}function on(e){let{data:t}=sX("Annotation",e.plugin.kind),r=aR(),n=a8(),{absoluteTimeRange:i}=aG(),s={absoluteTimeRange:i,datasourceStore:r,variableState:n},a=Object.keys(n);if(t?.dependsOn){let r=t.dependsOn(e.plugin.spec,s);a=r.variables?r.variables:a}let o=a8(a),l=!1;return a&&(l=a.some(e=>o[e]?.loading)),sB({queryKey:["annotation",e,i,a0(o)],queryFn:async({signal:r})=>{let n=await t?.getAnnotationData(e.plugin.spec,{...s,variableState:o},r);return n?.length?n:[]},enabled:!!t||l})}function oi({value:e,formatWithUserTimeZone:t,...r}){let n=(0,z.getDateAndTime)(e.start,t),i=void 0!==e.end?(0,z.getDateAndTime)(e.start,t):null,s=(0,L.useMemo)(()=>Object.entries(e.tags??[]).map(([e,t])=>({key:e,value:t})),[e.tags]);return(0,O.jsx)(af,{...r,children:(0,O.jsxs)(av,{children:[(0,O.jsxs)($.A,{gap:2,children:[e.title&&(0,O.jsx)(R.A,{variant:"h3",children:e.title}),e.legend&&(0,O.jsx)(R.A,{children:e.legend}),(0,O.jsx)($.A,{flexWrap:"wrap",direction:"row",gap:.5,children:s.map(e=>(0,O.jsx)(ay.A,{size:"small",label:`${e.key}: ${e.value}`},`${e.key}=${e.value}`))})]}),(0,O.jsx)(M.A,{sx:{marginY:2}}),(0,O.jsxs)($.A,{gap:.5,direction:"row",children:[(0,O.jsxs)(R.A,{variant:"caption",children:[n.formattedDate," - ",(0,O.jsx)("strong",{children:n.formattedTime})]}),i&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(R.A,{variant:"caption",children:" → "}),(0,O.jsxs)(R.A,{variant:"caption",children:[i.formattedDate," - ",(0,O.jsx)("strong",{children:i.formattedTime})]})]})]})]})})}function os({spec:e,...t}){let{data:r,isFetching:n,error:i}=on(e),{formatWithUserTimeZone:s}=(0,z.useTimeZone)(),[a,o]=(0,L.useState)(!1),l=a?r:r?.slice(0,1),u=0;r&&r?.length>0&&l&&(u=r.length-l.length);let c=(0,L.useMemo)(()=>n?(0,O.jsx)(s3.A,{"aria-label":"loading",size:"1.125rem"}):i?(0,O.jsx)(z.InfoTooltip,{description:i.toString(),children:(0,O.jsx)(I.A,{"aria-label":"preview errors",size:"small",children:(0,O.jsx)(aS,{fontSize:"inherit",sx:{color:e=>e.palette.error.main}})})}):void 0,[n,i]);return(0,O.jsxs)(af,{variant:"outlined",...t,children:[(0,O.jsx)(aO,{title:(0,O.jsxs)($.A,{direction:"row",justifyContent:"space-between",children:[(0,O.jsx)(R.A,{variant:"h4",children:"Preview Annotations"}),c]})}),(0,O.jsxs)(av,{sx:{display:"flex",flexWrap:"wrap",gap:1,paddingY:0},children:[l?.map((e,t)=>(0,O.jsx)(oi,{value:e,formatWithUserTimeZone:s,sx:{width:"100%"}},t)),u>0&&(0,O.jsx)(ay.A,{onClick:()=>o(!0),variant:"outlined",size:"small",label:`+${u} more`}),a&&r&&r.length>1&&(0,O.jsx)(ay.A,{onClick:()=>o(!1),variant:"outlined",size:"small",label:"-"})]})]})}function oa(){return(0,O.jsx)("div",{children:"Error previewing annotations"})}function oo({action:e,control:t,onRunQuery:r}){let n=(0,Z.useWatch)({control:t,name:"plugin"}),i=n?.kind,s=n?.spec;return(0,O.jsx)(Z.Controller,{control:t,name:"plugin",render:({field:t})=>(0,O.jsx)(an,{withRunQueryButton:!0,width:"100%",pluginTypes:["Annotation"],pluginKindLabel:"Source",value:{selection:{type:"Annotation",kind:i??"StaticListAnnotation"},spec:s??{}},isReadonly:"read"===e,onChange:e=>{t.onChange({kind:e.selection.kind,spec:e.spec})},onRunQuery:r})})}function ol({initialAnnotationSpec:e,action:t,isDraft:r,isReadonly:n,onActionChange:i,onSave:s,onClose:a,onDelete:o}){let l=q(),[u,c]=(0,L.useState)(!1),d=(0,z.getTitleAction)(t,r),p=(0,z.getSubmitText)(t,r),{annotationEditorSchema:h}=iG(),f=(0,Z.useForm)({resolver:(0,S.zodResolver)(h),mode:"onBlur",defaultValues:e}),[m,g]=(0,L.useState)(structuredClone(f.getValues())),v=(0,L.useCallback)(async()=>{let e=f.getValues();JSON.stringify(m)===JSON.stringify(e)?await l.invalidateQueries({queryKey:["annotation",m]}):g(structuredClone(e))},[f,m,l]);return(0,O.jsxs)(Z.FormProvider,{...f,children:[(0,O.jsxs)(k.A,{sx:{display:"flex",alignItems:"center",padding:e=>e.spacing(1,2),borderBottom:e=>`1px solid ${e.palette.divider}`},children:[(0,O.jsxs)(R.A,{variant:"h2",children:[d," Annotation"]}),(0,O.jsx)(z.FormActions,{action:t,submitText:p,isReadonly:n,isValid:f.formState.isValid,onActionChange:i,onSubmit:f.handleSubmit(e=>{s(e)}),onDelete:o,onCancel:function(){JSON.stringify(e)!==JSON.stringify(f.getValues())?c(!0):a()}})]}),(0,O.jsxs)(k.A,{padding:2,sx:{overflowY:"scroll"},children:[(0,O.jsxs)(P.Ay,{container:!0,spacing:2,mb:2,children:[(0,O.jsx)(P.Ay,{item:!0,xs:12,children:(0,O.jsx)(Z.Controller,{control:f.control,name:"display.name",render:({field:e,fieldState:n})=>(0,O.jsx)(T.A,{...e,required:!0,fullWidth:!0,label:"Name",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{disabled:"update"===t&&!r,readOnly:"read"===t},error:!!n.error,helperText:n.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:12,children:(0,O.jsxs)($.A,{direction:"row",gap:1,children:[(0,O.jsx)(Z.Controller,{control:f.control,name:"display.color",render:({field:e})=>{let t=void 0!==e.value;return(0,O.jsx)(O.Fragment,{children:t?(0,O.jsx)(z.OptionsColorPicker,{size:"medium",label:"annotation",color:e.value??ai,onColorChange:t=>e.onChange(t),onClear:()=>e.onChange(void 0)}):(0,O.jsx)(I.A,{size:"medium",onClick:()=>e.onChange(ai),children:(0,O.jsx)(Q,{})})})}}),(0,O.jsx)(Z.Controller,{control:f.control,name:"display.description",render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Description",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{readOnly:"read"===t},error:!!r.error,helperText:r.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})]})})]}),(0,O.jsx)(M.A,{}),(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:oa,resetKeys:[m],children:(0,O.jsx)(os,{spec:m,sx:{marginY:2}})}),(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:z.ErrorAlert,children:(0,O.jsx)(oo,{action:t,control:f.control,onRunQuery:v})})]}),(0,O.jsx)(z.DiscardChangesConfirmationDialog,{description:"Are you sure you want to discard these changes? Changes cannot be recovered.",isOpen:u,onCancel:()=>{c(!1)},onDiscardChanges:()=>{c(!1),a()}})]})}let ou={first:function(e){return op(e,"first")},last:function(e){return op(e,"last")},"first-number":function(e){return op(e,"first-number")},"last-number":function(e){return op(e,"last-number")},mean:function(e){return op(e,"mean")},sum:function(e){return op(e,"sum")},min:function(e){return op(e,"min")},max:function(e){return op(e,"max")}},oc={first:{label:"First",description:"First value"},last:{label:"Last",description:"Last value"},"first-number":{label:"First *",description:"First numeric value"},"last-number":{label:"Last *",description:"Last numeric value"},mean:{label:"Avg",description:"Average value excluding nulls"},sum:{label:"Sum",description:"The sum of all values"},min:{label:"Min",description:"Minimum value"},max:{label:"Max",description:"Maximum value"}};function od(e,t){let r=t.reduce((e,t)=>(e[t]=void 0,e),{}),n=0,i=0;return e.forEach((t,s)=>{let a=t[1];0===s&&"first"in r&&(r.first=a),s===e.length-1&&"last"in r&&(r.last=a),"number"==typeof a&&(n+=1,i+=a,"first-number"in r&&void 0===r["first-number"]&&(r["first-number"]=a),"last-number"in r&&(r["last-number"]=a),"min"in r&&("number"!=typeof r.min?r.min=a:r.min=Math.min(r.min,a)),"max"in r&&("number"!=typeof r.max?r.max=a:r.max=Math.max(r.max,a)))}),n>0&&"sum"in r&&(r.sum=i),n>0&&"mean"in r&&(r.mean=i/n),r}function op(e,t){return od(e,[t])[t]}let oh=Object.entries(oc).map(([e,t])=>({id:e,...t}));function of({value:e,onChange:t}){let r=oc[e];return(0,O.jsx)(z.OptionsEditorControl,{label:"Calculation",control:(0,O.jsx)(z.SettingsAutocomplete,{value:{...r,id:e},options:oh,onChange:(e,r)=>{t(r.id)},disableClearable:!0})})}var om=r(10740),og=r(68003);function ov(e){let{initialDatasourceDefinition:t,action:r,isDraft:n,isReadonly:i,onActionChange:s,onSave:a,onClose:o,onDelete:l,testConnection:u}=e,[c,d]=(0,L.useState)(!1),p=(0,z.getTitleAction)(r,n),h=(0,z.getSubmitText)(r,n),{datasourceEditorSchema:f}=iG(),m=(0,Z.useForm)({resolver:(0,S.zodResolver)(f),mode:"onBlur",defaultValues:t});function g(e){let t={...e};return t.spec.display?.name===void 0&&t.spec.display?.description===void 0&&delete t.spec.display,t}return(0,O.jsxs)(Z.FormProvider,{...m,children:[(0,O.jsxs)(k.A,{sx:{display:"flex",alignItems:"center",padding:e=>e.spacing(1,2),borderBottom:e=>`1px solid ${e.palette.divider}`},children:[(0,O.jsxs)(R.A,{variant:"h2",children:[p," Datasource"]}),(0,O.jsx)(z.FormActions,{action:r,submitText:h,isReadonly:i,isValid:m.formState.isValid,onActionChange:s,onSubmit:m.handleSubmit(e=>{a(g(e))}),onDelete:l,onCancel:function(){JSON.stringify(t)!==JSON.stringify(g(m.getValues()))?d(!0):o()}})]}),(0,O.jsxs)(k.A,{padding:2,sx:{overflowY:"scroll"},children:[(0,O.jsxs)(P.Ay,{container:!0,spacing:2,mb:2,children:[(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(Z.Controller,{control:m.control,name:"name",render:({field:e,fieldState:t})=>(0,O.jsx)(T.A,{...e,required:!0,fullWidth:!0,name:"name",label:"Name",InputLabelProps:{shrink:"read"===r||void 0},InputProps:{disabled:"update"===r&&!n,readOnly:"read"===r},error:!!t.error,helperText:t.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:8,children:(0,O.jsx)(Z.Controller,{control:m.control,name:"spec.display.name",render:({field:e,fieldState:t})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,name:"title",label:"Display Label",InputLabelProps:{shrink:"read"===r||void 0},InputProps:{readOnly:"read"===r},error:!!t.error,helperText:t.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:12,children:(0,O.jsx)(Z.Controller,{control:m.control,name:"spec.display.description",render:({field:e,fieldState:t})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,name:"description",label:"Description",InputLabelProps:{shrink:"read"===r||void 0},InputProps:{readOnly:"read"===r},error:!!t.error,helperText:t.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:6,sx:{paddingTop:"5px !important"},children:(0,O.jsxs)($.A,{children:[(0,O.jsx)(Z.Controller,{control:m.control,name:"spec.default",render:({field:e})=>(0,O.jsx)(om.A,{label:"Set as default",control:(0,O.jsx)(og.A,{...e,checked:!!e.value,readOnly:"read"===r,onChange:t=>{"read"!==r&&e.onChange(t)}})})}),(0,O.jsxs)(R.A,{variant:"caption",children:["Whether this datasource should be the default ",m.getValues().spec.plugin.kind," to be used"]})]})})]}),(0,O.jsx)(M.A,{}),(0,O.jsx)(R.A,{py:1,variant:"h3",children:"Plugin Options"}),(0,O.jsx)(Z.Controller,{control:m.control,name:"spec.plugin",render:({field:e})=>(0,O.jsx)(an,{width:"100%",pluginTypes:["Datasource"],pluginKindLabel:"Source",withRunQueryButton:!1,value:{selection:{type:"Datasource",kind:e.value.kind},spec:e.value.spec},isReadonly:"read"===r,onChange:t=>{e.onChange({kind:t.selection.kind,spec:t.spec})},testConnection:u})})]}),(0,O.jsx)(z.DiscardChangesConfirmationDialog,{description:"Are you sure you want to discard your changes? Changes cannot be recovered.",isOpen:c,onCancel:()=>d(!1),onDiscardChanges:()=>{d(!1),o()}})]})}var oy=r(31271),ob=r(14045),ox=r(10571);let oA="__DATASOURCE_VARIABLE_VALUE__",o_={name:"",value:""};function oj(e){let{datasourcePluginKind:t,value:r,project:n,readOnly:i,onChange:s,...a}=e,{data:o,isLoading:l}=aP(t,n),u=a6(),c=(0,L.useMemo)(()=>{if(oS(r))return r;let e=(o??[]).flatMap(e=>e.items).find(e=>r.kind===e.selector.kind&&r.name===e.selector.name&&!e.overridden)?.selector.group;return{...r,group:e}},[r,o]),d=(0,L.useMemo)(()=>{let e=(o||[]).flatMap(e=>e.items.map(t=>({groupLabel:e.group,groupEditLink:e.editLink,name:t.name,overriding:t.overriding,overridden:t.overridden,saved:t.saved??!0,group:t.selector.group,value:oE(t.selector)}))),t=new Map(e.map(e=>[e.name,e]));return[...e,...Object.entries(u).flatMap(([e,r])=>Array.isArray(r.value)||!t.get(r.value??"")?[]:{groupLabel:"Variables",name:`$${e}`,saved:!0,value:`${oA}$${e}`})]},[o,u]),p=l?o_:d.find(e=>e.value===oE(c)),h=()=>{};return(0,O.jsx)(oy.A,{readOnly:i,options:d,renderInput:e=>(0,O.jsx)(T.A,{...e,label:a.label,placeholder:""}),groupBy:e=>e.groupLabel||"No group",getOptionLabel:e=>e.name,onChange:(e,r)=>{r?s(oO(r?.value||"")):s({kind:t})},value:p,renderOption:(e,t)=>(0,L.createElement)("li",{...e,key:t.value},(0,O.jsxs)($.A,{direction:"row",alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,O.jsx)(ob.A,{children:(0,O.jsx)(ow,{name:t.name,overridden:t.overridden,overriding:t.overriding})}),!t.saved&&(0,O.jsx)(ob.A,{children:"Save the dashboard to enable this datasource"}),(0,O.jsx)(ob.A,{style:{textAlign:"right"},children:t.groupLabel&&t.groupLabel.length>0&&(0,O.jsx)(ay.A,{disabled:!1,label:t.groupLabel,size:"small",onDelete:t.groupEditLink?h:void 0,deleteIcon:t.groupEditLink?(0,O.jsx)(I.A,{href:t.groupEditLink,target:"_blank",children:(0,O.jsx)(ox,{fontSize:"small"})}):void 0})})]}))})}function ow(e){let{name:t,overridden:r,overriding:n}=e;return(0,O.jsxs)(O.Fragment,{children:[`${t} `,!r&&n&&(0,O.jsx)(k.A,{display:"inline",fontWeight:"normal",color:e=>e.palette.primary.main,children:"(overriding)"}),r&&"(overridden)"]})}let oC="_____";function oE(e){return oS(e)?`${oA}${e}`:[e.kind,e.group??"",e.name??""].join(oC)}function oO(e){if(e.startsWith(oA))return e.split(oA)[1];let t=e.split(oC),r=t[0],n=t[2];if(void 0===r||void 0===n)throw Error("Invalid optionValue string");return{kind:r,name:""===n?void 0:n}}function oS(e){return"string"==typeof e&&e.startsWith("$")}let ok=(e,t,r)=>{if(!oS(e))return e;let[n]=(0,z.parseVariables)(e),i=t[n??""];if(!i||Array.isArray(i.value))return;let s=(r||[]).flatMap(e=>e.items).find(e=>e.name===i.value);if(void 0!==s)return{kind:s.selector.kind,name:s.selector.name}},oR=(e,t)=>{let{data:r}=aP(t),n=a6();return oS(e)?ok(e,n,r)??{kind:t}:e};var oP=r(42524),oT=r(86742);let o$=({testConnection:e,disabled:t,...r})=>{let{successSnackbar:n,exceptionSnackbar:i}=(0,z.useSnackbar)(),[s,a]=(0,L.useState)(!1),o=(0,L.useCallback)(async()=>{a(!0);try{await e(),n("Datasource is healthy")}catch(e){i(e instanceof Error?e:Error("Datasource is not healthy"))}finally{a(!1)}},[e,n,i]);return(0,O.jsx)(iX.A,{onClick:o,color:"info",variant:"outlined",disabled:t||s,...r,children:"Test Connection"})};var oI=r(67987);function oM(e){return(0,ad.Ay)("MuiFormGroup",e)}(0,ac.A)("MuiFormGroup",["root","row","error"]);var oz=r(42872),oL=r(87842);let oV=(0,ao.A)("div",{name:"MuiFormGroup",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:r}=e;return[t.root,r.row&&t.row]}})({display:"flex",flexDirection:"column",flexWrap:"wrap",variants:[{props:{row:!0},style:{flexDirection:"row"}}]}),oN=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiFormGroup"}),{className:n,row:i=!1,...s}=r,a=(0,oz.A)(),o=(0,oL.A)({props:r,muiFormControl:a,states:["error"]}),l={...r,row:i,error:o.error},u=(e=>{let{classes:t,row:r,error:n}=e;return(0,aa.A)({root:["root",r&&"row",n&&"error"]},oM,t)})(l);return(0,O.jsx)(oV,{className:(0,as.A)(u.root,n),ownerState:l,ref:t,...s})});function oF(e){return(0,ad.Ay)("MuiRadioGroup",e)}(0,ac.A)("MuiRadioGroup",["root","row","error"]);var oD=r(29424),oq=r(2203);let oU=L.createContext(void 0);var oQ=r(63392);let oZ=L.forwardRef(function(e,t){let{actions:r,children:n,className:i,defaultValue:s,name:a,onChange:o,value:l,...u}=e,c=L.useRef(null),d=(e=>{let{classes:t,row:r,error:n}=e;return(0,aa.A)({root:["root",r&&"row",n&&"error"]},oF,t)})(e),[p,h]=(0,oq.A)({controlled:l,default:s,name:"RadioGroup"});L.useImperativeHandle(r,()=>({focus:()=>{let e=c.current.querySelector("input:not(:disabled):checked");e||(e=c.current.querySelector("input:not(:disabled)")),e&&e.focus()}}),[]);let f=(0,oD.A)(t,c),m=(0,oQ.A)(a),g=L.useMemo(()=>({name:m,onChange(e){h(e.target.value),o&&o(e,e.target.value)},value:p}),[m,o,h,p]);return(0,O.jsx)(oU.Provider,{value:g,children:(0,O.jsx)(oN,{role:"radiogroup",ref:f,className:(0,as.A)(d.root,i),...u,children:n})})});var oH=r(59238),oB=r(32560),oW=r(22402);let oK=(0,oW.A)((0,O.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"RadioButtonUnchecked"),oG=(0,oW.A)((0,O.jsx)("path",{d:"M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"}),"RadioButtonChecked");var oJ=r(83926),oX=r(23434);let oY=(0,ao.A)("span",{name:"MuiRadioButtonIcon",shouldForwardProp:oJ.A})({position:"relative",display:"flex"}),o0=(0,ao.A)(oK,{name:"MuiRadioButtonIcon"})({transform:"scale(1)"}),o1=(0,ao.A)(oG,{name:"MuiRadioButtonIcon"})((0,oX.A)(({theme:e})=>({left:0,position:"absolute",transform:"scale(0)",transition:e.transitions.create("transform",{easing:e.transitions.easing.easeIn,duration:e.transitions.duration.shortest}),variants:[{props:{checked:!0},style:{transform:"scale(1)",transition:e.transitions.create("transform",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.shortest})}}]}))),o2=function(e){let{checked:t=!1,classes:r={},fontSize:n}=e,i={...e,checked:t};return(0,O.jsxs)(oY,{className:r.root,ownerState:i,children:[(0,O.jsx)(o0,{fontSize:n,className:r.background,ownerState:i}),(0,O.jsx)(o1,{fontSize:n,className:r.dot,ownerState:i})]})};var o4=r(24726),o5=r(70498);function o9(e){return(0,ad.Ay)("MuiRadio",e)}let o3=(0,ac.A)("MuiRadio",["root","checked","disabled","colorPrimary","colorSecondary","sizeSmall"]);var o6=r(26952);let o8=(0,ao.A)(oB.A,{shouldForwardProp:e=>(0,oJ.A)(e)||"classes"===e,name:"MuiRadio",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:r}=e;return[t.root,"medium"!==r.size&&t[`size${(0,o4.A)(r.size)}`],t[`color${(0,o4.A)(r.color)}`]]}})((0,oX.A)(({theme:e})=>({color:(e.vars||e).palette.text.secondary,[`&.${o3.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:{color:"default",disabled:!1,disableRipple:!1},style:{"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:(0,oH.X4)(e.palette.action.active,e.palette.action.hoverOpacity)}}},...Object.entries(e.palette).filter((0,o6.A)()).map(([t])=>({props:{color:t,disabled:!1,disableRipple:!1},style:{"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[t].mainChannel} / ${e.vars.palette.action.hoverOpacity})`:(0,oH.X4)(e.palette[t].main,e.palette.action.hoverOpacity)}}})),...Object.entries(e.palette).filter((0,o6.A)()).map(([t])=>({props:{color:t,disabled:!1},style:{[`&.${o3.checked}`]:{color:(e.vars||e).palette[t].main}}})),{props:{disableRipple:!1},style:{"&:hover":{"@media (hover: none)":{backgroundColor:"transparent"}}}}]}))),o7=(0,O.jsx)(o2,{checked:!0}),le=(0,O.jsx)(o2,{}),lt=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiRadio"}),{checked:n,checkedIcon:i=o7,color:s="primary",icon:a=le,name:o,onChange:l,size:u="medium",className:c,disabled:d,disableRipple:p=!1,slots:h={},slotProps:f={},inputProps:m,...g}=r,v=(0,oz.A)(),y=d;v&&void 0===y&&(y=v.disabled),y??=!1;let b={...r,disabled:y,disableRipple:p,color:s,size:u},x=(e=>{let{classes:t,color:r,size:n}=e,i={root:["root",`color${(0,o4.A)(r)}`,"medium"!==n&&`size${(0,o4.A)(n)}`]};return{...t,...(0,aa.A)(i,o9,t)}})(b),A=L.useContext(oU),_=n,j=(0,o5.A)(l,A&&A.onChange),w=o;if(A){var C,E;void 0===_&&(C=A.value,_="object"==typeof(E=r.value)&&null!==E?C===E:String(C)===String(E)),void 0===w&&(w=A.name)}let S=f.input??m,[k,R]=(0,a_.A)("root",{ref:t,elementType:o8,className:(0,as.A)(x.root,c),shouldForwardComponentProp:!0,externalForwardedProps:{slots:h,slotProps:f,...g},getSlotProps:e=>({...e,onChange:(t,...r)=>{e.onChange?.(t,...r),j(t,...r)}}),ownerState:b,additionalProps:{type:"radio",icon:L.cloneElement(a,{fontSize:a.props.fontSize??u}),checkedIcon:L.cloneElement(i,{fontSize:i.props.fontSize??u}),disabled:y,name:w,checked:_,slots:h,slotProps:{input:"function"==typeof S?S(b):S}}});return(0,O.jsx)(k,{...R,classes:x})});function lr(e){let{children:t,value:r,index:n,...i}=e,s=r===n;return(0,O.jsx)("div",{role:"tabpanel",hidden:!s,id:`options-editor-tabpanel-${n}`,"aria-labelledby":`options-editor-tab-${n}`,...i,children:s&&(0,O.jsx)(k.A,{mt:2,children:t})})}let ln=e=>{let{tabs:t,defaultTab:r,onModeChange:n,isReadonly:i}=e,[s,a]=(0,L.useState)(r);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(k.A,{sx:{borderBottom:1,borderColor:e=>e.palette.divider},children:(0,O.jsx)(oI.A,{children:(0,O.jsx)(oZ,{row:!0,defaultValue:r,value:s,onChange:(e,t)=>{let r=parseInt(t);a(r),n(r)},"aria-labelledby":"Configuration radio",children:t.map(({label:e},t)=>(0,O.jsx)(om.A,{disabled:i,value:t,control:(0,O.jsx)(lt,{}),label:e},e))})})}),t.map(({label:e,content:t},r)=>(0,O.jsx)(lr,{value:s,index:r,children:t},e))]})},li=[],ls=[{name:"allowHeaders",label:"Allowed headers",otherName:"dropHeaders",description:"Only these request headers may be forwarded to the datasource. All other request headers are dropped."},{name:"dropHeaders",label:"Dropped headers",otherName:"allowHeaders",description:"These request headers must not be forwarded to the datasource."}];function la({value:e,onChange:t,isReadonly:r}){return(0,O.jsxs)($.A,{spacing:1,mb:2,children:[(0,O.jsx)(R.A,{variant:"h5",children:"Request header forwarding"}),(0,O.jsx)(R.A,{variant:"body2",children:"Configure either allowed headers or dropped headers. Clear the current list before using the other. Type a header name and press Enter to add it."}),ls.map(n=>(0,O.jsx)(lo,{policy:n,value:e,onChange:t,isReadonly:r},n.name))]})}function lo({policy:e,value:t,onChange:r,isReadonly:n}){let{name:i,label:s,otherName:a,description:o}=e,l=!!(t.allowHeaders?.length&&t.dropHeaders?.length),u=(0,L.useCallback)((e,n)=>{let s=n.map(e=>e.trim()).filter(Boolean);r({...t,[i]:s.length>0?s:void 0})},[i,t,r]),c=(0,L.useCallback)(e=>(0,O.jsx)(T.A,{...e,label:s,error:l,helperText:l?"Allowed headers and dropped headers cannot both be configured.":o,InputProps:{...e.InputProps,readOnly:n},InputLabelProps:{...e.InputLabelProps,shrink:!!n||void 0}}),[n,s,l,o]);return(0,O.jsx)(oy.A,{multiple:!0,freeSolo:!0,autoSelect:!0,options:li,value:t[i]??li,readOnly:n,disabled:!!t[a]?.length&&!t[i]?.length,onChange:u,renderInput:c})}let ll=nE().url();function lu(e){let{value:t,onChange:r,isReadonly:n,initialSpecDirect:i,initialSpecProxy:s,testConnection:a}=e,o="Direct access",l="Proxy";void 0===t.directUrl&&void 0===t.proxy&&Object.assign(t,s);let u=(0,Z.useForm)({defaultValues:{headers:Object.entries(t.proxy?.spec.headers??{}).map(([e,t])=>({name:e,value:t}))}}),{fields:c,append:d,remove:p}=(0,Z.useFieldArray)({control:u.control,name:"headers"}),h=u.watch("headers"),f=new Map,m=new Set;h.forEach(({name:e})=>{if(""!==e){let t=(f.get(e)||0)+1;f.set(e,t),t>1&&m.add(e)}});let g=m.size>0,v=e=>{let n={};e.forEach(({name:e,value:t})=>{""!==e&&(n[e]=t)}),r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.headers=Object.keys(n).length>0?n:void 0)}))},y=(0,L.useCallback)(e=>{r((0,s8.produce)(t,t=>{void 0!==t.proxy&&(t.proxy.spec=e)}))},[t,r]),b=[{label:l,content:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Z.Controller,{name:"URL",render:({field:e,fieldState:i})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"URL",value:t.proxy?.spec.url||"",error:!!i.error,helperText:i.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:n=>{e.onChange(n),r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.url=n.target.value)}))},sx:{mb:2}})}),a&&(0,O.jsx)(k.A,{mb:2,display:"flex",justifyContent:"flex-end",children:(0,O.jsx)(o$,{testConnection:a,disabled:!ll.safeParse(t.proxy?.spec.url).success})}),(0,O.jsx)(R.A,{variant:"h5",mb:2,children:"Allowed endpoints"}),(0,O.jsxs)(P.Ay,{container:!0,spacing:2,mb:2,children:[t.proxy?.spec.allowedEndpoints&&t.proxy?.spec.allowedEndpoints.length!==0?t.proxy.spec.allowedEndpoints.map(({endpointPattern:e,method:i},s)=>(0,O.jsxs)(L.Fragment,{children:[(0,O.jsx)(P.Ay,{item:!0,xs:8,children:(0,O.jsx)(Z.Controller,{name:`Endpoint pattern ${s}`,render:({field:i,fieldState:a})=>(0,O.jsx)(T.A,{...i,fullWidth:!0,label:"Endpoint pattern",value:e,error:!!a.error,helperText:a.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:e=>{i.onChange(e),r((0,s8.produce)(t,t=>{void 0!==t.proxy&&(t.proxy.spec.allowedEndpoints=t.proxy.spec.allowedEndpoints?.map((t,r)=>s===r?{endpointPattern:e.target.value,method:t.method}:t))}))}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:3,children:(0,O.jsx)(Z.Controller,{name:`Method ${s}`,render:({field:e,fieldState:a})=>(0,O.jsxs)(T.A,{...e,select:!0,fullWidth:!0,label:"Method",value:i,error:!!a.error,helperText:a.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:n=>{e.onChange(n),r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.allowedEndpoints=e.proxy.spec.allowedEndpoints?.map((e,t)=>s===t?{endpointPattern:e.endpointPattern,method:n.target.value}:e))}))},children:[(0,O.jsx)(i0.A,{value:"GET",children:"GET"}),(0,O.jsx)(i0.A,{value:"POST",children:"POST"}),(0,O.jsx)(i0.A,{value:"PUT",children:"PUT"}),(0,O.jsx)(i0.A,{value:"PATCH",children:"PATCH"}),(0,O.jsx)(i0.A,{value:"DELETE",children:"DELETE"})]})})}),(0,O.jsx)(P.Ay,{item:!0,xs:1,children:(0,O.jsx)(Z.Controller,{name:`Remove Endpoint ${s}`,render:({field:e})=>(0,O.jsx)(I.A,{...e,disabled:n,onClick:n=>{e.onChange(n),r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.allowedEndpoints=[...e.proxy.spec.allowedEndpoints?.filter((e,t)=>t!==s)||[]])}))},children:(0,O.jsx)(oP,{})})})})]},s)):(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(R.A,{sx:{fontStyle:"italic"},children:"None"})}),(0,O.jsx)(P.Ay,{item:!0,xs:12,sx:{paddingTop:"0px !important",paddingLeft:"5px !important"},children:(0,O.jsx)(I.A,{disabled:n,onClick:()=>r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.allowedEndpoints=[...e.proxy.spec.allowedEndpoints??[],{endpointPattern:"",method:""}])})),children:(0,O.jsx)(oT,{})})})]}),(0,O.jsx)(R.A,{variant:"h5",mb:2,children:"Request Headers"}),(0,O.jsxs)(P.Ay,{container:!0,spacing:2,mb:2,children:[c.length>0?c.map((e,t)=>(0,O.jsxs)(L.Fragment,{children:[(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(Z.Controller,{control:u.control,name:`headers.${t}.name`,render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Header name",error:!!r.error||m.has(e.value),helperText:r.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:r=>{e.onChange(r);let n=[...h];n[t]={name:r.target.value,value:n[t]?.value??""},v(n)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:7,children:(0,O.jsx)(Z.Controller,{control:u.control,name:`headers.${t}.value`,render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Header value",error:!!r.error,helperText:r.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:r=>{e.onChange(r);let n=[...h];n[t]={name:n[t]?.name??"",value:r.target.value},v(n)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:1,children:(0,O.jsx)(I.A,{disabled:n,"aria-label":`Remove header ${h[t]?.name||t}`,onClick:()=>{p(t),v(h.filter((e,r)=>r!==t))},children:(0,O.jsx)(oP,{})})})]},e.id)):(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(R.A,{sx:{fontStyle:"italic"},children:"None"})}),g&&(0,O.jsx)(P.Ay,{item:!0,xs:12,children:(0,O.jsx)(R.A,{variant:"body2",color:"error",children:"Duplicate header names detected. Each header name must be unique."})}),(0,O.jsx)(P.Ay,{item:!0,xs:12,sx:{paddingTop:"0px !important",paddingLeft:"5px !important"},children:(0,O.jsx)(I.A,{disabled:n,onClick:()=>d({name:"",value:""}),children:(0,O.jsx)(oT,{})})})]}),t.proxy&&(0,O.jsx)(la,{value:t.proxy.spec,isReadonly:n,onChange:y}),(0,O.jsxs)($.A,{spacing:1,children:[(0,O.jsx)(R.A,{variant:"h5",children:"Secret"}),(0,O.jsx)(Z.Controller,{name:"Secret",render:({field:e,fieldState:i})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Secret",value:t.proxy?.spec.secret||"",error:!!i.error,helperText:i.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:n=>{e.onChange(n),r((0,s8.produce)(t,e=>{void 0!==e.proxy&&(e.proxy.spec.secret=n.target.value)}))}})})]})]})},{label:o,content:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Z.Controller,{name:"URL",render:({field:e,fieldState:i})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"URL",value:t.directUrl||"",error:!!i.error,helperText:i.error?.message,InputProps:{readOnly:n},InputLabelProps:{shrink:!!n||void 0},onChange:n=>{e.onChange(n),r((0,s8.produce)(t,e=>{e.directUrl=n.target.value}))}})}),a&&(0,O.jsx)(k.A,{my:2,display:"flex",justifyContent:"flex-end",children:(0,O.jsx)(o$,{testConnection:a,disabled:!ll.safeParse(t.directUrl).success})})]})}],x=b.findIndex(e=>e.label===o),A=b.findIndex(e=>e.label===l),_=t.proxy?A:x,[j,w]=(0,L.useState)(i),[C,E]=(0,L.useState)(s);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(R.A,{variant:"h4",mt:2,children:"HTTP Settings"}),(0,O.jsx)(ln,{isReadonly:n,tabs:b,defaultTab:_,onModeChange:e=>{if(b[e]?.label===o){E(t);let{proxy:e,...n}=t;r({...n,directUrl:j.directUrl})}else if(b[e]?.label===l){w(t);let{directUrl:e,...n}=t;r({...n,proxy:C.proxy})}}})]})}var lc=r(54227),ld=r(76795),lp=r(9799),lh=r(92890),lf=r(91467),lm=r(66834);function lg(e){return(0,ad.Ay)("MuiDialogContentText",e)}(0,ac.A)("MuiDialogContentText",["root"]);let lv=(0,ao.A)(R.A,{shouldForwardProp:e=>(0,oJ.A)(e)||"classes"===e,name:"MuiDialogContentText",slot:"Root",overridesResolver:(e,t)=>t.root})({}),ly=L.forwardRef(function(e,t){let r=(0,al.b)({props:e,name:"MuiDialogContentText"}),{children:n,className:i,...s}=r,a=(e=>{let{classes:t}=e,r=(0,aa.A)({root:["root"]},lg,t);return{...t,...r}})(s);return(0,O.jsx)(lv,{component:"p",variant:"body1",color:"textSecondary",ref:t,ownerState:s,className:(0,as.A)(a.root,i),...r,classes:a})});var lb=r(39750),lx=r(3908),lA=r(87275),l_=r(11061),lj=r(7800),lw=r(10871),lC=r(86067),lE=r(54042),lO=r(17366),lS=r(15810),lk=r(70002),lR=r(4918),lP=r(63808),lT=r(74987),l$=r(82920),lI=r(22996),lM=r(22182),lz=r(70645),lL=r(27683);let lV=["GET","POST","PUT","PATCH","DELETE"],lN=[{value:"individual",label:"Individual (one request per selection)"},{value:"batch",label:"Batch (single request with all selections)"}],lF=[{value:"none",label:"None"},{value:"json",label:"JSON"},{value:"text",label:"Text"}],lD=new Set(["POST","PUT","PATCH"]),lq=[{value:"play",label:"Play",icon:(0,O.jsx)(lP,{fontSize:"inherit"})},{value:"pause",label:"Pause",icon:(0,O.jsx)(lR,{fontSize:"inherit"})},{value:"stop",label:"Stop",icon:(0,O.jsx)(lM,{fontSize:"inherit"})},{value:"delete",label:"Delete",icon:(0,O.jsx)(lC,{fontSize:"inherit"})},{value:"refresh",label:"Refresh",icon:(0,O.jsx)(lT,{fontSize:"inherit"})},{value:"send",label:"Send",icon:(0,O.jsx)(lI,{fontSize:"inherit"})},{value:"download",label:"Download",icon:(0,O.jsx)(lE,{fontSize:"inherit"})},{value:"upload",label:"Upload",icon:(0,O.jsx)(lL,{fontSize:"inherit"})},{value:"check",label:"Check",icon:(0,O.jsx)(lx,{fontSize:"inherit"})},{value:"close",label:"Close",icon:(0,O.jsx)(lj,{fontSize:"inherit"})},{value:"alert",label:"Alert",icon:(0,O.jsx)(aS,{fontSize:"inherit"})},{value:"info",label:"Info",icon:(0,O.jsx)(lO,{fontSize:"inherit"})},{value:"settings",label:"Settings",icon:(0,O.jsx)(lw,{fontSize:"inherit"})},{value:"link",label:"Link",icon:(0,O.jsx)(lS,{fontSize:"inherit"})},{value:"sync",label:"Sync",icon:(0,O.jsx)(lz,{fontSize:"inherit"})},{value:"troubleshoot",label:"Troubleshoot",icon:(0,O.jsx)(lk,{fontSize:"inherit"})},{value:"ask-ai",label:"Ask AI",icon:(0,O.jsx)(l$,{fontSize:"inherit"})}];function lU({batchMode:e}){let t=(0,O.jsxs)("div",{children:["Individual mode patterns: ",(0,O.jsx)("code",{children:'${__data.fields["field"]}'}),", ",(0,O.jsx)("code",{children:"${__data.index}"}),","," ",(0,O.jsx)("code",{children:"${__data.count}"})]});return"batch"===e&&(t=(0,O.jsxs)("div",{children:["Batch mode patterns: ",(0,O.jsx)("code",{children:"${__data}"}),", ",(0,O.jsx)("code",{children:"${__data[0].fields['field']}"}),","," ",(0,O.jsx)("code",{children:"${__data.fields['field']:csv}"}),", ",(0,O.jsx)("code",{children:"${__data.count}"})]})),(0,O.jsx)(R.A,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:t})}function lQ({action:e,index:t,onChange:r,onRemove:n,onMoveDown:i,onMoveUp:s}){let[a,o]=(0,L.useState)(!0),l=(e.bodyTemplate??"").trim().length>0,u=(0,L.useCallback)(n=>{let i="custom"===n.target.value?JSON.stringify({}):void 0;r(t,{...e,bodyTemplate:i})},[t,r,e]),c=(0,L.useCallback)(n=>{r(t,{...e,bodyTemplate:n||void 0})},[t,r,e]),d=(0,L.useMemo)(()=>{if(e.bodyTemplate)try{return JSON.parse(e.bodyTemplate)}catch{return{}}},[e.bodyTemplate]);return(0,O.jsxs)(z.DragAndDropElement,{data:e,children:[(0,O.jsxs)($.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:4,children:[(0,O.jsxs)($.A,{direction:"row",gap:1,children:[(0,O.jsx)(I.A,{"data-testid":`event-action-toggle#${e.name}`,size:"small",onClick:()=>o(!a),children:a?(0,O.jsx)(l_,{}):(0,O.jsx)(lA,{})}),(0,O.jsxs)(R.A,{variant:"overline",component:"h4",sx:{textTransform:"none"},children:["EVENT ACTION:"," ",e.name?(0,O.jsx)("span",{children:(0,O.jsx)("strong",{children:e.name})}):(0,O.jsx)("strong",{children:e.name})]})]}),(0,O.jsxs)($.A,{direction:"row",gap:1,children:[(0,O.jsx)(z.InfoTooltip,{description:"Remove action settings",placement:"top",children:(0,O.jsx)(I.A,{size:"small",sx:{marginLeft:"auto"},onClick:()=>n(t),children:(0,O.jsx)(lC,{})},"delete-action-button")}),(0,O.jsx)(z.InfoTooltip,{description:"Reorder action settings",placement:"top",children:(0,O.jsx)(z.DragButton,{onMoveUp:s,onMoveDown:i,menuSx:{".MuiPaper-root":{backgroundColor:e=>e.palette.background.lighter}}},"reorder-action-button")})]})]}),!a&&(0,O.jsxs)($.A,{spacing:2,children:[(0,O.jsx)(z.OptionsEditorControl,{label:"Enabled",control:(0,O.jsx)(og.A,{checked:e?.enabled??!1,onChange:n=>r(t,{...e,enabled:n.target.checked})})}),(0,O.jsxs)($.A,{direction:"row",spacing:2,children:[(0,O.jsx)(T.A,{label:"Action Name",size:"small",value:e.name,onChange:n=>r(t,{...e,name:n.target.value}),sx:{flexGrow:1}}),(0,O.jsxs)(oI.A,{size:"small",sx:{minWidth:120},children:[(0,O.jsx)(lc.A,{children:"Icon"}),(0,O.jsxs)(ld.A,{value:e.icon||"",label:"Icon",onChange:n=>r(t,{...e,icon:n.target.value||void 0}),children:[(0,O.jsx)(i0.A,{value:"",children:(0,O.jsx)("em",{children:"None"})}),lq.map(e=>(0,O.jsx)(i0.A,{value:e.value,children:(0,O.jsxs)($.A,{direction:"row",alignItems:"center",spacing:1,children:[e.icon,(0,O.jsx)("span",{children:e.label})]})},e.value))]})]})]}),(0,O.jsxs)($.A,{direction:"row",spacing:2,children:[(0,O.jsx)(T.A,{label:"Event Name",size:"small",value:e.eventName,onChange:n=>r(t,{...e,eventName:n.target.value}),helperText:"Name of the CustomEvent to dispatch (e.g., 'selection-action')",fullWidth:!0}),(0,O.jsxs)(oI.A,{size:"small",sx:{flexGrow:1,minWidth:280},children:[(0,O.jsx)(lc.A,{children:"Batch Mode"}),(0,O.jsx)(ld.A,{value:e.batchMode??"individual",label:"Batch Mode",onChange:n=>r(t,{...e,batchMode:n.target.value}),children:lN.map(e=>(0,O.jsx)(i0.A,{value:e.value,children:e.label},e.value))})]})]}),(0,O.jsxs)(oI.A,{component:"fieldset",size:"small",children:[(0,O.jsx)(lp.A,{component:"legend",children:"Template"}),(0,O.jsxs)(oZ,{row:!0,value:l?"custom":"none",onChange:u,children:[(0,O.jsx)(om.A,{value:"none",control:(0,O.jsx)(lt,{size:"small"}),label:"None"}),(0,O.jsx)(om.A,{value:"custom",control:(0,O.jsx)(lt,{size:"small"}),label:"JSON template"})]})]}),l&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(lU,{batchMode:e.batchMode}),(0,O.jsx)(z.JSONEditor,{value:d||"",onChange:c,minHeight:"100px",maxHeight:"200px"})]}),(0,O.jsx)(T.A,{label:"Confirmation Message (optional)",size:"small",value:e.confirmMessage||"",onChange:n=>r(t,{...e,confirmMessage:n.target.value||void 0}),helperText:"If set, shows a confirmation dialog before executing the action",fullWidth:!0,multiline:!0,rows:2})]})]})}function lZ({action:e,index:t,onChange:r,onRemove:n,onMoveUp:i,onMoveDown:s}){let[a,o]=(0,L.useState)(null),l=e.contentType??"none",u=(e.bodyTemplate??"").trim().length>0,c=lD.has(e.method),[d,p]=(0,L.useState)(!0),h=(0,L.useCallback)(n=>{r(t,{...e,bodyTemplate:n||void 0})},[t,r,e]),f=(0,L.useCallback)(n=>{r(t,{...e,bodyTemplate:n.target.value||void 0})},[t,r,e]),m=(0,L.useCallback)(n=>{let i=n.target.value;if(i!==l){if(u)return void o({kind:"contentType",value:i});r(t,{...e,contentType:i})}},[l,u,t,r,e]),g=(0,L.useCallback)(n=>{let i=n.target.value;i===e.method||(!lD.has(i)&&u?o({kind:"method",value:i}):r(t,{...e,method:i}))},[u,t,r,e]),v=(0,L.useCallback)(()=>{o(null)},[]),y=(0,L.useCallback)(()=>{a&&("contentType"===a.kind?r(t,{...e,contentType:a.value,bodyTemplate:void 0}):r(t,{...e,method:a.value,bodyTemplate:void 0}),o(null))},[t,r,a,e]),b=(0,L.useMemo)(()=>{if("json"===e.contentType&&e.bodyTemplate)try{return JSON.parse(e.bodyTemplate)}catch{return{}}},[e.bodyTemplate,e.contentType]);return(0,O.jsxs)(z.DragAndDropElement,{data:e,children:[(0,O.jsxs)($.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:4,children:[(0,O.jsxs)($.A,{direction:"row",gap:1,children:[(0,O.jsx)(I.A,{"data-testid":`column-toggle#${e.name}`,size:"small",onClick:()=>p(!d),children:d?(0,O.jsx)(l_,{}):(0,O.jsx)(lA,{})}),(0,O.jsxs)(R.A,{variant:"overline",component:"h4",sx:{textTransform:"none"},children:["WEBHOOK ACTION: ",(0,O.jsx)("strong",{children:e.name})]})]}),(0,O.jsxs)($.A,{direction:"row",gap:1,children:[(0,O.jsx)(z.InfoTooltip,{description:"Remove action settings",placement:"top",children:(0,O.jsx)(I.A,{size:"small",sx:{marginLeft:"auto"},onClick:()=>n(t),children:(0,O.jsx)(lC,{})},"delete-action-button")}),(0,O.jsx)(z.InfoTooltip,{description:"Reorder action settings",placement:"top",children:(0,O.jsx)(z.DragButton,{onMoveUp:i,onMoveDown:s,menuSx:{".MuiPaper-root":{backgroundColor:e=>e.palette.background.lighter}}},"reorder-action-button")})]})]}),!d&&(0,O.jsxs)($.A,{spacing:2,children:[(0,O.jsx)(z.OptionsEditorControl,{label:"Enabled",control:(0,O.jsx)(og.A,{checked:e?.enabled??!1,onChange:n=>r(t,{...e,enabled:n.target.checked})})}),(0,O.jsxs)($.A,{direction:"row",spacing:2,children:[(0,O.jsx)(T.A,{label:"Action Name",size:"small",value:e.name,onChange:n=>r(t,{...e,name:n.target.value}),sx:{flexGrow:1}}),(0,O.jsxs)(oI.A,{size:"small",sx:{minWidth:120},children:[(0,O.jsx)(lc.A,{children:"Icon"}),(0,O.jsxs)(ld.A,{value:e.icon||"",label:"Icon",onChange:n=>r(t,{...e,icon:n.target.value||void 0}),children:[(0,O.jsx)(i0.A,{value:"",children:(0,O.jsx)("em",{children:"None"})}),lq.map(e=>(0,O.jsx)(i0.A,{value:e.value,children:(0,O.jsxs)($.A,{direction:"row",alignItems:"center",spacing:1,children:[e.icon,(0,O.jsx)("span",{children:e.label})]})},e.value))]})]})]}),(0,O.jsx)(T.A,{label:"URL",size:"small",value:e.url,onChange:n=>r(t,{...e,url:n.target.value}),helperText:'Supports interpolation: ${__data.fields["fieldName"]}, ${__data.index}, ${__data.count}',fullWidth:!0}),(0,O.jsxs)($.A,{direction:"row",spacing:2,children:[(0,O.jsxs)(oI.A,{size:"small",sx:{minWidth:120},children:[(0,O.jsx)(lc.A,{children:"Method"}),(0,O.jsx)(ld.A,{value:e.method,label:"Method",onChange:g,children:lV.map(e=>(0,O.jsx)(i0.A,{value:e,children:e},e))})]}),(0,O.jsxs)(oI.A,{size:"small",sx:{flexGrow:1},children:[(0,O.jsx)(lc.A,{children:"Batch Mode"}),(0,O.jsx)(ld.A,{value:e.batchMode,label:"Batch Mode",onChange:n=>r(t,{...e,batchMode:n.target.value}),children:lN.map(e=>(0,O.jsx)(i0.A,{value:e.value,children:e.label},e.value))})]})]}),(0,O.jsxs)(oI.A,{component:"fieldset",size:"small",children:[(0,O.jsx)(lp.A,{component:"legend",children:"Content Type"}),(0,O.jsx)(oZ,{row:!0,value:l,onChange:m,children:lF.map(e=>(0,O.jsx)(om.A,{value:e.value,control:(0,O.jsx)(lt,{size:"small"}),label:e.label},e.value))})]}),c&&"none"!==l&&(0,O.jsxs)(k.A,{children:[(0,O.jsx)(R.A,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"json"===l?"Body Template (JSON)":"Body Template (Text)"}),(0,O.jsx)(lU,{batchMode:e.batchMode}),"json"===l?(0,O.jsx)(z.JSONEditor,{value:b||"",onChange:h,minHeight:"100px",maxHeight:"200px"}):(0,O.jsx)(T.A,{value:e.bodyTemplate||"",onChange:f,fullWidth:!0,multiline:!0,rows:5})]}),(0,O.jsx)(T.A,{label:"Confirmation Message (optional)",size:"small",value:e.confirmMessage||"",onChange:n=>r(t,{...e,confirmMessage:n.target.value||void 0}),helperText:"If set, shows a confirmation dialog before executing the action",fullWidth:!0,multiline:!0,rows:2})]}),(0,O.jsxs)(lh.A,{open:!!a,onClose:v,"aria-labelledby":"selection-body-clear-title",children:[(0,O.jsx)(lf.A,{id:"selection-body-clear-title",children:"Remove Body Template?"}),(0,O.jsx)(lm.A,{children:(0,O.jsx)(ly,{children:"Changing this option will remove the current body template. Continue?"})}),(0,O.jsxs)(lb.A,{children:[(0,O.jsx)(iX.A,{onClick:v,children:"Cancel"}),(0,O.jsx)(iX.A,{onClick:y,variant:"contained",color:"primary",children:"Continue"})]})]})]})}function lH({actionOptions:e,selectionOptions:t,onChangeActions:r,onChangeSelection:n}){let i=(0,L.useMemo)(()=>e||{enabled:!0,displayInHeader:!0,displayWithItem:!1},[e]),s=(0,L.useCallback)(()=>{r({...i,actionsList:[...i.actionsList??[],{type:"event",name:"New Event Action",eventName:"selection-action",batchMode:"individual",enabled:!0}]})},[i,r]),a=(0,L.useCallback)(()=>{r({...i,actionsList:[...i.actionsList??[],{type:"webhook",name:"New Webhook Action",url:"",method:"POST",contentType:"none",batchMode:"individual",enabled:!0}]})},[i,r]),o=(0,L.useCallback)((e,t)=>{let n=i.actionsList?[...i.actionsList]:[];n[e]=t,r({...i,actionsList:n})},[i,r]),l=(0,L.useCallback)(e=>{let t=i.actionsList?i.actionsList.filter((t,r)=>r!==e):[];r(t.length>0?{...i,actionsList:t}:void 0)},[i,r]);return(0,z.useDragAndDropMonitor)({elements:i.actionsList,accessKey:"name",onChange:e=>{r({...i,actionsList:e})}}),(0,O.jsxs)($.A,{spacing:1,children:[(0,O.jsx)(z.OptionsEditorControl,{label:"Enable Item Selection",description:"Allow selecting items",control:(0,O.jsx)(og.A,{checked:t?.enabled??!1,onChange:(e,r)=>{n({...t,enabled:!!r||void 0})}})}),(0,O.jsx)(z.OptionsEditorControl,{label:"Enable Item Actions",description:"Allow executing actions on selected items",control:(0,O.jsx)(og.A,{checked:e?.enabled??!1,onChange:(e,t)=>{r({...i,enabled:!!t||void 0})}})}),(0,O.jsx)(z.OptionsEditorControl,{label:"Display Actions in Panel Header",description:"Show action buttons in the panel header when items are selected",control:(0,O.jsx)(og.A,{checked:e?.displayInHeader??!1,onChange:(e,t)=>{r({...i,displayInHeader:!!t||void 0})}})}),(0,O.jsx)(z.OptionsEditorControl,{label:"Display Actions with Each Item",description:"Show action buttons alongside each item when selected",control:(0,O.jsx)(og.A,{checked:e?.displayWithItem??!1,onChange:(e,t)=>{r({...i,displayWithItem:!!t||void 0})}})}),(0,O.jsx)(z.OptionsEditorGroup,{title:"Actions",children:(0,O.jsxs)($.A,{spacing:3,children:[i.actionsList&&0!==i.actionsList.length?(0,O.jsx)($.A,{spacing:1,border:"none",children:i.actionsList&&i.actionsList.map((e,t)=>(0,O.jsx)(k.A,{borderBottom:1,borderColor:e=>e.palette.divider,pb:1,children:"event"===e.type?(0,O.jsx)(lQ,{action:e,index:t,onChange:o,onRemove:l,onMoveDown:()=>r({...i,actionsList:(0,z.handleMoveDown)(e,i.actionsList)}),onMoveUp:()=>r({...i,actionsList:(0,z.handleMoveUp)(e,i.actionsList)})}):(0,O.jsx)(lZ,{action:e,index:t,onChange:o,onRemove:l,onMoveDown:()=>r({...i,actionsList:(0,z.handleMoveDown)(e,i.actionsList)}),onMoveUp:()=>r({...i,actionsList:(0,z.handleMoveUp)(e,i.actionsList)})})},t))}):(0,O.jsx)(R.A,{variant:"body2",color:"text.secondary",fontStyle:"italic",children:"No actions defined. Add an action to enable triggering events or webhooks on selected data."}),(0,O.jsxs)($.A,{direction:"row",spacing:1,children:[(0,O.jsx)(iX.A,{variant:"contained",startIcon:(0,O.jsx)(oT,{}),onClick:s,children:"Add Event Action"}),(0,O.jsx)(iX.A,{variant:"contained",startIcon:(0,O.jsx)(oT,{}),onClick:a,children:"Add Webhook Action"})]})]})})]})}var lB=r(54381);let lW="horizontal";function lK({optionCount:e,maxPer:t}){let r=(0,L.useMemo)(()=>Array.from({length:e},(e,t)=>t),[e]);return(0,O.jsxs)(k.A,{children:[(0,O.jsxs)(k.A,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[(0,O.jsxs)(R.A,{variant:"subtitle2",color:"text.secondary",children:["Layout preview (",e," panel",1!==e?"s":"",")"]}),(0,O.jsx)(z.InfoTooltip,{description:"Preview of the layout when all available options of the selected variable are selected.",enterDelay:100,children:(0,O.jsx)(I.A,{size:"small",sx:e=>({borderRadius:e.shape.borderRadius,padding:"2px"}),children:(0,O.jsx)(lO,{"aria-hidden":!1,"aria-label":"Show layout preview information",fontSize:"inherit",sx:{color:e=>e.palette.grey[700]}})})})]}),(0,O.jsx)(k.A,{sx:{height:315,overflow:"auto"},children:(0,O.jsx)(z.RepeatGrid,{repeatItems:r,maxPer:t,gap:4,renderItem:()=>(0,O.jsx)(k.A,{sx:{width:"100%",height:150,borderRadius:1,bgcolor:"action.selected",border:"1px solid",borderColor:"divider"}})})})]})}var lG=r(59078);function lJ({value:e,onChange:t,errors:r,variableDefinitionGroups:n,isVertical:i,onRepeatVariableSet:s}){let a=(0,L.useCallback)(r=>{r?(t(e?{...e,value:r}:{value:r,alignment:lW}),e||s()):t(void 0)},[e,t,s]),o=(0,L.useCallback)(r=>{e&&t("vertical"===r?{...e,alignment:r,maxPer:void 0}:{...e,alignment:r})},[e,t]),l=(0,L.useCallback)(r=>{e&&t({...e,maxPer:""===r?void 0:Number(r)})},[e,t]);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(lB.A,{size:4,children:(0,O.jsxs)(T.A,{select:!0,fullWidth:!0,label:"Repeat Variable",value:e?.value??"",error:!!r.value,helperText:r.value?.message,onChange:e=>a(e.target.value),slotProps:{select:{MenuProps:{PaperProps:{sx:{maxHeight:240}}}}},children:[(0,O.jsx)(i0.A,{value:"",children:(0,O.jsx)(R.A,{sx:{fontStyle:"italic"},children:"None"})}),n.flatMap(({source:e,definitions:t})=>{let r=t.filter(e=>"ListVariable"===e.kind&&e.spec.allowMultiple);return 0===r.length?[]:[e&&(0,O.jsx)(lG.A,{children:e},`group-${e}`),...r.map(t=>(0,O.jsx)(i0.A,{value:t.spec.name,children:t.spec.display?.name??t.spec.name},`${e??"dashboard"}-${t.spec.name}`))]})]})}),(0,O.jsx)(lB.A,{size:4,children:(0,O.jsxs)(T.A,{select:!0,fullWidth:!0,label:"Alignment",value:e?.alignment??lW,disabled:!e,error:!!r.alignment,helperText:r.alignment?.message,onChange:e=>o(e.target.value),children:[(0,O.jsx)(i0.A,{value:"horizontal",children:"Horizontal"}),(0,O.jsx)(i0.A,{value:"vertical",children:"Vertical"})]})}),(0,O.jsx)(lB.A,{size:4,children:(0,O.jsx)(T.A,{select:!0,fullWidth:!0,label:"Max Per Row",value:e?.maxPer??4,disabled:!e||i,error:!!r.maxPer,helperText:r.maxPer?.message,onChange:e=>l(e.target.value),slotProps:{select:{MenuProps:{PaperProps:{sx:{maxHeight:240}}}}},children:Array.from({length:12},(e,t)=>t+1).map(e=>(0,O.jsx)(i0.A,{value:e,children:e},e))})})]})}function lX({control:e,variableDefinitionGroups:t,panelGroups:r}){let{formState:n,setValue:i}=(0,Z.useFormContext)(),s=a6(),a=(0,Z.useWatch)({control:e,name:"layoutDefinition.repeatVariable.value"}),o=(0,Z.useWatch)({control:e,name:"layoutDefinition.repeatVariable.alignment"}),l=(0,Z.useWatch)({control:e,name:"layoutDefinition.repeatVariable.maxPer"}),u=(0,L.useMemo)(()=>a?s[a]?.options?.length??0:0,[a,s]),c=(o??lW)==="vertical";return(0,O.jsxs)(lB.A,{container:!0,spacing:2,width:"100%",children:[r&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(lB.A,{size:12,children:(0,O.jsx)(R.A,{variant:"h4",children:"Panel Group"})}),(0,O.jsx)(lB.A,{size:4,children:(0,O.jsx)(Z.Controller,{control:e,name:"groupId",render:({field:e,fieldState:t})=>(0,O.jsx)(T.A,{select:!0,...e,required:!0,fullWidth:!0,label:"Group",error:!!t.error,helperText:t.error?.message,children:r.map((e,t)=>(0,O.jsx)(i0.A,{value:e.id,children:e.title??`Group ${t+1}`},e.id))})})}),(0,O.jsx)(lB.A,{size:8})]}),(0,O.jsx)(lB.A,{size:12,children:(0,O.jsx)(R.A,{variant:"h4",children:"Repeat Options"})}),(0,O.jsx)(Z.Controller,{control:e,name:"layoutDefinition.repeatVariable",render:({field:e})=>(0,O.jsx)(lJ,{value:e.value,onChange:e.onChange,errors:n.errors.layoutDefinition?.repeatVariable??{},variableDefinitionGroups:t,isVertical:c,onRepeatVariableSet:()=>i("layoutDefinition.width",24)})}),a&&u>0&&(0,O.jsx)(lB.A,{size:12,children:(0,O.jsx)(lK,{optionCount:u,maxPer:c?1:l??4})})]})}var lY=r(61375),l0=r(31729);let l1=["mean","first","first-number","last","last-number","min","max","sum"],l2={abs:{label:"Absolute",description:"Absolute value"},relative:{label:"Relative",description:"Relative value"}},l4={bottom:{label:"Bottom"},right:{label:"Right"}},l5={list:{label:"List"},table:{label:"Table"}},l9={small:{label:"Small"},medium:{label:"Medium"}},l3=l1.reduce((e,t)=>(e[t]=oc[t],e),{});function l6(e){return void 0===e||!!(0,z.isValidLegendPosition)(e.position)&&(!e.mode||!!(0,z.isValidLegendMode)(e.mode))&&(!e.size||!!(0,z.isValidLegendSize)(e.size))}let l8=Object.entries(l4).map(([e,t])=>({id:e,...t})),l7=Object.entries(l9).map(([e,t])=>({id:e,...t}));function ue({value:e,onChange:t,showValuesEditor:r=!0,calculation:n="aggregation"}){let i=l6(e),s=(0,z.getLegendPosition)(e?.position),a=l4[s],o=(0,z.getLegendMode)(e?.mode),l=(0,z.getLegendSize)(e?.size),u=l9[l],c=(0,L.useMemo)(()=>{let t=e?.values;return t?.length?"aggregation"===n?t.reduce((e,t)=>{let r=l3[t];return r&&e.push({...r,id:t}),e},[]):t.map(e=>{let{label:t,description:r}=l2[e];return{id:e,label:t,description:r}}):[]},[n,e?.values]),d=(0,L.useMemo)(()=>"aggregation"===n?Object.entries(l3||{}).map(([e,t])=>({id:e,...t})):Object.entries(l2).map(([e,t])=>({id:e,...t})),[n]);return(0,O.jsxs)(z.OptionsEditorGroup,{title:"Legend",children:[!i&&(0,O.jsx)(z.ErrorAlert,{error:{name:"invalid-legend",message:"Invalid legend spec"}}),(0,O.jsx)(z.OptionsEditorControl,{label:"Show",control:(0,O.jsx)(og.A,{checked:!!e,onChange:(e,r)=>{t(!0===r?{position:z.DEFAULT_LEGEND.position}:void 0)}})}),e&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(z.OptionsEditorControl,{label:"Position",control:(0,O.jsx)(z.SettingsAutocomplete,{value:{...a,id:s},options:l8,onChange:(r,n)=>{t({...e,position:n.id})},disableClearable:!0})}),(0,O.jsx)(z.OptionsEditorControl,{label:"Mode",control:(0,O.jsx)(lY.A,{color:"primary",exclusive:!0,value:o,"aria-label":"Mode",onChange:(r,n)=>{t({...e,position:s,mode:n})},children:Object.entries(l5).map(([e,t])=>(0,O.jsx)(l0.A,{value:e,selected:o===e,"aria-label":`display ${e} mode`,children:t.label},e))})}),"table"===o&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(z.OptionsEditorControl,{label:"Size",control:(0,O.jsx)(z.SettingsAutocomplete,{value:{...u,id:l},options:l7,onChange:(r,n)=>{t({...e,position:s,size:n.id})},disableClearable:!0})}),r&&(0,O.jsx)(z.OptionsEditorControl,{label:"Values",control:(0,O.jsx)(z.SettingsAutocomplete,{multiple:!0,disableCloseOnSelect:!0,disableClearable:!0,value:c,options:d,onChange:(r,n)=>{t({...e,position:s,values:n.map(e=>e.id)})},limitTags:1,ChipProps:{size:"small"}})})]})]})]})}function ut({control:e,...t}){let{fields:r,append:n,remove:i}=(0,Z.useFieldArray)({control:e,name:"panelDefinition.spec.links"});return(0,O.jsxs)($.A,{...t,gap:3,children:[r&&r.length>0?r.map((t,r)=>(0,O.jsxs)(L.Fragment,{children:[(0,O.jsxs)($.A,{direction:"row",gap:1,alignItems:"center",children:[(0,O.jsx)(ur,{control:e,index:r}),(0,O.jsx)(I.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>i(r),children:(0,O.jsx)(oP,{})})]}),(0,O.jsx)(M.A,{})]},t.id)):(0,O.jsx)(R.A,{variant:"subtitle1",mb:2,fontStyle:"italic",children:"No links defined"}),(0,O.jsx)(I.A,{style:{width:"fit-content",height:"fit-content"},onClick:()=>n({url:"",name:"",tooltip:"",renderVariables:!1,targetBlank:!1}),children:(0,O.jsx)(oT,{})})]})}function ur({control:e,index:t}){let r={url:"",name:"",tooltip:"",renderVariables:!1,targetBlank:!1};return(0,O.jsx)(Z.Controller,{control:e,name:`panelDefinition.spec.links.${t}`,render:({field:e,field:{value:t},fieldState:n})=>{let i=t??r;return(0,O.jsx)(z.LinkEditorForm,{mode:"inline",url:{value:i.url,label:"URL",error:{hasError:!!n.error,helperText:n.error?.message},onChange:r=>{e.onChange({...t,url:r})}},newTabOpen:{value:!!i.targetBlank,onChange:r=>{e.onChange({...t,targetBlank:r})},label:"Open in new tab"},name:{value:i.name??"",label:"Name",onChange:r=>{e.onChange({...t,name:r})}},renderVariables:{value:!!i.renderVariables,label:"Render variables",onChange:r=>{e.onChange({...t,renderVariables:r})}},tooltip:{value:i.tooltip??"",label:"Tooltip",onChange:r=>{e.onChange({...t,tooltip:r})}}})}})}var un=r(2582),ui=r(49603);function us(e){return`Query #${e+1}`}function ua(e){return e.map((e,t)=>e.spec.name??us(t))}let uo=(0,L.forwardRef)((e,t)=>{let{queryTypes:r,index:n,query:i,queryResult:s,filteredQueryPlugins:a,isCollapsed:o,onDelete:l,onChange:u,onQueryRun:c,onCollapseExpand:d}=e,p=i.spec.name??us(n),[h,f]=(0,L.useState)(!1);return(0,O.jsxs)($.A,{spacing:1,children:[(0,O.jsxs)($.A,{direction:"row",alignItems:"center",justifyContent:"space-between",borderBottom:1,borderColor:e=>e.palette.divider,children:[(0,O.jsxs)($.A,{direction:"row",gap:1,sx:{width:"100%"},children:[(0,O.jsx)(I.A,{size:"small",sx:{width:"fit-content",height:"fit-content"},onClick:()=>d(n),children:o?(0,O.jsx)(l_,{}):(0,O.jsx)(lA,{})}),(0,O.jsx)($.A,{direction:"row",gap:1,alignItems:"center",alignContent:"center",sx:{width:"100%","&:hover button":{visibility:"visible"}},children:h?(0,O.jsx)(ul,{initialName:p,onSave:function(e){f(!1),u(n,(0,s8.produce)(i,t=>{t.spec.name=e}))},onCancel:()=>f(!1)},p):(0,O.jsx)(R.A,{variant:"overline",component:"h4",children:p})})]}),(0,O.jsxs)($.A,{direction:"row",alignItems:"center",children:[s?.isFetching&&(0,O.jsx)(s3.A,{"aria-label":"loading",size:"1.125rem"}),s?.error&&(0,O.jsx)(z.InfoTooltip,{description:s.error.message,children:(0,O.jsxs)($.A,{direction:"row",alignItems:"center",sx:{color:e=>e.palette.error.main},children:[(0,O.jsx)(I.A,{"aria-label":"query error",size:"small",sx:{color:e=>e.palette.error.main},children:(0,O.jsx)(aS,{})}),(0,O.jsx)(R.A,{sx:{maxWidth:300,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis","&:hover ::after":{content:'"Click to copy"'}},children:s.error.message})]})}),(0,O.jsxs)($.A,{direction:"row",children:[!h&&(0,O.jsx)(I.A,{"aria-label":"edit query name",size:"small",onClick:()=>f(!0),children:(0,O.jsx)(ui,{fontSize:"small"})}),l&&(0,O.jsx)(I.A,{"aria-label":"delete query",size:"small",onClick:()=>l&&l(n),children:(0,O.jsx)(lC,{})})]})]})]}),!o&&(0,O.jsx)(uu,{ref:t,queryTypes:r,value:i,filteredQueryPlugins:a,onChange:e=>u(n,e),onQueryRun:()=>c(n,i)})]},n)});function ul({initialName:e,onSave:t,onCancel:r}){let[n,i]=(0,L.useState)(e);return(0,O.jsx)(T.A,{size:"small",variant:"outlined",label:"Query name","aria-label":"query name",value:n,onChange:e=>i(e.target.value),fullWidth:!0,InputProps:{endAdornment:(0,O.jsxs)(un.A,{position:"end",children:[(0,O.jsx)(I.A,{size:"small","aria-label":"cancel edit",onClick:r,edge:"end",children:(0,O.jsx)(lj,{})}),(0,O.jsx)(I.A,{size:"small","aria-label":"save query name",onClick:()=>t(n),edge:"end",children:(0,O.jsx)(lx,{})})]})}})}uo.displayName="QueryEditorContainer";let uu=(0,L.forwardRef)((e,t)=>{let{queryTypes:r,value:n,filteredQueryPlugins:i,onChange:s,onQueryRun:a,...o}=e;return(0,O.jsx)(k.A,{...o,children:(0,O.jsx)(an,{ref:t,pluginTypes:r,pluginKindLabel:"Query Type",value:{selection:{kind:n.spec.plugin.kind,type:n.kind},spec:n.spec.plugin.spec},filteredQueryPlugins:i,withRunQueryButton:!0,onRunQuery:a,onChange:e=>{s((0,s8.produce)(n,t=>{t.kind=e.selection.type,t.spec.plugin.kind=e.selection.kind,t.spec.plugin.spec=e.spec}))}})})});uu.displayName="QueryEditor";let uc=(0,L.forwardRef)((e,t)=>{let{queryTypes:r,queries:n=[],queryResults:i,filteredQueryPlugins:s,onChange:a,onQueryRun:o}=e,{defaultInitialQueryDefinition:l,isLoading:u}=function(e,t){let r=e[0],{data:n,isLoading:i}=s0(e),{defaultPluginKinds:s}=sJ(),a="";a=t?.length?n?.find(e=>t.includes(e.spec.name)).spec.name??"":s?.[r]??n?.[0]?.spec.name??"";let{data:o,isLoading:l}=sX(r,a,{useErrorBoundary:!0,enabled:!0});return{defaultInitialQueryDefinition:{kind:r,spec:{plugin:{kind:a,spec:o?.createInitialOptions()||{}}}},isLoading:i||l}}(r,s),[c,d]=(0,L.useState)(n.map(()=>!1)),p=(e,t)=>{a((0,s8.produce)(n,r=>{r?r[e]=t:r=[t]}))},h=(e,t)=>{o(e,t)},f=e=>{a((0,s8.produce)(n,t=>{t.splice(e,1)})),d(t=>(t.splice(e,1),[...t]))},m=e=>{d(t=>(t[e]=!t[e],[...t]))},g=n;return 0!==n.length||u||(g=[l]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)($.A,{spacing:1,children:g.map((e,a)=>(0,O.jsx)(uo,{ref:t,queryTypes:r,index:a,query:e,queryResult:i?.[a],filteredQueryPlugins:s,isCollapsed:!!c[a],onChange:p,onQueryRun:h,onDelete:n.length>1?f:void 0,onCollapseExpand:m},a))}),(0,O.jsx)(iX.A,{variant:"contained",startIcon:(0,O.jsx)(oT,{}),sx:{marginTop:1},onClick:()=>{a((0,s8.produce)(n,e=>{e?e.push(l):e=[...n,l]})),d(e=>(e.push(!1),[...e]))},children:"Add Query"})]})});uc.displayName="MultiQueryEditor";var ud=r(87034),up=r(33868);let uh=({tabs:e})=>{let[t,r]=(0,L.useState)(0);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(k.A,{sx:{borderBottom:1,borderColor:e=>e.palette.divider},children:(0,O.jsx)(ud.A,{value:t,onChange:(e,t)=>{r(t)},"aria-label":"Panel configuration tabs",children:e.map(({label:e},t)=>(0,O.jsx)(up.A,{label:e,id:`options-editor-tab-${t}`,"aria-controls":`options-editor-tabpanel-${t}`},e))})}),e.map(({label:e,content:r},n)=>(0,O.jsx)(lr,{value:t,index:n,children:r},e))]})},uf="AlertsQuery";function um(e){let{getPlugin:t}=sJ(),r={variableState:a8(),datasourceStore:aR()},n=sY("AlertsQuery",e.map(e=>({kind:e.spec.plugin.kind})));return sK({queries:e.map((e,i)=>{let{queryEnabled:s,queryKey:a}=function({plugin:e,definition:t,context:r}){let{variableState:n}=r,i=e?.dependsOn?e.dependsOn(t.spec.plugin.spec,r):{},s=i?.variables,a=["query",uf,t,a0(aY(n,s))],o=!1;return s&&(o=s.some(e=>n[e]?.loading)),{queryKey:a,queryEnabled:void 0!==e&&!o}}({context:r,definition:e,plugin:n[i]?.data}),o=e?.spec?.plugin?.kind;return{enabled:s,queryKey:a,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:6e4,queryFn:async({signal:n})=>{let i=await t({kind:uf,name:o});return await i.getAlertsData(e.spec.plugin.spec,r,n)}}})})}let ug="JsonQuery";function uv(e){let{getPlugin:t}=sJ(),r=aR(),n=a6(),i={variableState:n,datasourceStore:r};return sK({queries:e.map(e=>{let r=["query",ug,e,n],s=e?.spec?.plugin?.kind;return{queryKey:r,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryFn:async({signal:r})=>(await t({kind:ug,name:s})).getJsonData(e.spec.plugin.spec,i,r),structuralSharing:!1}})})}let uy="LogQuery",ub="ProfileQuery";function ux(e){let{getPlugin:t}=sJ(),r=aR(),{absoluteTimeRange:n}=aG(),i={datasourceStore:r,absoluteTimeRange:n};return sK({queries:e.map(e=>{let r=["query",ub,e,n],s=e?.spec?.plugin?.kind;return{queryKey:r,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryFn:async({signal:r})=>{let n=await t({kind:ub,name:s});return await n.getProfileData(e.spec.plugin.spec,i,r)},structuralSharing:!1}})})}let uA="SilencesQuery";function u_(e){let{getPlugin:t}=sJ(),r={variableState:a8(),datasourceStore:aR()},n=sY("SilencesQuery",e.map(e=>({kind:e.spec.plugin.kind})));return sK({queries:e.map((e,i)=>{let{queryEnabled:s,queryKey:a}=function({plugin:e,definition:t,context:r}){let{variableState:n}=r,i=e?.dependsOn?e.dependsOn(t.spec.plugin.spec,r):{},s=i?.variables,a=["query",uA,t,a0(aY(n,s))],o=!1;return s&&(o=s.some(e=>n[e]?.loading)),{queryKey:a,queryEnabled:void 0!==e&&!o}}({context:r,definition:e,plugin:n[i]?.data}),o=e?.spec?.plugin?.kind;return{enabled:s,queryKey:a,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:6e4,queryFn:async({signal:n})=>{let i=await t({kind:uA,name:o});return await i.getSilencesData(e.spec.plugin.spec,r,n)}}})})}let uj="TimeSeriesQuery";function uw({plugin:e,definition:t,context:r}){let{timeRange:n,suggestedStepMs:i,mode:s,variableState:a}=r,o=e?.dependsOn?e.dependsOn(t.spec.plugin.spec,r):{},l=o?.variables,u=["query",uj,t,n,a0(aY(a,l)),i,s],c=!1;return l&&(c=l.some(e=>a[e]?.loading)),{queryKey:u,queryEnabled:void 0!==e&&!c}}let uC=(e,t,r)=>{let{data:n}=sX(uj,e.spec.plugin.kind),i=uO(),{queryEnabled:s,queryKey:a}=uw({plugin:n,definition:e,context:i});return sB({enabled:(r?.enabled??!0)||s,queryKey:a,queryFn:({signal:r})=>{if(void 0===n)throw Error("Expected plugin to be loaded");let s={...i,suggestedStepMs:t?.suggestedStepMs};return n.getTimeSeriesData(e.spec.plugin.spec,s,r)}})};function uE(e,t,r){let{getPlugin:n}=sJ(),i={...uO(),mode:t?.mode,suggestedStepMs:t?.suggestedStepMs},s=sY(uj,e.map(e=>({kind:e.spec.plugin.kind})));return sK({queries:e.map((e,t)=>{let{queryEnabled:a,queryKey:o}=uw({plugin:s[t]?.data,definition:e,context:i});return{...r,enabled:(r?.enabled??!0)&&a,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryKey:o,queryFn:async({signal:t})=>{let r=await n({kind:uj,name:e.spec.plugin.kind});return await r.getTimeSeriesData(e.spec.plugin.spec,i,t)}}})})}function uO(){let{absoluteTimeRange:e}=aG();return{timeRange:e,variableState:a8(),datasourceStore:aR()}}function uS(){return uk(q().getQueryCache())}function uk(e){let t=[];for(let r of e.findAll({type:"active"})){let e=r.queryKey?.[0];e?.kind&&e.kind.startsWith(uj)&&t.push(r)}return t}let uR="TraceQuery";function uP(e){let{getPlugin:t}=sJ(),r=function(){let{absoluteTimeRange:e}=aG();return{variableState:a8(),datasourceStore:aR(),absoluteTimeRange:e}}(),n=sY("TraceQuery",e.map(e=>({kind:e.spec.plugin.kind})));return sK({queries:e.map((e,i)=>{let{queryEnabled:s,queryKey:a}=function({plugin:e,definition:t,context:r}){let{variableState:n,absoluteTimeRange:i}=r,s=e?.dependsOn?e.dependsOn(t.spec.plugin.spec,r):{},a=s?.variables,o=["query",uR,t,i,a0(aY(n,a))],l=!1;return a&&(l=a.some(e=>n[e]?.loading)),{queryKey:o,queryEnabled:void 0!==e&&!l}}({context:r,definition:e,plugin:n[i]?.data}),o=e?.spec?.plugin?.kind;return{enabled:s,queryKey:a,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryFn:async({signal:n})=>{let i=await t({kind:uR,name:o});return await i.getTraceData(e.spec.plugin.spec,r,n)}}})})}var uT=r(65152);let u$=(0,L.createContext)(uT.hd),uI=(0,L.createContext)(void 0),uM=()=>(0,L.useContext)(uI),uz=()=>{let e=uM();return{markQuery:(t,r)=>{if(void 0===e)return;let n=JSON.stringify(t);if((!e.pendingQueries.has(n)||"pending"!==r)&&e.pendingQueries.get(n)!==r){e.pendingQueries.set(n,r),"error"===r&&(e.renderErrorCount+=1);let t=[...e.pendingQueries.values()].every(e=>"pending"!==e);0===e.renderDurationMs&&t&&(e.renderDurationMs=Date.now()-e.startRenderTime,uL(e))}}}},uL=async e=>{await e.fetchFn(`${e.apiPrefix??""}/api/v1/view`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.project,dashboard:e.dashboard,render_time:e.renderDurationMs/1e3,render_errors:e.renderErrorCount})})},uV=({apiPrefix:e,project:t,dashboard:r,children:n})=>{let i,s,{fetch:a}=(i=(0,L.useContext)(u$),s=(0,L.useCallback)(async(...e)=>{let t=await i(...e);return await t.json()},[i]),{fetch:i,fetchJson:s}),o={project:t,dashboard:r,renderErrorCount:0,startRenderTime:Date.now(),renderDurationMs:0,pendingQueries:new Map,apiPrefix:e,fetchFn:a};return(0,O.jsx)(uI.Provider,{value:o,children:n})};function uN(e,t){return e.map(({data:e,isFetching:r,isLoading:n,refetch:i,error:s},a)=>({definition:t[a],data:e,isFetching:r,isLoading:n,refetch:i,error:s}))}let uF=(0,L.createContext)(void 0);function uD(){let e=(0,L.useContext)(uF);if(void 0===e)throw Error("No DataQueriesContext found. Did you forget a Provider?");return e}function uq(e){let t=uD(),r=t.queryDefinitions.filter(t=>t.kind===e),n=t.queryResults.filter(t=>t?.definition?.kind===e),i=t.errors.filter((r,n)=>t.queryResults[n]?.definition?.kind===e);return{queryDefinitions:r,queryResults:n,isFetching:n.some(e=>e.isFetching),isLoading:n.some(e=>e.isLoading),refetchAll:t.refetchAll,errors:i}}function uU(e){let{definitions:t,options:r,children:n,queryOptions:i}=e,s=uz(),a=t.filter(e=>"TimeSeriesQuery"===e.kind),o=uE(a,r,i),l=t.filter(e=>"TraceQuery"===e.kind),u=uP(l),c=t.filter(e=>"ProfileQuery"===e.kind),d=ux(c),p=t.filter(e=>"LogQuery"===e.kind),h=function(e){let{getPlugin:t}=sJ(),r=aR(),{absoluteTimeRange:n}=aG(),i=a6(),s={timeRange:n,variableState:i,datasourceStore:r,refreshKey:""};return sK({queries:e.map(e=>{let r=["query",uy,e,n,i],a=e?.spec?.plugin?.kind;return{queryKey:r,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,staleTime:1/0,queryFn:async({signal:r})=>{let n=await t({kind:uy,name:a});return await n.getLogData(e.spec.plugin.spec,s,r)},structuralSharing:!1}})})}(p),f=t.filter(e=>"AlertsQuery"===e.kind),m=um(f),g=t.filter(e=>"SilencesQuery"===e.kind),v=u_(g),y=t.filter(e=>"JsonQuery"===e.kind),b=uv(y),x=(0,L.useCallback)(()=>{o.forEach(e=>e.refetch()),u.forEach(e=>e.refetch()),d.forEach(e=>e.refetch()),h.forEach(e=>e.refetch()),m.forEach(e=>e.refetch()),v.forEach(e=>e.refetch()),b.forEach(e=>e.refetch())},[o,u,d,h,m,v,b]),A=(0,L.useMemo)(()=>{let e=[...uN(o,a),...uN(u,l),...uN(d,c),...uN(h,p),...uN(m,f),...uN(v,g),...uN(b,y)];if(i?.enabled)for(let t of e)t.isLoading||t.isFetching||t.error?t.error?s.markQuery(t.definition,"error"):s.markQuery(t.definition,"pending"):s.markQuery(t.definition,"success");return{queryDefinitions:t,queryResults:e,isFetching:e.some(e=>e.isFetching),isLoading:e.some(e=>e.isLoading),refetchAll:x,errors:e.map(e=>e.error)}},[f,m,p,h,c,d,g,v,y,b,a,o,l,u,t,i?.enabled,x,s]);return(0,O.jsx)(uF.Provider,{value:A,children:n})}var uQ=r(45271),uZ=r(34007),uH=r(347),uB=r(91394),uW=r(70561),uK=r(3399),uG=r(5139),uJ=r(46001),uX=r(65168),uY=r(4150);let u0=(0,ao.A)(uQ.A)(({theme:e})=>({borderBottom:`solid 1px ${e.palette.divider}`}));function u1({value:e,onChange:t,isReadonly:r}){let[n,i]=(0,L.useState)(null),[s,a]=(0,L.useState)("update"),o=(0,L.useMemo)(()=>(function(e){let t=new Set,r=new Set;for(let n of e){let e=n.display.name;t.has(e)&&r.add(e),t.add(e)}return Array.from(r)})(e),[e]),l=(0,L.useMemo)(()=>n?.kind==="new"?{display:{name:"NewAnnotation"},plugin:{}}:n?.kind==="edit"?e[n.index]:void 0,[n,e]),u=(r,n)=>{let i=r+("up"===n?-1:1),s=e[r],a=e[i];if(!s||!a)return;let o=[...e];o[r]=a,o[i]=s,t(o)};return null!==n&&l?(0,O.jsx)(iJ,{children:(0,O.jsx)(ol,{initialAnnotationSpec:l,action:s,isDraft:!0,isReadonly:r,onActionChange:a,onSave:r=>{n?.kind==="new"?t([...e,r]):n?.kind==="edit"&&t(e.map((e,t)=>t===n.index?r:e)),i(null)},onClose:()=>i(null)})}):(0,O.jsxs)($.A,{spacing:2,padding:1,children:[o.map(e=>(0,O.jsx)(uZ.A,{severity:"error",children:`Duplicate annotation name: ${e}`},e)),(0,O.jsx)(uH.A,{children:(0,O.jsxs)(uB.A,{"aria-label":"table of panel annotations",children:[(0,O.jsx)(uW.A,{children:(0,O.jsxs)(uK.A,{children:[(0,O.jsx)(u0,{children:"Visibility"}),(0,O.jsx)(u0,{children:"Name"}),(0,O.jsx)(u0,{children:"Type"}),(0,O.jsx)(u0,{children:"Description"}),(0,O.jsx)(u0,{align:"right",children:"Actions"})]})}),(0,O.jsx)(uG.A,{children:e.map((n,s)=>(0,O.jsxs)(uK.A,{children:[(0,O.jsx)(u0,{component:"th",scope:"row",children:(0,O.jsx)(og.A,{checked:n.display?.hidden!==!0,disabled:r,onChange:r=>{var n;return n=r.target.checked,void t(e.map((e,t)=>t===s?{...e,display:{...e.display,hidden:!n}}:e))}})}),(0,O.jsx)(u0,{component:"th",scope:"row",sx:{fontWeight:"bold"},children:n.display.name}),(0,O.jsx)(u0,{children:n.plugin.kind}),(0,O.jsx)(u0,{children:n.display?.description??""}),(0,O.jsxs)(u0,{align:"right",sx:{whiteSpace:"nowrap"},children:[(0,O.jsx)(I.A,{onClick:()=>u(s,"up"),disabled:r||0===s,children:(0,O.jsx)(uX,{})}),(0,O.jsx)(I.A,{onClick:()=>u(s,"down"),disabled:r||s===e.length-1,children:(0,O.jsx)(uJ,{})}),(0,O.jsx)(I.A,{onClick:()=>{a("update"),i({kind:"edit",index:s})},children:(0,O.jsx)(ui,{})}),(0,O.jsx)(I.A,{disabled:r,onClick:()=>{t(e.filter((e,t)=>t!==s))},children:(0,O.jsx)(uY,{})})]})]},`${n.display.name}-${s}`))})]})}),(0,O.jsx)(k.A,{display:"flex",children:(0,O.jsx)(iX.A,{variant:"contained",startIcon:(0,O.jsx)(oT,{}),sx:{marginLeft:"auto"},disabled:r,onClick:()=>{a("create"),i({kind:"new"})},children:"Add Annotation"})})]})}let u2=(0,L.forwardRef)((e,t)=>{let{control:r,panelDefinition:n,variableDefinitionGroups:i,panelGroups:s,onQueriesChange:a,onQueryRun:o,onPluginSpecChange:l,onAnnotationsChange:u,onJSONChange:c}=e,{kind:d}=n.spec.plugin,{data:p,isLoading:h,error:f}=sX("Panel",d),{queryResults:m}=uD();if(f)return(0,O.jsx)(z.ErrorAlert,{error:f});if(h)return null;if(!p)throw Error(`Missing implementation for panel plugin with kind '${d}'`);let{panelOptionsEditorComponents:g,hideQueryEditor:v,supportsAnnotations:y}=p,b=[];return v||b.push({label:"Query",content:(0,O.jsx)(Z.Controller,{control:r,name:"panelDefinition.spec.queries",render:({field:e})=>(0,O.jsx)(uc,{ref:t,queryTypes:p.supportedQueryTypes??[],queries:n.spec.queries??[],queryResults:m,onChange:t=>{e.onChange(t),a(t)},onQueryRun:(e,t)=>{o(e,t),JSON.stringify(n.spec.queries?.[e])===JSON.stringify(t)&&m[e]?.refetch?.()}})})}),g&&(b=b.concat(g.map(({label:e,content:t})=>({label:e,content:(0,O.jsx)(Z.Controller,{control:r,name:"panelDefinition.spec.plugin.spec",render:({field:e})=>(0,O.jsx)(t,{value:n.spec.plugin.spec,onChange:t=>{e.onChange(t),l(t)}})})})))),y&&b.push({label:"Annotations",content:(0,O.jsx)(Z.Controller,{control:r,name:"panelDefinition.spec.annotations",render:({field:e})=>(0,O.jsx)(u1,{value:n.spec.annotations??[],onChange:t=>{e.onChange(t),u(t)}})})}),b.push({label:"Links",content:(0,O.jsx)(ut,{control:r})}),b.push({label:"JSON",content:(0,O.jsx)(Z.Controller,{control:r,name:"panelDefinition",render:({field:e})=>(0,O.jsx)(z.JSONEditor,{maxHeight:"80vh",value:n,onChange:t=>{e.onChange(JSON.parse(t)),c(t)}})})}),b.push({label:"Layout",content:(0,O.jsx)(lX,{control:r,variableDefinitionGroups:i,panelGroups:s})}),(0,O.jsx)(uh,{tabs:b},b.length)});u2.displayName="PanelSpecEditor";var u4=r(98449);function u5(e){let{kind:t,name:r,registry:n,version:i}=e;return`${t}:${r}:${n??""}:${i??""}`}let u9={registryOverVersion:!1};function u3(e){let t,r,{pluginLoader:{getInstalledPlugins:n,importPluginModule:i},children:s,defaultPluginKinds:a}=e,o=(t=at(async()=>{let e=await n(),t=new Map,r=new Map;for(let n of e){let{metadata:{version:e,registry:i}}=n;for(let s of n.spec.plugins){let{kind:a,spec:{name:o}}=s,l=u5({kind:a,name:o,registry:i,version:e});t.has(l)&&console.warn(`Got more than one ${a} plugin for kind ${o}, registry '${i||"undefined"}', and version '${e||"undefined"}'`),t.set(l,n);let u=r.get(a);void 0===u&&(u=[],r.set(a,u)),u.push({...s,module:n.metadata})}}return{pluginResourcesByNameKindRegistryVersion:t,pluginMetadataByKind:r}}),r=(0,L.useRef)(void 0),(0,L.useCallback)(()=>{let e=r.current;return void 0===e&&(r.current=e=t(),e.catch(()=>r.current=void 0)),e},[t])),l=(0,L.useRef)(new Map),u=at(e=>{let t=l.current.get(e);return void 0===t&&(t=i(e),l.current.set(e,t),t.catch(()=>l.current.delete(e))),t}),c=(0,L.useCallback)(async e=>{let t=await o(),{kind:r,name:n}=e;for(let r of((e,t,r=u9)=>{let n,{kind:i,name:s,version:a,registry:o}=t,l=[];(a||o)&&l.push(u5({kind:i,name:s,registry:o,version:a}));let u={key:"",version:""},c={key:"",version:""},d=`${i}:${s}:`;for(let t of e){if(!t.startsWith(d))continue;let e=t.split(":");if(4!==e.length){console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${t}`);continue}let[,,r,n]=e;if(!n){console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${t}`);continue}r?(!u.key||(0,u4.gt)(n,u.version))&&(u.key=t,u.version=n):(!c.key||(0,u4.gt)(n,c.version))&&(c.key=t,c.version=n)}if(u.key&&c.key){let{registryOverVersion:e}=r;n=(0,u4.gt)(u.version,c.version)?u.key:(0,u4.gt)(c.version,u.version)?c.key:e?u.key:c.key}else n=u.key||c.key||void 0;return n&&!l.includes(n)&&l.push(n),l})(t.pluginResourcesByNameKindRegistryVersion.keys(),e)){let e=t.pluginResourcesByNameKindRegistryVersion.get(r);if(!e)continue;let i=await u(e),s=i?.[r];if(s)return s;let a=i?.[n];if(a)return a}throw Error(`A ${n} plugin for kind '${r}' is not installed`)},[o,u]),d=(0,L.useCallback)(async e=>{let t=await o();return e.flatMap(e=>t.pluginMetadataByKind.get(e)??[])},[o]),p=(0,L.useMemo)(()=>({getPlugin:c,listPluginMetadata:d,defaultPluginKinds:a}),[c,d,a]);return(0,O.jsx)(sG.Provider,{value:p,children:s})}var u6=r(84864),u8=r(86138);let u7={refreshVariableValues:"Refresh values",copyVariableValues:"Copy values to clipboard",refresh:"Refresh",refreshInterval:"Auto refresh interval",zoomIn:"Zoom in",zoomOut:"Zoom out"};function ce({heightPx:e,showTimeRangeSelector:t=!0,showRefreshButton:r=!0,showRefreshInterval:n=!0,showCustomTimeRange:i,showZoomButtons:s=!0,timePresets:a,timeZone:o,refreshIntervalOptions:l,onTimeZoneChange:u}){let{timeRange:c,setTimeRange:d,refresh:p,refreshInterval:h,setRefreshInterval:f}=aG(),m=aq(i),g=aU(s),v=aZ(),y=aQ(a),b=aH(l),x=void 0===e?"34px":`${e}px`;if("pastDuration"in c&&!y.some(e=>e.value.pastDuration===c.pastDuration)){let e=(0,az.R)((0,aM.pW)(c.pastDuration)),t=y.findIndex(t=>(0,az.R)((0,aM.pW)(t.value.pastDuration))>e);y.splice(-1===t?y.length:t,0,(0,z.buildRelativeTimeOption)(c.pastDuration))}let A=(0,L.useCallback)(e=>{f(e)},[f]),_=e=>{let t=(0,aM.pW)(e);return((t.seconds??0)+(t.minutes??0)*60+(t.hours??0)*3600+(t.days??0)*86400+(t.weeks??0)*604800+(t.months??0)*2629746+(t.years??0)*0x1e18558)*1e3},j=(0,L.useCallback)(e=>{u(e)},[u]);return(0,O.jsxs)($.A,{direction:"row",spacing:1,children:[t&&(0,O.jsx)(z.TimeRangeSelector,{timeOptions:y,value:c,onChange:d,height:x,showCustomTimeRange:m,timeZone:o,timeZoneOptions:(0,z.getTimeZoneOptions)(),onTimeZoneChange:j}),g&&(0,O.jsx)(z.InfoTooltip,{description:u7.zoomOut,children:(0,O.jsx)(z.ToolbarIconButton,{"aria-label":u7.zoomOut,onClick:()=>{let e,t,r,n;return d((n=new Date,Object.hasOwn(c,"start")?(r=(c.end.getTime()-c.start.getTime())/2,e=new Date(c.start.getTime()-r),t=new Date(c.end.getTime()+r)):(r=_(c.pastDuration)/2,e=new Date((t=void 0===c.end?n:new Date(c.end.getTime()+r)).getTime()-4*r)),t.getTime()>n.getTime()&&(t=n,e.setTime(n.getTime()-4*r)),1>e.getTime()&&e.setTime(1),{start:e,end:t}))},sx:{height:x},children:(0,O.jsx)(u6,{})})}),g&&(0,O.jsx)(z.InfoTooltip,{description:u7.zoomIn,children:(0,O.jsx)(z.ToolbarIconButton,{"aria-label":u7.zoomIn,onClick:()=>d((()=>{let e,t;if(Object.hasOwn(c,"start")){let r=(c.end.getTime()-c.start.getTime())/4;e=new Date(c.start.getTime()+r),t=new Date(c.end.getTime()-r)}else{let r=_(c.pastDuration)/4;e=new Date((t=void 0!==c.end?new Date(c.end.getTime()-r):new Date).getTime()-2*r)}return e.getTime()>=t.getTime()-1e3&&e.setTime(t.getTime()-1e3),{start:e,end:t}})()),sx:{height:x},children:(0,O.jsx)(u8,{})})}),r&&(0,O.jsx)(z.InfoTooltip,{description:u7.refresh,children:(0,O.jsx)(z.ToolbarIconButton,{"aria-label":u7.refresh,onClick:p,sx:{height:x},children:(0,O.jsx)(lT,{})})}),n&&!v&&(0,O.jsx)(z.InfoTooltip,{description:u7.refreshInterval,children:(0,O.jsx)(z.RefreshIntervalPicker,{timeOptions:b,value:b.some(e=>e.value.pastDuration===h)?h:b.find(e=>e.display===h)?.value.pastDuration,onChange:A,height:x})})]})}function ct(e,t){let r=[],n=new Set;for(let i of e){let e=i.value.matchAll(t),s="";for(let t of e)for(let e=1;e<t.length;e++){let r=t[e];void 0!==r&&(s=`${s}${r}`)}""===s||n.has(s)||(n.add(s),r.push({label:i.label,value:s}))}return r}function cr(){let e=aR(),t=a8(),{absoluteTimeRange:r}=aG();return{timeRange:r,datasourceStore:e,variables:t}}let cn=(e,t,r,n,i)=>{let s=void 0!==e.spec.capturingRegexp?RegExp(e.spec.capturingRegexp,"g"):void 0,a=co(t.variables);return{queryKey:["variable",e,t.timeRange,a],queryFn:async({signal:n})=>{let a=await r?.getVariableOptions(e.spec.plugin.spec,t,n);if(!a?.data?.length)return i?.(e.spec.name,[],e),[];let o=s?ct(a.data,s):a.data;return i?.(e.spec.name,o,e),o},enabled:n}};function ci(e,t,r){if(e?.dependsOn){let n=e.dependsOn(r.spec.plugin.spec,t);return n.variables?n.variables.filter(e=>e!==r.spec.name):[]}return[]}function cs(e){let{data:t}=sX("Variable",e.spec.plugin.kind),r=cr(),n=ci(t,r,e),i=a8(n),s=n.some(e=>i[e]?.loading);return sB(cn(e,{...r,variables:i},t,!!t&&!s))}function ca(e){let{timeRange:t,datasourceStore:r,variables:n}=cr(),i=(0,L.useMemo)(()=>e.filter(e=>"ListVariable"===e.kind),[e]),s=sY("Variable",i.map(e=>({kind:e.spec.plugin.kind}))),[a,o]=(0,L.useState)({}),l=(0,L.useMemo)(()=>({...n,...a}),[n,a]),u=(0,L.useCallback)((e,t,r)=>{o(n=>({...n,[e]:{value:function(e,t){let{defaultValue:r,allowMultiple:n}=e.spec;if(null!=r)return r;if(t[0]?.value){let e=t[0].value;return n?[e]:e}return n?[]:""}(r,t),loading:!1,options:t}}))},[]),c=sK({queries:i.map((e,n)=>{let o=s[n]?.data,c=s[n]?.isLoading??!0,d=ci(o,{timeRange:t,datasourceStore:r,variables:l},e),p=d.some(e=>void 0===a[e]&&i.some(t=>t.spec.name===e)||l[e]?.loading),h={};for(let e of d){let t=l[e];t&&(h[e]=t)}return cn(e,{timeRange:t,datasourceStore:r,variables:h},o,!p&&!c,u)})});return{initialVariableValues:(0,L.useMemo)(()=>Object.fromEntries(Object.entries(l).filter(([,e])=>e?.value!==void 0).map(([e,t])=>[e,t.value])),[l]),isLoading:c.some(e=>e.isLoading)}}function co(e){return Object.values(e).map(e=>JSON.stringify(e.value)).join(",")}let cl=[{label:"List",kind:"ListVariable"},{label:"Text",kind:"TextVariable"}],cu={none:{label:"None",sort:e=>e.slice()},"alphabetical-asc":{label:"Alphabetical, asc",sort:e=>e.slice().toSorted((e,t)=>e.label>t.label?1:-1)},"alphabetical-desc":{label:"Alphabetical, desc",sort:e=>e.slice().toSorted((e,t)=>e.label>t.label?-1:1)},"numerical-asc":{label:"Numerical, asc",sort:e=>e.slice().toSorted((e,t)=>parseInt(e.label)>parseInt(t.label)?1:-1)},"numerical-desc":{label:"Numerical, desc",sort:e=>e.slice().toSorted((e,t)=>parseInt(e.label)<parseInt(t.label)?1:-1)},"alphabetical-ci-asc":{label:"Alphabetical, case-insensitive, asc",sort:e=>e.slice().toSorted((e,t)=>e.label.toLowerCase()>t.label.toLowerCase()?1:-1)},"alphabetical-ci-desc":{label:"Alphabetical, case-insensitive, desc",sort:e=>e.slice().toSorted((e,t)=>e.label.toLowerCase()>t.label.toLowerCase()?-1:1)}};function cc(e){let t={value:e.spec.value??"",constant:e.spec.constant??!1},r={allowMultiple:!1,allowAllValue:!1,customAllValue:void 0,capturingRegexp:void 0,sort:void 0,plugin:{kind:"",spec:{}}};return"ListVariable"===e.kind&&(r.allowMultiple=e.spec.allowMultiple??!1,r.allowAllValue=e.spec.allowAllValue??!1,r.customAllValue=e.spec.customAllValue,r.capturingRegexp=e.spec.capturingRegexp,r.sort=e.spec.sort,r.plugin=e.spec.plugin),{name:e.spec.name,title:e.spec.display?.name??"",kind:e.kind,description:e.spec.display?.description??"",listVariableFields:r,textVariableFields:t}}function cd(e){let{name:t,title:r,kind:n,description:i}=e,s={name:r,description:i};if("TextVariable"===n)return{kind:n,spec:{name:t,display:s,...e.textVariableFields}};if("ListVariable"===n)return{kind:n,spec:{name:t,display:s,allowMultiple:e.listVariableFields.allowMultiple,allowAllValue:e.listVariableFields.allowAllValue,customAllValue:e.listVariableFields.customAllValue,capturingRegexp:e.listVariableFields.capturingRegexp,sort:e.listVariableFields.sort,plugin:e.listVariableFields.plugin}};throw Error(`Unknown variable kind: ${n}`)}var cp=r(42514);function ch(e){let{values:t,isLoading:r,error:n}=e,[i,s]=(0,L.useState)(50),{infoSnackbar:a}=(0,z.useSnackbar)(),o=0;t&&t?.length>0&&i&&(o=t.length-i);let l=(0,L.useMemo)(()=>r?(0,O.jsx)($.A,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,O.jsx)(s3.A,{})}):n?(0,O.jsx)(uZ.A,{severity:"error",children:n}):t?.length?null:(0,O.jsx)(uZ.A,{severity:"info",children:"No results"}),[n,r,t]);return(0,O.jsxs)(k.A,{children:[(0,O.jsxs)($.A,{direction:"row",spacing:1,alignItems:"center",mb:1,children:[(0,O.jsx)(R.A,{variant:"h4",children:"Preview Values"}),(0,O.jsx)(z.InfoTooltip,{description:u7.copyVariableValues,children:(0,O.jsx)(I.A,{onClick:async()=>{t?.length&&(await navigator.clipboard.writeText(t.map(e=>e).join(", ")),a("Preview values copied to clipboard!"))},size:"small",children:(0,O.jsx)(cp,{})})})]}),(0,O.jsx)(af,{variant:"outlined",children:(0,O.jsxs)(k.A,{sx:{display:"flex",flexWrap:"wrap",gap:1,m:2},children:[l,t?.slice(0,i).filter(e=>e).map((e,t)=>(0,O.jsx)(ay.A,{size:"small",label:e},t)),o>0&&(0,O.jsx)(ay.A,{onClick:()=>{s(void 0)},variant:"outlined",size:"small",label:`+${o} more`})]})})]})}function cf(e){let{definition:t,sortMethod:r}=e,{data:n,isFetching:i,error:s}=cs(t),a=s?.message,o=r&&"none"!==r&&n?cu[r].sort(n):n;return(0,L.useMemo)(()=>(0,O.jsx)(ch,{values:o?.map(e=>e.label||e.value),isLoading:i,error:a}),[a,i,o])}function cm(){return(0,O.jsx)("div",{children:"Error previewing values"})}function cg({action:e,control:t}){return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(R.A,{py:1,variant:"subtitle1",children:"Text Options"}),(0,O.jsxs)($.A,{spacing:2,children:[(0,O.jsx)(Z.Controller,{control:t,name:"spec.value",render:({field:t,fieldState:r})=>(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(k.A,{children:(0,O.jsx)(ch,{values:[t.value]})}),(0,O.jsx)(T.A,{...t,label:"Value",InputLabelProps:{shrink:"read"===e||void 0},InputProps:{readOnly:"read"===e},error:!!r.error,helperText:r.error?.message,value:t.value??"",onChange:e=>{t.onChange(e)}})]})}),(0,O.jsx)(Z.Controller,{control:t,name:"spec.constant",render:({field:t})=>(0,O.jsx)(om.A,{label:"Constant",control:(0,O.jsx)(og.A,{...t,checked:!!t.value,readOnly:"read"===e,value:t.value??!1,onChange:r=>{"read"!==e&&t.onChange(r)}})})})]})]})}function cv({action:e,control:t}){let r=(0,Z.useFormContext)(),n=q(),i=r.getValues(),[s,a]=(0,L.useState)(structuredClone(i)),o=(0,L.useCallback)(async()=>{JSON.stringify(s)===JSON.stringify(i)?await n.invalidateQueries({queryKey:["variable",s]}):a(structuredClone(i))},[s,n,i]),l=(0,Z.useWatch)({control:t,name:"spec.plugin"}),u=l?.kind,c=l?.spec,d=(0,Z.useWatch)({control:t,name:"spec.allowAllValue"}),p=(0,Z.useWatch)({control:t,name:"spec.customAllValue"}),h=(0,Z.useWatch)({control:t,name:"spec.sort"});return void 0===i.spec.allowAllValue&&r.setValue("spec.allowAllValue",!1),void 0===i.spec.allowMultiple&&r.setValue("spec.allowMultiple",!1),i.spec.plugin||r.setValue("spec.plugin",{kind:"StaticListVariable",spec:{}}),i.spec.sort||r.setValue("spec.sort","none"),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(R.A,{py:1,variant:"subtitle1",children:"List Options"}),(0,O.jsxs)($.A,{spacing:2,mb:2,children:[(0,O.jsx)(k.A,{children:(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:cm,resetKeys:[s],children:(0,O.jsx)(cf,{sortMethod:h,definition:s})})}),(0,O.jsx)($.A,{children:(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:z.ErrorAlert,children:(0,O.jsx)(Z.Controller,{control:t,name:"spec.plugin",render:({field:t})=>(0,O.jsx)(an,{withRunQueryButton:!0,width:"100%",pluginTypes:["Variable"],pluginKindLabel:"Source",value:{selection:{type:"Variable",kind:u??"StaticListVariable"},spec:c??{}},isReadonly:"read"===e,onChange:e=>{t.onChange({kind:e.selection.kind,spec:e.spec})},onRunQuery:o})})})}),(0,O.jsx)($.A,{children:(0,O.jsx)(Z.Controller,{control:t,name:"spec.capturingRegexp",render:({field:t,fieldState:r})=>(0,O.jsx)(T.A,{...t,label:"Capturing Regexp Filter",InputLabelProps:{shrink:"read"===e||void 0},InputProps:{readOnly:"read"===e},error:!!r.error,value:t.value??"",onChange:e=>{""===e.target.value?t.onChange(void 0):t.onChange(e)},helperText:r.error?.message?r.error.message:"Optional, if you want to filter on captured result."})})}),(0,O.jsx)($.A,{children:(0,O.jsx)(Z.Controller,{control:t,name:"spec.sort",render:({field:t,fieldState:r})=>(0,O.jsx)(T.A,{select:!0,...t,fullWidth:!0,label:"Sort",InputLabelProps:{shrink:"read"===e||void 0},InputProps:{readOnly:"read"===e},error:!!r.error,helperText:r.error?.message,value:t.value??"none",onChange:e=>{t.onChange(e)},children:Object.keys(cu).map(e=>{if(!cu[e])return null;let{label:t}=cu[e];return(0,O.jsx)(i0.A,{value:e,children:t},e)})})})})]}),(0,O.jsx)(M.A,{}),(0,O.jsx)(R.A,{py:1,variant:"subtitle1",children:"Dropdown Options"}),(0,O.jsxs)($.A,{spacing:"2",children:[(0,O.jsxs)($.A,{children:[(0,O.jsx)(Z.Controller,{control:t,name:"spec.allowMultiple",render:({field:t})=>(0,O.jsx)(om.A,{label:"Allow Multiple Values",control:(0,O.jsx)(og.A,{...t,checked:!!t.value,readOnly:"read"===e,value:t.value??!1,onChange:r=>{"read"!==e&&t.onChange(r)}})})}),(0,O.jsx)(R.A,{variant:"caption",children:"Enables multiple values to be selected at the same time"})]}),(0,O.jsxs)($.A,{children:[(0,O.jsx)(Z.Controller,{control:t,name:"spec.allowAllValue",render:({field:t})=>(0,O.jsx)(om.A,{label:"Allow All option",control:(0,O.jsx)(og.A,{...t,checked:!!t.value,readOnly:"read"===e,value:t.value??!1,onChange:r=>{"read"!==e&&t.onChange(r)}})})}),(0,O.jsx)(R.A,{mb:1,variant:"caption",children:"Enables an option to include all variable values"}),d&&(0,O.jsxs)($.A,{spacing:1,children:[(0,O.jsx)(om.A,{label:"Use Custom All Value",control:(0,O.jsx)(og.A,{checked:void 0!==p,readOnly:"read"===e,onChange:t=>{"read"===e||(t.target.checked?r.setValue("spec.customAllValue",""):r.setValue("spec.customAllValue",void 0))}})}),(0,O.jsx)(R.A,{variant:"caption",sx:{mt:-.5},children:'Enable to set a custom value when "All" is selected'}),void 0!==p&&(0,O.jsx)(Z.Controller,{control:t,name:"spec.customAllValue",render:({field:t,fieldState:r})=>(0,O.jsx)(T.A,{...t,fullWidth:!0,label:"Custom All Value",InputLabelProps:{shrink:"read"===e||void 0},InputProps:{readOnly:"read"===e},error:!!r.error,helperText:r.error?.message,value:t.value??"",onChange:e=>{t.onChange(e.target.value||"")}})})]})]})]})]})}function cy({initialVariableDefinition:e,action:t,isDraft:r,isReadonly:n,onActionChange:i,onSave:s,onClose:a,onDelete:o}){let[l,u]=(0,L.useState)(!1),c=(0,z.getTitleAction)(t,r),d=(0,z.getSubmitText)(t,r),{variableEditorSchema:p}=iG(),h=(0,Z.useForm)({resolver:(0,S.zodResolver)(p),mode:"onBlur",defaultValues:e}),f=(0,Z.useWatch)({control:h.control,name:"kind"});function m(e){let t={...e};return t.spec.display?.name===void 0&&t.spec.display?.description===void 0&&t.spec.display?.hidden===void 0&&delete t.spec.display,t}return(0,O.jsxs)(Z.FormProvider,{...h,children:[(0,O.jsxs)(k.A,{sx:{display:"flex",alignItems:"center",padding:e=>e.spacing(1,2),borderBottom:e=>`1px solid ${e.palette.divider}`},children:[(0,O.jsxs)(R.A,{variant:"h2",children:[c," Variable"]}),(0,O.jsx)(z.FormActions,{action:t,submitText:d,isReadonly:n,isValid:h.formState.isValid,onActionChange:i,onSubmit:h.handleSubmit(e=>{s(m(e))}),onDelete:o,onCancel:function(){JSON.stringify(e)!==JSON.stringify(m(h.getValues()))?u(!0):a()}})]}),(0,O.jsxs)(k.A,{padding:2,sx:{overflowY:"scroll"},children:[(0,O.jsxs)(P.Ay,{container:!0,spacing:2,mb:2,children:[(0,O.jsx)(P.Ay,{item:!0,xs:8,children:(0,O.jsx)(Z.Controller,{control:h.control,name:"spec.name",render:({field:e,fieldState:n})=>(0,O.jsx)(T.A,{...e,required:!0,fullWidth:!0,label:"Name",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{disabled:"update"===t&&!r,readOnly:"read"===t},error:!!n.error,helperText:n.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(Z.Controller,{control:h.control,name:"spec.display.name",render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Display Label",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{readOnly:"read"===t},error:!!r.error,helperText:r.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:8,children:(0,O.jsx)(Z.Controller,{control:h.control,name:"spec.display.description",render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{...e,fullWidth:!0,label:"Description",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{readOnly:"read"===t},error:!!r.error,helperText:r.error?.message,value:e.value??"",onChange:t=>{e.onChange(t)}})})}),(0,O.jsx)(P.Ay,{item:!0,xs:4,children:(0,O.jsx)(Z.Controller,{control:h.control,name:"kind",render:({field:e,fieldState:r})=>(0,O.jsx)(T.A,{select:!0,...e,fullWidth:!0,label:"Type",InputLabelProps:{shrink:"read"===t||void 0},InputProps:{readOnly:"read"===t},error:!!r.error,helperText:r.error?.message,value:e.value??"TextVariable",onChange:t=>{e.onChange(t)},children:cl.map(e=>(0,O.jsx)(i0.A,{value:e.kind,children:e.label},e.kind))})})})]}),(0,O.jsx)(M.A,{}),"TextVariable"===f&&(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:z.ErrorAlert,children:(0,O.jsx)(cg,{action:t,control:h.control})}),"ListVariable"===f&&(0,O.jsx)(z.ErrorBoundary,{FallbackComponent:z.ErrorAlert,children:(0,O.jsx)(cv,{action:t,control:h.control})})]}),(0,O.jsx)(z.DiscardChangesConfirmationDialog,{description:"Are you sure you want to discard these changes? Changes cannot be recovered.",isOpen:l,onCancel:()=>{u(!1)},onDiscardChanges:()=>{u(!1),a()}})]})}let cb=({value:e,onChange:t})=>(0,O.jsx)(z.OptionsEditorControl,{label:"Metric label",description:"Specify label to display",control:(0,O.jsx)(T.A,{fullWidth:!0,name:"Metric label",value:e||"",onChange:e=>{t(e.target.value||void 0)}})}),cx=[{ms:1e3,label:"1s"},{ms:2e3,label:"2s"},{ms:5e3,label:"5s"},{ms:1e4,label:"10s"},{ms:15e3,label:"15s"},{ms:3e4,label:"30s"},{ms:6e4,label:"1m"},{ms:12e4,label:"2m"},{ms:3e5,label:"5m"},{ms:6e5,label:"10m"},{ms:9e5,label:"15m"},{ms:18e5,label:"30m"},{ms:36e5,label:"1h"},{ms:72e5,label:"2h"},{ms:216e5,label:"6h"},{ms:432e5,label:"12h"},{ms:864e5,label:"1d"},{ms:6048e5,label:"7d"},{ms:2592e6,label:"30d"}];function cA(e){for(let t of cx){let r=e/t.ms;if(r>=20&&r<=100)return t.label}let t=cx[cx.length-1],r=1/0;for(let n of cx){let i=Math.abs(e/n.ms-40);i<r&&(r=i,t=n)}return t.label}function c_(e){let t=new Map;for(let r of e){let{resource:e,resource:{kind:n,metadata:{name:i,registry:s,version:a}},importPlugin:o}=r;t.set(u5({kind:n,name:i,registry:s,version:a}),{resource:e,importPlugin:o})}return{getInstalledPlugins:async()=>Promise.resolve(Array.from(t.values()).map(e=>e.resource)),importPluginModule(e){let{kind:r,metadata:{name:n,version:i,registry:s}}=e,{importPlugin:a}=t.get(u5({kind:r,name:n,registry:s,version:i}))||{};if(void 0===a)throw Error("Plugin not found");return a()}}}function cj(e){return 2===e.length}var cw=r(22457),cC=r(15708);let cE={encode:function(e){return null==e?e:String(e)},decode:function(e){let t=function(e,t){if(null==e)return e;if(0===e.length&&(!t||t&&""!==e))return null;let r=e instanceof Array?e[0]:e;return null==r||t||""!==r?r:null}(e,!0);return null==t?t:String(t)}};'{}[],":'.split("").map(e=>[e,encodeURIComponent(e)]);let cO=new class{constructor(){this.paramsMap=new Map,this.registeredParams=new Map}set(e,t,r,n){this.paramsMap.set(e,{stringified:t,decoded:r,decode:n})}has(e,t,r){if(!this.paramsMap.has(e))return!1;let n=this.paramsMap.get(e);return!!n&&n.stringified===t&&(null==r||n.decode===r)}get(e){var t;if(this.paramsMap.has(e))return null==(t=this.paramsMap.get(e))?void 0:t.decoded}registerParams(e){for(let t of e){let e=this.registeredParams.get(t)||0;this.registeredParams.set(t,e+1)}}unregisterParams(e){for(let t of e){let e=(this.registeredParams.get(t)||0)-1;e<=0?(this.registeredParams.delete(t),this.paramsMap.has(t)&&this.paramsMap.delete(t)):this.registeredParams.set(t,e)}}clear(){this.paramsMap.clear(),this.registeredParams.clear()}};function cS(e,t,r,n){var i;if(!r||!t.length)return e;let s={...e},a=!1;for(let e of t)Object.prototype.hasOwnProperty.call(s,e)||(s[e]=null!=(i=r[e])?i:n,a=!0);return a?s:e}let ck=Object.prototype.hasOwnProperty;function cR(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function cP(e,t,r){var n,i;if(cR(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;let s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(let a=0;a<s.length;a++){let o=null!=(i=null==(n=null==r?void 0:r[s[a]])?void 0:n.equals)?i:cR;if(!ck.call(t,s[a])||!o(e[s[a]],t[s[a]]))return!1}return!0}function cT(e,t,r){let n={};for(let i of Object.keys(t)){let s,a=t[i],o=e[i];if(r.has(i,o,a.decode))s=r.get(i);else{if(s=a.decode(o),a.equals&&r.has(i,o)){let e=r.get(i);a.equals(s,e)&&(s=e)}void 0!==s&&r.set(i,o,s,a.decode)}void 0===s&&void 0!==a.default&&(s=a.default),n[i]=s}return n}function c$(){let e;return function(t,r,n){let i=cT(t,r,n);return null!=e&&cP(e,i)?e:(e=i,i)}}let cI={},cM=(e,t,r)=>{if(s===t&&o===e&&a===r)return cI;s=t,o=e;let n=e(null!=t?t:"");a=r;let i=function(e){if(e)return Object.fromEntries(e.split("\n").map(e=>e.split("\0")))}(r);for(let[e,t]of Object.entries(n)){(null==i?void 0:i[e])&&(delete n[e],n[e=i[e]]=t);let r=cI[e];cP(t,r)&&(n[e]=r)}return cI=n,n},cz={adapter:{},options:{searchStringToObject:function(e){let t=new URLSearchParams(e),r={};for(let[e,n]of t)Object.prototype.hasOwnProperty.call(r,e)?Array.isArray(r[e])?r[e].push(n):r[e]=[r[e],n]:r[e]=n;return r},objectToSearchString:function(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(void 0!==n&&null!==n)if(Array.isArray(n))for(let e of n)t.append(r,null!=e?e:"");else t.append(r,n);return t.toString()},updateType:"pushIn",includeKnownParams:void 0,includeAllParams:!1,removeDefaultsFromUrl:!1,enableBatching:!1,skipUpdateWhenNoChange:!0}},cL=L.createContext(cz),cV=[];function cN(e,t){let{adapter:r,options:n}=function(){let e=L.useContext(cL);if(void 0===e||e===cz)throw Error("useQueryParams must be used within a QueryParamProvider");return e}(),[i]=(0,L.useState)(c$),{paramConfigMap:s,options:a}=function(e,t){let r;return{paramConfigMap:r=void 0===e?{}:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,"inherit"])):e,options:t}}(e,t),o=(0,L.useMemo)(()=>{var e;let t;return null==(e=a)&&(e={}),t={...n,...e},e.params&&n.params&&(t.params={...n.params,...e.params}),t},[n,a]),l=function(e,t){var r,n,i;let s={},a=!1,o=Object.keys(e);if(t.includeKnownParams||!1!==t.includeKnownParams&&0===o.length){let e=Object.keys(null!=(r=t.params)?r:{});o.push(...e)}for(let r of o){let o=e[r];if(null!=o&&"object"==typeof o){s[r]=o;continue}a=!0,s[r]=null!=(i=null==(n=t.params)?void 0:n[r])?i:cE}return a?s:e}(s,o),u=cM(o.searchStringToObject,r.location.search,function(e){let t;for(let r in e)if(e[r].urlName){let n=e[r].urlName,i=`${n}\0${r}`;t?t.push(i):t=[i]}return t?t.join("\n"):void 0}(l));o.includeAllParams&&(l=cS(l,Object.keys(u),o.params,cE));let c=i(u,l,cO),d=Object.keys(l).join("\0");(0,L.useEffect)(()=>{let e=d.split("\0");return cO.registerParams(e),()=>{cO.unregisterParams(e)}},[d]);let p={adapter:r,paramConfigMap:l,options:o},h=(0,L.useRef)(p);null==h.current&&(h.current=p),(0,L.useEffect)(()=>{h.current.adapter=r,h.current.paramConfigMap=l,h.current.options=o},[r,l,o]);let[f]=(0,L.useState)(()=>(e,t)=>{let{adapter:r,paramConfigMap:n,options:i}=h.current;null==t&&(t=i.updateType),function(e,{immediate:t}={}){cV.push(e),1===cV.length&&(t?e=>e():e=>setTimeout(()=>e(),0))(()=>{let t,r=cV.slice();cV.length=0;let n=r[0].currentSearchString;for(let e=0;e<r.length;++e)t=function({changes:e,updateType:t,currentSearchString:r,paramConfigMap:n,options:i}){let s,a,o,{searchStringToObject:l,objectToSearchString:u}=i;null==t&&(t=i.updateType);let c=cM(l,r),d=cS(n,Object.keys(e),i.params);return a="function"==typeof e?e(cT(c,d,cO)):e,s=function(e,t){let r={};for(let n of Object.keys(t)){let i=t[n];e[n]?r[n]=e[n].encode(t[n]):r[n]=null==i?i:String(i)}return r}(d,a),i.removeDefaultsFromUrl&&function(e,t){var r;for(let n in e)(null==(r=t[n])?void 0:r.default)!==void 0&&void 0!==e[n]&&t[n].encode(t[n].default)===e[n]&&(e[n]=void 0)}(s,d),s=function(e,t){var r;let n={};for(let i in e)(null==(r=t[i])?void 0:r.urlName)!=null?n[t[i].urlName]=e[i]:n[i]=e[i];return n}(s,d),(null==(o=u("push"===t||"replace"===t?s:{...c,...s}))?void 0:o.length)&&"?"!==o[0]&&(o=`?${o}`),null!=o?o:""}(0===e?r[e]:{...r[e],currentSearchString:t});e.options.skipUpdateWhenNoChange&&t===n||function({searchString:e,adapter:t,navigate:r,updateType:n}){let i={...t.location,search:e};r&&("string"==typeof n&&n.startsWith("replace")?t.replace(i):t.push(i))}({searchString:null!=t?t:"",adapter:r[r.length-1].adapter,navigate:!0,updateType:r[r.length-1].updateType})})}({changes:e,updateType:t,currentSearchString:r.location.search,paramConfigMap:n,options:i,adapter:r},{immediate:!i.enableBatching})});return[c,f]}function cF(e){return!e||"string"==typeof e&&(0,aM.g3)(e)?e:(1e3*(0,cw._)(e)).toString()}function cD(e){let t=function(e){if(!e||0===e.length)return null;let t=e instanceof Array?e[0]:e;return null==t?t:""===t?null:t}(e);return t?(0,aM.g3)(t)?t:new Date(Number(t)):null}let cq={encode:cF,decode:cD,equals:(e,t)=>e===t||(e&&t?e.valueOf()===t.valueOf():e===t)},cU={start:cq,end:cq},cQ={refresh:cq},cZ={tz:cE};function cH(e){let[t]=cN(cU,{updateType:"replaceIn"}),{start:r,end:n}=t;return(0,L.useMemo)(()=>{let t={pastDuration:e};if(!r)return t;let i=r.toString();return(0,aM.g3)(i)?t={pastDuration:i}:(0,cC.$)(r)&&(0,cC.$)(n)&&(t={start:r,end:n}),t},[r,n,e])}function cB(e){let[t,r]=cN(cU,{updateType:"replaceIn"}),[n,i]=(0,L.useState)(!1),{start:s}=t;return(0,L.useEffect)(()=>{!n&&!s&&(0,aI.bB)(e)&&(r({start:e.pastDuration,end:void 0}),i(!0))},[e,n,s,r]),{timeRange:e,setTimeRange:(0,L.useCallback)(e=>{(0,aI.bB)(e)?r({start:e.pastDuration,end:void 0}):r(e)},[r])}}function cW(e){let[t]=cN(cQ,{updateType:"replaceIn"}),{refresh:r}=t;return(0,L.useMemo)(()=>{let t=e;if(!r)return t;let n=r.toString();return(0,aM.g3)(n)&&(t=n),t},[e,r])}function cK(e){let[t,r]=cN(cQ,{updateType:"replaceIn"}),[n,i]=(0,L.useState)(!1),{refresh:s}=t;return(0,L.useEffect)(()=>{n||s||(r({refresh:e}),i(!0))},[e,n,s,r]),{refreshInterval:e,setRefreshInterval:(0,L.useCallback)(e=>r({refresh:e}),[r])}}function cG(e){let[t,r]=cN(cZ,{updateType:"replaceIn"}),{tz:n}=t;return{timeZone:n??e??"local",setTimeZone:(0,L.useCallback)(e=>{r({tz:e})},[r])}}function cJ({initialTimeRange:e,initialRefreshInterval:t,children:r}){let{timeRange:n,setTimeRange:i}=cB(e),{refreshInterval:s,setRefreshInterval:a}=cK(t),{timeZone:o}=cG("local");return(0,O.jsx)(aX,{timeRange:n,refreshInterval:s,setTimeRange:i,setRefreshInterval:a,children:(0,O.jsx)(z.TimeZoneProvider,{timeZone:o,children:r})})}function cX({initialTimeRange:e,initialRefreshInterval:t,children:r}){let[n,i]=V().useState(e),[s,a]=V().useState(t);return(0,O.jsx)(aX,{timeRange:n,refreshInterval:s,setTimeRange:i,setRefreshInterval:a,children:r})}let cY=new Set(["POST","PUT","PATCH"]);function c0(e){let t={...e.headers},r=e.contentType??"none",n=cY.has(e.method);return n&&"json"===r?t["Content-Type"]="application/json":n&&"text"===r&&(t["Content-Type"]="text/plain; charset=utf-8"),t}async function c1(e,t,r,n,i){let s=Array.from(t.entries()),a=s.length,o=new Map;n(e.name,{loading:!0,itemStatuses:new Map});for(let t=0;t<s.length;t++){let[l,u]=s[t];n(e.name,{loading:!0},l);try{let s,c=(0,z.interpolateSelectionIndividual)(e.url,u,t,a,r),d=e.contentType??"none";cY.has(e.method)&&"none"!==d&&e.bodyTemplate&&(s=(0,z.interpolateSelectionIndividual)(e.bodyTemplate,u,t,a,r).text);let p=await i(c.text,{method:e.method,headers:c0(e),body:s});if(!p.ok)throw Error(`HTTP ${p.status}: ${p.statusText}`);n(e.name,{loading:!1,success:!0},l),o.set(l,{success:!0})}catch(r){let t=r instanceof Error?r:Error(String(r));n(e.name,{loading:!1,error:t},l),o.set(l,{success:!1,error:t})}}let l=Array.from(o.values()).every(e=>e.success),u=Array.from(o.values()).some(e=>!e.success);return l?n(e.name,{loading:!1,success:!0}):u&&n(e.name,{loading:!1,error:Error("Some requests failed")}),{success:l,itemResults:o}}async function c2(e,t,r,n,i){let s=Array.from(t.values());n(e.name,{loading:!0});try{let t,a=(0,z.interpolateSelectionBatch)(e.url,s,r),o=e.contentType??"none";cY.has(e.method)&&"none"!==o&&e.bodyTemplate&&(t=(0,z.interpolateSelectionBatch)(e.bodyTemplate,s,r).text);let l=await i(a.text,{method:e.method,headers:c0(e),body:t});if(!l.ok)throw Error(`HTTP ${l.status}: ${l.statusText}`);return n(e.name,{loading:!1,success:!0}),{success:!0}}catch(r){let t=r instanceof Error?r:Error(String(r));return n(e.name,{loading:!1,error:t}),{success:!1,error:t}}}async function c4(e,t,r,n,i){return"batch"===e.batchMode?c2(e,t,r,n,i):c1(e,t,r,n,i)}async function c5(e,t,r,n){if("batch"!==e.batchMode)return function(e,t,r,n){let i=Array.from(t.entries()),s=i.length,a=new Map;n(e.name,{loading:!0,itemStatuses:new Map});for(let t=0;t<i.length;t++){let[o,l]=i[t];n(e.name,{loading:!0},o);try{let i;i=e.bodyTemplate?(0,z.interpolateSelectionIndividual)(e.bodyTemplate,l,t,s,r).text:JSON.stringify({id:o,data:l});let u=new CustomEvent(e.eventName,{detail:i,bubbles:!0,cancelable:!0});window.dispatchEvent(u),a.set(o,{success:!0}),n(e.name,{loading:!1,success:!0},o)}catch(r){let t=r instanceof Error?r:Error(String(r));n(e.name,{loading:!1,error:t},o),a.set(o,{success:!1,error:t})}}return n(e.name,{loading:!1,success:!0}),{success:!0,itemResults:a}}(e,t,r,n);try{let i;n(e.name,{loading:!0});let s=Array.from(t.values());i=e.bodyTemplate?(0,z.interpolateSelectionBatch)(e.bodyTemplate,s,r).text:JSON.stringify({items:s});let a=new CustomEvent(e.eventName,{detail:i,bubbles:!0,cancelable:!0});return window.dispatchEvent(a),n(e.name,{loading:!1,success:!0}),{success:!0}}catch(r){let t=r instanceof Error?r:Error(String(r));return n(e.name,{loading:!1,error:t}),{success:!1,error:t}}}async function c9(e){let{action:t,selectionMap:r,variableState:n,setActionStatus:i,fetchFn:s}=e;return 0===r.size?{success:!0}:"event"===t.type?c5(t,r,n,i):"webhook"===t.type?c4(t,r,n,i,s):{success:!1,error:Error("Unknown action type")}}var c3=r(67435),c6=r(49348);let c8=(0,L.createContext)(void 0);function c7(){let e=(0,L.useContext)(c8);return void 0===e?(console.warn("No RouterContext found. Did you forget a <RouterProvider>?"),{}):e}function de(e){let{RouterComponent:t,navigate:r,children:n}=e,i=(0,L.useMemo)(()=>({RouterComponent:t,navigate:r}),[t,r]);return(0,O.jsx)(c8.Provider,{value:i,children:n})}function dt(e){let{children:t}=e,r=(0,c3.Zp)();return(0,O.jsx)(de,{RouterComponent:c6.Link,navigate:r,children:t})}function dr(...e){let t={kind:"PluginModule",metadata:{name:"Fake Plugin Module for Tests",version:"1.0.0"},spec:{plugins:e.map(({kind:e,spec:{name:t}})=>({kind:e,spec:{name:t,display:{name:dn(e,t)}}}))}},r={};for(let n of e)r[u5({kind:n.kind,name:n.spec.name,registry:t.metadata.registry,version:t.metadata.version})]=n.plugin;return{pluginLoader:{getInstalledPlugins:()=>Promise.resolve([t]),importPluginModule:()=>Promise.resolve(r)},defaultPluginKinds:{TimeSeriesQuery:"PrometheusTimeSeriesQuery"}}}function dn(e,t){return`${e} Plugin for ${t}`}let di=e=>!!(e&&"object"==typeof e&&"series"in e&&Array.isArray(e.series)&&e.series.length>0),ds=e=>{let t,r,n;if(!e||0===e.length)return;let i=[];if(e.forEach(e=>{if(e?.data&&"object"==typeof e.data&&"series"in e.data){let s=e.data;s.series&&Array.isArray(s.series)&&s.series.length>0&&(i.push(...s.series),!t&&s.timeRange&&(t=s.timeRange),!r&&s.stepMs&&(r=s.stepMs),!n&&s.metadata&&(n=s.metadata))}}),i.length>0)return{series:i,timeRange:t,stepMs:r,metadata:n}},da=(e,t)=>{let r=e.formattedName||e.name;if(r&&r!==`Series ${t+1}`||(r=e.legendName||e.displayName||e.legend||e.name||""),(!r||r===e.name)&&e.labels){let n=e.labels,i={...n},s=i.__name__;delete i.__name__;let a=Object.entries(i).filter(([e])=>null!=e&&""!==e).map(([e,t])=>`${e}="${t}"`).join(", ");r=s&&a?`${s}{${a}}`:s||(a?`{${a}}`:n.job||n.instance||n.metric||`Series ${t+1}`)}return r&&""!==r.trim()||(r=`Series ${t+1}`),r},dl=e=>e.replace(/[,"\n\r]/g,"_").replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").substring(0,255),du=e=>e.replace(/[<>:"/\\|?*]/g," ").trim().split(/\s+/).filter(e=>e.length>0).map((e,t)=>0===t?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(""),dc=e=>{let t;if("string"==typeof e){let r=new Date(e);if(isNaN(r.getTime()))return e;t=r.getTime()}else t=e>1e10?e:1e3*e;let r=new Date(t);return isNaN(r.getTime())?new Date(t).toISOString():r.toISOString()},dd=e=>{if(null==e)return"";let t=String(e);return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t.replace(/"/g,'""')}"`:t},dp=({data:e})=>{if(!di(e))return console.warn("No valid data found to export to CSV."),new Blob([""],{type:"text/csv;charset=utf-8"});let t="",r={},n=[],i=0;for(let t=0;t<e.series.length;t++){let s=e.series[t];if(!s||!Array.isArray(s.values)||0===s.values.length)continue;let a=da(s,t),o=dl(a),l={legendName:a,columnName:o||`Series_${t+1}`,originalName:s.name||""};n.push(l),i++;for(let e=0;e<s.values.length;e++){let t,n,i=s.values[e];if(Array.isArray(i)&&i.length>=2)t=i[0],n=i[1];else{if("object"!=typeof i||null===i||!("timestamp"in i)||!("value"in i))continue;t=i.timestamp,n=i.value}if(null==n)continue;let a=dc(t);r[a]||(r[a]={}),r[a][l.columnName]=n}}if(0===i||0===n.length)return console.warn("No valid data found to export to CSV."),new Blob([""],{type:"text/csv;charset=utf-8"});if(0===Object.keys(r).length)return console.warn("No valid timestamp data found to export to CSV."),new Blob([""],{type:"text/csv;charset=utf-8"});let s=n.map(e=>e.columnName);for(let e of(t+=`DateTime,${s.join(",")}
|
|
52
|
+
`,Object.keys(r).toSorted((e,t)=>new Date(e).getTime()-new Date(t).getTime()))){let n=r[e],i=[];if(n){for(let e of s){let t=n[e];i.push(dd(t))}t+=`${dd(e)},${i.join(",")}
|
|
53
|
+
`}}return new Blob([t],{type:"text/csv;charset=utf-8"})};var dh=r(91785),df=r(63859),dm=r(79706);let dg=console;class dv{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),i4(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(e){this.cacheTime=Math.max(this.cacheTime||0,null!=e?e:i1?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class dy extends dv{constructor(e){super(),this.abortSignalConsumed=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.logger=e.logger||dg,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||function(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,n=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?null!=n?n:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(e,t){let r=sf(this.state.data,e,this.options);return this.dispatch({data:r,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt,manual:null==t?void 0:t.manual}),r}setState(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})}cancel(e){var t;let r=this.promise;return null==(t=this.retryer)||t.cancel(e),r?r.then(i2).catch(i2):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(e=>!1!==e.options.enabled)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!i9(this.state.dataUpdatedAt,e)}onFocus(){var e;let t=this.observers.find(e=>e.shouldFetchOnWindowFocus());t&&t.refetch({cancelRefetch:!1}),null==(e=this.retryer)||e.continue()}onOnline(){var e;let t=this.observers.find(e=>e.shouldFetchOnReconnect());t&&t.refetch({cancelRefetch:!1}),null==(e=this.retryer)||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(e,t){var r,n,i,s;if("idle"!==this.state.fetchStatus){if(this.state.dataUpdatedAt&&null!=t&&t.cancelRefetch)this.cancel({silent:!0});else if(this.promise)return null==(i=this.retryer)||i.continueRetry(),this.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let a=function(){if("function"==typeof AbortController)return new AbortController}(),o={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>{if(a)return this.abortSignalConsumed=!0,a.signal}})};l(o);let u=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(o)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),c={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:u};l(c),null==(r=this.options.behavior)||r.onFetch(c),this.revertState=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(n=c.fetchOptions)?void 0:n.meta))&&this.dispatch({type:"fetch",meta:null==(s=c.fetchOptions)?void 0:s.meta});let d=e=>{if(sj(e)&&e.silent||this.dispatch({type:"error",error:e}),!sj(e)){var t,r,n,i;null==(t=(r=this.cache.config).onError)||t.call(r,e,this),null==(n=(i=this.cache.config).onSettled)||n.call(i,this.state.data,e,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=sw({fn:c.fetchFn,abort:null==a?void 0:a.abort.bind(a),onSuccess:e=>{var t,r,n,i;void 0===e?d(Error(this.queryHash+" data is undefined")):(this.setData(e),null==(t=(r=this.cache.config).onSuccess)||t.call(r,e,this),null==(n=(i=this.cache.config).onSettled)||n.call(i,e,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1)},onError:d,onFail:(e,t)=>{this.dispatch({type:"failed",failureCount:e,error:t})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(e){let t=t=>{var r,n;switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null!=(r=e.meta)?r:null,fetchStatus:sA(this.options.networkMode)?"fetching":"paused",...!t.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:null!=(n=e.dataUpdatedAt)?n:Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let i=e.error;if(sj(i)&&i.revert&&this.revertState)return{...this.revertState,fetchStatus:"idle"};return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),sm.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate(e)}),this.cache.notify({query:this,type:"updated",action:e})})}}class db extends sg{constructor(e){super(),this.config=e||{},this.queries=[],this.queriesMap={}}build(e,t,r){var n;let i=t.queryKey,s=null!=(n=t.queryHash)?n:sr(i,t),a=this.get(s);return a||(a=new dy({cache:this,logger:e.getLogger(),queryKey:i,queryHash:s,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"added",query:e}))}remove(e){let t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(t=>t!==e),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"removed",query:e}))}clear(){sm.batch(()=>{this.queries.forEach(e=>{this.remove(e)})})}get(e){return this.queriesMap[e]}getAll(){return this.queries}find(e,t){let[r]=i8(e,t);return void 0===r.exact&&(r.exact=!0),this.queries.find(e=>se(r,e))}findAll(e,t){let[r]=i8(e,t);return Object.keys(r).length>0?this.queries.filter(e=>se(r,e)):this.queries}notify(e){sm.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}onFocus(){sm.batch(()=>{this.queries.forEach(e=>{e.onFocus()})})}onOnline(){sm.batch(()=>{this.queries.forEach(e=>{e.onOnline()})})}}class dx extends dv{constructor(e){super(),this.defaultOptions=e.defaultOptions,this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.logger=e.logger||dg,this.observers=[],this.state=e.state||dA(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(e){this.dispatch({type:"setState",state:e})}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.observers=this.observers.filter(t=>t!==e),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){var e,t;return null!=(e=null==(t=this.retryer)?void 0:t.continue())?e:this.execute()}async execute(){var e,t,r,n,i,s,a,o,l,u,c,d,p,h,f,m,g,v,y,b;let x=()=>{var e;return this.retryer=sw({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(e,t)=>{this.dispatch({type:"failed",failureCount:e,error:t})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},A="loading"===this.state.status;try{if(!A){this.dispatch({type:"loading",variables:this.options.variables}),await (null==(l=(u=this.mutationCache.config).onMutate)?void 0:l.call(u,this.state.variables,this));let e=await (null==(c=(d=this.options).onMutate)?void 0:c.call(d,this.state.variables));e!==this.state.context&&this.dispatch({type:"loading",context:e,variables:this.state.variables})}let p=await x();return await (null==(e=(t=this.mutationCache.config).onSuccess)?void 0:e.call(t,p,this.state.variables,this.state.context,this)),await (null==(r=(n=this.options).onSuccess)?void 0:r.call(n,p,this.state.variables,this.state.context)),await (null==(i=(s=this.mutationCache.config).onSettled)?void 0:i.call(s,p,null,this.state.variables,this.state.context,this)),await (null==(a=(o=this.options).onSettled)?void 0:a.call(o,p,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:p}),p}catch(e){try{throw await (null==(p=(h=this.mutationCache.config).onError)?void 0:p.call(h,e,this.state.variables,this.state.context,this)),await (null==(f=(m=this.options).onError)?void 0:f.call(m,e,this.state.variables,this.state.context)),await (null==(g=(v=this.mutationCache.config).onSettled)?void 0:g.call(v,void 0,e,this.state.variables,this.state.context,this)),await (null==(y=(b=this.options).onSettled)?void 0:y.call(b,void 0,e,this.state.variables,this.state.context)),e}finally{this.dispatch({type:"error",error:e})}}}dispatch(e){let t=t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"loading":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!sA(this.options.networkMode),status:"loading",variables:e.variables};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"};case"setState":return{...t,...e.state}}};this.state=t(this.state),sm.batch(()=>{this.observers.forEach(t=>{t.onMutationUpdate(e)}),this.mutationCache.notify({mutation:this,type:"updated",action:e})})}}function dA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class d_ extends sg{constructor(e){super(),this.config=e||{},this.mutations=[],this.mutationId=0}build(e,t,r){let n=new dx({mutationCache:this,logger:e.getLogger(),mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:r,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0});return this.add(n),n}add(e){this.mutations.push(e),this.notify({type:"added",mutation:e})}remove(e){this.mutations=this.mutations.filter(t=>t!==e),this.notify({type:"removed",mutation:e})}clear(){sm.batch(()=>{this.mutations.forEach(e=>{this.remove(e)})})}getAll(){return this.mutations}find(e){return void 0===e.exact&&(e.exact=!0),this.mutations.find(t=>st(e,t))}findAll(e){return this.mutations.filter(t=>st(e,t))}notify(e){sm.batch(()=>{this.listeners.forEach(({listener:t})=>{t(e)})})}resumePausedMutations(){var e;return this.resuming=(null!=(e=this.resuming)?e:Promise.resolve()).then(()=>{let e=this.mutations.filter(e=>e.state.isPaused);return sm.batch(()=>e.reduce((e,t)=>e.then(()=>t.continue().catch(i2)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function dj(){return{onFetch:e=>{e.fetchFn=()=>{var t,r,n,i,s,a;let o,l=null==(t=e.fetchOptions)||null==(r=t.meta)?void 0:r.refetchPage,u=null==(n=e.fetchOptions)||null==(i=n.meta)?void 0:i.fetchMore,c=null==u?void 0:u.pageParam,d=(null==u?void 0:u.direction)==="forward",p=(null==u?void 0:u.direction)==="backward",h=(null==(s=e.state.data)?void 0:s.pages)||[],f=(null==(a=e.state.data)?void 0:a.pageParams)||[],m=f,g=!1,v=e.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+e.options.queryHash+"'")),y=(e,t,r,n)=>(m=n?[t,...m]:[...m,t],n?[r,...e]:[...e,r]),b=(t,r,n,i)=>{if(g)return Promise.reject("Cancelled");if(void 0===n&&!r&&t.length)return Promise.resolve(t);let s={queryKey:e.queryKey,pageParam:n,meta:e.options.meta};return Object.defineProperty(s,"signal",{enumerable:!0,get:()=>{var t,r;return null!=(t=e.signal)&&t.aborted?g=!0:null==(r=e.signal)||r.addEventListener("abort",()=>{g=!0}),e.signal}}),Promise.resolve(v(s)).then(e=>y(t,n,e,i))};if(h.length)if(d){let t=void 0!==c,r=t?c:dw(e.options,h);o=b(h,t,r)}else if(p){let t=void 0!==c,r=t?c:dC(e.options,h);o=b(h,t,r,!0)}else{m=[];let t=void 0===e.options.getNextPageParam;o=!l||!h[0]||l(h[0],0,h)?b([],t,f[0]):Promise.resolve(y([],f[0],h[0]));for(let r=1;r<h.length;r++)o=o.then(n=>{if(!l||!h[r]||l(h[r],r,h)){let i=t?f[r]:dw(e.options,n);return b(n,t,i)}return Promise.resolve(y(n,f[r],h[r]))})}else o=b([]);return o.then(e=>({pages:e,pageParams:m}))}}}}function dw(e,t){return null==e.getNextPageParam?void 0:e.getNextPageParam(t[t.length-1],t)}function dC(e,t){return null==e.getPreviousPageParam?void 0:e.getPreviousPageParam(t[0],t)}class dE{constructor(e={}){this.queryCache=e.queryCache||new db,this.mutationCache=e.mutationCache||new d_,this.logger=e.logger||dg,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,1===this.mountCount&&(this.unsubscribeFocus=sv.subscribe(()=>{sv.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=sb.subscribe(()=>{sb.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var e,t;this.mountCount--,0===this.mountCount&&(null==(e=this.unsubscribeFocus)||e.call(this),this.unsubscribeFocus=void 0,null==(t=this.unsubscribeOnline)||t.call(this),this.unsubscribeOnline=void 0)}isFetching(e,t){let[r]=i8(e,t);return r.fetchStatus="fetching",this.queryCache.findAll(r).length}isMutating(e){return this.mutationCache.findAll({...e,fetching:!0}).length}getQueryData(e,t){var r;return null==(r=this.queryCache.find(e,t))?void 0:r.state.data}ensureQueryData(e,t,r){let n=i3(e,t,r),i=this.getQueryData(n.queryKey);return i?Promise.resolve(i):this.fetchQuery(n)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,r){let n=this.queryCache.find(e),i=null==n?void 0:n.state.data,s="function"==typeof t?t(i):t;if(void 0===s)return;let a=i3(e),o=this.defaultQueryOptions(a);return this.queryCache.build(this,o).setData(s,{...r,manual:!0})}setQueriesData(e,t,r){return sm.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e,t){var r;return null==(r=this.queryCache.find(e,t))?void 0:r.state}removeQueries(e,t){let[r]=i8(e,t),n=this.queryCache;sm.batch(()=>{n.findAll(r).forEach(e=>{n.remove(e)})})}resetQueries(e,t,r){let[n,i]=i8(e,t,r),s=this.queryCache,a={type:"active",...n};return sm.batch(()=>(s.findAll(n).forEach(e=>{e.reset()}),this.refetchQueries(a,i)))}cancelQueries(e,t,r){let[n,i={}]=i8(e,t,r);return void 0===i.revert&&(i.revert=!0),Promise.all(sm.batch(()=>this.queryCache.findAll(n).map(e=>e.cancel(i)))).then(i2).catch(i2)}invalidateQueries(e,t,r){let[n,i]=i8(e,t,r);return sm.batch(()=>{var e,t;if(this.queryCache.findAll(n).forEach(e=>{e.invalidate()}),"none"===n.refetchType)return Promise.resolve();let r={...n,type:null!=(e=null!=(t=n.refetchType)?t:n.type)?e:"active"};return this.refetchQueries(r,i)})}refetchQueries(e,t,r){let[n,i]=i8(e,t,r),s=Promise.all(sm.batch(()=>this.queryCache.findAll(n).filter(e=>!e.isDisabled()).map(e=>{var t;return e.fetch(void 0,{...i,cancelRefetch:null==(t=null==i?void 0:i.cancelRefetch)||t,meta:{refetchPage:n.refetchPage}})}))).then(i2);return null!=i&&i.throwOnError||(s=s.catch(i2)),s}fetchQuery(e,t,r){let n=i3(e,t,r),i=this.defaultQueryOptions(n);void 0===i.retry&&(i.retry=!1);let s=this.queryCache.build(this,i);return s.isStaleByTime(i.staleTime)?s.fetch(i):Promise.resolve(s.state.data)}prefetchQuery(e,t,r){return this.fetchQuery(e,t,r).then(i2).catch(i2)}fetchInfiniteQuery(e,t,r){let n=i3(e,t,r);return n.behavior=dj(),this.fetchQuery(n)}prefetchInfiniteQuery(e,t,r){return this.fetchInfiniteQuery(e,t,r).then(i2).catch(i2)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(e){this.defaultOptions=e}setQueryDefaults(e,t){let r=this.queryDefaults.find(t=>sn(e)===sn(t.queryKey));r?r.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})}getQueryDefaults(e){if(!e)return;let t=this.queryDefaults.find(t=>si(e,t.queryKey));return null==t?void 0:t.defaultOptions}setMutationDefaults(e,t){let r=this.mutationDefaults.find(t=>sn(e)===sn(t.mutationKey));r?r.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})}getMutationDefaults(e){if(!e)return;let t=this.mutationDefaults.find(t=>si(e,t.mutationKey));return null==t?void 0:t.defaultOptions}defaultQueryOptions(e){if(null!=e&&e._defaulted)return e;let t={...this.defaultOptions.queries,...this.getQueryDefaults(null==e?void 0:e.queryKey),...e,_defaulted:!0};return!t.queryHash&&t.queryKey&&(t.queryHash=sr(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.useErrorBoundary&&(t.useErrorBoundary=!!t.suspense),t}defaultMutationOptions(e){return null!=e&&e._defaulted?e:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==e?void 0:e.mutationKey),...e,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}class dO extends sC{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:dj()},t)}getOptimisticResult(e){return e.behavior=dj(),super.getOptimisticResult(e)}fetchNextPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"forward",pageParam:e}}})}fetchPreviousPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"backward",pageParam:e}}})}createResult(e,t){var r,n,i,s,a,o;let{state:l}=e,u=super.createResult(e,t),{isFetching:c,isRefetching:d}=u,p=c&&(null==(r=l.fetchMeta)||null==(n=r.fetchMore)?void 0:n.direction)==="forward",h=c&&(null==(i=l.fetchMeta)||null==(s=i.fetchMore)?void 0:s.direction)==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:function(e,t){if(e.getNextPageParam&&Array.isArray(t)){let r=dw(e,t);return null!=r&&!1!==r}}(t,null==(a=l.data)?void 0:a.pages),hasPreviousPage:function(e,t){if(e.getPreviousPageParam&&Array.isArray(t)){let r=dC(e,t);return null!=r&&!1!==r}}(t,null==(o=l.data)?void 0:o.pages),isFetchingNextPage:p,isFetchingPreviousPage:h,isRefetching:d&&!p&&!h}}}class dS extends sg{constructor(e,t){super(),this.client=e,this.setOptions(t),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;let r=this.options;this.options=this.client.defaultMutationOptions(e),sa(r,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),null==(t=this.currentMutation)||t.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var e;null==(e=this.currentMutation)||e.removeObserver(this)}}onMutationUpdate(e){this.updateResult();let t={listeners:!0};"success"===e.type?t.onSuccess=!0:"error"===e.type&&(t.onError=!0),this.notify(t)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:void 0!==e?e:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){let e=this.currentMutation?this.currentMutation.state:dA(),t="loading"===e.status,r={...e,isLoading:t,isPending:t,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset};this.currentResult=r}notify(e){sm.batch(()=>{if(this.mutateOptions&&this.hasListeners()){var t,r,n,i,s,a,o,l;e.onSuccess?(null==(t=(r=this.mutateOptions).onSuccess)||t.call(r,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(n=(i=this.mutateOptions).onSettled)||n.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)):e.onError&&(null==(s=(a=this.mutateOptions).onError)||s.call(a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(o=(l=this.mutateOptions).onSettled)||o.call(l,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context))}e.listeners&&this.listeners.forEach(({listener:e})=>{e(this.currentResult)})})}}function dk(e){return e.state.isPaused}function dR(e){return"success"===e.state.status}function dP(e,t={}){let r=[],n=[];if(!1!==t.dehydrateMutations){let n=t.shouldDehydrateMutation||dk;e.getMutationCache().getAll().forEach(e=>{n(e)&&r.push({mutationKey:e.options.mutationKey,state:e.state})})}if(!1!==t.dehydrateQueries){let r=t.shouldDehydrateQuery||dR;e.getQueryCache().getAll().forEach(e=>{r(e)&&n.push({state:e.state,queryKey:e.queryKey,queryHash:e.queryHash})})}return{mutations:r,queries:n}}function dT(e,t,r){if("object"!=typeof t||null===t)return;let n=e.getMutationCache(),i=e.getQueryCache(),s=t.mutations||[],a=t.queries||[];s.forEach(t=>{var i;n.build(e,{...null==r||null==(i=r.defaultOptions)?void 0:i.mutations,mutationKey:t.mutationKey},t.state)}),a.forEach(({queryKey:t,state:n,queryHash:s})=>{var a;let o=i.get(s);if(o){if(o.state.dataUpdatedAt<n.dataUpdatedAt){let{fetchStatus:e,...t}=n;o.setState(t)}return}i.build(e,{...null==r||null==(a=r.defaultOptions)?void 0:a.queries,queryKey:t,queryHash:s},{...n,fetchStatus:"idle"})})}function d$(e){return sH({...e,enabled:!0,useErrorBoundary:!0,suspense:!0,placeholderData:void 0,networkMode:"always",onSuccess:void 0,onError:void 0,onSettled:void 0},sC)}function dI(e){return sH({...e,enabled:!0,suspense:!0,useErrorBoundary:!0,networkMode:"always"},dO)}function dM({queries:e,context:t}){return sK({queries:e.map(e=>({...e,enabled:!0,useErrorBoundary:!0,suspense:!0,placeholderData:void 0,networkMode:"always"})),context:t})}function dz(e){return e}function dL(e){return e}function dV(e,t={}){let r=q({context:t.context}),n=L.useRef(t);n.current=t,L.useMemo(()=>{e&&dT(r,e,n.current)},[r,e])}let dN=({children:e,options:t,state:r})=>(dV(r,t),e);function dF(e,t,r){let[n,i={}]=i8(e,t,r),s=q({context:i.context}),a=s.getQueryCache();return sR(L.useCallback(e=>a.subscribe(sm.batchCalls(e)),[a]),()=>s.isFetching(n),()=>s.isFetching(n))}function dD(e,t,r){let[n,i={}]=i7(e,t,r),s=q({context:i.context}),a=s.getMutationCache();return sR(L.useCallback(e=>a.subscribe(sm.batchCalls(e)),[a]),()=>s.isMutating(n),()=>s.isMutating(n))}function dq(e){return e}function dU(e,t,r){let n=i6(e,t,r),i=q({context:n.context}),[s]=L.useState(()=>new dS(i,n));L.useEffect(()=>{s.setOptions(n)},[s,n]);let a=sR(L.useCallback(e=>s.subscribe(sm.batchCalls(e)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),o=L.useCallback((e,t)=>{s.mutate(e,t).catch(dQ)},[s]);if(a.error&&sV(s.options.useErrorBoundary,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function dQ(){}function dZ(e,t,r){return sH(i3(e,t,r),dO)}function dH(e){let t=q();t.getQueryState(e.queryKey)||t.prefetchQuery(e)}function dB(e){let t=q();t.getQueryState(e.queryKey)||t.prefetchInfiniteQuery(e)}var dW=r(78325);let dK=null;function dG(e){return async()=>{let t=await e();return()=>t}}let dJ=new Map;function dX(e){for(let[t,r]of Object.entries(e))dJ.set(t,r)}function dY(e){let t=dJ.get(e);if(!t)throw Error(`Shared module "${e}" was not registered before a plugin tried to consume it. Call registerHostSharedModules() during app bootstrap.`);return t}let d0=()=>(null===dK&&(dK=(0,dm.createInstance)({name:"@perses/perses-ui-host",remotes:[],shared:{react:{version:V().version,lib:()=>V(),shareConfig:{singleton:!0,requiredVersion:`^${V().version}`}},"react-dom":{version:"18.3.1",lib:()=>dW,shareConfig:{singleton:!0,requiredVersion:"^18.3.1"}},"react-router-dom":{version:"6.30.4",lib:()=>c6,shareConfig:{singleton:!0,requiredVersion:"^6.26.0"}},"@tanstack/react-query":{version:"4.44.0",lib:()=>E,shareConfig:{singleton:!0,requiredVersion:"^4.39.1"}},"react-hook-form":{version:"7.87.0",lib:()=>Z,shareConfig:{singleton:!0,requiredVersion:"^7.87.0"}},"@emotion/react":{version:"11.14.0",lib:()=>dh,shareConfig:{singleton:!0,requiredVersion:"^11.11.3"}},"@emotion/styled":{version:"11.14.1",lib:()=>df,shareConfig:{singleton:!0,requiredVersion:"^11.11.0"}},"@perses-dev/spec":{version:"0.3.0-beta.7",lib:()=>dY("@perses-dev/spec"),shareConfig:{singleton:!0,requiredVersion:"^0.3.0-beta.7"}},"@perses-dev/client":{version:"0.55.0-beta.8",lib:()=>dY("@perses-dev/client"),shareConfig:{singleton:!0,requiredVersion:"^0.55.0-beta.8"}},"@perses-dev/components":{version:"0.55.0-beta.8",lib:()=>dY("@perses-dev/components"),shareConfig:{singleton:!0,requiredVersion:"^0.55.0-beta.8"}},"@perses-dev/plugin-system":{version:"0.55.0-beta.8",lib:()=>dY("@perses-dev/plugin-system"),shareConfig:{singleton:!0,requiredVersion:"^0.55.0-beta.8"}},"@perses-dev/explore":{version:"0.55.0-beta.8",lib:()=>dY("@perses-dev/explore"),shareConfig:{singleton:!0,requiredVersion:"^0.55.0-beta.8"}},"@perses-dev/dashboards":{version:"0.55.0-beta.8",lib:()=>dY("@perses-dev/dashboards"),shareConfig:{singleton:!0,requiredVersion:"^0.55.0-beta.8"}},echarts:{version:"5.5.0",get:dG(()=>Promise.all([r.e("43"),r.e("873")]).then(r.bind(r,83824))),shareConfig:{singleton:!0,requiredVersion:"^5.5.0"}},"date-fns":{version:"4.2.1",get:dG(()=>Promise.all([r.e("967"),r.e("882"),r.e("230")]).then(r.bind(r,30781))),shareConfig:{singleton:!0,requiredVersion:"^4.1.0"}},"date-fns-tz":{version:"3.2.0",get:dG(()=>Promise.all([r.e("967"),r.e("978")]).then(r.bind(r,61153))),shareConfig:{singleton:!0,requiredVersion:"^3.2.0"}},lodash:{version:"4.18.1",get:dG(()=>r.e("392").then(r.t.bind(r,17243,19))),shareConfig:{singleton:!0,requiredVersion:"^4.17.21"}},"@hookform/resolvers/zod":{version:"5.9.1",get:dG(()=>Promise.resolve().then(r.bind(r,18019))),shareConfig:{singleton:!0,requiredVersion:"^5.9.1"}},"use-resize-observer":{version:"9.1.0",get:dG(()=>r.e("77").then(r.bind(r,85180))),shareConfig:{singleton:!0,requiredVersion:"^9.1.0"}},"mdi-material-ui":{version:"7.9.4",get:dG(()=>r.e("496").then(r.bind(r,64531))),shareConfig:{singleton:!0,requiredVersion:"^7.4.0"}},immer:{version:"10.2.0",get:dG(()=>Promise.resolve().then(r.t.bind(r,43945,23))),shareConfig:{singleton:!0,requiredVersion:"^10.1.1"}}}})),dK);function d1(e,t,r){return`${e}:${t??""}:${r??""}`}let d2=async e=>{let{moduleName:t,pluginName:r,registry:n,version:i,baseURL:s}=e,a=d0(),o=d1(t,n,i);if(!a.options.remotes.find(e=>e.name===o)){let e=[t,i,n].filter(Boolean).join("~"),r=`${s||"/plugins"}/${e}/mf-manifest.json`;a.registerRemotes([{name:o,entry:r,alias:o}])}let l=d0(),u=d1(t,n,i);return l.loadRemote(`${u}/${r}`)};function d4({plugin:e}){return{pluginRuntime:d0(),loadPlugin:()=>{let{moduleName:t,name:r,registry:n,version:i,baseURL:s}=e;return d2({moduleName:t,pluginName:r,registry:n,version:i,baseURL:s})}}}function d5({pluginFn:e,props:t}){return e(t)}function d9({plugin:e,props:t,field:r}){let{loadPlugin:n}=d4({plugin:e}),[i,s]=(0,L.useState)(null),[a,o]=(0,L.useState)(null),l=`${e.moduleName}-${e.name}`,u=(0,L.useRef)(l);if((0,L.useEffect)(()=>{u.current=l,o(null),n().then(e=>{s(e)}).catch(t=>{s(null),console.error(`PluginLoaderComponent: Error loading plugin ${e.name} from module ${e.moduleName}:`,t),o(Error(`PluginLoaderComponent: Error loading plugin ${e.name} from module ${e.moduleName}`))})},[l]),a)throw a;if(!i)return null;let c=i[e.name];if(r&&c&&"object"==typeof c&&r in c&&(c=c[r]),!c)throw Error(`PluginLoaderComponent: Plugin module ${e.moduleName} does not have a ${e.name} export`);if("function"!=typeof c)throw Error(`PluginLoaderComponent: Plugin ${e.name} export is not a function`);return u.current!==l?null:(0,O.jsx)(d5,{pluginFn:c,props:t},l)}var d3=r(71935);let d6=e=>"object"==typeof e&&null!==e&&"kind"in e&&"spec"in e&&"object"==typeof e.spec&&null!==e.spec&&"name"in e.spec,d8=e=>"object"==typeof e&&null!==e&&"metadata"in e&&"spec"in e&&"object"==typeof e.spec&&null!==e.spec&&"plugins"in e.spec&&Array.isArray(e.spec.plugins)&&e.spec.plugins.every(d6),d7="/api/v1/plugins",pe="/plugins";function pt(e){let{pluginsApiPath:t,pluginsAssetsPath:r}=void 0===e?{pluginsApiPath:d7,pluginsAssetsPath:pe}:{pluginsApiPath:`${e?.apiPrefix??""}${d7}`,pluginsAssetsPath:`${e?.baseURL??""}${pe}`},n=e?.fetchFn??uT.hd;return{getInstalledPlugins:async()=>{let e=await n(t),r=await e.json(),i=[];return Array.isArray(r)?i=r.filter(d8):console.error("RemotePluginLoader: Error loading plugins, response is not an array"),i.length||console.error("RemotePluginLoader: No valid plugins found"),i},importPluginModule:async e=>{let{name:t,version:n,registry:i}=e.metadata,s={},a=e.spec.plugins.map(async e=>{let s=await d2({moduleName:t,pluginName:e.spec.name,registry:i,version:n,baseURL:r}),a=s?.[e.spec.name];return a?{kind:e.kind,name:e.spec.name,remotePlugin:a}:(console.error(`RemotePluginLoader: Error loading plugin ${e.spec.name}`),null)});return(await Promise.all(a)).forEach(e=>{e?.remotePlugin&&(s[(0,d3.getPluginModuleCompoundKey)({kind:e.kind,name:e.name,registry:i,version:n})]=e.remotePlugin)}),s}}}},22457(e,t,r){r.d(t,{_:()=>i});var n=r(4721);function i(e){return Math.trunc((0,n.a)(e)/1e3)}},88034(e,t,r){r.d(t,{R:()=>i});var n=r(30439);function i({years:e,months:t,weeks:r,days:s,hours:a,minutes:o,seconds:l}){let u=0;e&&(u+=e*n.Ki),t&&(u+=t*(n.Ki/12)),r&&(u+=7*r),s&&(u+=s);let c=24*u*3600;return a&&(c+=60*a*60),o&&(c+=60*o),l&&(c+=l),Math.trunc(1e3*c)}},79215(e,t,r){r.r(t),r.d(t,{Controller:()=>U,FieldArray:()=>eb,Form:()=>eO,FormProvider:()=>eC,FormState:()=>eS,FormStateSubscribe:()=>ek,Watch:()=>eX,appendErrors:()=>X,createFormControl:()=>eG,get:()=>S,set:()=>R,useController:()=>q,useFieldArray:()=>ey,useForm:()=>eJ,useFormContext:()=>ew,useFormState:()=>V,useWatch:()=>D});var n=r(70451),i=r.n(n),s=e=>e instanceof Date,a=e=>null==e;let o=e=>"object"==typeof e;var l=e=>!a(e)&&!Array.isArray(e)&&o(e)&&!s(e),u=e=>l(e)&&e.target?"checkbox"===e.target.type?e.target.checked:"file"===e.target.type?e.target.files:e.target.value:e;let c=/[.[\]'"]/;var d=e=>e.split(c).filter(Boolean),p=(e,t)=>t.split(".").some((t,r,n)=>!isNaN(Number(t))&&e.has(n.slice(0,r).join("."))),h="u">typeof window&&void 0!==window.HTMLElement&&"u">typeof document;function f(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e);let t="u">typeof FileList&&e instanceof FileList;if(h&&(e instanceof Blob||t))return e;let r=Array.isArray(e);if(!r&&e.constructor!==Object)return e;let n=r?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=f(e[t]));return n}let m="blur",g="trigger",v="onChange",y="onSubmit",b="maxLength",x="minLength",A="pattern",_="required",j="validate",w="root",C=["__proto__","constructor","prototype"],E=/^\w*$/;var O=e=>void 0===e,S=(e,t,r)=>{if(!t||!l(e))return r;let n=E.test(t)?[t]:d(t);if(n.some(e=>C.includes(e)))return r;let i=n.reduce((e,t)=>a(e)?void 0:e[t],e);return O(i)||i===e?O(e[t])?r:e[t]:i},k=e=>"function"==typeof e,R=(e,t,r)=>{let n=-1,i=E.test(t)?[t]:d(t),s=i.length,a=s-1;for(;++n<s;){let t=i[n],s=r;if(n!==a){let r=e[t];s=l(r)||Array.isArray(r)?r:isNaN(+i[n+1])?{}:[]}if(C.includes(t))return;e[t]=s,e=e[t]}};let P=i().createContext(null);P.displayName="HookFormControlContext";var T=(e,t,r,n=!0)=>{let i={};for(let s in e)Object.defineProperty(i,s,{get:()=>("all"!==t._proxyFormState[s]&&(t._proxyFormState[s]=!n||"all"),r&&(r[s]=!0),e[s])});return i};let $=h?i().useLayoutEffect:i().useEffect;var I=e=>a(e)||!o(e);let M=(e,t)=>{let r;return 0===t.length&&!Array.isArray(e)&&!(l(r=e.constructor&&e.constructor.prototype)&&r.hasOwnProperty("isPrototypeOf"))};function z(e,t,r=new WeakMap){if(e===t)return!0;if(I(e)||I(t))return Object.is(e,t);if(s(e)&&s(t))return Object.is(e.getTime(),t.getTime());let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;if(M(e,n)||M(t,i))return Object.is(e,t);if(!n.length&&Array.isArray(e)!==Array.isArray(t))return!1;let a=r.get(e);if(a&&a.has(t))return!0;if(a)a.add(t);else{let n=new WeakSet;n.add(t),r.set(e,n)}for(let i of n){let n=e[i];if(!(i in t))return!1;if("ref"!==i){let e=t[i];if(s(n)&&s(e)||(l(n)||Array.isArray(n))&&(l(e)||Array.isArray(e))?!z(n,e,r):!Object.is(n,e))return!1}}return!0}function L(e){let t=i().useRef(!1),r=i().useRef(!1),n=i().useRef(void 0),s=i().useRef(0);return s.current++,!r.current&&e&&(r.current=!0,n.current=f(e())),{resyncIfNeeded:i().useCallback((e,i,a)=>{if(e&&(t.current||r.current&&s.current>1)){let e=i();z(n.current,e)||a(e)}t.current=!0},[]),snapshot:i().useCallback((e,t)=>{e&&(n.current=f(t()))},[])}}function V(e){let t=i().useContext(P),{control:r=t,disabled:n,name:s,exact:a}=e||{},o=()=>({...r._formState,defaultValues:r._defaultValues}),[l,u]=i().useState(o),c=i().useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),{resyncIfNeeded:d,snapshot:p}=L(o);return $(()=>{d(!n,o,u);let e=r._subscribe({name:s,formState:c.current,exact:a,callback:e=>{n||u({...r._formState,...e,defaultValues:r._defaultValues})}});return()=>{e(),p(!n,o)}},[s,n,a,d,p]),i().useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),i().useMemo(()=>T(l,r,c.current,!1),[l,r])}var N=e=>"string"==typeof e,F=(e,t,r,n,i)=>N(e)?(n&&t.watch.add(e),S(r,e,i)):Array.isArray(e)?e.map(e=>(n&&t.watch.add(e),S(r,e,S(i,e)))):(n&&(t.watchAll=!0),r);function D(e){let t=i().useContext(P),{control:r=t,name:n,defaultValue:s,disabled:a,exact:o,compute:l}=e||{},u=i().useRef(s),c=i().useRef(l),d=i().useRef(void 0),p=i().useRef(r),h=i().useRef(n);c.current=l;let f=()=>{let e=r._getWatch(n,u.current);return c.current?c.current(e):e},[m,g]=i().useState(f),v=i().useCallback(e=>{let t=F(n,r._names,e||r._formValues,!1,u.current);return c.current?c.current(t):t},[r._formValues,r._names,n]),y=i().useCallback(e=>{if(!a){let t=F(n,r._names,e||r._formValues,!1,u.current);if(c.current){let e=c.current(t);z(e,d.current)||(g(e),d.current=e)}else g(t)}},[r._formValues,r._names,a,n]),{resyncIfNeeded:b,snapshot:x}=L(f),A=i().useRef(y);A.current=y;let _=i().useRef(v);_.current=v,$(()=>{p.current===r&&z(h.current,n)?b(!a,()=>_.current(),e=>{g(e),d.current=e}):(p.current=r,h.current=n,A.current());let e=r._subscribe({name:n,formState:{values:!0},exact:o,callback:e=>{A.current(e.values)}});return()=>{e(),x(!a,()=>_.current())}},[r,o,n,a,b,x]),i().useEffect(()=>r._removeUnmounted());let j=p.current!==r,w=h.current;return i().useMemo(()=>{if(a)return!1;let e=!j&&!z(w,n);return j||e},[a,j,n,w])?v():m}function q(e){let t=i().useContext(P),{name:r,disabled:n,control:s=t,shouldUnregister:a,defaultValue:o,exact:l=!0}=e,c=p(s._names.array,r),h=i().useMemo(()=>{let e=S(s._formValues,r,S(s._defaultValues,r,o));return O(e)?function(e,t){let r=d(t),n=e._formValues,i=e._defaultValues;for(let e=0;e<r.length-1;e++){let t=r[e];if(n=null==n?n:n[t],i=null==i?i:i[t],null===n||null===i)return null}}(s,r):e},[s,r,o]),g=D({control:s,name:r,defaultValue:h,exact:l}),v=V({control:s,name:r,exact:l}),y=i().useRef(e),b=i().useRef(null),x=i().useRef(s.register(r,{...e.rules,value:g,..."boolean"==typeof e.disabled?{disabled:e.disabled}:{}}));y.current=e;let A=i().useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!S(v.errors,r)},isDirty:{enumerable:!0,get:()=>!!S(v.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!S(v.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!S(v.validatingFields,r)},error:{enumerable:!0,get:()=>S(v.errors,r)}}),[v,r]),_=i().useCallback(e=>{let t=u(e);return S(s._fields,r)||(x.current=s.register(r,{...y.current.rules,value:t})),x.current.onChange({target:{value:u(e),name:r},type:"change"})},[r,s]),j=i().useCallback(()=>x.current.onBlur({target:{value:S(s._formValues,r),name:r},type:m}),[r,s._formValues]),w=i().useCallback(e=>{e&&(b.current={focus:()=>k(e.focus)&&e.focus(),select:()=>k(e.select)&&e.select(),setCustomValidity:t=>k(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>k(e.reportValidity)&&e.reportValidity()});let t=S(s._fields,r);t&&t._f&&e&&(t._f.ref=b.current)},[s._fields,r]),C=i().useMemo(()=>({name:r,value:g,..."boolean"==typeof n||v.disabled?{disabled:v.disabled||n}:{},onChange:_,onBlur:j,ref:w}),[r,n,v.disabled,_,j,w,g]);return i().useEffect(()=>{let e=s._options.shouldUnregister||a;x.current=s.register(r,{...y.current.rules,..."boolean"==typeof y.current.disabled?{disabled:y.current.disabled}:{}});let t=(e,t)=>{let r=S(s._fields,e);r&&r._f&&(r._f.mount=t)};if(t(r,!0),e){let e=f(S(a?s._defaultValues:s._options.values||s._defaultValues,r,S(s._options.defaultValues,r,y.current.defaultValue)));R(s._defaultValues,r,e),O(S(s._formValues,r))&&R(s._formValues,r,e)}if(c||s.register(r),b.current){let e=S(s._fields,r);e&&e._f&&(e._f.ref=b.current)}return()=>{(c?e&&!s._state.action:e)?s.unregister(r):t(r,!1)}},[r,s,c,a]),i().useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),i().useMemo(()=>({field:C,formState:v,fieldState:A}),[C,v,A])}let U=e=>e.render(q(e));var Q=()=>"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),Z=(e,t,r={})=>r.shouldFocus||O(r.shouldFocus)?r.focusName||`${e}.${O(r.focusIndex)?t:r.focusIndex}.`:"",H=e=>({isOnSubmit:!e||e===y,isOnBlur:"onBlur"===e,isOnChange:e===v,isOnAll:"all"===e,isOnTouch:"onTouched"===e}),B=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(let r of t.watch)if(e.startsWith(r)&&"."===e.charAt(r.length))return!0;return!1};let W=(e,t,r,n)=>{for(let i of r||Object.keys(e)){if("_f"===i)continue;let s=r?S(e,i):e[i];if(s){let{_f:e}=s;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!n)return!0;else if(e.ref&&t(e.ref,e.name)&&!n)return!0;else if(W(s,t))break}else if((l(s)||Array.isArray(s))&&W(s,t))break}}};var K=(e,t,r)=>{let n=S(e,r),i=Array.isArray(n)?n:[];return R(i,w,t[r]),R(e,r,i),e},G=e=>l(e)&&!Object.keys(e).length,J=e=>{if(!h)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},X=(e,t,r,n,i)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:i||!0}}:{};let Y={value:!1,isValid:!1},ee={value:!0,isValid:!0};var et=e=>{if(!Array.isArray(e))return Y;if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}let t=e[0];return t&&t.checked&&!t.disabled?t.attributes&&"value"in t.attributes?O(t.value)||""===t.value?ee:{value:t.value,isValid:!0}:ee:Y};let er={isValid:!1,value:null};var en=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,er):er;function ei(e,t,r="validate"){if(N(e)||Array.isArray(e)&&e.every(N)||"boolean"==typeof e&&!e)return{type:r,message:N(e)?e:"",ref:t}}var es=e=>!l(e)||e instanceof RegExp?{value:e,message:""}:e,ea=async(e,t,r,n,i,o)=>{let{ref:u,refs:c,required:d,maxLength:p,minLength:h,min:f,max:m,pattern:g,validate:v,name:y,valueAsNumber:w,mount:C}=e._f,E=S(r,y);if(!C||t.has(y))return{};let R=c?c[0]:u,P=e=>{if(i&&R.reportValidity){let t="boolean"==typeof e?"":e||"";c?c.forEach(e=>e.setCustomValidity(t)):R.setCustomValidity(t),R.reportValidity()}},T={},$="radio"===u.type,I="checkbox"===u.type,M=(w||"file"===u.type)&&O(u.value)&&O(E)||J(u)&&""===u.value||""===E||Array.isArray(E)&&!E.length,z=X.bind(null,y,n,T),L=(e,t,r,n=b,i=x)=>{let s=e?t:r;T[y]={type:e?n:i,message:s,ref:u,...z(e?n:i,s)}};if(o?!Array.isArray(E)||!E.length:d&&(!($||I)&&(M||a(E))||"boolean"==typeof E&&!E||I&&!et(c).isValid||$&&!en(c).isValid)){let{value:e,message:t}=N(d)?{value:!!d,message:d}:es(d);if(e&&(T[y]={type:_,message:t,ref:R,...z(_,t)},!n))return P(t),T}if(!M&&(!a(f)||!a(m))){let e,t,r=es(m),i=es(f);if(a(E)||s(E)||isNaN(E)){let n=u.valueAsDate||new Date(E),s=e=>new Date(new Date().toDateString()+" "+e),a="time"==u.type,o="week"==u.type;N(r.value)&&E&&(e=a?s(E)>s(r.value):o?E>r.value:n>new Date(r.value)),N(i.value)&&E&&(t=a?s(E)<s(i.value):o?E<i.value:n<new Date(i.value))}else{let n=u.valueAsNumber||(E?+E:E);a(r.value)||(e=n>r.value),a(i.value)||(t=n<i.value)}if((e||t)&&(L(!!e,r.message,i.message,"max","min"),!n))return P(T[y].message),T}if((p||h)&&!M&&(N(E)||o&&Array.isArray(E))){let e=es(p),t=es(h),r=!a(e.value)&&E.length>+e.value,i=!a(t.value)&&E.length<+t.value;if((r||i)&&(L(r,e.message,t.message),!n))return P(T[y].message),T}if(g&&!M&&N(E)){let{value:e,message:t}=es(g);if(e instanceof RegExp&&!E.match(e)&&(T[y]={type:A,message:t,ref:u,...z(A,t)},!n))return P(t),T}if(v){if(k(v)){let e=ei(await v(E,r),R);if(e&&(T[y]={...e,...z(j,e.message)},!n))return P(e.message),T}else if(l(v)){let e={};for(let t in v){if(!G(e)&&!n)break;let i=ei(await v[t](E,r),R,t);i&&(e={...i,...z(t,i.message)},P(i.message),n&&(T[y]=e))}if(!G(e)&&(T[y]={ref:R,...e},!n))return T}}let V=T[y];return P(!V||V.message),T},eo=e=>Array.isArray(e)?e:[e],el=(e,t)=>[...e,...eo(t)],eu=e=>Array.isArray(e)?e.map(()=>void 0):void 0;function ec(e,t,r){return[...e.slice(0,t),...eo(r),...e.slice(t)]}var ed=(e,t,r)=>Array.isArray(e)?(O(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],ep=(e,t)=>[...eo(t),...eo(e)],eh=e=>Array.isArray(e)?e.filter(Boolean):[],ef=(e,t)=>O(t)?[]:function(e,t){let r=0,n=[...e];for(let e of t)n.splice(e-r,1),r++;return eh(n).length?n:[]}(e,eo(t).sort((e,t)=>e-t)),em=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]};function eg(e,t){if(N(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;let r=Array.isArray(t)?t:E.test(t)?[t]:d(t);if(r.some(e=>C.includes(String(e))))return e;let n=1===r.length?e:function(e,t){let r=t.length-1,n=0;for(;n<r;){if(a(e)){e=void 0;break}e=e[t[n]],n++}return e}(e,r),i=r.length-1,s=r[i];return n&&delete n[s],0!==i&&(l(n)&&G(n)||Array.isArray(n)&&function(e){for(let t in e)if(e.hasOwnProperty(t)&&!O(e[t]))return!1;return!0}(n))&&eg(e,r.slice(0,-1)),e}var ev=(e,t,r)=>(e[t]=r,e);function ey(e){let t=i().useContext(P),{control:r=t,name:n,keyName:s="id",disabled:a,shouldUnregister:o,rules:u}=e,[c,d]=i().useState(r._getFieldArray(n)),p=i().useRef(r._getFieldArray(n).map(Q)),h=i().useRef(!1);a||r._names.array.add(n),i().useMemo(()=>!a&&u&&c.length>=0&&r.register(n,u),[r,n,c.length,u,a]),$(()=>{if(!a)return r._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===n||!t){let r=S(e,n);Array.isArray(r)?(d(r),p.current=r.map(Q)):t||(d([]),p.current=[])}}}).unsubscribe},[r,n,a]);let m=i().useCallback(e=>{h.current=!0,r._setFieldArray(n,e)},[r,n]);return i().useEffect(()=>{if(a)return void r._state.actionArrayLengths.delete(n);r._state.action=!1,r._state.actionArrayLengths.delete(n),B(n,r._names)&&r._subjects.state.next({...r._formState});let e=H(r._options.mode);if(h.current&&(!e.isOnSubmit||r._formState.isSubmitted)&&!H(r._options.reValidateMode).isOnSubmit&&!e.isOnBlur)if(r._options.resolver)r._runSchema([n]).then(e=>{var t,i;r._updateIsValidating([n]);let s=S(e.errors,n),a=S(r._formState.errors,n),o=a&&(a.type||(null==(t=a.root)?void 0:t.type)),u=a&&(a.message||(null==(i=a.root)?void 0:i.message));(a?!s&&o||s&&(o!==s.type||u!==s.message):s&&s.type)&&(s?l(s)&&!Object.keys(s).some(e=>!Number.isNaN(+e))?K(r._formState.errors,{[n]:s},n):R(r._formState.errors,n,s):eg(r._formState.errors,n),r._subjects.state.next({errors:r._formState.errors}))});else{let e=S(r._fields,n);e&&e._f&&ea(e,r._names.disabled,r._formValues,"all"===r._options.criteriaMode,r._options.shouldUseNativeValidation,!0).then(e=>!G(e)&&r._subjects.state.next({errors:K(r._formState.errors,e,n)}))}h.current&&r._subjects.state.next({name:n,values:f(r._formValues)}),r._names.focus&&W(r._fields,(e,t)=>{if(r._names.focus&&t.startsWith(r._names.focus)&&e.focus)return e.focus(),1}),r._names.focus="",r._setValid(),h.current=!1},[c,n,r,a]),i().useEffect(()=>(!a&&(S(r._formValues,n)||r._setFieldArray(n)),()=>{let e;if(r._state.actionArrayLengths.delete(n),a)return;let t=!(r._options.shouldUnregister||o);h.current&&t&&r._subjects.state.next({name:n,values:f(r._formValues)}),t?(e=S(r._fields,n))&&e._f&&(e._f.mount=!1):r.unregister(n)}),[n,r,s,o,a]),{swap:i().useCallback((e,t)=>{if(a)return;let i=r._getFieldArray(n);em(i,e,t),em(p.current,e,t),m(i),d(i),r._setFieldArray(n,i,em,{argA:e,argB:t},!1)},[m,n,r,a]),move:i().useCallback((e,t)=>{if(a)return;let i=r._getFieldArray(n);ed(i,e,t),ed(p.current,e,t),m(i),d(i),r._setFieldArray(n,i,ed,{argA:e,argB:t},!1)},[m,n,r,a]),prepend:i().useCallback((e,t)=>{if(a)return;let i=eo(f(e)),s=ep(r._getFieldArray(n),i);r._names.focus=Z(n,0,t),p.current=ep(p.current,i.map(Q)),m(s),d(s),r._setFieldArray(n,s,ep,{argA:eu(e)})},[m,n,r,a]),append:i().useCallback((e,t)=>{if(a)return;let i=eo(f(e)),s=el(r._getFieldArray(n),i);r._names.focus=Z(n,s.length-1,t),p.current=el(p.current,i.map(Q)),m(s),d(s),r._setFieldArray(n,s,el,{argA:eu(e)})},[m,n,r,a]),remove:i().useCallback(e=>{if(a)return;let t=ef(r._getFieldArray(n),e);p.current=ef(p.current,e),m(t),d(t),Array.isArray(S(r._fields,n))||R(r._fields,n,void 0),r._setFieldArray(n,t,ef,{argA:e})},[m,n,r,a]),insert:i().useCallback((e,t,i)=>{if(a)return;let s=eo(f(t)),o=ec(r._getFieldArray(n),e,s);r._names.focus=Z(n,e,i),p.current=ec(p.current,e,s.map(Q)),m(o),d(o),r._setFieldArray(n,o,ec,{argA:e,argB:eu(t)})},[m,n,r,a]),update:i().useCallback((e,t)=>{if(a)return;let i=f(t),s=ev(r._getFieldArray(n),e,i);p.current=[...s].map((t,r)=>t&&r!==e?p.current[r]:Q()),m(s),d([...s]),r._setFieldArray(n,s,ev,{argA:e,argB:eu(t)})},[m,n,r,a]),replace:i().useCallback(e=>{if(a)return;let t=eo(f(e));p.current=t.map(Q),m([...t]),d([...t]),r._setFieldArray(n,[...t],e=>e,{},!0,!1)},[m,n,r,a]),fields:i().useMemo(()=>c.map((e,t)=>({...e,..."boolean"==typeof a?{disabled:a}:{},[s]:p.current[t]||Q()})),[c,s,a])}}let eb=e=>e.render(ey(e)),ex=e=>"u">typeof Blob&&e instanceof Blob||"u">typeof File&&e instanceof File,eA=e=>{let t={};for(let r of Object.keys(e))if(!o(e[r])||null===e[r]||s(e[r])||ex(e[r]))t[r]=e[r];else{let n=eA(e[r]);for(let e of Object.keys(n))t[`${r}.${e}`]=n[e]}return t};function e_(){}let ej=i().createContext(null);ej.displayName="HookFormContext";let ew=()=>i().useContext(ej),eC=({children:e,watch:t,getValues:r,getErrors:n,getFieldState:s,setError:a,clearErrors:o,setValue:l,setValues:u,trigger:c,formState:d,resetField:p,reset:h,resetDefaultValues:f,handleSubmit:m,unregister:g,control:v,register:y,setFocus:b,subscribe:x})=>{let A=i().useMemo(()=>({watch:t,getValues:r,getErrors:n,getFieldState:s,setError:a,clearErrors:o,setValue:l,setValues:u,trigger:c,formState:d,resetField:p,reset:h,resetDefaultValues:f,handleSubmit:m,unregister:g,control:v,register:y,setFocus:b,subscribe:x}),[o,v,d,n,s,r,m,y,h,f,p,a,b,l,u,x,c,g,t]);return i().createElement(ej.Provider,{value:A},i().createElement(P.Provider,{value:A.control},e))};function eE(e){return e>=200&&e<300}function eO(e){let t=ew(),[r,n]=i().useState(!1),{control:s=t.control,onSubmit:a=e_,children:o,action:l,method:u="post",headers:c,encType:d,onError:p=e_,render:h,onSuccess:f=e_,validateStatus:m=eE,...g}=e,v=i().useMemo(()=>s.handleSubmit(async(e,t)=>{let r=function(e){let t=new FormData,r=eA(e);for(let e in r)t.append(e,r[e]);return t}(e),n=function(e){try{return JSON.stringify(e)}catch(e){return""}}(e);if(a&&await a({data:e,event:t,method:u,formData:r,formDataJson:n}),N(l))try{let e=c&&c["Content-Type"]&&c["Content-Type"].includes("json")||d&&d.includes("json"),t=await fetch(l,{method:u,headers:{...c,...d&&"multipart/form-data"!==d&&{"Content-Type":d}},body:e?n:r});if(t&&!m(t.status))return p({response:t}),{type:String(t.status)};f({response:t})}catch(e){return p({error:e}),{type:""}}if(k(l))try{await l(r)}catch(e){return p({error:e}),{type:""}}}),[s,a,u,l,c,d,m,p,f]),y=i().useCallback(async e=>{let t=await v(e);t&&s&&(s._subjects.state.next({isSubmitSuccessful:!1}),s.setError("root.server",t))},[v,s]);return(i().useEffect(()=>{n(!0)},[]),h)?h({submit:y}):i().createElement("form",{noValidate:r,action:l,...!k(l)&&{method:u,encType:d},onSubmit:y,...g},o)}let eS=({control:e,disabled:t,exact:r,name:n,render:i})=>i(V({control:e,name:n,disabled:t,exact:r})),ek=eS;var eR=()=>{let e=[];return{get observers(){return e},next:t=>{for(let r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};let eP=(e,t)=>null!==e&&o(e)&&Object.prototype.hasOwnProperty.call(e,t);var eT=(e,t)=>{if(!t)return!1;let r=e;for(let n of E.test(t)?[t]:d(t)){if(!eP(r,n))return eP(e,t);r=r[n]}return!0},e$=e=>J(e)&&e.isConnected;function eI(e){return Array.isArray(e)||l(e)}function eM(e){return Array.isArray(e)||l(e)&&!(e=>{for(let t in e)if(k(e[t]))return!0;return!1})(e)}function ez(e){return!!(e&&"_f"in e)}function eL(e){return Array.isArray(e)?!e.some(e=>!O(e)):!Object.keys(e).length}function eV(e,t){Array.isArray(e)?e[t]=void 0:delete e[t]}function eN(e,t={},r){for(let n in e){let i=e[n],s=r&&r[n];!eM(i)||Array.isArray(i)&&ez(s)?O(i)||(t[n]=!0):(t[n]=Array.isArray(i)?[]:{},eN(i,t[n],s),eL(t[n])&&eV(t,n))}return t}function eF(e,t,r,n){for(let i in r||(r=eN(t,{},n)),e){let s=e[i],o=n&&n[i];!eM(s)||Array.isArray(s)&&ez(o)?z(s,t[i])?eV(r,i):r[i]=!0:(O(t)||I(r[i])?r[i]=eN(s,Array.isArray(s)?[]:{},o):eF(s,a(t)?{}:t[i],r[i],o),eL(r[i])&&eV(r,i))}return r}var eD=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>O(e)?e:t?""===e?NaN:e?+e:e:r&&N(e)?new Date(e):n?n(e):e;function eq(e){let t=e.ref;return"file"===t.type?t.files:"radio"===t.type?en(e.refs).value:"select-multiple"===t.type?[...t.selectedOptions].map(({value:e})=>e):"checkbox"===t.type?et(e.refs).value:eD(t.value,e)}var eU=e=>O(e)?e:e instanceof RegExp?e.source:l(e)?e.value instanceof RegExp?e.value.source:e.value:e;let eQ="AsyncFunction";var eZ=e=>{if(!e||!e.validate)return!1;if(k(e.validate))return e.validate.constructor.name===eQ;if(l(e.validate)){for(let t in e.validate)if(e.validate[t].constructor.name===eQ)return!0}return!1};function eH(e,t,r){let n=S(e,r);if(n||E.test(r))return{error:n,name:r};let i=r.split(".");for(;i.length;){let n=i.join("."),s=S(t,n),a=S(e,n);if(s&&!Array.isArray(s)&&r!==n)break;if(a&&a.type)return{name:n,error:a};if(a&&a.root&&a.root.type)return{name:`${n}.root`,error:a.root};i.pop()}return{name:r}}let eB={mode:y,reValidateMode:v,shouldFocusError:!0},eW="form",eK={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function eG(e={}){let t={...eB,...e},r={...f(eK),isLoading:k(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},i=(l(t.defaultValues)||l(t.values))&&f(t.defaultValues||t.values)||{},o=t.shouldUnregister?{}:f(i),c={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},v={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},y={},b={},x=0,A=H(t.mode),_=H(t.reValidateMode),C={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},P={...C},T={...P},$={array:eR(),state:eR()},I=0,M="all"===t.criteriaMode,L=(e,t)=>r=>{clearTimeout(b[e]),b[e]=setTimeout(t,r)},V=async e=>{if(!c.keepIsValid&&!t.disabled&&(P.isValid||T.isValid||e)){let e,i=++I;t.resolver?(e=G((await X()).errors),i===I&&D()):e=await et({fields:n,onlyCheckValid:!0,eventType:"valid"}),i===I&&e!==r.isValid&&$.state.next({isValid:e})}},D=(e,n)=>{!t.disabled&&(P.isValidating||P.validatingFields||T.isValidating||T.validatingFields)&&((e||v.mount).forEach(e=>{e&&(n?R(r.validatingFields,e,n):eg(r.validatingFields,e))}),$.state.next({validatingFields:r.validatingFields,isValidating:!G(r.validatingFields)}))},q=()=>{r.dirtyFields=eF(i,o,void 0,n)},U=(e,t)=>{R(r.errors,e,t),r.errors={...r.errors},$.state.next({errors:r.errors})},Q=(t,s,l,u)=>{let p=S(n,t);if(p){if((e=>{let t=E.test(e)?[e]:d(e),r=o,n=i;for(let e=0;e<t.length-1;e++){let i=t[e];if(r=a(r)?r:r[i],n=a(n)?n:n[i],null===r&&null!==n)return!0}return!1})(t)||(e=>{if(!c.actionArrayLengths.size)return!1;let t=E.test(e)?[e]:d(e),r=o,n="",i=-1,s=0;for(let e=0;e<t.length&&!a(r);e++){let a=t[e];if(n=n?`${n}.${a}`:a,Array.isArray(r)&&+a>=r.length)return -1!==i&&(e!==i||+a<s);c.actionArrayLengths.has(n)&&(i=e+1,s=c.actionArrayLengths.get(n)),r=r[a]}return!1})(t))return;let n=O(S(o,t)),h=S(o,t,O(l)?S(i,t):l);O(h)||u&&u.defaultChecked||s?R(o,t,s?h:eq(p._f)):ei(t,h),c.mount&&!c.action&&(V(),n&&r.isDirty&&(P.isDirty||T.isDirty)&&(er()||(r.isDirty=!1,$.state.next({...r}))),e.shouldUnregister&&n&&!O(S(o,t))&&B(t,v)&&(c.watch=!0))}},Z=(e,s,a,l,u)=>{let c=!1,d=!1,p={name:e};if(!t.disabled||!0===l){if(!a||l){let t=z(S(i,e),s);if((P.isDirty||T.isDirty)&&(d=r.isDirty,r.isDirty=p.isDirty=!t||er(),c=d!==p.isDirty),d=!!S(r.dirtyFields,e),t!==r.isDirty){var h=r.dirtyFields,f=eF(i,o,void 0,n);for(let e in h)e in f||delete h[e];Object.assign(h,f)}else t?eg(r.dirtyFields,e):R(r.dirtyFields,e,!0);p.dirtyFields=r.dirtyFields,c=c||(P.dirtyFields||T.dirtyFields)&&!t!==d}if(a){let t=S(r.touchedFields,e);t||(R(r.touchedFields,e,a),p.touchedFields=r.touchedFields,c=c||(P.touchedFields||T.touchedFields)&&t!==a)}c&&u&&$.state.next(p)}return c?p:{}},X=async e=>(D(e,!0),await t.resolver(o,t.context,((e,t,r,n)=>{let i={};for(let r of e){let e=S(t,r);e&&R(i,r,e._f)}return{criteriaMode:r,names:[...e],fields:i,shouldUseNativeValidation:n}})(e||v.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),Y=async e=>{let{errors:t}=await X(e);if(D(e),e){for(let n of e){let e=S(t,n);e?v.array.has(n)&&l(e)&&!Object.keys(e).some(e=>!Number.isNaN(Number(e)))?K(r.errors,{[n]:e},n):R(r.errors,n,e):eg(r.errors,n)}r.errors={...r.errors}}else r.errors=t;return t},ee=async({name:t,eventType:n})=>{if(e.validate){let i=await e.validate({formValues:o,formState:r,name:t,eventType:n});if(l(i))for(let e in i){let t=i[e];t&&ev(`${eW}.${e}`,{message:N(t.message)?t.message:"",type:t.type||j})}else N(i)||!i?ev(eW,{message:i||"",type:j}):em(eW);return i}return!0},et=async({fields:n,onlyCheckValid:i,name:s,eventType:a,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await ee({name:s,eventType:a}))&&(l.valid=!1,i))return l.valid;for(let s in n){let u=n[s];if(u){let{_f:n,...c}=u;if(n){let s=v.array.has(n.name),a=u._f&&eZ(u._f),c=P.validatingFields||P.isValidating||T.validatingFields||T.isValidating;a&&c&&D([n.name],!0);let d=await ea(u,v.disabled,o,M,t.shouldUseNativeValidation&&!i,s);if(a&&c&&D([n.name]),d[n.name]&&(l.valid=!1,i)||(i||(S(d,n.name)?s?K(r.errors,d,n.name):R(r.errors,n.name,d[n.name]):eg(r.errors,n.name)),e.shouldUseNativeValidation&&d[n.name]))break}G(c)||await et({context:l,onlyCheckValid:i,fields:c,name:s,eventType:a})}}return l.valid},er=(e,t)=>(e&&t&&R(o,e,t),!z(c.mount?o:i,i)),en=(e,t,r)=>F(e,v,{...c.mount?o:O(t)||N(e)?i:t},r,t),ei=(e,t,r={},i=!1,s=!1,l=!1)=>{let u=S(n,e),c=t;if(u){let r=u._f;r&&(r.disabled||R(o,e,eD(t,r)),c=J(r.ref)&&a(t)?"":t,"select-multiple"===r.ref.type?[...r.ref.options].forEach(e=>e.selected=c.includes(e.value)):r.refs?"checkbox"===r.ref.type?r.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(c)?e.checked=!!c.find(t=>t===e.value):e.checked=c===e.value||!!c)}):r.refs.forEach(e=>e.checked=e.value===c):"file"===r.ref.type?r.ref.value="":(r.ref.value=c,r.ref.type||s||l||$.state.next({name:e,values:i?o:f(o)})))}(r.shouldDirty||r.shouldTouch)&&Z(e,c,r.shouldTouch,r.shouldDirty,!s),r.shouldValidate&&ep(e,{delayError:r.delayError})},es=(e,t,r,i=!1,a=!1,u=!1)=>{for(let c in v.array.has(e)&&$.array.next({name:e,values:i?o:f(o)}),t){if(!t.hasOwnProperty(c))continue;let o=t[c],d=e+"."+c,p=S(n,d);(v.array.has(e)||l(o)||p&&!p._f)&&!s(o)?es(d,o,r,i,a,u):ei(d,o,r,i,a,u)}},el=(e,t,i,s,l=!1)=>{let u=S(n,e),d=v.array.has(e),p=s?t:f(t),h=z(S(o,e),p);if(h||R(o,e,p),d)$.array.next({name:e,values:s?o:f(o)}),(P.isDirty||P.dirtyFields||T.isDirty||T.dirtyFields)&&i.shouldDirty&&(q(),l||$.state.next({name:e,dirtyFields:r.dirtyFields,isDirty:er(e,p)}));else{let t=Array.isArray(p)&&!p.length||G(p),r=!h&&!l;!u||u._f||a(p)||t?ei(e,p,i,s,l,r):es(e,p,i,s,l,r)}if(!h&&!l){let t=B(e,v),n=s?o:f(o);if($.state.next({...t&&r,name:c.mount||t?e:void 0,values:n}),!d)for(let t of((e,t)=>{let r=t.split("."),n=[],i=r[0];for(let t=1;t<r.length;i+="."+r[t++])!isNaN(+r[t])&&e.has(i)&&n.push(`${i}.${r[t]}`);return n})(v.array,e))$.state.next({name:t,values:n})}},eu=(e,t,r={})=>el(e,t,r,!1),ec=async i=>{c.mount=!0;let a=i.target,l=a.name,d=!0,p=S(n,l),h=e=>{d=Number.isNaN(e)||s(e)&&isNaN(e.getTime())||z(e,S(o,l,e))};if(p){var g,j,w,C,E;let s,c,F,q=a.type?eq(p._f):u(i),Q=i.type===m||"focusout"===i.type,H=!((F=p._f).mount&&(F.required||!O(F.required)&&!1!==F.required||!O(F.min)||!O(F.max)||!O(F.maxLength)||!O(F.minLength)||F.pattern||F.validate))&&!e.validate&&!t.resolver&&!S(r.errors,l)&&!p._f.deps,W=H||(g=Q,j=S(r.touchedFields,l),w=r.isSubmitted,C=_,!(E=A).isOnAll&&(!w&&E.isOnTouch?!(j||g):(w?C.isOnBlur:E.isOnBlur)?!g:(w?!C.isOnChange:!E.isOnChange)||g)),K=B(l,v,Q);if(R(o,l,f(q)),Q){if(!a||!a.readOnly){p._f.onBlur&&p._f.onBlur(i);let e=y[l];e&&e(0)}}else p._f.onChange&&p._f.onChange(i);let J=Z(l,q,Q),Y=!G(J)||K;if(Q||$.state.next({name:l,type:i.type,...x?{values:f(o)}:{}}),W)return(!H||!r.isValid)&&(P.isValid||T.isValid)&&("onBlur"===t.mode?Q&&V():Q||V()),Y&&$.state.next({name:l,...K?{}:J});if(!t.resolver&&e.validate&&await ee({name:l,eventType:i.type}),!Q&&K&&$.state.next({...r}),t.resolver){let{errors:e}=await X([l]);if(D([l]),h(q),!d){G(J)||$.state.next(J);return}let t=eH(r.errors,n,l),i=eH(e,n,t.name||l);s=i.error,l=i.name,c=G(e)}else D([l],!0),s=(await ea(p,v.disabled,o,M,t.shouldUseNativeValidation))[l],D([l]),h(q),d&&(s?c=!1:(P.isValid||T.isValid)&&(c=await et({fields:n,onlyCheckValid:!0,name:l,eventType:i.type})));if(d){p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&ep(p._f.deps);var k=l,I=c,N=s;let e=S(r.errors,k),n=(P.isValid||T.isValid)&&"boolean"==typeof I&&r.isValid!==I;if(t.delayError&&N?(y[k]=L(k,()=>U(k,N)),y[k](t.delayError)):(clearTimeout(b[k]),delete y[k],N?R(r.errors,k,N):eg(r.errors,k),r.errors={...r.errors}),(N?!z(e,N):e)||!G(J)||n){let e={...J,...n&&"boolean"==typeof I?{isValid:I}:{},errors:r.errors,name:k};$.state.next(e)}}}},ed=(e,t)=>{if(S(r.errors,t)&&e.focus)return e.focus(),1},ep=async(e,i={})=>{let s,a,o=eo(e);if(t.resolver){let t=await Y(O(e)?e:o);s=G(t),a=e?!o.some(e=>S(t,e)):s}else e?((a=(await Promise.all(o.map(async e=>{let t=S(n,e);return await et({fields:t&&t._f?{[e]:t}:t,eventType:g})}))).every(Boolean))||r.isValid)&&V():a=s=await et({fields:n,name:e,eventType:g});if(i.delayError&&t.delayError&&N(e)){let n=S(r.errors,e);n?(eg(r.errors,e),y[e]=L(e,()=>U(e,n)),y[e](t.delayError)):(clearTimeout(b[e]),delete y[e])}if(i.shouldTouch)for(let t of e?o:v.mount)v.array.has(t)||R(r.touchedFields,t,!0);return $.state.next({...!N(e)||(P.isValid||T.isValid)&&s!==r.isValid?{}:{name:e},...t.resolver||!e?{isValid:s}:{},...i.shouldTouch&&(P.touchedFields||T.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),i.shouldFocus&&!a&&W(n,ed,e?o:v.mount),a},ef=(e,t)=>{let n=t||r,i=S(n.errors,e);return{invalid:!!i,isDirty:!!S(n.dirtyFields,e),error:i,isValidating:!!S(r.validatingFields,e),isTouched:!!S(n.touchedFields,e)}},em=e=>{let t=e?eo(e):void 0;null==t||t.forEach(e=>eg(r.errors,e)),t?t.forEach(e=>{$.state.next({name:e,errors:r.errors})}):(r.errors={},$.state.next({errors:r.errors}))},ev=(e,t,i)=>{let s=(S(n,e,{_f:{}})._f||{}).ref,{ref:a,message:o,type:l,...u}=S(r.errors,e)||{};R(r.errors,e,{...u,...t,ref:s}),$.state.next({name:e,errors:r.errors,isValid:!1}),i&&i.shouldFocus&&s&&s.focus&&s.focus()},ey=e=>{var t;let n=!!(null==(t=e.formState)?void 0:t.values);n&&x++;let{unsubscribe:s}=$.state.subscribe({next:t=>{var n,s;let a,l,u,c;if(a=e.name,l=t.name,u=e.exact,(!a||!l||a===l||eo(a).some(e=>e&&(u?e===l||e.startsWith(l+"."):e.startsWith(l)||l.startsWith(e))))&&(n=e.formState||P,s=e.reRenderRoot,eE(t),!(c=Object.keys(t).filter(e=>"name"!==e)).length||s&&c.length>=Object.keys(n).length||c.find(e=>n[e]===(!s||"all")))){let n={...o};e.callback({values:n,...r,...t,defaultValues:i})}}});if(!n)return s;let a=!1;return()=>{a||(a=!0,x--,s())}},eb=(e,s={})=>{for(let a of e?eo(e):v.mount)v.mount.delete(a),v.array.delete(a),s.keepValue||(eg(n,a),eg(o,a)),s.keepError||eg(r.errors,a),s.keepDirty||eg(r.dirtyFields,a),s.keepTouched||eg(r.touchedFields,a),s.keepIsValidating||eg(r.validatingFields,a),t.shouldUnregister||s.keepDefaultValue||eg(i,a);x&&$.state.next({values:f(o)}),$.state.next({...r,...s.keepDirty?{}:{isDirty:er()}}),s.keepIsValid||V()},ex=({disabled:e,name:t})=>{if("boolean"==typeof e&&c.mount||e||v.disabled.has(t)){let r=v.disabled.has(t);e?v.disabled.add(t):v.disabled.delete(t),!!e!==r&&c.mount&&!c.action&&V()}},eA=(e,r={})=>{let s=S(n,e),a="boolean"==typeof r.disabled||"boolean"==typeof t.disabled,o=!v.registerName.has(e)&&s&&s._f&&!s._f.mount;return(R(n,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...r}}),v.mount.add(e),s&&!o)?ex({disabled:"boolean"==typeof r.disabled?r.disabled:t.disabled,name:e}):Q(e,!0,r.value),{...a?{disabled:r.disabled||t.disabled}:{},...t.progressive?{required:!!r.required,min:eU(r.min),max:eU(r.max),minLength:eU(r.minLength),maxLength:eU(r.maxLength),pattern:eU(r.pattern)}:{},name:e,onChange:ec,onBlur:ec,ref:a=>{if(a){let t;v.registerName.add(e),eA(e,r),v.registerName.delete(e),s=S(n,e);let o=O(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,l="radio"===(t=o).type||"checkbox"===t.type,u=s._f.refs||[];if(l?u.find(e=>e===o):o===s._f.ref)return;let c={...s._f};l?(c.refs=[...u.filter(e$),o,...Array.isArray(S(i,e))?[{}]:[]],c.ref={type:o.type,name:e}):(c.ref=o,delete c.refs),R(n,e,{_f:c}),Q(e,!1,void 0,o)}else(s=S(n,e,{}))._f&&(s._f.mount=!1),(t.shouldUnregister||r.shouldUnregister)&&!(p(v.array,e)&&c.action)&&v.unMount.add(e)}}},e_=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&W(n,ed,v.mount),ej=(e,i)=>async s=>{let a,l;s&&(s.preventDefault&&s.preventDefault(),s.persist&&s.persist());let u=f(o);if($.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await X();D(),r.errors=e,u=f(t)}else await et({fields:n,eventType:"submit"});if(v.disabled.size)for(let e of v.disabled)eg(u,e);if(eg(r.errors,w),G(r.errors)){$.state.next({errors:{}});try{a=await e(u,s)}catch(e){l=e}}else i&&await i({...r.errors},s),e_(),setTimeout(e_);if($.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(r.errors)&&!l,submitCount:r.submitCount+1,errors:r.errors}),l)throw l;return a},ew=(e,s={})=>{let a=e?f(e):i,l=f(a),u=G(e),d=n;if(s.keepDefaultValues||(i=a),!s.keepValues){if(s.keepDirtyValues)for(let e of new Set([...v.mount,...function e(t,r,n="",i=[]){for(let s in t){let a=n?`${n}.${s}`:s,o=t[s];eI(o)&&eI(S(r,a))?e(o,r,a,i):i.push(a)}return i}(eF(i,o,void 0,d),r.dirtyFields)])){let t=S(r.dirtyFields,e),n=S(o,e),i=S(l,e);t&&!O(n)?R(l,e,n):t||O(i)||eu(e,i)}else{if(h&&O(e))for(let e of v.mount){let t=S(n,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(J(e)){let t=e.closest("form");if(t){t.reset();break}}}}if(s.keepFieldsRef)for(let e of v.mount)eu(e,S(l,e));else n={}}if(t.shouldUnregister){if(o=s.keepDefaultValues?f(i):{},s.keepFieldsRef)for(let e of v.mount)R(o,e,S(l,e))}else o=f(l);$.array.next({values:{...l}}),$.state.next({name:void 0,type:void 0,values:{...l}})}v={mount:s.keepDirtyValues?v.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},c.mount=!P.isValid||!!s.keepIsValid||!!s.keepDirtyValues||!t.shouldUnregister&&!G(l),c.watch=!!t.shouldUnregister,c.keepIsValid=!!s.keepIsValid,c.action=!1,c.actionArrayLengths.clear(),s.keepErrors||(r.errors={}),$.state.next({submitCount:s.keepSubmitCount?r.submitCount:0,isDirty:!u&&(s.keepDirty?r.isDirty:s.keepValues?er():!!(s.keepDefaultValues&&!z(e,i))),isSubmitted:!!s.keepIsSubmitted&&r.isSubmitted,dirtyFields:u?{}:s.keepDirtyValues?s.keepDefaultValues&&o?eF(i,o,void 0,d):r.dirtyFields:s.keepDefaultValues&&e?eF(i,e,void 0,d):s.keepDirty?r.dirtyFields:{},touchedFields:s.keepTouched?r.touchedFields:{},errors:s.keepErrors?r.errors:{},isSubmitSuccessful:!!s.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:i})},eC=(e,r)=>ew(k(e)?e(o):e,{...t.resetOptions,...r}),eE=e=>{let{name:t,type:n,values:i,...s}=e;r={...r,...s}};$.state.subscribe({next:eE});let eO={control:{register:eA,unregister:eb,getFieldState:ef,handleSubmit:ej,setError:ev,_subscribe:ey,_runSchema:X,_updateIsValidating:D,_focusError:e_,_getWatch:en,_getDirty:er,_setValid:V,_setFieldArray:(e,i=[],s,a,l=!0,u=!0)=>{if(a&&s&&!t.disabled){c.action=!0;let t=S(n,e);if(c.actionArrayLengths.has(e)||c.actionArrayLengths.set(e,Array.isArray(t)?t.length:0),u&&Array.isArray(t)){let r=s(t,a.argA,a.argB);l&&R(n,e,r)}let o=S(r.errors,e);if(u&&Array.isArray(o)){var d;let t,n=o.root,i=s(o,a.argA,a.argB)||o;n&&(i.root=n),l&&R(r.errors,e,i),eh(t=S(d=r.errors,e)).length||(null==t?void 0:t.root)||eg(d,e)}let p=S(r.touchedFields,e);if((P.touchedFields||T.touchedFields)&&u&&Array.isArray(p)){let t=s(p,a.argA,a.argB);l&&R(r.touchedFields,e,t)}(P.dirtyFields||T.dirtyFields)&&q(),$.state.next({name:e,isDirty:er(e,i),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else R(o,e,i)},_setDisabledField:ex,_setErrors:e=>{r.errors=e,$.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>eh(S(c.mount?o:i,e,t.shouldUnregister?S(i,e,[]):[])),_reset:ew,_resetDefaultValues:()=>k(t.defaultValues)&&t.defaultValues().then(e=>{eC(e,t.resetOptions),$.state.next({isLoading:!1})}),_removeUnmounted:()=>{for(let e of v.unMount){let t=S(n,e);t&&(t._f.refs?t._f.refs.every(e=>!e$(e)):!e$(t._f.ref))&&eb(e)}v.unMount=new Set},_disableForm:e=>{"boolean"==typeof e&&($.state.next({disabled:e}),W(n,(t,r)=>{let i=S(n,r);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},_subjects:$,_proxyFormState:P,get _fields(){return n},get _formValues(){return o},get _state(){return c},set _state(value){c=value},get _defaultValues(){return i},get _names(){return v},set _names(value){v=value},get _formState(){return r},get _options(){return t},set _options(value){A=H((t={...t,...value}).mode),_=H(t.reValidateMode)}},subscribe:e=>(c.mount=!0,T={...T,...e.formState},ey({...e,formState:{...C,...e.formState}})),trigger:ep,register:eA,handleSubmit:ej,watch:(e,t)=>{if(k(e)){x++;let{unsubscribe:r}=$.state.subscribe({next:r=>"values"in r&&e(r.values||en(void 0,t),r)}),n=!1;return{unsubscribe:()=>{n||(n=!0,x--,r())}}}return en(e,t,!0)},setValue:eu,setValues:(e,t={})=>{let n=k(e)?e(o):e;if(!z(o,n)){for(let e of(o={...o,...n},v.mount))eT(n,e)&&el(e,S(n,e),t,!0,!0);$.state.next({...r,name:void 0,type:void 0,...x?{values:o}:{}}),t.shouldValidate&&V()}},getValues:(e,t)=>{let n={...c.mount?o:i};return t&&(n=function e(t,r){let n={};for(let i in t)if(t.hasOwnProperty(i)){let s=t[i],a=r[i];if(s&&l(s)&&a){let t=e(s,a);l(t)&&(n[i]=t)}else t[i]&&(n[i]=a)}return n}(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),O(e)?n:N(e)?S(n,e):e.map(e=>S(n,e))},getErrors:e=>O(e)?{...r.errors}:N(e)?S(r.errors,e):e.map(e=>S(r.errors,e)),reset:eC,resetField:(e,t={})=>{S(n,e)&&(O(t.defaultValue)?eu(e,f(S(i,e))):(eu(e,t.defaultValue),R(i,e,f(t.defaultValue))),t.keepTouched||eg(r.touchedFields,e),t.keepDirty||(eg(r.dirtyFields,e),r.isDirty=t.defaultValue?er(e,f(S(i,e))):er()),t.keepError||(eg(r.errors,e),V()),$.state.next({...r}))},resetDefaultValues:(e,t={})=>{if(i=f(e),!t.keepDirty){let e=eF(i,o,void 0,n);r.dirtyFields=e,r.isDirty=!G(e)}t.keepIsValid||V(),$.state.next({...r,defaultValues:i})},clearErrors:em,unregister:eb,setError:ev,setFocus:(e,t={})=>{let r=S(n,e),i=r&&r._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&k(e.select)&&e.select()})}},getFieldState:ef};return{...eO,formControl:eO}}function eJ(e={}){let t=i().useRef(void 0),r=i().useRef(void 0),n=i().useRef(e.formControl),[s,a]=i().useState(()=>({...f(eK),isLoading:k(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:k(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!k(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:r,...n}=eG(e);t.current={...n,formState:s}}let o=t.current.control;o._options=e;let{resyncIfNeeded:l,snapshot:u}=L();return $(()=>{let e=()=>({...o._formState,defaultValues:o._defaultValues});l(!0,e,a);let t=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return a(e=>({...e,isReady:!0})),o._formState.isReady=!0,()=>{t(),u(!0,e)}},[o,l,u]),i().useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),i().useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),i().useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),i().useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),i().useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==s.isDirty&&o._subjects.state.next({isDirty:e})}},[o,s.isDirty]),i().useEffect(()=>{var t;e.values&&!z(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null==(t=o._options.resetOptions)?void 0:t.keepIsValid)||o._setValid(),r.current=e.values,a(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),i().useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=i().useMemo(()=>T(s,o),[o,s]),t.current}let eX=e=>e.render(D({name:e.names,...e}))}}]);
|