@flanksource/clicky-ui 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/comments/CommentCard.cjs +9 -8
  2. package/dist/comments/CommentCard.cjs.map +1 -1
  3. package/dist/comments/CommentCard.d.ts.map +1 -1
  4. package/dist/comments/CommentCard.js +2 -1
  5. package/dist/comments/CommentCard.js.map +1 -1
  6. package/dist/comments/CommentCardParts.cjs +2 -1
  7. package/dist/comments/CommentCardParts.cjs.map +1 -1
  8. package/dist/comments/CommentCardParts.d.ts.map +1 -1
  9. package/dist/comments/CommentCardParts.js +2 -1
  10. package/dist/comments/CommentCardParts.js.map +1 -1
  11. package/dist/comments/CommentSidePanel.cjs +3 -2
  12. package/dist/comments/CommentSidePanel.cjs.map +1 -1
  13. package/dist/comments/CommentSidePanel.d.ts.map +1 -1
  14. package/dist/comments/CommentSidePanel.js +2 -1
  15. package/dist/comments/CommentSidePanel.js.map +1 -1
  16. package/dist/comments/comment-utils.cjs +0 -27
  17. package/dist/comments/comment-utils.cjs.map +1 -1
  18. package/dist/comments/comment-utils.d.ts +1 -7
  19. package/dist/comments/comment-utils.d.ts.map +1 -1
  20. package/dist/comments/comment-utils.js +0 -27
  21. package/dist/comments/comment-utils.js.map +1 -1
  22. package/dist/comments.cjs +4 -3
  23. package/dist/comments.cjs.map +1 -1
  24. package/dist/comments.d.ts +1 -0
  25. package/dist/comments.d.ts.map +1 -1
  26. package/dist/comments.js +2 -1
  27. package/dist/comments.js.map +1 -1
  28. package/dist/components/EndpointSelector.cjs +6 -6
  29. package/dist/components/EndpointSelector.cjs.map +1 -1
  30. package/dist/components/EndpointSelector.d.ts.map +1 -1
  31. package/dist/components/EndpointSelector.js +6 -6
  32. package/dist/components/EndpointSelector.js.map +1 -1
  33. package/dist/components/ErrorWrapper.cjs +3 -2
  34. package/dist/components/ErrorWrapper.cjs.map +1 -1
  35. package/dist/components/ErrorWrapper.js +3 -2
  36. package/dist/components/ErrorWrapper.js.map +1 -1
  37. package/dist/components/RangeSlider.cjs +122 -45
  38. package/dist/components/RangeSlider.cjs.map +1 -1
  39. package/dist/components/RangeSlider.d.ts +3 -1
  40. package/dist/components/RangeSlider.d.ts.map +1 -1
  41. package/dist/components/RangeSlider.js +122 -45
  42. package/dist/components/RangeSlider.js.map +1 -1
  43. package/dist/components/SecretKeySelector.cjs +4 -4
  44. package/dist/components/SecretKeySelector.cjs.map +1 -1
  45. package/dist/components/SecretKeySelector.js +4 -4
  46. package/dist/components/SecretKeySelector.js.map +1 -1
  47. package/dist/data/badge-variants.d.ts +2 -2
  48. package/dist/data/version-info.cjs +3 -3
  49. package/dist/data/version-info.js +3 -3
  50. package/dist/index.cjs +4 -3
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.js +2 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/lib/comment-stage.cjs +31 -0
  55. package/dist/lib/comment-stage.cjs.map +1 -0
  56. package/dist/lib/comment-stage.d.ts +8 -0
  57. package/dist/lib/comment-stage.d.ts.map +1 -0
  58. package/dist/lib/comment-stage.js +31 -0
  59. package/dist/lib/comment-stage.js.map +1 -0
  60. package/dist/styles.css +1 -1
  61. package/dist/utils.cjs +4 -0
  62. package/dist/utils.cjs.map +1 -1
  63. package/dist/utils.d.ts +1 -0
  64. package/dist/utils.d.ts.map +1 -1
  65. package/dist/utils.js +4 -0
  66. package/dist/utils.js.map +1 -1
  67. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SecretKeySelector.cjs","sources":["../../src/components/SecretKeySelector.tsx"],"sourcesContent":["import { createElement, useEffect, useMemo, useState } from \"react\";\nimport {\n K8SSecret,\n K8SConfigmap,\n Helm,\n K8SServiceaccount,\n Vault,\n} from \"@flanksource/icons/mi\";\nimport { type StaticIconComponent } from \"../data/Icon\";\nimport { cn } from \"../lib/utils\";\nimport { UiEdit } from \"../icons\";\nimport { Combobox, type ComboboxOption } from \"./Combobox\";\nimport { IconMenuPicker, type IconMenuOption } from \"./icon-menu-picker\";\nimport { OnePasswordSelector } from \"./OnePasswordSelector\";\nimport type { OnePasswordLoaders } from \"./OnePasswordSelector.model\";\n\n// SecretKeySelector picks how a credential is sourced and lowers the choice into\n// a single reference string the consumer persists. It supports Kubernetes\n// Secrets and ConfigMaps (name + key), Helm release values (name + jsonpath\n// key), a service-account token (name only), a 1Password reference\n// (op://vault/item/field), and a static inline \"Value\". It is presentational:\n// it fetches nothing — the consumer supplies async `loadResources` /\n// `loadKeyPreview` (for keyed kinds) and optional `loadServiceAccounts` getters.\n\n/** Kinds that reference a named resource plus one of its keys. */\nexport type SecretKind = \"secret\" | \"configmap\" | \"helm\";\n\n/** Every source the picker can emit, including the non-keyed ones. */\nexport type SecretValueSource =\n | SecretKind\n | \"serviceaccount\"\n | \"onepassword\"\n | \"value\";\n\n/** One key's mid-masked preview. `value` is already masked by the consumer. */\nexport type KeyPreview = { key: string; value: string };\n\n/**\n * The selector's value: a {kind,name,key} reference into a Secret / ConfigMap /\n * Helm release, a service-account token by name, a 1Password op:// reference, or\n * a static inline literal.\n */\nexport type SecretKeyValue =\n | { kind: SecretKind; name: string; key: string }\n | { kind: \"serviceaccount\"; name: string }\n | { kind: \"onepassword\"; ref: string }\n | { kind: \"value\"; value: string };\n\n/** A named secret/configmap/helm-release and its data key names (values never returned). */\nexport type SecretResource = { name: string; keys?: string[] };\n\nexport type SecretKeySelectorProps = {\n value: SecretKeyValue | undefined;\n onChange: (next: SecretKeyValue | undefined) => void;\n /** Loads the named keyed kind's resources (name + data key names). */\n loadResources: (kind: SecretKind) => Promise<SecretResource[]>;\n /** Loads mid-masked previews for the named keyed resource's keys. */\n loadKeyPreview: (kind: SecretKind, name: string) => Promise<KeyPreview[]>;\n /**\n * Loads the service-account names (no keys) for the \"serviceaccount\" source.\n * When omitted, that source's name field accepts freeform entry only.\n */\n loadServiceAccounts?: () => Promise<SecretResource[]>;\n /** Loads metadata for the cascading 1Password vault, item, and field pickers. */\n onePassword?: OnePasswordLoaders;\n /**\n * The sources offered in the picker, in order. Defaults to\n * `[\"secret\", \"configmap\", \"value\"]` (or drops \"value\" when `allowLiteral` is\n * false). Pass an explicit list to offer helm / serviceaccount / onepassword.\n */\n sources?: SecretValueSource[];\n /**\n * Shorthand honoured only when `sources` is not supplied: `false` drops the\n * inline \"Value\" source, leaving Secret/ConfigMap. Ignored when `sources` is\n * given.\n */\n allowLiteral?: boolean;\n /**\n * When true, a chosen name absent from the loaded resources, or a key absent\n * from the chosen keyed resource's keys, is flagged invalid (once the load\n * settles). The onepassword and literal sources are never strict-flagged.\n */\n strict?: boolean;\n className?: string;\n};\n\nconst DEFAULT_SOURCES: SecretValueSource[] = [\"secret\", \"configmap\", \"value\"];\n\nconst SHRINKABLE_FIELD = \"max-w-full min-w-0 shrink\";\nconst SOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst RESOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst KEY_FIELD = `${SHRINKABLE_FIELD} basis-72 grow`;\nconst VALUE_FIELD = `${SHRINKABLE_FIELD} basis-64 grow`;\n\nexport function SecretKeySelector({\n value,\n onChange,\n loadResources,\n loadKeyPreview,\n loadServiceAccounts,\n onePassword,\n sources,\n allowLiteral = true,\n strict = false,\n className,\n}: SecretKeySelectorProps) {\n const sourceList = useMemo<SecretValueSource[]>(\n () => sources ?? (allowLiteral ? DEFAULT_SOURCES : [\"secret\", \"configmap\"]),\n [sources, allowLiteral],\n );\n\n const source: SecretValueSource = value?.kind ?? sourceList[0] ?? \"secret\";\n const isKeyed =\n source === \"secret\" || source === \"configmap\" || source === \"helm\";\n const isServiceAccount = source === \"serviceaccount\";\n const isOnePassword = source === \"onepassword\";\n const isLiteral = source === \"value\";\n // A keyed source's refKind drives the loaders; other sources default to \"secret\".\n const refKind: SecretKind = isKeyed ? (source as SecretKind) : \"secret\";\n\n const selectedName =\n value && (value.kind === \"serviceaccount\" || isRefKind(value))\n ? value.name\n : \"\";\n const selectedKey = value && isRefKind(value) ? value.key : \"\";\n const literalValue = value && value.kind === \"value\" ? value.value : \"\";\n const opRef = value && value.kind === \"onepassword\" ? value.ref : \"\";\n\n const [resources, setResources] = useState<SecretResource[]>([]);\n const [resourcesLoading, setResourcesLoading] = useState(false);\n const [previews, setPreviews] = useState<KeyPreview[]>([]);\n const [previewLoading, setPreviewLoading] = useState(false);\n\n // Load the name list for keyed kinds (secret/configmap/helm) and, when a\n // loader is supplied, for the serviceaccount source. Other sources list nothing.\n useEffect(() => {\n const loader = isKeyed\n ? () => loadResources(refKind)\n : isServiceAccount && loadServiceAccounts\n ? loadServiceAccounts\n : null;\n if (!loader) {\n setResources([]);\n return;\n }\n let cancelled = false;\n setResourcesLoading(true);\n loader()\n .then((res) => !cancelled && setResources(res))\n .finally(() => !cancelled && setResourcesLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadResources, loadServiceAccounts, refKind, isKeyed, isServiceAccount]);\n\n useEffect(() => {\n if (!isKeyed || !selectedName) {\n setPreviews([]);\n return;\n }\n let cancelled = false;\n setPreviewLoading(true);\n loadKeyPreview(refKind, selectedName)\n .then((res) => !cancelled && setPreviews(res))\n .catch(() => !cancelled && setPreviews([]))\n .finally(() => !cancelled && setPreviewLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadKeyPreview, refKind, selectedName, isKeyed]);\n\n const nameOptions = useMemo<ComboboxOption[]>(\n () => resources.map((r) => ({ value: r.name, label: r.name })),\n [resources],\n );\n const selectedResource = useMemo(\n () => resources.find((r) => r.name === selectedName),\n [resources, selectedName],\n );\n const keyOptions = useMemo(\n () => buildKeyOptions(selectedResource?.keys ?? [], previews, selectedKey),\n [selectedResource, selectedKey, previews],\n );\n\n // Strict validity: the name is invalid when it names no loaded resource; the\n // key is invalid when, with a resolved resource, it isn't one of that\n // resource's keys. Only names from a listed source are checked (a\n // serviceaccount source with no loader lists nothing, so it never flags).\n const listsNames = isKeyed || (isServiceAccount && !!loadServiceAccounts);\n const nameInvalid =\n strict &&\n listsNames &&\n !!selectedName &&\n !resourcesLoading &&\n !selectedResource;\n const keyInvalid =\n strict &&\n isKeyed &&\n !!selectedKey &&\n !!selectedResource &&\n !resourcesLoading &&\n !(selectedResource.keys ?? []).includes(selectedKey);\n\n const setSource = (next: SecretValueSource) => {\n switch (next) {\n case \"value\":\n return onChange({ kind: \"value\", value: \"\" });\n case \"onepassword\":\n return onChange({ kind: \"onepassword\", ref: \"\" });\n case \"serviceaccount\":\n return onChange({ kind: \"serviceaccount\", name: \"\" });\n default:\n return onChange({ kind: next, name: \"\", key: \"\" });\n }\n };\n const setName = (name: string) => {\n if (isServiceAccount)\n return onChange(name ? { kind: \"serviceaccount\", name } : undefined);\n return onChange(\n name ? { kind: refKind, name, key: selectedKey } : undefined,\n );\n };\n const setKey = (key: string) =>\n selectedName\n ? onChange({ kind: refKind, name: selectedName, key })\n : undefined;\n const setLiteral = (v: string) => onChange({ kind: \"value\", value: v });\n const setOpRef = (ref: string) => onChange({ kind: \"onepassword\", ref });\n\n const sourceOptions = useMemo<ComboboxOption[]>(\n () =>\n sourceList.map((k) => ({\n value: k,\n label: SOURCE_LABEL[k],\n icon: createElement(SOURCE_ICON[k], { className: \"size-4\" }),\n })),\n [sourceList],\n );\n const sourceMenuOptions = useMemo<IconMenuOption<SecretValueSource>[]>(\n () =>\n sourceList.map((kind) => ({\n value: kind,\n label: SOURCE_LABEL[kind],\n icon: SOURCE_ICON[kind],\n })),\n [sourceList],\n );\n\n return (\n <div\n data-slot=\"secret-key-selector\"\n className={cn(\"@container w-full min-w-0\", className)}\n >\n <div\n className=\"flex w-full max-w-full min-w-0 flex-nowrap items-center gap-2\"\n data-slot=\"secret-fields\"\n >\n <div\n className={cn(SOURCE_FIELD, \"@max-md:hidden\")}\n data-slot=\"secret-source-combobox\"\n >\n <Combobox\n ariaLabel=\"Secret value source\"\n options={sourceOptions}\n value={source}\n onChange={(next) => setSource(next as SecretValueSource)}\n allowCustomValue={false}\n required\n />\n </div>\n <div\n className=\"hidden shrink-0 @max-md:!block\"\n data-slot=\"secret-source-menu\"\n >\n <IconMenuPicker\n value={source}\n onChange={setSource}\n options={sourceMenuOptions}\n ariaLabel=\"Secret value source\"\n triggerClassName=\"size-control-h rounded-md border border-input bg-background\"\n />\n </div>\n {isLiteral ? (\n <TextField\n value={literalValue}\n onChange={setLiteral}\n placeholder=\"Static value…\"\n ariaLabel=\"Static value\"\n />\n ) : isOnePassword ? (\n (() => {\n if (!onePassword) {\n throw new Error(\n \"SecretKeySelector onepassword source requires onePassword loaders\",\n );\n }\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-onepassword-field\">\n <OnePasswordSelector\n value={opRef}\n onChange={setOpRef}\n {...onePassword}\n allowCustomValue\n />\n </div>\n );\n })()\n ) : isServiceAccount ? (\n <div\n className={VALUE_FIELD}\n data-slot=\"secret-serviceaccount-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder=\"Service account…\"\n />\n </div>\n ) : (\n <div\n className={cn(\n \"flex flex-nowrap items-center gap-2\",\n SHRINKABLE_FIELD,\n \"grow\",\n )}\n data-slot=\"secret-reference-fields\"\n >\n <div\n className={RESOURCE_FIELD}\n data-slot=\"secret-resource-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder={`Select ${refKind}…`}\n />\n </div>\n <div className={KEY_FIELD} data-slot=\"secret-key-field\">\n <Combobox\n options={keyOptions}\n value={selectedKey}\n onChange={setKey}\n allowCustomValue\n loading={previewLoading}\n invalid={keyInvalid}\n placeholder={selectedName ? keyPlaceholder(refKind) : \"—\"}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction TextField({\n value,\n onChange,\n placeholder,\n ariaLabel,\n}: {\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n ariaLabel: string;\n}) {\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-value-fields\">\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n aria-label={ariaLabel}\n className={cn(\n \"h-control-h w-full min-w-0 rounded border border-input bg-background px-control-px text-sm\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n );\n}\n\n// isRefKind narrows to the keyed variants that carry both a name and a key.\nfunction isRefKind(\n v: SecretKeyValue,\n): v is { kind: SecretKind; name: string; key: string } {\n return v.kind === \"secret\" || v.kind === \"configmap\" || v.kind === \"helm\";\n}\n\n// keyPlaceholder hints the key field: helm keys are jsonpath expressions into\n// the merged release values, the others are literal data keys.\nfunction keyPlaceholder(kind: SecretKind): string {\n return kind === \"helm\" ? \"jsonpath…\" : \"Key…\";\n}\n\n// Each source's leading glyph. The flanksource FCs carry static metadata that\n// doesn't unify with ComponentType, so type the slot as a plain render function.\nconst SOURCE_ICON: Record<SecretValueSource, StaticIconComponent> = {\n secret: K8SSecret,\n configmap: K8SConfigmap,\n helm: Helm,\n serviceaccount: K8SServiceaccount,\n onepassword: Vault,\n value: UiEdit,\n};\n\nconst SOURCE_LABEL: Record<SecretValueSource, string> = {\n secret: \"Secret\",\n configmap: \"ConfigMap\",\n helm: \"Helm\",\n serviceaccount: \"Service Account\",\n onepassword: \"1Password\",\n value: \"Value\",\n};\n\n// buildKeyOptions labels each key with its mid-masked preview value when one is\n// available. A selected key absent from the list is pinned so the selection\n// stays visible.\nfunction buildKeyOptions(\n keys: string[],\n previews: KeyPreview[],\n selectedKey: string,\n): ComboboxOption[] {\n const masked = new Map(previews.map((p) => [p.key, p.value]));\n const base = keys.map((k) => ({\n value: k,\n label: masked.has(k) ? `${k} — ${masked.get(k)}` : k,\n }));\n if (selectedKey && !base.some((o) => o.value === selectedKey)) {\n return [{ value: selectedKey, label: selectedKey }, ...base];\n }\n return base;\n}\n"],"names":["useMemo","useState","useEffect","createElement","jsx","cn","jsxs","Combobox","IconMenuPicker","OnePasswordSelector","K8SSecret","K8SConfigmap","Helm","K8SServiceaccount","Vault","UiEdit"],"mappings":";;;;;;;;;;AAsFA,MAAM,kBAAuC,CAAC,UAAU,aAAa,OAAO;AAE5E,MAAM,mBAAmB;AACzB,MAAM,eAAe,GAAG,gBAAgB;AACxC,MAAM,iBAAiB,GAAG,gBAAgB;AAC1C,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,cAAc,GAAG,gBAAgB;AAEhC,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,EACT;AACF,GAA2B;AACzB,QAAM,aAAaA,MAAAA;AAAAA,IACjB,MAAM,YAAY,eAAe,kBAAkB,CAAC,UAAU,WAAW;AAAA,IACzE,CAAC,SAAS,YAAY;AAAA,EAAA;AAGxB,QAAM,UAA4B,+BAAO,SAAQ,WAAW,CAAC,KAAK;AAClE,QAAM,UACJ,WAAW,YAAY,WAAW,eAAe,WAAW;AAC9D,QAAM,mBAAmB,WAAW;AACpC,QAAM,gBAAgB,WAAW;AACjC,QAAM,YAAY,WAAW;AAE7B,QAAM,UAAsB,UAAW,SAAwB;AAE/D,QAAM,eACJ,UAAU,MAAM,SAAS,oBAAoB,UAAU,KAAK,KACxD,MAAM,OACN;AACN,QAAM,cAAc,SAAS,UAAU,KAAK,IAAI,MAAM,MAAM;AAC5D,QAAM,eAAe,SAAS,MAAM,SAAS,UAAU,MAAM,QAAQ;AACrE,QAAM,QAAQ,SAAS,MAAM,SAAS,gBAAgB,MAAM,MAAM;AAElE,QAAM,CAAC,WAAW,YAAY,IAAIC,MAAAA,SAA2B,CAAA,CAAE;AAC/D,QAAM,CAAC,kBAAkB,mBAAmB,IAAIA,MAAAA,SAAS,KAAK;AAC9D,QAAM,CAAC,UAAU,WAAW,IAAIA,MAA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AQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,OAAO;AACT;AAKA,SAAS,gBACP,MACA,UACA,aACkB;AAClB,QAAM,SAAS,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5D,QAAM,OAAO,KAAK,IAAI,CAAC,OAAO;AAAA,IAC5B,OAAO;AAAA,IACP,OAAO,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC,KAAK;AAAA,EAAA,EACnD;AACF,MAAI,eAAe,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,UAAU,WAAW,GAAG;AAC7D,WAAO,CAAC,EAAE,OAAO,aAAa,OAAO,YAAA,GAAe,GAAG,IAAI;AAAA,EAC7D;AACA,SAAO;AACT;;"}
1
+ {"version":3,"file":"SecretKeySelector.cjs","sources":["../../src/components/SecretKeySelector.tsx"],"sourcesContent":["import { createElement, useEffect, useMemo, useState } from \"react\";\nimport {\n K8SSecret,\n K8SConfigmap,\n Helm,\n K8SServiceaccount,\n Vault,\n} from \"@flanksource/icons/mi\";\nimport { type StaticIconComponent } from \"../data/Icon\";\nimport { cn } from \"../lib/utils\";\nimport { UiEdit } from \"../icons\";\nimport { Combobox, type ComboboxOption } from \"./Combobox\";\nimport { IconMenuPicker, type IconMenuOption } from \"./icon-menu-picker\";\nimport { OnePasswordSelector } from \"./OnePasswordSelector\";\nimport type { OnePasswordLoaders } from \"./OnePasswordSelector.model\";\n\n// SecretKeySelector picks how a credential is sourced and lowers the choice into\n// a single reference string the consumer persists. It supports Kubernetes\n// Secrets and ConfigMaps (name + key), Helm release values (name + jsonpath\n// key), a service-account token (name only), a 1Password reference\n// (op://vault/item/field), and a static inline \"Value\". It is presentational:\n// it fetches nothing — the consumer supplies async `loadResources` /\n// `loadKeyPreview` (for keyed kinds) and optional `loadServiceAccounts` getters.\n\n/** Kinds that reference a named resource plus one of its keys. */\nexport type SecretKind = \"secret\" | \"configmap\" | \"helm\";\n\n/** Every source the picker can emit, including the non-keyed ones. */\nexport type SecretValueSource =\n | SecretKind\n | \"serviceaccount\"\n | \"onepassword\"\n | \"value\";\n\n/** One key's mid-masked preview. `value` is already masked by the consumer. */\nexport type KeyPreview = { key: string; value: string };\n\n/**\n * The selector's value: a {kind,name,key} reference into a Secret / ConfigMap /\n * Helm release, a service-account token by name, a 1Password op:// reference, or\n * a static inline literal.\n */\nexport type SecretKeyValue =\n | { kind: SecretKind; name: string; key: string }\n | { kind: \"serviceaccount\"; name: string }\n | { kind: \"onepassword\"; ref: string }\n | { kind: \"value\"; value: string };\n\n/** A named secret/configmap/helm-release and its data key names (values never returned). */\nexport type SecretResource = { name: string; keys?: string[] };\n\nexport type SecretKeySelectorProps = {\n value: SecretKeyValue | undefined;\n onChange: (next: SecretKeyValue | undefined) => void;\n /** Loads the named keyed kind's resources (name + data key names). */\n loadResources: (kind: SecretKind) => Promise<SecretResource[]>;\n /** Loads mid-masked previews for the named keyed resource's keys. */\n loadKeyPreview: (kind: SecretKind, name: string) => Promise<KeyPreview[]>;\n /**\n * Loads the service-account names (no keys) for the \"serviceaccount\" source.\n * When omitted, that source's name field accepts freeform entry only.\n */\n loadServiceAccounts?: () => Promise<SecretResource[]>;\n /** Loads metadata for the cascading 1Password vault, item, and field pickers. */\n onePassword?: OnePasswordLoaders;\n /**\n * The sources offered in the picker, in order. Defaults to\n * `[\"secret\", \"configmap\", \"value\"]` (or drops \"value\" when `allowLiteral` is\n * false). Pass an explicit list to offer helm / serviceaccount / onepassword.\n */\n sources?: SecretValueSource[];\n /**\n * Shorthand honoured only when `sources` is not supplied: `false` drops the\n * inline \"Value\" source, leaving Secret/ConfigMap. Ignored when `sources` is\n * given.\n */\n allowLiteral?: boolean;\n /**\n * When true, a chosen name absent from the loaded resources, or a key absent\n * from the chosen keyed resource's keys, is flagged invalid (once the load\n * settles). The onepassword and literal sources are never strict-flagged.\n */\n strict?: boolean;\n className?: string;\n};\n\nconst DEFAULT_SOURCES: SecretValueSource[] = [\"secret\", \"configmap\", \"value\"];\n\nconst SHRINKABLE_FIELD = \"max-w-full min-w-0 shrink\";\nconst SOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst RESOURCE_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow-0 @min-[22rem]/secret:basis-40`;\nconst KEY_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow @min-[22rem]/secret:basis-72`;\nconst VALUE_FIELD = `${SHRINKABLE_FIELD} basis-64 grow`;\n\nexport function SecretKeySelector({\n value,\n onChange,\n loadResources,\n loadKeyPreview,\n loadServiceAccounts,\n onePassword,\n sources,\n allowLiteral = true,\n strict = false,\n className,\n}: SecretKeySelectorProps) {\n const sourceList = useMemo<SecretValueSource[]>(\n () => sources ?? (allowLiteral ? DEFAULT_SOURCES : [\"secret\", \"configmap\"]),\n [sources, allowLiteral],\n );\n\n const source: SecretValueSource = value?.kind ?? sourceList[0] ?? \"secret\";\n const isKeyed =\n source === \"secret\" || source === \"configmap\" || source === \"helm\";\n const isServiceAccount = source === \"serviceaccount\";\n const isOnePassword = source === \"onepassword\";\n const isLiteral = source === \"value\";\n // A keyed source's refKind drives the loaders; other sources default to \"secret\".\n const refKind: SecretKind = isKeyed ? (source as SecretKind) : \"secret\";\n\n const selectedName =\n value && (value.kind === \"serviceaccount\" || isRefKind(value))\n ? value.name\n : \"\";\n const selectedKey = value && isRefKind(value) ? value.key : \"\";\n const literalValue = value && value.kind === \"value\" ? value.value : \"\";\n const opRef = value && value.kind === \"onepassword\" ? value.ref : \"\";\n\n const [resources, setResources] = useState<SecretResource[]>([]);\n const [resourcesLoading, setResourcesLoading] = useState(false);\n const [previews, setPreviews] = useState<KeyPreview[]>([]);\n const [previewLoading, setPreviewLoading] = useState(false);\n\n // Load the name list for keyed kinds (secret/configmap/helm) and, when a\n // loader is supplied, for the serviceaccount source. Other sources list nothing.\n useEffect(() => {\n const loader = isKeyed\n ? () => loadResources(refKind)\n : isServiceAccount && loadServiceAccounts\n ? loadServiceAccounts\n : null;\n if (!loader) {\n setResources([]);\n return;\n }\n let cancelled = false;\n setResourcesLoading(true);\n loader()\n .then((res) => !cancelled && setResources(res))\n .finally(() => !cancelled && setResourcesLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadResources, loadServiceAccounts, refKind, isKeyed, isServiceAccount]);\n\n useEffect(() => {\n if (!isKeyed || !selectedName) {\n setPreviews([]);\n return;\n }\n let cancelled = false;\n setPreviewLoading(true);\n loadKeyPreview(refKind, selectedName)\n .then((res) => !cancelled && setPreviews(res))\n .catch(() => !cancelled && setPreviews([]))\n .finally(() => !cancelled && setPreviewLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadKeyPreview, refKind, selectedName, isKeyed]);\n\n const nameOptions = useMemo<ComboboxOption[]>(\n () => resources.map((r) => ({ value: r.name, label: r.name })),\n [resources],\n );\n const selectedResource = useMemo(\n () => resources.find((r) => r.name === selectedName),\n [resources, selectedName],\n );\n const keyOptions = useMemo(\n () => buildKeyOptions(selectedResource?.keys ?? [], previews, selectedKey),\n [selectedResource, selectedKey, previews],\n );\n\n // Strict validity: the name is invalid when it names no loaded resource; the\n // key is invalid when, with a resolved resource, it isn't one of that\n // resource's keys. Only names from a listed source are checked (a\n // serviceaccount source with no loader lists nothing, so it never flags).\n const listsNames = isKeyed || (isServiceAccount && !!loadServiceAccounts);\n const nameInvalid =\n strict &&\n listsNames &&\n !!selectedName &&\n !resourcesLoading &&\n !selectedResource;\n const keyInvalid =\n strict &&\n isKeyed &&\n !!selectedKey &&\n !!selectedResource &&\n !resourcesLoading &&\n !(selectedResource.keys ?? []).includes(selectedKey);\n\n const setSource = (next: SecretValueSource) => {\n switch (next) {\n case \"value\":\n return onChange({ kind: \"value\", value: \"\" });\n case \"onepassword\":\n return onChange({ kind: \"onepassword\", ref: \"\" });\n case \"serviceaccount\":\n return onChange({ kind: \"serviceaccount\", name: \"\" });\n default:\n return onChange({ kind: next, name: \"\", key: \"\" });\n }\n };\n const setName = (name: string) => {\n if (isServiceAccount)\n return onChange(name ? { kind: \"serviceaccount\", name } : undefined);\n return onChange(\n name ? { kind: refKind, name, key: selectedKey } : undefined,\n );\n };\n const setKey = (key: string) =>\n selectedName\n ? onChange({ kind: refKind, name: selectedName, key })\n : undefined;\n const setLiteral = (v: string) => onChange({ kind: \"value\", value: v });\n const setOpRef = (ref: string) => onChange({ kind: \"onepassword\", ref });\n\n const sourceOptions = useMemo<ComboboxOption[]>(\n () =>\n sourceList.map((k) => ({\n value: k,\n label: SOURCE_LABEL[k],\n icon: createElement(SOURCE_ICON[k], { className: \"size-4\" }),\n })),\n [sourceList],\n );\n const sourceMenuOptions = useMemo<IconMenuOption<SecretValueSource>[]>(\n () =>\n sourceList.map((kind) => ({\n value: kind,\n label: SOURCE_LABEL[kind],\n icon: SOURCE_ICON[kind],\n })),\n [sourceList],\n );\n\n return (\n <div\n data-slot=\"secret-key-selector\"\n className={cn(\"@container/secret w-full min-w-0\", className)}\n >\n <div\n className=\"flex w-full max-w-full min-w-0 flex-nowrap items-center gap-2\"\n data-slot=\"secret-fields\"\n >\n <div\n className={cn(SOURCE_FIELD, \"@max-md:hidden\")}\n data-slot=\"secret-source-combobox\"\n >\n <Combobox\n ariaLabel=\"Secret value source\"\n options={sourceOptions}\n value={source}\n onChange={(next) => setSource(next as SecretValueSource)}\n allowCustomValue={false}\n required\n />\n </div>\n <div\n className=\"hidden shrink-0 @max-md:!block\"\n data-slot=\"secret-source-menu\"\n >\n <IconMenuPicker\n value={source}\n onChange={setSource}\n options={sourceMenuOptions}\n ariaLabel=\"Secret value source\"\n triggerClassName=\"size-control-h rounded-md border border-input bg-background\"\n />\n </div>\n {isLiteral ? (\n <TextField\n value={literalValue}\n onChange={setLiteral}\n placeholder=\"Static value…\"\n ariaLabel=\"Static value\"\n />\n ) : isOnePassword ? (\n (() => {\n if (!onePassword) {\n throw new Error(\n \"SecretKeySelector onepassword source requires onePassword loaders\",\n );\n }\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-onepassword-field\">\n <OnePasswordSelector\n value={opRef}\n onChange={setOpRef}\n {...onePassword}\n allowCustomValue\n />\n </div>\n );\n })()\n ) : isServiceAccount ? (\n <div\n className={VALUE_FIELD}\n data-slot=\"secret-serviceaccount-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder=\"Service account…\"\n />\n </div>\n ) : (\n <div\n className={cn(\n \"flex flex-col items-center gap-2 @min-[22rem]/secret:flex-row\",\n SHRINKABLE_FIELD,\n \"grow\",\n )}\n data-slot=\"secret-reference-fields\"\n >\n <div\n className={RESOURCE_FIELD}\n data-slot=\"secret-resource-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder={`Select ${refKind}…`}\n />\n </div>\n <div className={KEY_FIELD} data-slot=\"secret-key-field\">\n <Combobox\n options={keyOptions}\n value={selectedKey}\n onChange={setKey}\n allowCustomValue\n loading={previewLoading}\n invalid={keyInvalid}\n placeholder={selectedName ? keyPlaceholder(refKind) : \"—\"}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction TextField({\n value,\n onChange,\n placeholder,\n ariaLabel,\n}: {\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n ariaLabel: string;\n}) {\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-value-fields\">\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n aria-label={ariaLabel}\n className={cn(\n \"h-control-h w-full min-w-0 rounded border border-input bg-background px-control-px text-sm\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n );\n}\n\n// isRefKind narrows to the keyed variants that carry both a name and a key.\nfunction isRefKind(\n v: SecretKeyValue,\n): v is { kind: SecretKind; name: string; key: string } {\n return v.kind === \"secret\" || v.kind === \"configmap\" || v.kind === \"helm\";\n}\n\n// keyPlaceholder hints the key field: helm keys are jsonpath expressions into\n// the merged release values, the others are literal data keys.\nfunction keyPlaceholder(kind: SecretKind): string {\n return kind === \"helm\" ? \"jsonpath…\" : \"Key…\";\n}\n\n// Each source's leading glyph. The flanksource FCs carry static metadata that\n// doesn't unify with ComponentType, so type the slot as a plain render function.\nconst SOURCE_ICON: Record<SecretValueSource, StaticIconComponent> = {\n secret: K8SSecret,\n configmap: K8SConfigmap,\n helm: Helm,\n serviceaccount: K8SServiceaccount,\n onepassword: Vault,\n value: UiEdit,\n};\n\nconst SOURCE_LABEL: Record<SecretValueSource, string> = {\n secret: \"Secret\",\n configmap: \"ConfigMap\",\n helm: \"Helm\",\n serviceaccount: \"Service Account\",\n onepassword: \"1Password\",\n value: \"Value\",\n};\n\n// buildKeyOptions labels each key with its mid-masked preview value when one is\n// available. A selected key absent from the list is pinned so the selection\n// stays visible.\nfunction buildKeyOptions(\n keys: string[],\n previews: KeyPreview[],\n selectedKey: string,\n): ComboboxOption[] {\n const masked = new Map(previews.map((p) => [p.key, p.value]));\n const base = keys.map((k) => ({\n value: k,\n label: masked.has(k) ? `${k} — ${masked.get(k)}` : k,\n }));\n if (selectedKey && !base.some((o) => o.value === selectedKey)) {\n return [{ value: selectedKey, label: selectedKey }, ...base];\n }\n return base;\n}\n"],"names":["useMemo","useState","useEffect","createElement","jsx","cn","jsxs","Combobox","IconMenuPicker","OnePasswordSelector","K8SSecret","K8SConfigmap","Helm","K8SServiceaccount","Vault","UiEdit"],"mappings":";;;;;;;;;;AAsFA,MAAM,kBAAuC,CAAC,UAAU,aAAa,OAAO;AAE5E,MAAM,mBAAmB;AACzB,MAAM,eAAe,GAAG,gBAAgB;AACxC,MAAM,iBAAiB,GAAG,gBAAgB;AAC1C,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,cA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AO,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC,KAAK;AAAA,EAAA,EACnD;AACF,MAAI,eAAe,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,UAAU,WAAW,GAAG;AAC7D,WAAO,CAAC,EAAE,OAAO,aAAa,OAAO,YAAA,GAAe,GAAG,IAAI;AAAA,EAC7D;AACA,SAAO;AACT;;"}
@@ -9,8 +9,8 @@ import { UiEdit } from "../icons/components/UiEdit.js";
9
9
  const DEFAULT_SOURCES = ["secret", "configmap", "value"];
10
10
  const SHRINKABLE_FIELD = "max-w-full min-w-0 shrink";
11
11
  const SOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;
12
- const RESOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;
13
- const KEY_FIELD = `${SHRINKABLE_FIELD} basis-72 grow`;
12
+ const RESOURCE_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow-0 @min-[22rem]/secret:basis-40`;
13
+ const KEY_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow @min-[22rem]/secret:basis-72`;
14
14
  const VALUE_FIELD = `${SHRINKABLE_FIELD} basis-64 grow`;
15
15
  function SecretKeySelector({
16
16
  value,
@@ -124,7 +124,7 @@ function SecretKeySelector({
124
124
  "div",
125
125
  {
126
126
  "data-slot": "secret-key-selector",
127
- className: cn("@container w-full min-w-0", className),
127
+ className: cn("@container/secret w-full min-w-0", className),
128
128
  children: /* @__PURE__ */ jsxs(
129
129
  "div",
130
130
  {
@@ -211,7 +211,7 @@ function SecretKeySelector({
211
211
  "div",
212
212
  {
213
213
  className: cn(
214
- "flex flex-nowrap items-center gap-2",
214
+ "flex flex-col items-center gap-2 @min-[22rem]/secret:flex-row",
215
215
  SHRINKABLE_FIELD,
216
216
  "grow"
217
217
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"SecretKeySelector.js","sources":["../../src/components/SecretKeySelector.tsx"],"sourcesContent":["import { createElement, useEffect, useMemo, useState } from \"react\";\nimport {\n K8SSecret,\n K8SConfigmap,\n Helm,\n K8SServiceaccount,\n Vault,\n} from \"@flanksource/icons/mi\";\nimport { type StaticIconComponent } from \"../data/Icon\";\nimport { cn } from \"../lib/utils\";\nimport { UiEdit } from \"../icons\";\nimport { Combobox, type ComboboxOption } from \"./Combobox\";\nimport { IconMenuPicker, type IconMenuOption } from \"./icon-menu-picker\";\nimport { OnePasswordSelector } from \"./OnePasswordSelector\";\nimport type { OnePasswordLoaders } from \"./OnePasswordSelector.model\";\n\n// SecretKeySelector picks how a credential is sourced and lowers the choice into\n// a single reference string the consumer persists. It supports Kubernetes\n// Secrets and ConfigMaps (name + key), Helm release values (name + jsonpath\n// key), a service-account token (name only), a 1Password reference\n// (op://vault/item/field), and a static inline \"Value\". It is presentational:\n// it fetches nothing — the consumer supplies async `loadResources` /\n// `loadKeyPreview` (for keyed kinds) and optional `loadServiceAccounts` getters.\n\n/** Kinds that reference a named resource plus one of its keys. */\nexport type SecretKind = \"secret\" | \"configmap\" | \"helm\";\n\n/** Every source the picker can emit, including the non-keyed ones. */\nexport type SecretValueSource =\n | SecretKind\n | \"serviceaccount\"\n | \"onepassword\"\n | \"value\";\n\n/** One key's mid-masked preview. `value` is already masked by the consumer. */\nexport type KeyPreview = { key: string; value: string };\n\n/**\n * The selector's value: a {kind,name,key} reference into a Secret / ConfigMap /\n * Helm release, a service-account token by name, a 1Password op:// reference, or\n * a static inline literal.\n */\nexport type SecretKeyValue =\n | { kind: SecretKind; name: string; key: string }\n | { kind: \"serviceaccount\"; name: string }\n | { kind: \"onepassword\"; ref: string }\n | { kind: \"value\"; value: string };\n\n/** A named secret/configmap/helm-release and its data key names (values never returned). */\nexport type SecretResource = { name: string; keys?: string[] };\n\nexport type SecretKeySelectorProps = {\n value: SecretKeyValue | undefined;\n onChange: (next: SecretKeyValue | undefined) => void;\n /** Loads the named keyed kind's resources (name + data key names). */\n loadResources: (kind: SecretKind) => Promise<SecretResource[]>;\n /** Loads mid-masked previews for the named keyed resource's keys. */\n loadKeyPreview: (kind: SecretKind, name: string) => Promise<KeyPreview[]>;\n /**\n * Loads the service-account names (no keys) for the \"serviceaccount\" source.\n * When omitted, that source's name field accepts freeform entry only.\n */\n loadServiceAccounts?: () => Promise<SecretResource[]>;\n /** Loads metadata for the cascading 1Password vault, item, and field pickers. */\n onePassword?: OnePasswordLoaders;\n /**\n * The sources offered in the picker, in order. Defaults to\n * `[\"secret\", \"configmap\", \"value\"]` (or drops \"value\" when `allowLiteral` is\n * false). Pass an explicit list to offer helm / serviceaccount / onepassword.\n */\n sources?: SecretValueSource[];\n /**\n * Shorthand honoured only when `sources` is not supplied: `false` drops the\n * inline \"Value\" source, leaving Secret/ConfigMap. Ignored when `sources` is\n * given.\n */\n allowLiteral?: boolean;\n /**\n * When true, a chosen name absent from the loaded resources, or a key absent\n * from the chosen keyed resource's keys, is flagged invalid (once the load\n * settles). The onepassword and literal sources are never strict-flagged.\n */\n strict?: boolean;\n className?: string;\n};\n\nconst DEFAULT_SOURCES: SecretValueSource[] = [\"secret\", \"configmap\", \"value\"];\n\nconst SHRINKABLE_FIELD = \"max-w-full min-w-0 shrink\";\nconst SOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst RESOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst KEY_FIELD = `${SHRINKABLE_FIELD} basis-72 grow`;\nconst VALUE_FIELD = `${SHRINKABLE_FIELD} basis-64 grow`;\n\nexport function SecretKeySelector({\n value,\n onChange,\n loadResources,\n loadKeyPreview,\n loadServiceAccounts,\n onePassword,\n sources,\n allowLiteral = true,\n strict = false,\n className,\n}: SecretKeySelectorProps) {\n const sourceList = useMemo<SecretValueSource[]>(\n () => sources ?? (allowLiteral ? DEFAULT_SOURCES : [\"secret\", \"configmap\"]),\n [sources, allowLiteral],\n );\n\n const source: SecretValueSource = value?.kind ?? sourceList[0] ?? \"secret\";\n const isKeyed =\n source === \"secret\" || source === \"configmap\" || source === \"helm\";\n const isServiceAccount = source === \"serviceaccount\";\n const isOnePassword = source === \"onepassword\";\n const isLiteral = source === \"value\";\n // A keyed source's refKind drives the loaders; other sources default to \"secret\".\n const refKind: SecretKind = isKeyed ? (source as SecretKind) : \"secret\";\n\n const selectedName =\n value && (value.kind === \"serviceaccount\" || isRefKind(value))\n ? value.name\n : \"\";\n const selectedKey = value && isRefKind(value) ? value.key : \"\";\n const literalValue = value && value.kind === \"value\" ? value.value : \"\";\n const opRef = value && value.kind === \"onepassword\" ? value.ref : \"\";\n\n const [resources, setResources] = useState<SecretResource[]>([]);\n const [resourcesLoading, setResourcesLoading] = useState(false);\n const [previews, setPreviews] = useState<KeyPreview[]>([]);\n const [previewLoading, setPreviewLoading] = useState(false);\n\n // Load the name list for keyed kinds (secret/configmap/helm) and, when a\n // loader is supplied, for the serviceaccount source. Other sources list nothing.\n useEffect(() => {\n const loader = isKeyed\n ? () => loadResources(refKind)\n : isServiceAccount && loadServiceAccounts\n ? loadServiceAccounts\n : null;\n if (!loader) {\n setResources([]);\n return;\n }\n let cancelled = false;\n setResourcesLoading(true);\n loader()\n .then((res) => !cancelled && setResources(res))\n .finally(() => !cancelled && setResourcesLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadResources, loadServiceAccounts, refKind, isKeyed, isServiceAccount]);\n\n useEffect(() => {\n if (!isKeyed || !selectedName) {\n setPreviews([]);\n return;\n }\n let cancelled = false;\n setPreviewLoading(true);\n loadKeyPreview(refKind, selectedName)\n .then((res) => !cancelled && setPreviews(res))\n .catch(() => !cancelled && setPreviews([]))\n .finally(() => !cancelled && setPreviewLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadKeyPreview, refKind, selectedName, isKeyed]);\n\n const nameOptions = useMemo<ComboboxOption[]>(\n () => resources.map((r) => ({ value: r.name, label: r.name })),\n [resources],\n );\n const selectedResource = useMemo(\n () => resources.find((r) => r.name === selectedName),\n [resources, selectedName],\n );\n const keyOptions = useMemo(\n () => buildKeyOptions(selectedResource?.keys ?? [], previews, selectedKey),\n [selectedResource, selectedKey, previews],\n );\n\n // Strict validity: the name is invalid when it names no loaded resource; the\n // key is invalid when, with a resolved resource, it isn't one of that\n // resource's keys. Only names from a listed source are checked (a\n // serviceaccount source with no loader lists nothing, so it never flags).\n const listsNames = isKeyed || (isServiceAccount && !!loadServiceAccounts);\n const nameInvalid =\n strict &&\n listsNames &&\n !!selectedName &&\n !resourcesLoading &&\n !selectedResource;\n const keyInvalid =\n strict &&\n isKeyed &&\n !!selectedKey &&\n !!selectedResource &&\n !resourcesLoading &&\n !(selectedResource.keys ?? []).includes(selectedKey);\n\n const setSource = (next: SecretValueSource) => {\n switch (next) {\n case \"value\":\n return onChange({ kind: \"value\", value: \"\" });\n case \"onepassword\":\n return onChange({ kind: \"onepassword\", ref: \"\" });\n case \"serviceaccount\":\n return onChange({ kind: \"serviceaccount\", name: \"\" });\n default:\n return onChange({ kind: next, name: \"\", key: \"\" });\n }\n };\n const setName = (name: string) => {\n if (isServiceAccount)\n return onChange(name ? { kind: \"serviceaccount\", name } : undefined);\n return onChange(\n name ? { kind: refKind, name, key: selectedKey } : undefined,\n );\n };\n const setKey = (key: string) =>\n selectedName\n ? onChange({ kind: refKind, name: selectedName, key })\n : undefined;\n const setLiteral = (v: string) => onChange({ kind: \"value\", value: v });\n const setOpRef = (ref: string) => onChange({ kind: \"onepassword\", ref });\n\n const sourceOptions = useMemo<ComboboxOption[]>(\n () =>\n sourceList.map((k) => ({\n value: k,\n label: SOURCE_LABEL[k],\n icon: createElement(SOURCE_ICON[k], { className: \"size-4\" }),\n })),\n [sourceList],\n );\n const sourceMenuOptions = useMemo<IconMenuOption<SecretValueSource>[]>(\n () =>\n sourceList.map((kind) => ({\n value: kind,\n label: SOURCE_LABEL[kind],\n icon: SOURCE_ICON[kind],\n })),\n [sourceList],\n );\n\n return (\n <div\n data-slot=\"secret-key-selector\"\n className={cn(\"@container w-full min-w-0\", className)}\n >\n <div\n className=\"flex w-full max-w-full min-w-0 flex-nowrap items-center gap-2\"\n data-slot=\"secret-fields\"\n >\n <div\n className={cn(SOURCE_FIELD, \"@max-md:hidden\")}\n data-slot=\"secret-source-combobox\"\n >\n <Combobox\n ariaLabel=\"Secret value source\"\n options={sourceOptions}\n value={source}\n onChange={(next) => setSource(next as SecretValueSource)}\n allowCustomValue={false}\n required\n />\n </div>\n <div\n className=\"hidden shrink-0 @max-md:!block\"\n data-slot=\"secret-source-menu\"\n >\n <IconMenuPicker\n value={source}\n onChange={setSource}\n options={sourceMenuOptions}\n ariaLabel=\"Secret value source\"\n triggerClassName=\"size-control-h rounded-md border border-input bg-background\"\n />\n </div>\n {isLiteral ? (\n <TextField\n value={literalValue}\n onChange={setLiteral}\n placeholder=\"Static value…\"\n ariaLabel=\"Static value\"\n />\n ) : isOnePassword ? (\n (() => {\n if (!onePassword) {\n throw new Error(\n \"SecretKeySelector onepassword source requires onePassword loaders\",\n );\n }\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-onepassword-field\">\n <OnePasswordSelector\n value={opRef}\n onChange={setOpRef}\n {...onePassword}\n allowCustomValue\n />\n </div>\n );\n })()\n ) : isServiceAccount ? (\n <div\n className={VALUE_FIELD}\n data-slot=\"secret-serviceaccount-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder=\"Service account…\"\n />\n </div>\n ) : (\n <div\n className={cn(\n \"flex flex-nowrap items-center gap-2\",\n SHRINKABLE_FIELD,\n \"grow\",\n )}\n data-slot=\"secret-reference-fields\"\n >\n <div\n className={RESOURCE_FIELD}\n data-slot=\"secret-resource-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder={`Select ${refKind}…`}\n />\n </div>\n <div className={KEY_FIELD} data-slot=\"secret-key-field\">\n <Combobox\n options={keyOptions}\n value={selectedKey}\n onChange={setKey}\n allowCustomValue\n loading={previewLoading}\n invalid={keyInvalid}\n placeholder={selectedName ? keyPlaceholder(refKind) : \"—\"}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction TextField({\n value,\n onChange,\n placeholder,\n ariaLabel,\n}: {\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n ariaLabel: string;\n}) {\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-value-fields\">\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n aria-label={ariaLabel}\n className={cn(\n \"h-control-h w-full min-w-0 rounded border border-input bg-background px-control-px text-sm\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n );\n}\n\n// isRefKind narrows to the keyed variants that carry both a name and a key.\nfunction isRefKind(\n v: SecretKeyValue,\n): v is { kind: SecretKind; name: string; key: string } {\n return v.kind === \"secret\" || v.kind === \"configmap\" || v.kind === \"helm\";\n}\n\n// keyPlaceholder hints the key field: helm keys are jsonpath expressions into\n// the merged release values, the others are literal data keys.\nfunction keyPlaceholder(kind: SecretKind): string {\n return kind === \"helm\" ? \"jsonpath…\" : \"Key…\";\n}\n\n// Each source's leading glyph. The flanksource FCs carry static metadata that\n// doesn't unify with ComponentType, so type the slot as a plain render function.\nconst SOURCE_ICON: Record<SecretValueSource, StaticIconComponent> = {\n secret: K8SSecret,\n configmap: K8SConfigmap,\n helm: Helm,\n serviceaccount: K8SServiceaccount,\n onepassword: Vault,\n value: UiEdit,\n};\n\nconst SOURCE_LABEL: Record<SecretValueSource, string> = {\n secret: \"Secret\",\n configmap: \"ConfigMap\",\n helm: \"Helm\",\n serviceaccount: \"Service Account\",\n onepassword: \"1Password\",\n value: \"Value\",\n};\n\n// buildKeyOptions labels each key with its mid-masked preview value when one is\n// available. A selected key absent from the list is pinned so the selection\n// stays visible.\nfunction buildKeyOptions(\n keys: string[],\n previews: KeyPreview[],\n selectedKey: string,\n): ComboboxOption[] {\n const masked = new Map(previews.map((p) => [p.key, p.value]));\n const base = keys.map((k) => ({\n value: k,\n label: masked.has(k) ? `${k} — ${masked.get(k)}` : k,\n }));\n if (selectedKey && !base.some((o) => o.value === selectedKey)) {\n return [{ value: selectedKey, label: selectedKey }, ...base];\n }\n return base;\n}\n"],"names":[],"mappings":";;;;;;;;AAsFA,MAAM,kBAAuC,CAAC,UAAU,aAAa,OAAO;AAE5E,MAAM,mBAAmB;AACzB,MAAM,eAAe,GAAG,gBAAgB;AACxC,MAAM,iBAAiB,GAAG,gBAAgB;AAC1C,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,cAAc,GAAG,gBAAgB;AAEhC,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,EACT;AACF,GAA2B;AACzB,QAAM,aAAa;AAAA,IACjB,MAAM,YAAY,eAAe,kBAAkB,CAAC,UAAU,WAAW;AAAA,IACzE,CAAC,SAAS,YAAY;AAAA,EAAA;AAGxB,QAAM,UAA4B,+BAAO,SAAQ,WAAW,CAAC,KAAK;AAClE,QAAM,UACJ,WAAW,YAAY,WAAW,eAAe,WAAW;AAC9D,QAAM,mBAAmB,WAAW;AACpC,QAAM,gBAAgB,WAAW;AACjC,QAAM,YAAY,WAAW;AAE7B,QAAM,UAAsB,UAAW,SAAwB;AAE/D,QAAM,eACJ,UAAU,MAAM,SAAS,oBAAoB,UAAU,KAAK,KACxD,MAAM,OACN;AACN,QAAM,cAAc,SAAS,UAAU,KAAK,IAAI,MAAM,MAAM;AAC5D,QAAM,eAAe,SAAS,MAAM,SAAS,UAAU,MAAM,QAAQ;AACrE,QAAM,QAAQ,SAAS,MAAM,SAAS,gBAAgB,MAAM,MAAM;AAElE,QAAM,CAAC,WAAW,YAAY,IAAI,SAA2B,CAAA,CAAE;AAC/D,QAAM,CAAC,kBAAkB,mB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AAI,CAAC,CAAC,KAAK;AAAA,EAAA,EACnD;AACF,MAAI,eAAe,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,UAAU,WAAW,GAAG;AAC7D,WAAO,CAAC,EAAE,OAAO,aAAa,OAAO,YAAA,GAAe,GAAG,IAAI;AAAA,EAC7D;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"SecretKeySelector.js","sources":["../../src/components/SecretKeySelector.tsx"],"sourcesContent":["import { createElement, useEffect, useMemo, useState } from \"react\";\nimport {\n K8SSecret,\n K8SConfigmap,\n Helm,\n K8SServiceaccount,\n Vault,\n} from \"@flanksource/icons/mi\";\nimport { type StaticIconComponent } from \"../data/Icon\";\nimport { cn } from \"../lib/utils\";\nimport { UiEdit } from \"../icons\";\nimport { Combobox, type ComboboxOption } from \"./Combobox\";\nimport { IconMenuPicker, type IconMenuOption } from \"./icon-menu-picker\";\nimport { OnePasswordSelector } from \"./OnePasswordSelector\";\nimport type { OnePasswordLoaders } from \"./OnePasswordSelector.model\";\n\n// SecretKeySelector picks how a credential is sourced and lowers the choice into\n// a single reference string the consumer persists. It supports Kubernetes\n// Secrets and ConfigMaps (name + key), Helm release values (name + jsonpath\n// key), a service-account token (name only), a 1Password reference\n// (op://vault/item/field), and a static inline \"Value\". It is presentational:\n// it fetches nothing — the consumer supplies async `loadResources` /\n// `loadKeyPreview` (for keyed kinds) and optional `loadServiceAccounts` getters.\n\n/** Kinds that reference a named resource plus one of its keys. */\nexport type SecretKind = \"secret\" | \"configmap\" | \"helm\";\n\n/** Every source the picker can emit, including the non-keyed ones. */\nexport type SecretValueSource =\n | SecretKind\n | \"serviceaccount\"\n | \"onepassword\"\n | \"value\";\n\n/** One key's mid-masked preview. `value` is already masked by the consumer. */\nexport type KeyPreview = { key: string; value: string };\n\n/**\n * The selector's value: a {kind,name,key} reference into a Secret / ConfigMap /\n * Helm release, a service-account token by name, a 1Password op:// reference, or\n * a static inline literal.\n */\nexport type SecretKeyValue =\n | { kind: SecretKind; name: string; key: string }\n | { kind: \"serviceaccount\"; name: string }\n | { kind: \"onepassword\"; ref: string }\n | { kind: \"value\"; value: string };\n\n/** A named secret/configmap/helm-release and its data key names (values never returned). */\nexport type SecretResource = { name: string; keys?: string[] };\n\nexport type SecretKeySelectorProps = {\n value: SecretKeyValue | undefined;\n onChange: (next: SecretKeyValue | undefined) => void;\n /** Loads the named keyed kind's resources (name + data key names). */\n loadResources: (kind: SecretKind) => Promise<SecretResource[]>;\n /** Loads mid-masked previews for the named keyed resource's keys. */\n loadKeyPreview: (kind: SecretKind, name: string) => Promise<KeyPreview[]>;\n /**\n * Loads the service-account names (no keys) for the \"serviceaccount\" source.\n * When omitted, that source's name field accepts freeform entry only.\n */\n loadServiceAccounts?: () => Promise<SecretResource[]>;\n /** Loads metadata for the cascading 1Password vault, item, and field pickers. */\n onePassword?: OnePasswordLoaders;\n /**\n * The sources offered in the picker, in order. Defaults to\n * `[\"secret\", \"configmap\", \"value\"]` (or drops \"value\" when `allowLiteral` is\n * false). Pass an explicit list to offer helm / serviceaccount / onepassword.\n */\n sources?: SecretValueSource[];\n /**\n * Shorthand honoured only when `sources` is not supplied: `false` drops the\n * inline \"Value\" source, leaving Secret/ConfigMap. Ignored when `sources` is\n * given.\n */\n allowLiteral?: boolean;\n /**\n * When true, a chosen name absent from the loaded resources, or a key absent\n * from the chosen keyed resource's keys, is flagged invalid (once the load\n * settles). The onepassword and literal sources are never strict-flagged.\n */\n strict?: boolean;\n className?: string;\n};\n\nconst DEFAULT_SOURCES: SecretValueSource[] = [\"secret\", \"configmap\", \"value\"];\n\nconst SHRINKABLE_FIELD = \"max-w-full min-w-0 shrink\";\nconst SOURCE_FIELD = `${SHRINKABLE_FIELD} basis-40 grow-0`;\nconst RESOURCE_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow-0 @min-[22rem]/secret:basis-40`;\nconst KEY_FIELD = `${SHRINKABLE_FIELD} w-full basis-auto grow @min-[22rem]/secret:basis-72`;\nconst VALUE_FIELD = `${SHRINKABLE_FIELD} basis-64 grow`;\n\nexport function SecretKeySelector({\n value,\n onChange,\n loadResources,\n loadKeyPreview,\n loadServiceAccounts,\n onePassword,\n sources,\n allowLiteral = true,\n strict = false,\n className,\n}: SecretKeySelectorProps) {\n const sourceList = useMemo<SecretValueSource[]>(\n () => sources ?? (allowLiteral ? DEFAULT_SOURCES : [\"secret\", \"configmap\"]),\n [sources, allowLiteral],\n );\n\n const source: SecretValueSource = value?.kind ?? sourceList[0] ?? \"secret\";\n const isKeyed =\n source === \"secret\" || source === \"configmap\" || source === \"helm\";\n const isServiceAccount = source === \"serviceaccount\";\n const isOnePassword = source === \"onepassword\";\n const isLiteral = source === \"value\";\n // A keyed source's refKind drives the loaders; other sources default to \"secret\".\n const refKind: SecretKind = isKeyed ? (source as SecretKind) : \"secret\";\n\n const selectedName =\n value && (value.kind === \"serviceaccount\" || isRefKind(value))\n ? value.name\n : \"\";\n const selectedKey = value && isRefKind(value) ? value.key : \"\";\n const literalValue = value && value.kind === \"value\" ? value.value : \"\";\n const opRef = value && value.kind === \"onepassword\" ? value.ref : \"\";\n\n const [resources, setResources] = useState<SecretResource[]>([]);\n const [resourcesLoading, setResourcesLoading] = useState(false);\n const [previews, setPreviews] = useState<KeyPreview[]>([]);\n const [previewLoading, setPreviewLoading] = useState(false);\n\n // Load the name list for keyed kinds (secret/configmap/helm) and, when a\n // loader is supplied, for the serviceaccount source. Other sources list nothing.\n useEffect(() => {\n const loader = isKeyed\n ? () => loadResources(refKind)\n : isServiceAccount && loadServiceAccounts\n ? loadServiceAccounts\n : null;\n if (!loader) {\n setResources([]);\n return;\n }\n let cancelled = false;\n setResourcesLoading(true);\n loader()\n .then((res) => !cancelled && setResources(res))\n .finally(() => !cancelled && setResourcesLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadResources, loadServiceAccounts, refKind, isKeyed, isServiceAccount]);\n\n useEffect(() => {\n if (!isKeyed || !selectedName) {\n setPreviews([]);\n return;\n }\n let cancelled = false;\n setPreviewLoading(true);\n loadKeyPreview(refKind, selectedName)\n .then((res) => !cancelled && setPreviews(res))\n .catch(() => !cancelled && setPreviews([]))\n .finally(() => !cancelled && setPreviewLoading(false));\n return () => {\n cancelled = true;\n };\n }, [loadKeyPreview, refKind, selectedName, isKeyed]);\n\n const nameOptions = useMemo<ComboboxOption[]>(\n () => resources.map((r) => ({ value: r.name, label: r.name })),\n [resources],\n );\n const selectedResource = useMemo(\n () => resources.find((r) => r.name === selectedName),\n [resources, selectedName],\n );\n const keyOptions = useMemo(\n () => buildKeyOptions(selectedResource?.keys ?? [], previews, selectedKey),\n [selectedResource, selectedKey, previews],\n );\n\n // Strict validity: the name is invalid when it names no loaded resource; the\n // key is invalid when, with a resolved resource, it isn't one of that\n // resource's keys. Only names from a listed source are checked (a\n // serviceaccount source with no loader lists nothing, so it never flags).\n const listsNames = isKeyed || (isServiceAccount && !!loadServiceAccounts);\n const nameInvalid =\n strict &&\n listsNames &&\n !!selectedName &&\n !resourcesLoading &&\n !selectedResource;\n const keyInvalid =\n strict &&\n isKeyed &&\n !!selectedKey &&\n !!selectedResource &&\n !resourcesLoading &&\n !(selectedResource.keys ?? []).includes(selectedKey);\n\n const setSource = (next: SecretValueSource) => {\n switch (next) {\n case \"value\":\n return onChange({ kind: \"value\", value: \"\" });\n case \"onepassword\":\n return onChange({ kind: \"onepassword\", ref: \"\" });\n case \"serviceaccount\":\n return onChange({ kind: \"serviceaccount\", name: \"\" });\n default:\n return onChange({ kind: next, name: \"\", key: \"\" });\n }\n };\n const setName = (name: string) => {\n if (isServiceAccount)\n return onChange(name ? { kind: \"serviceaccount\", name } : undefined);\n return onChange(\n name ? { kind: refKind, name, key: selectedKey } : undefined,\n );\n };\n const setKey = (key: string) =>\n selectedName\n ? onChange({ kind: refKind, name: selectedName, key })\n : undefined;\n const setLiteral = (v: string) => onChange({ kind: \"value\", value: v });\n const setOpRef = (ref: string) => onChange({ kind: \"onepassword\", ref });\n\n const sourceOptions = useMemo<ComboboxOption[]>(\n () =>\n sourceList.map((k) => ({\n value: k,\n label: SOURCE_LABEL[k],\n icon: createElement(SOURCE_ICON[k], { className: \"size-4\" }),\n })),\n [sourceList],\n );\n const sourceMenuOptions = useMemo<IconMenuOption<SecretValueSource>[]>(\n () =>\n sourceList.map((kind) => ({\n value: kind,\n label: SOURCE_LABEL[kind],\n icon: SOURCE_ICON[kind],\n })),\n [sourceList],\n );\n\n return (\n <div\n data-slot=\"secret-key-selector\"\n className={cn(\"@container/secret w-full min-w-0\", className)}\n >\n <div\n className=\"flex w-full max-w-full min-w-0 flex-nowrap items-center gap-2\"\n data-slot=\"secret-fields\"\n >\n <div\n className={cn(SOURCE_FIELD, \"@max-md:hidden\")}\n data-slot=\"secret-source-combobox\"\n >\n <Combobox\n ariaLabel=\"Secret value source\"\n options={sourceOptions}\n value={source}\n onChange={(next) => setSource(next as SecretValueSource)}\n allowCustomValue={false}\n required\n />\n </div>\n <div\n className=\"hidden shrink-0 @max-md:!block\"\n data-slot=\"secret-source-menu\"\n >\n <IconMenuPicker\n value={source}\n onChange={setSource}\n options={sourceMenuOptions}\n ariaLabel=\"Secret value source\"\n triggerClassName=\"size-control-h rounded-md border border-input bg-background\"\n />\n </div>\n {isLiteral ? (\n <TextField\n value={literalValue}\n onChange={setLiteral}\n placeholder=\"Static value…\"\n ariaLabel=\"Static value\"\n />\n ) : isOnePassword ? (\n (() => {\n if (!onePassword) {\n throw new Error(\n \"SecretKeySelector onepassword source requires onePassword loaders\",\n );\n }\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-onepassword-field\">\n <OnePasswordSelector\n value={opRef}\n onChange={setOpRef}\n {...onePassword}\n allowCustomValue\n />\n </div>\n );\n })()\n ) : isServiceAccount ? (\n <div\n className={VALUE_FIELD}\n data-slot=\"secret-serviceaccount-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder=\"Service account…\"\n />\n </div>\n ) : (\n <div\n className={cn(\n \"flex flex-col items-center gap-2 @min-[22rem]/secret:flex-row\",\n SHRINKABLE_FIELD,\n \"grow\",\n )}\n data-slot=\"secret-reference-fields\"\n >\n <div\n className={RESOURCE_FIELD}\n data-slot=\"secret-resource-field\"\n >\n <Combobox\n options={nameOptions}\n value={selectedName}\n onChange={setName}\n allowCustomValue\n loading={resourcesLoading}\n invalid={nameInvalid}\n placeholder={`Select ${refKind}…`}\n />\n </div>\n <div className={KEY_FIELD} data-slot=\"secret-key-field\">\n <Combobox\n options={keyOptions}\n value={selectedKey}\n onChange={setKey}\n allowCustomValue\n loading={previewLoading}\n invalid={keyInvalid}\n placeholder={selectedName ? keyPlaceholder(refKind) : \"—\"}\n />\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction TextField({\n value,\n onChange,\n placeholder,\n ariaLabel,\n}: {\n value: string;\n onChange: (v: string) => void;\n placeholder: string;\n ariaLabel: string;\n}) {\n return (\n <div className={VALUE_FIELD} data-slot=\"secret-value-fields\">\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n aria-label={ariaLabel}\n className={cn(\n \"h-control-h w-full min-w-0 rounded border border-input bg-background px-control-px text-sm\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n );\n}\n\n// isRefKind narrows to the keyed variants that carry both a name and a key.\nfunction isRefKind(\n v: SecretKeyValue,\n): v is { kind: SecretKind; name: string; key: string } {\n return v.kind === \"secret\" || v.kind === \"configmap\" || v.kind === \"helm\";\n}\n\n// keyPlaceholder hints the key field: helm keys are jsonpath expressions into\n// the merged release values, the others are literal data keys.\nfunction keyPlaceholder(kind: SecretKind): string {\n return kind === \"helm\" ? \"jsonpath…\" : \"Key…\";\n}\n\n// Each source's leading glyph. The flanksource FCs carry static metadata that\n// doesn't unify with ComponentType, so type the slot as a plain render function.\nconst SOURCE_ICON: Record<SecretValueSource, StaticIconComponent> = {\n secret: K8SSecret,\n configmap: K8SConfigmap,\n helm: Helm,\n serviceaccount: K8SServiceaccount,\n onepassword: Vault,\n value: UiEdit,\n};\n\nconst SOURCE_LABEL: Record<SecretValueSource, string> = {\n secret: \"Secret\",\n configmap: \"ConfigMap\",\n helm: \"Helm\",\n serviceaccount: \"Service Account\",\n onepassword: \"1Password\",\n value: \"Value\",\n};\n\n// buildKeyOptions labels each key with its mid-masked preview value when one is\n// available. A selected key absent from the list is pinned so the selection\n// stays visible.\nfunction buildKeyOptions(\n keys: string[],\n previews: KeyPreview[],\n selectedKey: string,\n): ComboboxOption[] {\n const masked = new Map(previews.map((p) => [p.key, p.value]));\n const base = keys.map((k) => ({\n value: k,\n label: masked.has(k) ? `${k} — ${masked.get(k)}` : k,\n }));\n if (selectedKey && !base.some((o) => o.value === selectedKey)) {\n return [{ value: selectedKey, label: selectedKey }, ...base];\n }\n return base;\n}\n"],"names":[],"mappings":";;;;;;;;AAsFA,MAAM,kBAAuC,CAAC,UAAU,aAAa,OAAO;AAE5E,MAAM,mBAAmB;AACzB,MAAM,eAAe,GAAG,gBAAgB;AACxC,MAAM,iBAAiB,GAAG,gBAAgB;AAC1C,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,cAAc,GAAG,gBAAgB;AAEhC,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,EACT;AACF,GAA2B;AACzB,QAAM,aAAa;AAAA,IACjB,MAAM,YAAY,eAAe,kBAAkB,CAAC,UAAU,WAAW;AAAA,IACzE,CAAC,SAAS,YAAY;AAAA,EAAA;AAGxB,QAAM,UAA4B,+BAAO,SAAQ,WAAW,CAAC,KAAK;AAClE,QAAM,UACJ,WAAW,YAAY,WAAW,eAAe,WAAW;AAC9D,QAAM,mBAAmB,WAAW;AACpC,QAAM,gBAAgB,WAAW;AACjC,QAAM,YAAY,WAAW;AAE7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AQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,OAAO;AACT;AAKA,SAAS,gBACP,MACA,UACA,aACkB;AAClB,QAAM,SAAS,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5D,QAAM,OAAO,KAAK,IAAI,CAAC,OAAO;AAAA,IAC5B,OAAO;AAAA,IACP,OAAO,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC,KAAK;AAAA,EAAA,EACnD;AACF,MAAI,eAAe,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,UAAU,WAAW,GAAG;AAC7D,WAAO,CAAC,EAAE,OAAO,aAAa,OAAO,YAAA,GAAe,GAAG,IAAI;AAAA,EAC7D;AACA,SAAO;AACT;"}
@@ -1,6 +1,6 @@
1
1
  export declare const badgeVariants: (props?: ({
2
- tone?: "neutral" | "info" | "warning" | "success" | "danger" | null | undefined;
3
- variant?: "solid" | "outline" | "soft" | null | undefined;
2
+ tone?: "neutral" | "info" | "success" | "warning" | "danger" | null | undefined;
3
+ variant?: "soft" | "solid" | "outline" | null | undefined;
4
4
  size?: "xs" | "sm" | "md" | "lg" | "xxs" | null | undefined;
5
5
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
6
  //# sourceMappingURL=badge-variants.d.ts.map
@@ -15,9 +15,9 @@ function detectMode() {
15
15
  }
16
16
  function getVersionInfo() {
17
17
  return {
18
- commit: read(() => "ead3d947", ""),
19
- tag: read(() => "clicky-ui@0.3.31", ""),
20
- date: read(() => "2026-09-03T12:37:55.646Z", ""),
18
+ commit: read(() => "3bff864a", ""),
19
+ tag: read(() => "clicky-ui@0.3.33", ""),
20
+ date: read(() => "2026-09-03T18:57:19.779Z", ""),
21
21
  dirty: read(() => true, false),
22
22
  mode: detectMode()
23
23
  };
@@ -13,9 +13,9 @@ function detectMode() {
13
13
  }
14
14
  function getVersionInfo() {
15
15
  return {
16
- commit: read(() => "ead3d947", ""),
17
- tag: read(() => "clicky-ui@0.3.31", ""),
18
- date: read(() => "2026-09-03T12:37:31.755Z", ""),
16
+ commit: read(() => "3bff864a", ""),
17
+ tag: read(() => "clicky-ui@0.3.33", ""),
18
+ date: read(() => "2026-09-03T18:56:55.887Z", ""),
19
19
  dirty: read(() => true, false),
20
20
  mode: detectMode()
21
21
  };
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const utils = require("./lib/utils.cjs");
4
+ const commentStage = require("./lib/comment-stage.cjs");
4
5
  const collections = require("./lib/collections.cjs");
5
6
  const palette = require("./lib/palette.cjs");
6
7
  const size = require("./lib/size.cjs");
@@ -625,6 +626,9 @@ const useClickyExport = require("./data/clicky-export/useClickyExport.cjs");
625
626
  const adapters = require("./data/verification/adapters.cjs");
626
627
  const verifyReportTests = require("./data/verification/verifyReportTests.cjs");
627
628
  exports.cn = utils.cn;
629
+ exports.resolveCommentStage = commentStage.resolveCommentStage;
630
+ exports.selectCommentThreadsByStage = commentStage.selectCommentThreadsByStage;
631
+ exports.statusForCommentStage = commentStage.statusForCommentStage;
628
632
  exports.duplicateIndex = collections.duplicateIndex;
629
633
  exports.isPlainObject = collections.isPlainObject;
630
634
  exports.moveItem = collections.moveItem;
@@ -1054,14 +1058,11 @@ exports.hasActiveFilters = commentUtils.hasActiveFilters;
1054
1058
  exports.isUnresolved = commentUtils.isUnresolved;
1055
1059
  exports.matchMentionsInBody = commentUtils.matchMentionsInBody;
1056
1060
  exports.nextChecklistStatus = commentUtils.nextChecklistStatus;
1057
- exports.resolveCommentStage = commentUtils.resolveCommentStage;
1058
1061
  exports.resolveFacetOption = commentUtils.resolveFacetOption;
1059
1062
  exports.resolveStatusConfig = commentUtils.resolveStatusConfig;
1060
1063
  exports.selectAnchorThreads = commentUtils.selectAnchorThreads;
1061
- exports.selectCommentThreadsByStage = commentUtils.selectCommentThreadsByStage;
1062
1064
  exports.selectUnresolvedThreads = commentUtils.selectUnresolvedThreads;
1063
1065
  exports.sortReplies = commentUtils.sortReplies;
1064
- exports.statusForCommentStage = commentUtils.statusForCommentStage;
1065
1066
  exports.toneToBadgeTone = commentUtils.toneToBadgeTone;
1066
1067
  exports.truncatePlain = commentUtils.truncatePlain;
1067
1068
  exports.CommentMarkdown = CommentMarkdown.CommentMarkdown;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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entStage, selectCommentThreadsByStage, statusForCommentStage } from "./lib/comment-stage.js";
2
3
  import { duplicateIndex, isPlainObject, moveItem, removeIndex, setIndex } from "./lib/collections.js";
3
4
  import { AVATAR_PALETTE, fnv1a32, paletteClass } from "./lib/palette.js";
4
5
  import { SIZE_TOKENS, resolveSize } from "./lib/size.js";
@@ -212,7 +213,7 @@ import { CopyBadge, ErrorDetails, PrettyStackTrace } from "./data/diagnostics/Er
212
213
  import { compactStackPath, isApplicationStackFrame, normalizeErrorDiagnostics, parseDiagnosticsStackTrace, parseInlineJsonContextValue } from "./data/diagnostics/error-diagnostics.js";
213
214
  import { HarPanel } from "./data/har/HarPanel.js";
214
215
  import { DEFAULT_CHECKLIST_CYCLE, DEFAULT_COMMENT_STATUSES, DOCUMENT_ANCHOR } from "./comments/comment-types.js";
215
- import { applyCommentFilters, authorDisplayName, buildReplyMap, buildThreadListHandlers, commentCountForPrefix, defaultStatusValue, deriveAnchorCounts, deriveAnchorMeta, emptyCommentFilters, getRoots, groupByFacet, hasActiveFilters, isUnresolved, matchMentionsInBody, nextChecklistStatus, resolveCommentStage, resolveFacetOption, resolveStatusConfig, selectAnchorThreads, selectCommentThreadsByStage, selectUnresolvedThreads, sortReplies, statusForCommentStage, toneToBadgeTone, truncatePlain } from "./comments/comment-utils.js";
216
+ import { applyCommentFilters, authorDisplayName, buildReplyMap, buildThreadListHandlers, commentCountForPrefix, defaultStatusValue, deriveAnchorCounts, deriveAnchorMeta, emptyCommentFilters, getRoots, groupByFacet, hasActiveFilters, isUnresolved, matchMentionsInBody, nextChecklistStatus, resolveFacetOption, resolveStatusConfig, selectAnchorThreads, selectUnresolvedThreads, sortReplies, toneToBadgeTone, truncatePlain } from "./comments/comment-utils.js";
216
217
  import { CommentMarkdown } from "./comments/CommentMarkdown.js";
217
218
  import { CommentAuthorAvatar } from "./comments/CommentAuthor.js";
218
219
  import { MentionTextarea } from "./comments/MentionTextarea.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
-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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const commentUtils = require("../comments/comment-utils.cjs");
4
+ function resolveCommentStage(config, status) {
5
+ if (status == null) return "active";
6
+ const resolved = commentUtils.resolveStatusConfig(config, status);
7
+ if (!resolved) return void 0;
8
+ if (resolved.stage) return resolved.stage;
9
+ if (resolved.unresolved) return "active";
10
+ if (resolved.value.toLowerCase() === "closed" || resolved.label.toLowerCase() === "closed") {
11
+ return "closed";
12
+ }
13
+ return "resolved";
14
+ }
15
+ function statusForCommentStage(config, stage) {
16
+ return config.statuses.find(
17
+ (status) => resolveCommentStage(config, status.value) === stage
18
+ );
19
+ }
20
+ function selectCommentThreadsByStage(comments, config, stage) {
21
+ const keep = new Set(
22
+ commentUtils.getRoots(comments).filter((root) => resolveCommentStage(config, root.status) === stage).map((root) => String(root.id))
23
+ );
24
+ return comments.filter(
25
+ (comment) => keep.has(String(comment.parentId ?? comment.id))
26
+ );
27
+ }
28
+ exports.resolveCommentStage = resolveCommentStage;
29
+ exports.selectCommentThreadsByStage = selectCommentThreadsByStage;
30
+ exports.statusForCommentStage = statusForCommentStage;
31
+ //# sourceMappingURL=comment-stage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-stage.cjs","sources":["../../src/lib/comment-stage.ts"],"sourcesContent":["import type {\n Comment,\n CommentConfig,\n CommentStatusConfig,\n CommentStatusStage,\n} from \"../comments/comment-types\";\nimport { getRoots, resolveStatusConfig } from \"../comments/comment-utils\";\n\n/** Resolves a stored status to its lifecycle stage. */\nexport function resolveCommentStage(\n config: CommentConfig,\n status: string | undefined,\n): CommentStatusStage | undefined {\n if (status == null) return \"active\";\n const resolved = resolveStatusConfig(config, status);\n if (!resolved) return undefined;\n if (resolved.stage) return resolved.stage;\n if (resolved.unresolved) return \"active\";\n if (\n resolved.value.toLowerCase() === \"closed\" ||\n resolved.label.toLowerCase() === \"closed\"\n ) {\n return \"closed\";\n }\n return \"resolved\";\n}\n\n/** Returns the first configured stored status for a lifecycle stage. */\nexport function statusForCommentStage(\n config: CommentConfig,\n stage: CommentStatusStage,\n): CommentStatusConfig | undefined {\n return config.statuses.find(\n (status) => resolveCommentStage(config, status.value) === stage,\n );\n}\n\n/** Selects roots in one lifecycle stage together with every descendant reply. */\nexport function selectCommentThreadsByStage(\n comments: Comment[],\n config: CommentConfig,\n stage: CommentStatusStage,\n): Comment[] {\n const keep = new Set(\n getRoots(comments)\n .filter((root) => resolveCommentStage(config, root.status) === stage)\n .map((root) => String(root.id)),\n );\n return comments.filter((comment) =>\n keep.has(String(comment.parentId ?? comment.id)),\n );\n}\n"],"names":["resolveStatusConfig","getRoots"],"mappings":";;;AASO,SAAS,oBACd,QACA,QACgC;AAChC,MAAI,UAAU,KAAM,QAAO;AAC3B,QAAM,WAAWA,aAAAA,oBAAoB,QAAQ,MAAM;AACnD,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,SAAS,MAAO,QAAO,SAAS;AACpC,MAAI,SAAS,WAAY,QAAO;AAChC,MACE,SAAS,MAAM,kBAAkB,YACjC,SAAS,MAAM,YAAA,MAAkB,UACjC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,sBACd,QACA,OACiC;AACjC,SAAO,OAAO,SAAS;AAAA,IACrB,CAAC,WAAW,oBAAoB,QAAQ,OAAO,KAAK,MAAM;AAAA,EAAA;AAE9D;AAGO,SAAS,4BACd,UACA,QACA,OACW;AACX,QAAM,OAAO,IAAI;AAAA,IACfC,aAAAA,SAAS,QAAQ,EACd,OAAO,CAAC,SAAS,oBAAoB,QAAQ,KAAK,MAAM,MAAM,KAAK,EACnE,IAAI,CAAC,SAAS,OAAO,KAAK,EAAE,CAAC;AAAA,EAAA;AAElC,SAAO,SAAS;AAAA,IAAO,CAAC,YACtB,KAAK,IAAI,OAAO,QAAQ,YAAY,QAAQ,EAAE,CAAC;AAAA,EAAA;AAEnD;;;;"}
@@ -0,0 +1,8 @@
1
+ import { Comment, CommentConfig, CommentStatusConfig, CommentStatusStage } from '../comments/comment-types';
2
+ /** Resolves a stored status to its lifecycle stage. */
3
+ export declare function resolveCommentStage(config: CommentConfig, status: string | undefined): CommentStatusStage | undefined;
4
+ /** Returns the first configured stored status for a lifecycle stage. */
5
+ export declare function statusForCommentStage(config: CommentConfig, stage: CommentStatusStage): CommentStatusConfig | undefined;
6
+ /** Selects roots in one lifecycle stage together with every descendant reply. */
7
+ export declare function selectCommentThreadsByStage(comments: Comment[], config: CommentConfig, stage: CommentStatusStage): Comment[];
8
+ //# sourceMappingURL=comment-stage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-stage.d.ts","sourceRoot":"","sources":["../../src/lib/comment-stage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAGnC,uDAAuD;AACvD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,kBAAkB,GAAG,SAAS,CAahC;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,kBAAkB,GACxB,mBAAmB,GAAG,SAAS,CAIjC;AAED,iFAAiF;AACjF,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,kBAAkB,GACxB,OAAO,EAAE,CASX"}
@@ -0,0 +1,31 @@
1
+ import { resolveStatusConfig, getRoots } from "../comments/comment-utils.js";
2
+ function resolveCommentStage(config, status) {
3
+ if (status == null) return "active";
4
+ const resolved = resolveStatusConfig(config, status);
5
+ if (!resolved) return void 0;
6
+ if (resolved.stage) return resolved.stage;
7
+ if (resolved.unresolved) return "active";
8
+ if (resolved.value.toLowerCase() === "closed" || resolved.label.toLowerCase() === "closed") {
9
+ return "closed";
10
+ }
11
+ return "resolved";
12
+ }
13
+ function statusForCommentStage(config, stage) {
14
+ return config.statuses.find(
15
+ (status) => resolveCommentStage(config, status.value) === stage
16
+ );
17
+ }
18
+ function selectCommentThreadsByStage(comments, config, stage) {
19
+ const keep = new Set(
20
+ getRoots(comments).filter((root) => resolveCommentStage(config, root.status) === stage).map((root) => String(root.id))
21
+ );
22
+ return comments.filter(
23
+ (comment) => keep.has(String(comment.parentId ?? comment.id))
24
+ );
25
+ }
26
+ export {
27
+ resolveCommentStage,
28
+ selectCommentThreadsByStage,
29
+ statusForCommentStage
30
+ };
31
+ //# sourceMappingURL=comment-stage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-stage.js","sources":["../../src/lib/comment-stage.ts"],"sourcesContent":["import type {\n Comment,\n CommentConfig,\n CommentStatusConfig,\n CommentStatusStage,\n} from \"../comments/comment-types\";\nimport { getRoots, resolveStatusConfig } from \"../comments/comment-utils\";\n\n/** Resolves a stored status to its lifecycle stage. */\nexport function resolveCommentStage(\n config: CommentConfig,\n status: string | undefined,\n): CommentStatusStage | undefined {\n if (status == null) return \"active\";\n const resolved = resolveStatusConfig(config, status);\n if (!resolved) return undefined;\n if (resolved.stage) return resolved.stage;\n if (resolved.unresolved) return \"active\";\n if (\n resolved.value.toLowerCase() === \"closed\" ||\n resolved.label.toLowerCase() === \"closed\"\n ) {\n return \"closed\";\n }\n return \"resolved\";\n}\n\n/** Returns the first configured stored status for a lifecycle stage. */\nexport function statusForCommentStage(\n config: CommentConfig,\n stage: CommentStatusStage,\n): CommentStatusConfig | undefined {\n return config.statuses.find(\n (status) => resolveCommentStage(config, status.value) === stage,\n );\n}\n\n/** Selects roots in one lifecycle stage together with every descendant reply. */\nexport function selectCommentThreadsByStage(\n comments: Comment[],\n config: CommentConfig,\n stage: CommentStatusStage,\n): Comment[] {\n const keep = new Set(\n getRoots(comments)\n .filter((root) => resolveCommentStage(config, root.status) === stage)\n .map((root) => String(root.id)),\n );\n return comments.filter((comment) =>\n keep.has(String(comment.parentId ?? comment.id)),\n );\n}\n"],"names":[],"mappings":";AASO,SAAS,oBACd,QACA,QACgC;AAChC,MAAI,UAAU,KAAM,QAAO;AAC3B,QAAM,WAAW,oBAAoB,QAAQ,MAAM;AACnD,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,SAAS,MAAO,QAAO,SAAS;AACpC,MAAI,SAAS,WAAY,QAAO;AAChC,MACE,SAAS,MAAM,kBAAkB,YACjC,SAAS,MAAM,YAAA,MAAkB,UACjC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,sBACd,QACA,OACiC;AACjC,SAAO,OAAO,SAAS;AAAA,IACrB,CAAC,WAAW,oBAAoB,QAAQ,OAAO,KAAK,MAAM;AAAA,EAAA;AAE9D;AAGO,SAAS,4BACd,UACA,QACA,OACW;AACX,QAAM,OAAO,IAAI;AAAA,IACf,SAAS,QAAQ,EACd,OAAO,CAAC,SAAS,oBAAoB,QAAQ,KAAK,MAAM,MAAM,KAAK,EACnE,IAAI,CAAC,SAAS,OAAO,KAAK,EAAE,CAAC;AAAA,EAAA;AAElC,SAAO,SAAS;AAAA,IAAO,CAAC,YACtB,KAAK,IAAI,OAAO,QAAQ,YAAY,QAAQ,EAAE,CAAC;AAAA,EAAA;AAEnD;"}