pepr 0.32.1 → 0.32.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.
Files changed (79) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +2849 -0
  4. package/dist/controller.js +164 -0
  5. package/dist/lib/assets/deploy.d.ts +3 -0
  6. package/dist/lib/assets/deploy.d.ts.map +1 -0
  7. package/dist/lib/assets/destroy.d.ts +2 -0
  8. package/dist/lib/assets/destroy.d.ts.map +1 -0
  9. package/dist/lib/assets/helm.d.ts +5 -0
  10. package/dist/lib/assets/helm.d.ts.map +1 -0
  11. package/dist/lib/assets/index.d.ts +25 -0
  12. package/dist/lib/assets/index.d.ts.map +1 -0
  13. package/dist/lib/assets/loader.d.ts +8 -0
  14. package/dist/lib/assets/loader.d.ts.map +1 -0
  15. package/dist/lib/assets/networking.d.ts +7 -0
  16. package/dist/lib/assets/networking.d.ts.map +1 -0
  17. package/dist/lib/assets/pods.d.ts +126 -0
  18. package/dist/lib/assets/pods.d.ts.map +1 -0
  19. package/dist/lib/assets/rbac.d.ts +14 -0
  20. package/dist/lib/assets/rbac.d.ts.map +1 -0
  21. package/dist/lib/assets/store.d.ts +7 -0
  22. package/dist/lib/assets/store.d.ts.map +1 -0
  23. package/dist/lib/assets/webhooks.d.ts +6 -0
  24. package/dist/lib/assets/webhooks.d.ts.map +1 -0
  25. package/dist/lib/assets/yaml.d.ts +6 -0
  26. package/dist/lib/assets/yaml.d.ts.map +1 -0
  27. package/dist/lib/capability.d.ts +66 -0
  28. package/dist/lib/capability.d.ts.map +1 -0
  29. package/dist/lib/controller/index.d.ts +10 -0
  30. package/dist/lib/controller/index.d.ts.map +1 -0
  31. package/dist/lib/controller/store.d.ts +7 -0
  32. package/dist/lib/controller/store.d.ts.map +1 -0
  33. package/dist/lib/errors.d.ts +12 -0
  34. package/dist/lib/errors.d.ts.map +1 -0
  35. package/dist/lib/filter.d.ts +11 -0
  36. package/dist/lib/filter.d.ts.map +1 -0
  37. package/dist/lib/helpers.d.ts +34 -0
  38. package/dist/lib/helpers.d.ts.map +1 -0
  39. package/dist/lib/included-files.d.ts +2 -0
  40. package/dist/lib/included-files.d.ts.map +1 -0
  41. package/dist/lib/k8s.d.ts +132 -0
  42. package/dist/lib/k8s.d.ts.map +1 -0
  43. package/dist/lib/logger.d.ts +3 -0
  44. package/dist/lib/logger.d.ts.map +1 -0
  45. package/dist/lib/metrics.d.ts +39 -0
  46. package/dist/lib/metrics.d.ts.map +1 -0
  47. package/dist/lib/module.d.ts +62 -0
  48. package/dist/lib/module.d.ts.map +1 -0
  49. package/dist/lib/mutate-processor.d.ts +5 -0
  50. package/dist/lib/mutate-processor.d.ts.map +1 -0
  51. package/dist/lib/mutate-request.d.ts +79 -0
  52. package/dist/lib/mutate-request.d.ts.map +1 -0
  53. package/dist/lib/queue.d.ts +19 -0
  54. package/dist/lib/queue.d.ts.map +1 -0
  55. package/dist/lib/schedule.d.ts +76 -0
  56. package/dist/lib/schedule.d.ts.map +1 -0
  57. package/dist/lib/storage.d.ts +83 -0
  58. package/dist/lib/storage.d.ts.map +1 -0
  59. package/dist/lib/tls.d.ts +18 -0
  60. package/dist/lib/tls.d.ts.map +1 -0
  61. package/dist/lib/types.d.ts +192 -0
  62. package/dist/lib/types.d.ts.map +1 -0
  63. package/dist/lib/utils.d.ts +23 -0
  64. package/dist/lib/utils.d.ts.map +1 -0
  65. package/dist/lib/validate-processor.d.ts +4 -0
  66. package/dist/lib/validate-processor.d.ts.map +1 -0
  67. package/dist/lib/validate-request.d.ts +55 -0
  68. package/dist/lib/validate-request.d.ts.map +1 -0
  69. package/dist/lib/watch-processor.d.ts +10 -0
  70. package/dist/lib/watch-processor.d.ts.map +1 -0
  71. package/dist/lib.d.ts +11 -0
  72. package/dist/lib.d.ts.map +1 -0
  73. package/dist/lib.js +1808 -0
  74. package/dist/lib.js.map +7 -0
  75. package/dist/runtime/controller.d.ts +3 -0
  76. package/dist/runtime/controller.d.ts.map +1 -0
  77. package/dist/sdk/sdk.d.ts +38 -0
  78. package/dist/sdk/sdk.d.ts.map +1 -0
  79. package/package.json +1 -1
@@ -0,0 +1,192 @@
1
+ import { GenericClass, GroupVersionKind, KubernetesObject } from "kubernetes-fluent-client";
2
+ import { WatchAction } from "kubernetes-fluent-client/dist/fluent/types";
3
+ import { PeprMutateRequest } from "./mutate-request";
4
+ import { PeprValidateRequest } from "./validate-request";
5
+ /**
6
+ * Specifically for parsing logs in monitor mode
7
+ */
8
+ export interface ResponseItem {
9
+ uid?: string;
10
+ allowed: boolean;
11
+ status: {
12
+ message: string;
13
+ };
14
+ }
15
+ /**
16
+ * Recursively make all properties in T optional.
17
+ */
18
+ export type DeepPartial<T> = {
19
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
20
+ };
21
+ /**
22
+ * The type of Kubernetes mutating webhook event that the action is registered for.
23
+ */
24
+ export declare enum Event {
25
+ Create = "CREATE",
26
+ Update = "UPDATE",
27
+ Delete = "DELETE",
28
+ CreateOrUpdate = "CREATEORUPDATE",
29
+ Any = "*"
30
+ }
31
+ export interface CapabilityCfg {
32
+ /**
33
+ * The name of the capability. This should be unique.
34
+ */
35
+ name: string;
36
+ /**
37
+ * A description of the capability and what it does.
38
+ */
39
+ description: string;
40
+ /**
41
+ * List of namespaces that this capability applies to, if empty, applies to all namespaces (cluster-wide).
42
+ * This does not supersede the `alwaysIgnore` global configuration.
43
+ */
44
+ namespaces?: string[];
45
+ }
46
+ export interface CapabilityExport extends CapabilityCfg {
47
+ bindings: Binding[];
48
+ hasSchedule: boolean;
49
+ }
50
+ export type WhenSelector<T extends GenericClass> = {
51
+ /** Register an action to be executed when a Kubernetes resource is created or updated. */
52
+ IsCreatedOrUpdated: () => BindingAll<T>;
53
+ /** Register an action to be executed when a Kubernetes resource is created. */
54
+ IsCreated: () => BindingAll<T>;
55
+ /** Register ann action to be executed when a Kubernetes resource is updated. */
56
+ IsUpdated: () => BindingAll<T>;
57
+ /** Register an action to be executed when a Kubernetes resource is deleted. */
58
+ IsDeleted: () => BindingAll<T>;
59
+ };
60
+ export type Binding = {
61
+ event: Event;
62
+ isMutate?: boolean;
63
+ isValidate?: boolean;
64
+ isWatch?: boolean;
65
+ isQueue?: boolean;
66
+ readonly model: GenericClass;
67
+ readonly kind: GroupVersionKind;
68
+ readonly filters: {
69
+ name: string;
70
+ namespaces: string[];
71
+ labels: Record<string, string>;
72
+ annotations: Record<string, string>;
73
+ };
74
+ readonly mutateCallback?: MutateAction<GenericClass, InstanceType<GenericClass>>;
75
+ readonly validateCallback?: ValidateAction<GenericClass, InstanceType<GenericClass>>;
76
+ readonly watchCallback?: WatchAction<GenericClass, InstanceType<GenericClass>>;
77
+ };
78
+ export type BindingFilter<T extends GenericClass> = CommonActionChain<T> & {
79
+ /**
80
+ * Only apply the action if the resource has the specified label. If no value is specified, the label must exist.
81
+ * Note multiple calls to this method will result in an AND condition. e.g.
82
+ *
83
+ * ```ts
84
+ * When(a.Deployment)
85
+ * .IsCreated()
86
+ * .WithLabel("foo", "bar")
87
+ * .WithLabel("baz", "qux")
88
+ * .Mutate(...)
89
+ * ```
90
+ *
91
+ * Will only apply the action if the resource has both the `foo=bar` and `baz=qux` labels.
92
+ *
93
+ * @param key
94
+ * @param value
95
+ */
96
+ WithLabel: (key: string, value?: string) => BindingFilter<T>;
97
+ /**
98
+ * Only apply the action if the resource has the specified annotation. If no value is specified, the annotation must exist.
99
+ * Note multiple calls to this method will result in an AND condition. e.g.
100
+ *
101
+ * ```ts
102
+ * When(a.Deployment)
103
+ * .IsCreated()
104
+ * .WithAnnotation("foo", "bar")
105
+ * .WithAnnotation("baz", "qux")
106
+ * .Mutate(...)
107
+ * ```
108
+ *
109
+ * Will only apply the action if the resource has both the `foo=bar` and `baz=qux` annotations.
110
+ *
111
+ * @param key
112
+ * @param value
113
+ */
114
+ WithAnnotation: (key: string, value?: string) => BindingFilter<T>;
115
+ };
116
+ export type BindingWithName<T extends GenericClass> = BindingFilter<T> & {
117
+ /** Only apply the action if the resource name matches the specified name. */
118
+ WithName: (name: string) => BindingFilter<T>;
119
+ };
120
+ export type BindingAll<T extends GenericClass> = BindingWithName<T> & {
121
+ /** Only apply the action if the resource is in one of the specified namespaces.*/
122
+ InNamespace: (...namespaces: string[]) => BindingWithName<T>;
123
+ };
124
+ export type CommonActionChain<T extends GenericClass> = MutateActionChain<T> & {
125
+ /**
126
+ * Create a new MUTATE action with the specified callback function and previously specified
127
+ * filters.
128
+ *
129
+ * @since 0.13.0
130
+ *
131
+ * @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
132
+ */
133
+ Mutate: (action: MutateAction<T, InstanceType<T>>) => MutateActionChain<T>;
134
+ };
135
+ export type ValidateActionChain<T extends GenericClass> = {
136
+ /**
137
+ * Establish a watcher for the specified resource. The callback function will be executed after the admission controller has
138
+ * processed the resource and the request has been persisted to the cluster.
139
+ *
140
+ * **Beta Function**: This method is still in early testing and edge cases may still exist.
141
+ *
142
+ * @since 0.14.0
143
+ *
144
+ * @param action
145
+ * @returns
146
+ */
147
+ Watch: (action: WatchAction<T, InstanceType<T>>) => void;
148
+ /**
149
+ * Establish a reconcile for the specified resource. The callback function will be executed after the admission controller has
150
+ * processed the resource and the request has been persisted to the cluster.
151
+ *
152
+ * **Beta Function**: This method is still in early testing and edge cases may still exist.
153
+ *
154
+ * @since 0.14.0
155
+ *
156
+ * @param action
157
+ * @returns
158
+ */
159
+ Reconcile: (action: WatchAction<T, InstanceType<T>>) => void;
160
+ };
161
+ export type MutateActionChain<T extends GenericClass> = ValidateActionChain<T> & {
162
+ /**
163
+ * Create a new VALIDATE action with the specified callback function and previously specified
164
+ * filters. Return the `request.Approve()` or `Request.Deny()` methods to approve or deny the request:
165
+ *
166
+ * @since 0.13.0
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * When(a.Deployment)
171
+ * .IsCreated()
172
+ * .Validate(request => {
173
+ * if (request.HasLabel("foo")) {
174
+ * return request.Approve();
175
+ * }
176
+ *
177
+ * return request.Deny("Deployment must have label foo");
178
+ * });
179
+ * ```
180
+ *
181
+ * @param action The action to be executed when the Kubernetes resource is processed by the AdmissionController.
182
+ */
183
+ Validate: (action: ValidateAction<T, InstanceType<T>>) => ValidateActionChain<T>;
184
+ };
185
+ export type MutateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: PeprMutateRequest<K>) => Promise<void> | void | Promise<PeprMutateRequest<K>> | PeprMutateRequest<K>;
186
+ export type ValidateAction<T extends GenericClass, K extends KubernetesObject = InstanceType<T>> = (req: PeprValidateRequest<K>) => Promise<ValidateActionResponse> | ValidateActionResponse;
187
+ export type ValidateActionResponse = {
188
+ allowed: boolean;
189
+ statusCode?: number;
190
+ statusMessage?: string;
191
+ };
192
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AACD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,C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C,GAAG,sBAAsB,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** Test if a string is ascii or not */
2
+ export declare const isAscii: RegExp;
3
+ /**
4
+ * Encode all ascii values in a map to base64
5
+ * @param obj The object to encode
6
+ * @param skip A list of keys to skip encoding
7
+ */
8
+ export declare function convertToBase64Map(obj: {
9
+ data?: Record<string, string>;
10
+ }, skip: string[]): void;
11
+ /**
12
+ * Decode all ascii values in a map from base64 to utf-8
13
+ * @param obj The object to decode
14
+ * @returns A list of keys that were skipped
15
+ */
16
+ export declare function convertFromBase64Map(obj: {
17
+ data?: Record<string, string>;
18
+ }): string[];
19
+ /** Decode a base64 string */
20
+ export declare function base64Decode(data: string): string;
21
+ /** Encode a string to base64 */
22
+ export declare function base64Encode(data: string): string;
23
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAKA,uCAAuC;AACvC,eAAO,MAAM,OAAO,QAAqB,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAOxF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,YAmB1E;AAED,6BAA6B;AAC7B,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAExC;AAED,gCAAgC;AAChC,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAExC"}
@@ -0,0 +1,4 @@
1
+ import { Capability } from "./capability";
2
+ import { AdmissionRequest, ValidateResponse } from "./k8s";
3
+ export declare function validateProcessor(capabilities: Capability[], req: AdmissionRequest, reqMetadata: Record<string, string>): Promise<ValidateResponse[]>;
4
+ //# sourceMappingURL=validate-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-processor.d.ts","sourceRoot":"","sources":["../../src/lib/validate-processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAK3D,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA+D7B"}
@@ -0,0 +1,55 @@
1
+ import { KubernetesObject } from "kubernetes-fluent-client";
2
+ import { AdmissionRequest } from "./k8s";
3
+ import { ValidateActionResponse } from "./types";
4
+ /**
5
+ * The RequestWrapper class provides methods to modify Kubernetes objects in the context
6
+ * of a mutating webhook request.
7
+ */
8
+ export declare class PeprValidateRequest<T extends KubernetesObject> {
9
+ #private;
10
+ Raw: T;
11
+ /**
12
+ * Provides access to the old resource in the request if available.
13
+ * @returns The old Kubernetes resource object or null if not available.
14
+ */
15
+ get OldResource(): T | undefined;
16
+ /**
17
+ * Provides access to the request object.
18
+ * @returns The request object containing the Kubernetes resource.
19
+ */
20
+ get Request(): AdmissionRequest<T>;
21
+ /**
22
+ * Creates a new instance of the Action class.
23
+ * @param input - The request object containing the Kubernetes resource to modify.
24
+ */
25
+ constructor(input: AdmissionRequest<T>);
26
+ /**
27
+ * Check if a label exists on the Kubernetes resource.
28
+ *
29
+ * @param key the label key to check
30
+ * @returns
31
+ */
32
+ HasLabel: (key: string) => boolean;
33
+ /**
34
+ * Check if an annotation exists on the Kubernetes resource.
35
+ *
36
+ * @param key the annotation key to check
37
+ * @returns
38
+ */
39
+ HasAnnotation: (key: string) => boolean;
40
+ /**
41
+ * Create a validation response that allows the request.
42
+ *
43
+ * @returns The validation response.
44
+ */
45
+ Approve: () => ValidateActionResponse;
46
+ /**
47
+ * Create a validation response that denies the request.
48
+ *
49
+ * @param statusMessage Optional status message to return to the user.
50
+ * @param statusCode Optional status code to return to the user.
51
+ * @returns The validation response.
52
+ */
53
+ Deny: (statusMessage?: string, statusCode?: number) => ValidateActionResponse;
54
+ }
55
+ //# sourceMappingURL=validate-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-request.d.ts","sourceRoot":"","sources":["../../src/lib/validate-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAa,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,gBAAgB;;IACzD,GAAG,EAAE,CAAC,CAAC;IAIP;;;OAGG;IACH,IAAI,WAAW,kBAEd;IAED;;;OAGG;IACH,IAAI,OAAO,wBAEV;IAED;;;OAGG;gBACS,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAgBtC;;;;;OAKG;IACH,QAAQ,QAAS,MAAM,aAErB;IAEF;;;;;OAKG;IACH,aAAa,QAAS,MAAM,aAE1B;IAEF;;;;OAIG;IACH,OAAO,QAAO,sBAAsB,CAIlC;IAEF;;;;;;OAMG;IACH,IAAI,mBAAoB,MAAM,eAAe,MAAM,KAAG,sBAAsB,CAM1E;CACH"}
@@ -0,0 +1,10 @@
1
+ import { KubernetesObject, WatchEvent } from "kubernetes-fluent-client";
2
+ import { Capability } from "./capability";
3
+ /**
4
+ * Entrypoint for setting up watches for all capabilities
5
+ *
6
+ * @param capabilities The capabilities to load watches for
7
+ */
8
+ export declare function setupWatch(capabilities: Capability[]): void;
9
+ export declare function logEvent(type: WatchEvent, message?: string, obj?: KubernetesObject): void;
10
+ //# sourceMappingURL=watch-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,gBAAgB,EAAY,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAwB1C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,QAMpD;AA6ED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,MAAW,EAAE,GAAG,CAAC,EAAE,gBAAgB,QAOtF"}
package/dist/lib.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { K8s, RegisterKind, kind as a, fetch, fetchStatus, kind } from "kubernetes-fluent-client";
2
+ import * as R from "ramda";
3
+ import { Capability } from "./lib/capability";
4
+ import Log from "./lib/logger";
5
+ import { PeprModule } from "./lib/module";
6
+ import { PeprMutateRequest } from "./lib/mutate-request";
7
+ import * as PeprUtils from "./lib/utils";
8
+ import { PeprValidateRequest } from "./lib/validate-request";
9
+ import * as sdk from "./sdk/sdk";
10
+ export { Capability, K8s, Log, PeprModule, PeprMutateRequest, PeprUtils, PeprValidateRequest, R, RegisterKind, a, fetch, fetchStatus, kind, sdk, };
11
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,GAAG,EACH,GAAG,EACH,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,CAAC,EACD,YAAY,EACZ,CAAC,EACD,KAAK,EACL,WAAW,EACX,IAAI,EACJ,GAAG,GACJ,CAAC"}