@kong-ui-public/entities-shared 3.73.1-pr.4063.f9e4f8cdb.0 → 3.73.2

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.
@@ -0,0 +1,715 @@
1
+ import N from "axios";
2
+ import { inject as O, ref as y, computed as h, unref as S, toValue as m, watch as oe, provide as H } from "vue";
3
+ import { createI18n as W, i18nTComponent as ie } from "@kong-ui-public/i18n";
4
+ const nt = /* @__PURE__ */ Symbol("PLUGIN_FORM_LAYOUT_STATE"), rt = /* @__PURE__ */ Symbol("CONFIG_CARD_SHOW_SENSITIVE_FIELDS"), Y = /* @__PURE__ */ Symbol("DECK_COMMAND_EDITOR"), J = "[entities-shared] DeckCommandEditor was not provided. Provide it via the `DECK_COMMAND_EDITOR_KEY` injection key or the `provideDeckCommandEditor` helper (see @kong-ui-public/entities-shared/deck-editor).", ot = "50vh", it = 2e5, ce = {
5
+ /** Surfaces the `managed_by` ownership field in entity lists and detail cards. */
6
+ MANAGED_BY: "KM-3018-entity-managed-by"
7
+ };
8
+ function le() {
9
+ return {
10
+ getAxiosInstance: (e = {}) => {
11
+ try {
12
+ const n = O("get-axios-instance", void 0);
13
+ return typeof n == "function" ? n(e) : N.create({
14
+ withCredentials: !0,
15
+ timeout: 3e4,
16
+ ...e
17
+ });
18
+ } catch (n) {
19
+ return console.warn("getAxiosInstance:", n.message || n), N.create({
20
+ withCredentials: !0,
21
+ timeout: 3e4,
22
+ ...e
23
+ });
24
+ }
25
+ },
26
+ getTraceIdFromError: (e) => {
27
+ const n = e?.response?.headers || {};
28
+ return n["x-trace-id"] || n["x-datadog-trace-id"] || "";
29
+ }
30
+ };
31
+ }
32
+ function ue() {
33
+ return {
34
+ debounce: (e, n) => {
35
+ let o;
36
+ return (...t) => {
37
+ clearTimeout(o), o = window?.setTimeout(() => {
38
+ e(...t);
39
+ }, n);
40
+ };
41
+ }
42
+ };
43
+ }
44
+ const K = "khcp-user-table-preferences", de = {
45
+ pageSize: 30,
46
+ sortColumnKey: void 0,
47
+ sortColumnOrder: void 0,
48
+ columnVisibility: {}
49
+ };
50
+ function ct() {
51
+ const e = (o) => {
52
+ if (typeof o == "string")
53
+ try {
54
+ return JSON.parse(o);
55
+ } catch (t) {
56
+ console.error("useTablePreferences(tryParseJson)", t);
57
+ return;
58
+ }
59
+ }, n = () => {
60
+ const o = e(localStorage.getItem(K));
61
+ return !o || !Object.keys(o).length ? /* @__PURE__ */ new Map() : new Map(Object.entries(o));
62
+ };
63
+ return {
64
+ setTablePreferences: (o, t) => {
65
+ try {
66
+ const a = n();
67
+ a.set(o, t), localStorage.setItem(K, JSON.stringify(Object.fromEntries(a.entries())));
68
+ } catch (a) {
69
+ console.error("useTablePreferences(setTablePreferences)", a);
70
+ }
71
+ },
72
+ getTablePreferences: (o, t) => n()?.get(o) || void 0 || t || de,
73
+ deleteAllTablePreferences: () => {
74
+ localStorage.removeItem(K);
75
+ }
76
+ };
77
+ }
78
+ function P(e = {}) {
79
+ const { getAxiosInstance: n } = le();
80
+ return {
81
+ axiosInstance: n(e)
82
+ };
83
+ }
84
+ const fe = { actions: { copyId: "Copy ID", copied_id: 'Copied "{id}" to the clipboard', copyToClipboard: "Copied successfully!", copyToClipboardFailed: "Failed to copy to the clipboard" } }, pe = { message: "Are you sure you want to delete this {entityType}?", messageWithName: "Are you sure you want to delete this {entityType} {entityName}?" }, ge = { actions: { viewConfiguration: "View configuration", hideConfiguration: "Hide configuration", save: "Save", cancel: "Cancel", back: "Back" }, configuration: { title: "Configuration", message: "Export configurations for core Kong Gateway objects, like services, routes, and plugins, to either YAML or JSON. This allows for straightforward importing into APIOps tools like decK with YAML, or Insomnia and cURL with JSON.", yaml: "YAML", json: "JSON", terraform: "Terraform", deck: "decK" }, errors: { edit: "The entity could not be edited at this time." } }, me = { emptyState: { noSearchResultsTitle: "No results found", noSearchResultsMessage: "Please adjust the criteria and try again.", noSearchResultsCtaText: "Clear" } }, ye = { title: "Configuration", actions: { copy: "Copy JSON", deck_customize: "Customize before copying to CLI", deck_customize_cancel: "Cancel", sensitive_fields: "Show sensitive fields", sensitive_fields_tooltip: "View masked sensitive data in your configurations if any field values have been redacted." }, sections: { advanced: "Advanced", plugin: "Plugin specific configuration", policy: "Policy specific configuration" }, commonFields: { id_label: "ID", name_label: "Name", enabled_label: "Enabled", enabled_tooltip: "Enabled is FTW", updated_at_label: "Last updated", created_at_label: "Created", managed_by_label: "Managed By", tags_label: "Tags", link: "Link", partial_label: "Redis configuration" }, statusBadge: { enabledLabel: "Enabled", disabledLabel: "Disabled" }, copy: { tooltip: "Copy {label}", success: "Copied!" }, errors: { load: "The entity configuration data could not be loaded at this time.", copy: "Failed to copy to clipboard" }, general: { formatLabel: "Format:", entryTitle: "Entry {index}", structuredFormat: "Structured" } }, he = { learnMore: "Learn more", pricingTitle: "Pricing: " }, be = { filterButtonText: "Filter", fieldLabel: "Filter by:", inputPlaceholder: "Enter a value", selectPlaceholder: "Select an item", applyButtonText: "Apply", clearButtonText: "Clear", clearAllButtonText: "Clear all filters" }, ve = { errors: { fetch: "Could not fetch available items", invalid: "Please select a valid value" } }, _e = { unexpected: "An unexpected error has occurred", dataKeyUndefined: 'The data key "{dataKey}" does not exist in the response.' }, Ae = { utf8Name: "The name can be any string containing characters, letters, numbers, or the following characters: ., -, _, or ~. Do not use spaces." }, Ce = { enable: { title: "Enable {entityType}", message: "Are you sure you want to enable the {entityType} {entityName}?", confirmText: "Yes, enable" }, disable: { title: "Disable {entityType}", message: "Are you sure you want to disable the {entityType} {entityName}?", confirmText: "Yes, disable" } }, ke = { copy_url: "Copy URL" }, we = { hint: { konnect: "The {token} environment variable must be added first. See {link} for details.", kongManager: "If your Admin API is secured, set up authentication following {link}." }, documentation: "the documentation", steps: { step_1: "Step 1: Export token", step_2: "Step 2: Apply configuration" }, customization: { title: "Customize before copying to CLI", copy_pat: "Make sure to copy your personal access token now. You won't be able to see it again.", reuse_pat: "Use an existing PAT if you've already generated one.", generate_pat: "Generate PAT", footer_reminder: "Changes you make here won't affect your configuration. After you apply changes with decK in the CLI, refresh the page to view them.", secret_advise: "Command may contain sensitive values. Treat it as a secret." }, copy_tooltip: "Copy" }, Ie = { body: "Want a ready-to-use CLI command? {cta} to view this configuration as a decK sync snippet you can copy directly.", cta: "Switch to decK format" }, xe = { title: "Generate a Personal Access Token", description: "Personal access tokens are used to authenticate decK commands and Konnect API requests.", fields: { name: { label: "Name", placeholder: "Enter token name" }, expiresAt: { label: "Expiration date", placeholder: "Select an expiration date", n_days: "{n} days" } }, actions: { cancel: "Cancel", generate: "Generate", generating: "Generating…" } }, Ee = { dismissLabel: "Dismiss" }, De = { rotateKey: "Rotate key", generateKey: "Generate key", placeholder: "Enter or generate a key", oneTimeHint: "The key is shown only once. Copy it now and store it securely.", copy: "Copy", showKey: "Show key", hideKey: "Hide key" }, Q = {
85
+ global: fe,
86
+ deleteModal: pe,
87
+ baseForm: ge,
88
+ baseTable: me,
89
+ baseConfigCard: ye,
90
+ emptyState: he,
91
+ filter: be,
92
+ debouncedFilter: ve,
93
+ errors: _e,
94
+ validationErrors: Ae,
95
+ toggleModal: Ce,
96
+ jsonCodeBlock: ke,
97
+ deckCodeBlock: we,
98
+ deckCallout: Ie,
99
+ generatePatModal: xe,
100
+ onboardingCard: Ee,
101
+ sensitiveInput: De
102
+ };
103
+ function L() {
104
+ const e = W("en-us", Q);
105
+ return {
106
+ i18n: e,
107
+ i18nT: ie(e)
108
+ // Translation component <i18n-t>
109
+ };
110
+ }
111
+ var I = /* @__PURE__ */ ((e) => (e[e.InitialLoad = 0] = "InitialLoad", e[e.Loading = 1] = "Loading", e[e.Idle = 2] = "Idle", e[e.NoResults = 3] = "NoResults", e[e.NoRecords = 4] = "NoRecords", e[e.Error = 5] = "Error", e))(I || {}), X = /* @__PURE__ */ ((e) => (e.CaCertificate = "ca_certificate", e.Certificate = "certificate", e.Consumer = "consumer", e.ConsumerGroup = "consumer_group", e.GatewayService = "service", e.Key = "key", e.KeySet = "set", e.Plugin = "plugin", e.Route = "route", e.SNI = "sni", e.Upstream = "upstream", e.Target = "target", e.Vault = "vault", e.Partial = "partial", e.CloudGatewayAddon = "cloud_gateway_addon", e.BackendCluster = "backend_cluster", e.VirtualCluster = "virtual_cluster", e.Listener = "listener", e.ProducePolicy = "produce_policy", e.ConsumePolicy = "consume_policy", e.ClusterPolicy = "cluster_policy", e.ListenerPolicy = "listener_policy", e.SchemaRegistry = "schema_registry", e.StaticKey = "static_key", e.TlsTrustBundle = "tls_trust_bundle", e.AuthServer = "auth_server", e.AuthServerScopes = "auth_server_scopes", e.AuthServerClaims = "auth_server_claims", e.AuthServerClients = "auth_server_clients", e.Other = "other", e.PluginSchema = "plugin_schema", e.CustomPlugin = "custom_plugin", e.ClonedPlugin = "cloned_plugin", e))(X || {});
112
+ const lt = Object.values(X), Oe = [
113
+ "ca_certificate",
114
+ "certificate",
115
+ "consumer",
116
+ "consumer_group",
117
+ "service",
118
+ "key",
119
+ "set",
120
+ "plugin",
121
+ "plugin_schema",
122
+ "custom_plugin",
123
+ "cloned_plugin",
124
+ "route",
125
+ "upstream",
126
+ "target",
127
+ "vault",
128
+ "partial"
129
+ /* Partial */
130
+ ];
131
+ function Z(e) {
132
+ return Oe.includes(e);
133
+ }
134
+ const ut = ["backend_cluster", "virtual_cluster", "listener", "produce_policy", "consume_policy", "cluster_policy", "listener_policy", "schema_registry", "static_key", "tls_trust_bundle"], dt = ["auth_server", "auth_server_scopes", "auth_server_claims", "auth_server_clients"];
135
+ var R = /* @__PURE__ */ ((e) => (e.ID = "id", e.IdArray = "id-array", e.Text = "plain-text", e.Date = "date", e.Redacted = "redacted", e.RedactedArray = "redacted-array", e.Json = "json", e.JsonArray = "json-array", e.BadgeTag = "badge-tag", e.CopyBadge = "copy-badge", e.BadgeStatus = "badge-status", e.BadgeMethod = "badge-method", e.LinkInternal = "link-internal", e.LinkExternal = "link-external", e.ManagedBy = "managed-by", e))(R || {}), Le = /* @__PURE__ */ ((e) => (e.Basic = "basic", e.Advanced = "advanced", e.Plugin = "plugin", e.Policy = "policy", e))(Le || {});
136
+ const ft = ["structured", "yaml", "json", "terraform", "deck"];
137
+ function q() {
138
+ const e = (i, r) => r?.[i] ?? void 0, n = (i, r) => {
139
+ if (i.length !== r.length) return !1;
140
+ const d = /* @__PURE__ */ new Set([...i, ...r]);
141
+ for (const c of d) {
142
+ const f = i.filter((A) => A === c).length, b = r.filter((A) => A === c).length;
143
+ if (f !== b) return !1;
144
+ }
145
+ return !0;
146
+ }, o = (i, r, d) => {
147
+ if (d) {
148
+ if (Object.keys(i).length === Object.keys(r).length)
149
+ for (const c in i)
150
+ if (Array.isArray(i[c]) && Array.isArray(r[c])) {
151
+ if (n(i[c], r[c]))
152
+ continue;
153
+ return !1;
154
+ } else {
155
+ if (i[c] === r[c])
156
+ continue;
157
+ return !1;
158
+ }
159
+ else
160
+ return !1;
161
+ return !0;
162
+ }
163
+ try {
164
+ return JSON.stringify(i) === JSON.stringify(r);
165
+ } catch {
166
+ return !1;
167
+ }
168
+ }, t = (i) => (r, d) => {
169
+ let c = r[i] === void 0 || r[i] === null ? "" : r[i], f = d[i] === void 0 || d[i] === null ? "" : d[i];
170
+ return Array.isArray(r[i]) && (c = r[i][0]), Array.isArray(d[i]) && (f = d[i][0]), c.localeCompare(f);
171
+ }, a = (i) => i ? /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/.test(i) : !1, l = "********", s = (i) => !!i && typeof i == "object" && !Array.isArray(i), u = (i, r) => i?.find((c) => Object.keys(c)?.[0] === r)?.[r], p = (i, r) => {
172
+ if (!r || i === null || i === void 0)
173
+ return i;
174
+ if (r.type === "string")
175
+ return r.encrypted ? l : i;
176
+ if (r.type === "record" || r.type === "map") {
177
+ if (!s(i))
178
+ return i;
179
+ if (r.type === "map" && !r.values)
180
+ return { ...i };
181
+ const d = {};
182
+ for (const c in i)
183
+ if (r.type === "record") {
184
+ const f = u(r.fields, c);
185
+ d[c] = f ? p(i[c], f) : i[c];
186
+ } else if (r.type === "map") {
187
+ const f = r.values;
188
+ d[c] = p(i[c], {
189
+ ...f,
190
+ encrypted: !!(r.encrypted || f.encrypted)
191
+ });
192
+ }
193
+ return d;
194
+ }
195
+ if ((r.type === "array" || r.type === "set") && Array.isArray(i)) {
196
+ const d = r.elements;
197
+ return d ? i.map((c) => p(c, {
198
+ ...d,
199
+ // encryption set if either parent or child is encrypted
200
+ encrypted: !!(r.encrypted || d.encrypted)
201
+ })) : i.slice();
202
+ }
203
+ return i;
204
+ }, v = (i, r) => {
205
+ if (Array.isArray(i))
206
+ return i.map((c) => v(c, r));
207
+ if (!s(i))
208
+ return i;
209
+ const d = {};
210
+ for (const c in i) {
211
+ if (r[c]?.type === R.Redacted) {
212
+ d[c] = l;
213
+ continue;
214
+ }
215
+ if (r[c]?.type === R.RedactedArray && Array.isArray(i[c])) {
216
+ d[c] = i[c].map(() => l);
217
+ continue;
218
+ }
219
+ d[c] = v(i[c], r);
220
+ }
221
+ return d;
222
+ };
223
+ return {
224
+ getPropValue: e,
225
+ objectsAreEqual: o,
226
+ sortAlpha: t,
227
+ isValidUuid: a,
228
+ isObjectRecord: s,
229
+ getApiSchemaField: u,
230
+ redactByApiSchema: p,
231
+ redactByConfigSchema: v
232
+ };
233
+ }
234
+ function Ke(e, n, o, t = {
235
+ fetchedItemsKey: "data",
236
+ searchKeys: ["id"]
237
+ }) {
238
+ o || (o = "1000");
239
+ const { axiosInstance: a } = P(e.axiosRequestConfig), { i18n: { t: l } } = L(), { debounce: s } = ue(), u = s(async (g) => {
240
+ await x(g);
241
+ }, 200), p = y(!1), v = y(""), i = y(""), r = y([]), d = y([]), c = y(void 0), f = h(() => {
242
+ let g = `${e.apiBaseUrl}${S(n)}`;
243
+ return e.app === "konnect" && (g = g.replace(/{controlPlaneId}/gi, e?.controlPlaneId || "")), g.replace(/\/{workspace}/gi, e?.workspace ? `/${e.workspace}` : "");
244
+ }), { isValidUuid: b } = q(), A = async () => {
245
+ try {
246
+ p.value = !0;
247
+ const { data: g } = await a.get(`${f.value}?size=${o}`);
248
+ g?.next || (c.value = t.fetchedItemsKey in g ? g[t.fetchedItemsKey] : []), d.value = t.fetchedItemsKey in g ? g[t.fetchedItemsKey] : [], r.value = d.value;
249
+ } catch {
250
+ r.value = [], v.value = l("debouncedFilter.errors.fetch");
251
+ } finally {
252
+ p.value = !1;
253
+ }
254
+ }, w = y(""), x = async (g) => {
255
+ if (w.value !== g) {
256
+ if (w.value = g ?? "", !g) {
257
+ r.value = d.value;
258
+ return;
259
+ }
260
+ if (c.value === void 0)
261
+ try {
262
+ if (p.value = !0, v.value = "", i.value = "", e.app === "konnect") {
263
+ const _ = `${f.value}/${g}`, { data: C } = await a.get(`${_}?size=${o}`);
264
+ t.fetchedItemsKey in C ? r.value = C[t.fetchedItemsKey] : C?.[t.exactMatchKey ?? "id"] ? r.value = [C] : r.value = [];
265
+ } else {
266
+ const _ = [];
267
+ b(g) && t.searchKeys.includes("id") ? _.push((async () => {
268
+ const { data: k } = await a.get(`${f.value}/${g}`);
269
+ return [k[t.fetchedItemsKey] ?? k];
270
+ })()) : _.push(
271
+ ...t.searchKeys.filter((k) => k !== "id").map(async (k) => {
272
+ const { data: D } = await a.get(`${f.value}?${k}=${g}`);
273
+ return D[t.fetchedItemsKey];
274
+ })
275
+ );
276
+ const C = await Promise.all(_), E = /* @__PURE__ */ new Set();
277
+ r.value = [], C?.forEach?.((k) => {
278
+ k?.forEach?.((D) => {
279
+ E.has(D.id) || (E.add(D.id), r.value.push(D));
280
+ });
281
+ });
282
+ }
283
+ } catch (_) {
284
+ _?.response?.status === 404 ? i.value = l("debouncedFilter.errors.invalid") : (r.value = [], v.value = l("debouncedFilter.errors.fetch"));
285
+ } finally {
286
+ p.value = !1;
287
+ }
288
+ else
289
+ p.value = !0, i.value = "", r.value = c.value?.filter((_) => {
290
+ let C = !1;
291
+ for (const E of t.searchKeys)
292
+ (typeof _[E] == "string" ? _[E]?.toLowerCase() : _[E])?.includes(g.toLowerCase()) && (C = !0);
293
+ return C;
294
+ }), (!r.value || !r.value.length) && (i.value = l("debouncedFilter.errors.invalid")), p.value = !1;
295
+ }
296
+ };
297
+ return {
298
+ loading: p,
299
+ error: v,
300
+ validationError: i,
301
+ results: r,
302
+ allRecords: c,
303
+ loadItems: A,
304
+ debouncedQueryChange: u
305
+ };
306
+ }
307
+ function Me(e, n) {
308
+ const o = O(Y, null), t = h(() => {
309
+ const s = m(e), u = s.app === "kongManager" || !!(s.app === "konnect" && s.enableDeckConfig), p = m(n);
310
+ return u && p !== void 0 && Z(p);
311
+ }), a = h(() => {
312
+ const s = m(e), u = s.app === "konnect" && s.enableDeckConfig && typeof s.enableDeckConfig != "boolean" ? s.enableDeckConfig.customization : void 0;
313
+ if (u && !o) {
314
+ console.warn(J);
315
+ return;
316
+ }
317
+ return u;
318
+ }), l = h(() => {
319
+ const s = m(e);
320
+ return s.app === "konnect" && s.enableDeckConfig && typeof s.enableDeckConfig != "boolean" ? s.enableDeckConfig.calloutPreferenceKey : s.app === "kongManager" ? s.deckCalloutPreferenceKey : void 0;
321
+ });
322
+ return {
323
+ isDeckEnabled: t,
324
+ deckCustomizationOptions: a,
325
+ deckCalloutPreferenceKey: l
326
+ };
327
+ }
328
+ function Re(e, n) {
329
+ const o = O(Y, null), t = h(() => {
330
+ const s = m(e);
331
+ return (s.app === "kongManager" || !!(s.app === "konnect" && s.enableDeckTab)) && Z(m(n));
332
+ }), a = h(() => {
333
+ const s = m(e), u = s.app === "konnect" && s.enableDeckTab && typeof s.enableDeckTab != "boolean" ? s.enableDeckTab.customization : void 0;
334
+ if (u && !o) {
335
+ console.warn(J);
336
+ return;
337
+ }
338
+ return u;
339
+ }), l = h(() => {
340
+ const s = m(e);
341
+ return s.app === "konnect" && s.enableDeckTab && typeof s.enableDeckTab != "boolean" ? s.enableDeckTab.calloutPreferenceKey : s.app === "kongManager" ? s.deckCalloutPreferenceKey : void 0;
342
+ });
343
+ return {
344
+ isDeckEnabled: t,
345
+ deckCustomizationOptions: a,
346
+ deckCalloutPreferenceKey: l
347
+ };
348
+ }
349
+ function Pe(e, n) {
350
+ const o = S(n), t = h(
351
+ () => e.apiBaseUrl.startsWith("/") ? new URL(`${window.location.origin}${o}`) : new URL(o)
352
+ );
353
+ return t.value.search = "", (a) => `${t.value.href}/${a}`;
354
+ }
355
+ function Te() {
356
+ const { i18n: { t: e } } = L();
357
+ return {
358
+ getErrorFieldsFromError: (t) => {
359
+ if (!t)
360
+ return {
361
+ messages: [e("errors.unexpected")],
362
+ fields: []
363
+ };
364
+ if (t?.response?.status === 401)
365
+ return {
366
+ messages: [],
367
+ fields: []
368
+ };
369
+ let a = [e("errors.unexpected")];
370
+ const l = [];
371
+ if (t?.response?.data) {
372
+ if (t.response.data.details?.length)
373
+ return a = [], t.response.data.details.forEach((s) => {
374
+ let u = e("errors.unexpected");
375
+ s.messages && Array.isArray(s.messages) && s.messages.length && (u = s.messages.join(", ")), s.field && l.push({ field: s.field, message: u }), a.push(`${s.field ?? ""} ${u}`);
376
+ }), { messages: a, fields: l };
377
+ if (t.response.data.message && Array.isArray(t.response.data.message))
378
+ return a = [], t.response.data.message.forEach((s) => {
379
+ if (s?.constraints) {
380
+ const u = Object.values(s.constraints).join(", ");
381
+ a.push(u), s.property && l.push({ field: s.property, message: u });
382
+ } else s?.property && s?.message ? (l.push({ field: s.property, message: s.message }), a.push(s.message)) : a.push(s);
383
+ }), { messages: a, fields: l };
384
+ if (typeof t.response.data.message == "string" || typeof t.response.data == "string")
385
+ return {
386
+ messages: [t.response.data.message],
387
+ fields: []
388
+ };
389
+ if (typeof t.response.data == "object")
390
+ return a = [], Object.keys(t.response.data).forEach((s) => {
391
+ l.push({ field: s, message: t.response.data[s] }), a.push(t.response.data[s]);
392
+ }), { messages: a, fields: l };
393
+ }
394
+ return {
395
+ messages: [t.message || e("errors.unexpected")],
396
+ fields: []
397
+ };
398
+ },
399
+ getMessageFromError: (t) => {
400
+ if (!t)
401
+ return e("errors.unexpected");
402
+ if (t?.response?.status === 401)
403
+ return console.warn("getMessageFromError: User auth token is expired or missing, returning empty message."), "";
404
+ if (t?.response?.data) {
405
+ if (t.response.data.detail)
406
+ return t.response.data.detail;
407
+ if (t.response.data.details?.length)
408
+ return t.response.data.details.map((a) => {
409
+ let l = e("errors.unexpected");
410
+ return a.messages && typeof a.messages == "object" && a.messages.length && (l = a.messages.join(", ")), a.field ? `${a.field} - ${l}` : l;
411
+ }).join("; ");
412
+ if (t.response.data.message) {
413
+ const { message: a } = t.response.data;
414
+ return Array.isArray(a) ? a[0]?.constraints ? Object.values(a[0].constraints)[0] : a[0] : a;
415
+ }
416
+ if (typeof t.response.data == "string")
417
+ return t.response.data;
418
+ if (typeof t.response.data == "object")
419
+ return Object.keys(t.response.data).map((a) => `${a} ${t.response.data[a]}`).join(", ");
420
+ }
421
+ return t.message || e("errors.unexpected");
422
+ }
423
+ };
424
+ }
425
+ function Ne(e) {
426
+ const n = window.location.origin, o = n.endsWith("/") ? n : `${n}/`;
427
+ try {
428
+ const t = e.join("/"), a = `${o}${t}`, l = e.some((u) => u.trim() === "");
429
+ if (/^(https:\/\/(www\.)?([a-zA-Z0-9-]+\.){1,}[a-zA-Z]{2,}(:[0-9]+)?(\/[^\/]+)*)$|^(https|http):\/\/localhost(:[0-9]+)?(\/[^\/]+)*$/.test(a) && !l && new URL(a))
430
+ return `${o}${t}`;
431
+ throw new Error("Invalid url");
432
+ } catch (t) {
433
+ return console.warn("Failed to build valid URL:", t), "";
434
+ }
435
+ }
436
+ function ee(e, n) {
437
+ const o = h(() => {
438
+ const a = m(e);
439
+ return typeof a.isExactMatch == "boolean" ? a.isExactMatch : a.app === "konnect";
440
+ }), t = h(() => {
441
+ const a = m(n);
442
+ return a.startsWith("/") ? new URL(`${window.location.origin}${a}`) : new URL(a);
443
+ });
444
+ return (a) => {
445
+ const { page: l, pageSize: s, offset: u, sortColumnKey: p, sortColumnOrder: v, query: i } = a;
446
+ try {
447
+ let r = new URL(t.value.href);
448
+ if (o.value && i) {
449
+ const d = new URLSearchParams(t.value.search);
450
+ r.search = "", r = m(e).isExactMatch ? new URL(`${r.href}/${i}`) : new URL(`${r.href}?filter[name][contains]=${i}`), d.forEach((c, f) => r.searchParams.append(f, c));
451
+ } else
452
+ o.value || new URLSearchParams(i).forEach((d, c) => {
453
+ r.searchParams.append(c, d);
454
+ }), p && r.searchParams.append("sort_by", p), v === "desc" && r.searchParams.append("sort_desc", "1"), r.searchParams.append("size", String(s));
455
+ return u && l !== 1 && r.searchParams.append("offset", String(u)), r.href;
456
+ } catch (r) {
457
+ return console.error("RouteList(fetcher)", r), m(n);
458
+ }
459
+ };
460
+ }
461
+ const $ = /* @__PURE__ */ new Map();
462
+ function $e(e, n, o) {
463
+ const t = y(!0), a = m(e), { axiosInstance: l } = P(a.axiosRequestConfig), s = ee(e, n), u = y({
464
+ status: I.Idle
465
+ }), p = async (r) => {
466
+ const d = m(o) || "data";
467
+ try {
468
+ u.value = t.value ? { status: I.InitialLoad } : { status: I.Loading }, t.value = !1;
469
+ let c = s(r);
470
+ c.includes("filter[name]") && (c = `${c}&page[size]=${r.pageSize}&page[number]=${r.page}`);
471
+ const f = await l.get(c);
472
+ if (f.status >= 400)
473
+ throw f;
474
+ const b = f.data, A = d && d.replace(/[^\w-_]/gi, "");
475
+ let w;
476
+ b[A] ? w = Array.isArray(b[A]) ? b[A] : [b[A]] : Array.isArray(b) ? w = b : w = Object.keys(b).length ? [b] : [];
477
+ const x = {
478
+ data: w,
479
+ total: w.length,
480
+ ...b.offset ? {
481
+ pagination: {
482
+ offset: b.offset
483
+ }
484
+ } : null
485
+ };
486
+ return x.data.length === 0 && !r.query ? u.value = {
487
+ status: I.NoRecords,
488
+ response: x
489
+ } : u.value = {
490
+ status: I.Idle,
491
+ response: x
492
+ }, x;
493
+ } catch (c) {
494
+ const f = {
495
+ data: [],
496
+ total: 0
497
+ };
498
+ return r.query && (c.response?.status === 404 || c.status === 404) ? (u.value = {
499
+ status: I.NoResults,
500
+ response: f,
501
+ error: c.response ? c : { response: c }
502
+ }, f) : (u.value = {
503
+ status: I.Error,
504
+ response: f,
505
+ error: c.response ? c : { response: c }
506
+ }, f);
507
+ }
508
+ }, v = a.cacheIdentifier, i = te(v);
509
+ return { fetcher: p, fetcherState: u, fetcherCacheKey: i };
510
+ }
511
+ function te(e) {
512
+ if (e) {
513
+ let n = $.get(e);
514
+ return n || (n = y(1), $.set(e, n)), n;
515
+ }
516
+ return y(1);
517
+ }
518
+ function Ue() {
519
+ const e = (t, a = "_") => t ? t.split(a).map((l) => l.toLowerCase() === "id" ? l.toUpperCase() : l.charAt(0).toUpperCase() + l.substring(1)).join(" ") : "", n = /(?:^|[\s-:'"])\w/g;
520
+ return {
521
+ capitalize: (t) => t ? t.replace(n, (a) => a.toUpperCase()) : "",
522
+ convertKeyToTitle: e
523
+ };
524
+ }
525
+ const se = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, U = (e) => {
526
+ if (typeof e != "string")
527
+ throw new TypeError("Invalid argument expected string");
528
+ const n = e.match(se);
529
+ if (!n)
530
+ throw new Error(`Invalid argument not valid semver ('${e}' received)`);
531
+ return n.shift(), n;
532
+ }, B = (e) => e === "*" || e === "x" || e === "X", F = (e) => {
533
+ const n = parseInt(e, 10);
534
+ return isNaN(n) ? e : n;
535
+ }, Be = (e, n) => typeof e != typeof n ? [String(e), String(n)] : [e, n], Fe = (e, n) => {
536
+ if (B(e) || B(n))
537
+ return 0;
538
+ const [o, t] = Be(F(e), F(n));
539
+ return o > t ? 1 : o < t ? -1 : 0;
540
+ }, j = (e, n) => {
541
+ for (let o = 0; o < Math.max(e.length, n.length); o++) {
542
+ const t = Fe(e[o] || "0", n[o] || "0");
543
+ if (t !== 0)
544
+ return t;
545
+ }
546
+ return 0;
547
+ }, je = (e, n) => {
548
+ const o = U(e), t = U(n), a = o.pop(), l = t.pop(), s = j(o, t);
549
+ return s !== 0 ? s : a && l ? j(a.split("."), l.split(".")) : a || l ? a ? -1 : 1 : 0;
550
+ }, G = (e, n, o) => {
551
+ Ge(o);
552
+ const t = je(e, n);
553
+ return ae[o].includes(t);
554
+ }, ae = {
555
+ ">": [1],
556
+ ">=": [0, 1],
557
+ "=": [0],
558
+ "<=": [-1, 0],
559
+ "<": [-1],
560
+ "!=": [-1, 1]
561
+ }, z = Object.keys(ae), Ge = (e) => {
562
+ if (typeof e != "string")
563
+ throw new TypeError(`Invalid operator type, expected string but got ${typeof e}`);
564
+ if (z.indexOf(e) === -1)
565
+ throw new Error(`Invalid operator, expected one of ${z.join("|")}`);
566
+ }, ze = (e) => typeof e == "string" && /^[v\d]/.test(e) && se.test(e);
567
+ function Ve(e) {
568
+ const { gatewayInfo: n, supportedRange: o } = e;
569
+ if (!n)
570
+ return !0;
571
+ const { edition: t, version: a } = n;
572
+ if (!ze(a))
573
+ return console.error("Invalid version"), !1;
574
+ const l = o[t];
575
+ if (!l)
576
+ return !1;
577
+ const [s, u] = l;
578
+ return !(s && G(a, s, "<") || u && G(a, u, ">"));
579
+ }
580
+ function Se(e) {
581
+ const n = y(0), o = y(0), t = y(!1);
582
+ return oe(e, (l) => {
583
+ l && !t.value && (n.value = l.offsetWidth, o.value = l.scrollWidth, t.value = !0);
584
+ }), {
585
+ isTruncated: h(() => n.value < o.value)
586
+ };
587
+ }
588
+ function He() {
589
+ const { i18n: { t: e } } = L();
590
+ return {
591
+ utf8Name: (o) => /^[\p{N}\p{L}.\-_~]*$/u.test(o) ? "" : e("validationErrors.utf8Name")
592
+ };
593
+ }
594
+ const T = /* @__PURE__ */ Symbol("schema"), We = (e) => {
595
+ H(T, e);
596
+ }, ne = () => O(T, void 0), Ye = (e) => /^\d+$/.test(e), Je = (e) => {
597
+ const n = ne(), o = h(() => {
598
+ const t = n?.value, a = e();
599
+ if ((t?.type === "array" || t?.type === "set") && Ye(a)) {
600
+ const s = t.elements;
601
+ return s && {
602
+ ...s,
603
+ // encryption set if either parent or child is encrypted
604
+ encrypted: !!(t.encrypted || s.encrypted)
605
+ };
606
+ }
607
+ return t?.fields?.find((s) => Object.keys(s)[0] === a)?.[a];
608
+ });
609
+ return H(T, o), o;
610
+ };
611
+ function Qe(e) {
612
+ let n = "";
613
+ const o = y(!1), t = y(null), a = h(() => {
614
+ let s;
615
+ return o.value ? s = !0 : t.value ? s = t.value.hasData || e && m(e) : s = !1, !s;
616
+ });
617
+ return {
618
+ tableState: t,
619
+ hasRecords: o,
620
+ hideTableToolbar: a,
621
+ handleStateChange: (s) => {
622
+ s.hasData ? o.value = !0 : s.state === "success" && !s.hasData && (!e || !n) && (o.value = !1), e && (n = m(e)), t.value = { ...s };
623
+ }
624
+ };
625
+ }
626
+ function re() {
627
+ const e = O(ce.MANAGED_BY, !1);
628
+ return h(() => !!m(e));
629
+ }
630
+ const Xe = (e) => e?.service || e?.tool || null, Ze = "Custom", V = {
631
+ "terraform-provider-konnect": "Terraform",
632
+ deck: "decK",
633
+ "kong-gateway-operator": "Kong Gateway Operator",
634
+ kongctl: "kongctl",
635
+ "kong-ingress-controller": "Kong Ingress Controller",
636
+ "gw-manager": "Konnect UI",
637
+ "ai-manager": "AI Manager",
638
+ "dev-portal": "Dev Portal"
639
+ }, pt = (e) => {
640
+ const n = Xe(e);
641
+ return n ? Object.hasOwn(V, n) ? V[n] : Ze : null;
642
+ };
643
+ let M;
644
+ const qe = () => (M === void 0 && (M = W("en-us", Q).t("baseConfigCard.commonFields.managed_by_label")), M);
645
+ function et(e, n = {}) {
646
+ const o = re();
647
+ return {
648
+ defaultTablePreferences: {
649
+ columnVisibility: {
650
+ managed_by: !1,
651
+ ...n
652
+ }
653
+ },
654
+ tableHeaders: h(() => ({
655
+ ...m(e),
656
+ ...o.value ? { managed_by: { label: qe(), sortable: !1 } } : {}
657
+ }))
658
+ };
659
+ }
660
+ const gt = {
661
+ useAxios: P,
662
+ useDebouncedFilter: Ke,
663
+ useDeleteUrlBuilder: Pe,
664
+ useBaseEntityDeckOptions: Me,
665
+ useBaseFormDeckOptions: Re,
666
+ useErrors: Te,
667
+ useExternalLinkCreator: Ne,
668
+ useFetcher: $e,
669
+ useFetcherCacheKey: te,
670
+ useFetchUrlBuilder: ee,
671
+ useHelpers: q,
672
+ useStringHelpers: Ue,
673
+ useI18n: L,
674
+ useGatewayFeatureSupported: Ve,
675
+ useTruncationDetector: Se,
676
+ useValidators: He,
677
+ useSchema: ne,
678
+ useSchemaProvider: We,
679
+ useSubSchema: Je,
680
+ useTableState: Qe,
681
+ useManagedByEnabled: re,
682
+ useManagedByColumn: et
683
+ }, mt = (e, n) => {
684
+ const o = e.__vccOpts || e;
685
+ for (const [t, a] of n)
686
+ o[t] = a;
687
+ return o;
688
+ };
689
+ export {
690
+ R as C,
691
+ Y as D,
692
+ ut as E,
693
+ I as F,
694
+ dt as I,
695
+ V as M,
696
+ nt as P,
697
+ it as S,
698
+ mt as _,
699
+ rt as a,
700
+ ot as b,
701
+ gt as c,
702
+ X as d,
703
+ lt as e,
704
+ J as f,
705
+ pt as g,
706
+ Oe as h,
707
+ ft as i,
708
+ Le as j,
709
+ ct as k,
710
+ ce as l,
711
+ qe as m,
712
+ de as n,
713
+ Z as o,
714
+ q as u
715
+ };