Commit iniziale

This commit is contained in:
Paolo A
2025-02-18 22:59:07 +00:00
commit 4bbf35cefb
6879 changed files with 623784 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { LoggerOptions, INetworkModule, ProtocolMode, ICachePlugin, AzureCloudOptions, ApplicationTelemetry, INativeBrokerPlugin, ClientAssertionCallback } from "@azure/msal-common/node";
import http from "http";
import https from "https";
import { ManagedIdentityId } from "./ManagedIdentityId.js";
/**
* - clientId - Client id of the application.
* - authority - Url of the authority. If no value is set, defaults to https://login.microsoftonline.com/common.
* - knownAuthorities - Needed for Azure B2C and ADFS. All authorities that will be used in the client application. Only the host of the authority should be passed in.
* - clientSecret - Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal.
* - clientAssertion - A ClientAssertion object containing an assertion string or a callback function that returns an assertion string that the application uses when requesting a token, as well as the assertion's type (urn:ietf:params:oauth:client-assertion-type:jwt-bearer). Only used in confidential client applications.
* - clientCertificate - Certificate that the application uses when requesting a token. Only used in confidential client applications. Requires hex encoded X.509 SHA-1 or SHA-256 thumbprint of the certificate, and the PEM encoded private key (string should contain -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- )
* - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
* - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
* @public
*/
export type NodeAuthOptions = {
clientId: string;
authority?: string;
clientSecret?: string;
clientAssertion?: string | ClientAssertionCallback;
clientCertificate?: {
/**
* @deprecated Use thumbprintSha2 property instead. Thumbprint needs to be computed with SHA-256 algorithm.
* SHA-1 is only needed for backwards compatibility with older versions of ADFS.
*/
thumbprint?: string;
thumbprintSha256?: string;
privateKey: string;
x5c?: string;
};
knownAuthorities?: Array<string>;
cloudDiscoveryMetadata?: string;
authorityMetadata?: string;
clientCapabilities?: Array<string>;
protocolMode?: ProtocolMode;
azureCloudOptions?: AzureCloudOptions;
skipAuthorityMetadataCache?: boolean;
};
/**
* Use this to configure the below cache configuration options:
*
* - cachePlugin - Plugin for reading and writing token cache to disk.
* @public
*/
export type CacheOptions = {
cachePlugin?: ICachePlugin;
/**
* @deprecated claims-based-caching functionality will be removed in the next version of MSALJS
*/
claimsBasedCachingEnabled?: boolean;
};
/**
* Use this to configure the below broker options:
* - nativeBrokerPlugin - Native broker implementation (should be imported from msal-node-extensions)
*
* Note: These options are only available for PublicClientApplications using the Authorization Code Flow
* @public
*/
export type BrokerOptions = {
nativeBrokerPlugin?: INativeBrokerPlugin;
};
/**
* Type for configuring logger and http client options
*
* - logger - Used to initialize the Logger object; TODO: Expand on logger details or link to the documentation on logger
* - networkClient - Http client used for all http get and post calls. Defaults to using MSAL's default http client.
* @public
*/
export type NodeSystemOptions = {
loggerOptions?: LoggerOptions;
networkClient?: INetworkModule;
proxyUrl?: string;
customAgentOptions?: http.AgentOptions | https.AgentOptions;
disableInternalRetries?: boolean;
};
/** @public */
export type NodeTelemetryOptions = {
application?: ApplicationTelemetry;
};
/**
* Use the configuration object to configure MSAL and initialize the client application object
*
* - auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
* - broker: this is where you configure broker options
* - cache: this is where you configure cache location
* - system: this is where you can configure the network client, logger
* - telemetry: this is where you can configure telemetry options
* @public
*/
export type Configuration = {
auth: NodeAuthOptions;
broker?: BrokerOptions;
cache?: CacheOptions;
system?: NodeSystemOptions;
telemetry?: NodeTelemetryOptions;
};
/** @public */
export type ManagedIdentityIdParams = {
userAssignedClientId?: string;
userAssignedResourceId?: string;
userAssignedObjectId?: string;
};
/** @public */
export type ManagedIdentityConfiguration = {
managedIdentityIdParams?: ManagedIdentityIdParams;
system?: NodeSystemOptions;
};
/** @internal */
export type NodeConfiguration = {
auth: Required<NodeAuthOptions>;
broker: BrokerOptions;
cache: CacheOptions;
system: Required<NodeSystemOptions>;
telemetry: Required<NodeTelemetryOptions>;
};
/**
* Sets the default options when not explicitly configured from app developer
*
* @param auth - Authentication options
* @param cache - Cache options
* @param system - System options
* @param telemetry - Telemetry options
*
* @returns Configuration
* @internal
*/
export declare function buildAppConfiguration({ auth, broker, cache, system, telemetry, }: Configuration): NodeConfiguration;
/** @internal */
export type ManagedIdentityNodeConfiguration = {
managedIdentityId: ManagedIdentityId;
system: Required<Pick<NodeSystemOptions, "loggerOptions" | "networkClient">>;
};
export declare function buildManagedIdentityConfiguration({ managedIdentityIdParams, system, }: ManagedIdentityConfiguration): ManagedIdentityNodeConfiguration;
//# sourceMappingURL=Configuration.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/config/Configuration.ts"],"names":[],"mappings":";;AAKA,OAAO,EACH,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,YAAY,EAGZ,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EAC1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAU3D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC;IACnD,iBAAiB,CAAC,EAAE;QAChB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;I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CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,4BAA4B,GAAG;IACvC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAoDF,gBAAgB;AAChB,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACpC,SAAS,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACZ,EAAE,aAAa,GAAG,iBAAiB,CA2BnC;AAED,gBAAgB;AAChB,MAAM,MAAM,gCAAgC,GAAG;IAC3C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,QAAQ,CACZ,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,eAAe,CAAC,CAC7D,CAAC;CACL,CAAC;AAEF,wBAAgB,iCAAiC,CAAC,EAC9C,uBAAuB,EACvB,MAAM,GACT,EAAE,4BAA4B,GAAG,gCAAgC,CAwCjE"}

View File

@@ -0,0 +1,119 @@
/*! @azure/msal-node v2.16.2 2024-11-19 */
'use strict';
import { Constants, ProtocolMode, AzureCloudInstance, LogLevel } from '@azure/msal-common/node';
import { HttpClient } from '../network/HttpClient.mjs';
import { ManagedIdentityId } from './ManagedIdentityId.mjs';
import { MANAGED_IDENTITY_MAX_RETRIES, MANAGED_IDENTITY_RETRY_DELAY, MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON } from '../utils/Constants.mjs';
import { LinearRetryPolicy } from '../retry/LinearRetryPolicy.mjs';
import { HttpClientWithRetries } from '../network/HttpClientWithRetries.mjs';
import { NodeAuthError } from '../error/NodeAuthError.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const DEFAULT_AUTH_OPTIONS = {
clientId: Constants.EMPTY_STRING,
authority: Constants.DEFAULT_AUTHORITY,
clientSecret: Constants.EMPTY_STRING,
clientAssertion: Constants.EMPTY_STRING,
clientCertificate: {
thumbprint: Constants.EMPTY_STRING,
thumbprintSha256: Constants.EMPTY_STRING,
privateKey: Constants.EMPTY_STRING,
x5c: Constants.EMPTY_STRING,
},
knownAuthorities: [],
cloudDiscoveryMetadata: Constants.EMPTY_STRING,
authorityMetadata: Constants.EMPTY_STRING,
clientCapabilities: [],
protocolMode: ProtocolMode.AAD,
azureCloudOptions: {
azureCloudInstance: AzureCloudInstance.None,
tenant: Constants.EMPTY_STRING,
},
skipAuthorityMetadataCache: false,
};
const DEFAULT_CACHE_OPTIONS = {
claimsBasedCachingEnabled: false,
};
const DEFAULT_LOGGER_OPTIONS = {
loggerCallback: () => {
// allow users to not set logger call back
},
piiLoggingEnabled: false,
logLevel: LogLevel.Info,
};
const DEFAULT_SYSTEM_OPTIONS = {
loggerOptions: DEFAULT_LOGGER_OPTIONS,
networkClient: new HttpClient(),
proxyUrl: Constants.EMPTY_STRING,
customAgentOptions: {},
disableInternalRetries: false,
};
const DEFAULT_TELEMETRY_OPTIONS = {
application: {
appName: Constants.EMPTY_STRING,
appVersion: Constants.EMPTY_STRING,
},
};
/**
* Sets the default options when not explicitly configured from app developer
*
* @param auth - Authentication options
* @param cache - Cache options
* @param system - System options
* @param telemetry - Telemetry options
*
* @returns Configuration
* @internal
*/
function buildAppConfiguration({ auth, broker, cache, system, telemetry, }) {
const systemOptions = {
...DEFAULT_SYSTEM_OPTIONS,
networkClient: new HttpClient(system?.proxyUrl, system?.customAgentOptions),
loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
disableInternalRetries: system?.disableInternalRetries || false,
};
// if client certificate was provided, ensure that at least one of the SHA-1 or SHA-256 thumbprints were provided
if (!!auth.clientCertificate &&
!!!auth.clientCertificate.thumbprint &&
!!!auth.clientCertificate.thumbprintSha256) {
throw NodeAuthError.createStateNotFoundError();
}
return {
auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },
broker: { ...broker },
cache: { ...DEFAULT_CACHE_OPTIONS, ...cache },
system: { ...systemOptions, ...system },
telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },
};
}
function buildManagedIdentityConfiguration({ managedIdentityIdParams, system, }) {
const managedIdentityId = new ManagedIdentityId(managedIdentityIdParams);
const loggerOptions = system?.loggerOptions || DEFAULT_LOGGER_OPTIONS;
let networkClient;
// use developer provided network client if passed in
if (system?.networkClient) {
networkClient = system.networkClient;
// otherwise, create a new one
}
else {
networkClient = new HttpClient(system?.proxyUrl, system?.customAgentOptions);
}
// wrap the network client with a retry policy if the developer has not disabled the option to do so
if (!system?.disableInternalRetries) {
const linearRetryPolicy = new LinearRetryPolicy(MANAGED_IDENTITY_MAX_RETRIES, MANAGED_IDENTITY_RETRY_DELAY, MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON);
networkClient = new HttpClientWithRetries(networkClient, linearRetryPolicy);
}
return {
managedIdentityId: managedIdentityId,
system: {
loggerOptions,
networkClient,
},
};
}
export { buildAppConfiguration, buildManagedIdentityConfiguration };
//# sourceMappingURL=Configuration.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Configuration.mjs","sources":["../../src/config/Configuration.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAAA;;;AAGG;AA2IH,MAAM,oBAAoB,GAA8B;IACpD,QAAQ,EAAE,SAAS,CAAC,YAAY;IAChC,SAAS,EAAE,SAAS,CAAC,iBAAiB;IACtC,YAAY,EAAE,SAAS,CAAC,YAAY;IACpC,eAAe,EAAE,SAAS,CAAC,YAAY;AACvC,IAAA,iBAAiB,EAAE;QACf,UAAU,EAA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EAChB,MAAM,EAAE,kBAA4D,CACvE,CAAC;AACL,KAAA;;AAGD,IAAA,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE;QACjC,MAAM,iBAAiB,GAAsB,IAAI,iBAAiB,CAC9D,4BAA4B,EAC5B,4BAA4B,EAC5B,8CAA8C,CACjD,CAAC;QACF,aAAa,GAAG,IAAI,qBAAqB,CACrC,aAAa,EACb,iBAAiB,CACpB,CAAC;AACL,KAAA;IAED,OAAO;AACH,QAAA,iBAAiB,EAAE,iBAAiB;AACpC,QAAA,MAAM,EAAE;YACJ,aAAa;YACb,aAAa;AAChB,SAAA;KACJ,CAAC;AACN;;;;"}

View File

@@ -0,0 +1,12 @@
import { ManagedIdentityIdType } from "../utils/Constants.js";
import { ManagedIdentityIdParams } from "./Configuration.js";
export declare class ManagedIdentityId {
private _id;
get id(): string;
private set id(value);
private _idType;
get idType(): ManagedIdentityIdType;
private set idType(value);
constructor(managedIdentityIdParams?: ManagedIdentityIdParams);
}
//# sourceMappingURL=ManagedIdentityId.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ManagedIdentityId.d.ts","sourceRoot":"","sources":["../../src/config/ManagedIdentityId.ts"],"names":[],"mappings":"AASA,OAAO,EAEH,qBAAqB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,GAAG,CAAS;IACpB,IAAW,EAAE,IAAI,MAAM,CAEtB;IACD,OAAO,KAAK,EAAE,QAEb;IAED,OAAO,CAAC,OAAO,CAAwB;IACvC,IAAW,MAAM,IAAI,qBAAqB,CAEzC;IACD,OAAO,KAAK,MAAM,QAEjB;gBAEW,uBAAuB,CAAC,EAAE,uBAAuB;CAwChE"}

View File

@@ -0,0 +1,57 @@
/*! @azure/msal-node v2.16.2 2024-11-19 */
'use strict';
import { createManagedIdentityError } from '../error/ManagedIdentityError.mjs';
import { ManagedIdentityIdType, DEFAULT_MANAGED_IDENTITY_ID } from '../utils/Constants.mjs';
import { invalidManagedIdentityIdType } from '../error/ManagedIdentityErrorCodes.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
class ManagedIdentityId {
get id() {
return this._id;
}
set id(value) {
this._id = value;
}
get idType() {
return this._idType;
}
set idType(value) {
this._idType = value;
}
constructor(managedIdentityIdParams) {
const userAssignedClientId = managedIdentityIdParams?.userAssignedClientId;
const userAssignedResourceId = managedIdentityIdParams?.userAssignedResourceId;
const userAssignedObjectId = managedIdentityIdParams?.userAssignedObjectId;
if (userAssignedClientId) {
if (userAssignedResourceId || userAssignedObjectId) {
throw createManagedIdentityError(invalidManagedIdentityIdType);
}
this.id = userAssignedClientId;
this.idType = ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID;
}
else if (userAssignedResourceId) {
if (userAssignedClientId || userAssignedObjectId) {
throw createManagedIdentityError(invalidManagedIdentityIdType);
}
this.id = userAssignedResourceId;
this.idType = ManagedIdentityIdType.USER_ASSIGNED_RESOURCE_ID;
}
else if (userAssignedObjectId) {
if (userAssignedClientId || userAssignedResourceId) {
throw createManagedIdentityError(invalidManagedIdentityIdType);
}
this.id = userAssignedObjectId;
this.idType = ManagedIdentityIdType.USER_ASSIGNED_OBJECT_ID;
}
else {
this.id = DEFAULT_MANAGED_IDENTITY_ID;
this.idType = ManagedIdentityIdType.SYSTEM_ASSIGNED;
}
}
}
export { ManagedIdentityId };
//# sourceMappingURL=ManagedIdentityId.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ManagedIdentityId.mjs","sources":["../../src/config/ManagedIdentityId.ts"],"sourcesContent":[null],"names":["ManagedIdentityErrorCodes.invalidManagedIdentityIdType"],"mappings":";;;;;;AAAA;;;AAGG;MAYU,iBAAiB,CAAA;AAE1B,IAAA,IAAW,EAAE,GAAA;QACT,OAAO,IAAI,CAAC,GAAG,CAAC;KACnB;IACD,IAAY,EAAE,CAA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C,uBAAuB,CAAC;AAC/D,SAAA;AAAM,aAAA;AACH,YAAA,IAAI,CAAC,EAAE,GAAG,2BAA2B,CAAC;AACtC,YAAA,IAAI,CAAC,MAAM,GAAG,qBAAqB,CAAC,eAAe,CAAC;AACvD,SAAA;KACJ;AACJ;;;;"}

View File

@@ -0,0 +1,12 @@
import { HttpMethod } from "../utils/Constants.js";
export declare class ManagedIdentityRequestParameters {
private _baseEndpoint;
httpMethod: HttpMethod;
headers: Record<string, string>;
bodyParameters: Record<string, string>;
queryParameters: Record<string, string>;
constructor(httpMethod: HttpMethod, endpoint: string);
computeUri(): string;
computeParametersBodyString(): string;
}
//# sourceMappingURL=ManagedIdentityRequestParameters.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ManagedIdentityRequestParameters.d.ts","sourceRoot":"","sources":["../../src/config/ManagedIdentityRequestParameters.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,qBAAa,gCAAgC;IACzC,OAAO,CAAC,aAAa,CAAS;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEnC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM;IAQ7C,UAAU,IAAI,MAAM;IAepB,2BAA2B,IAAI,MAAM;CAS/C"}

View File

@@ -0,0 +1,35 @@
/*! @azure/msal-node v2.16.2 2024-11-19 */
'use strict';
import { RequestParameterBuilder, UrlString } from '@azure/msal-common/node';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
class ManagedIdentityRequestParameters {
constructor(httpMethod, endpoint) {
this.httpMethod = httpMethod;
this._baseEndpoint = endpoint;
this.headers = {};
this.bodyParameters = {};
this.queryParameters = {};
}
computeUri() {
const parameterBuilder = new RequestParameterBuilder();
if (this.queryParameters) {
parameterBuilder.addExtraQueryParameters(this.queryParameters);
}
const queryParametersString = parameterBuilder.createQueryString();
return UrlString.appendQueryString(this._baseEndpoint, queryParametersString);
}
computeParametersBodyString() {
const parameterBuilder = new RequestParameterBuilder();
if (this.bodyParameters) {
parameterBuilder.addExtraQueryParameters(this.bodyParameters);
}
return parameterBuilder.createQueryString();
}
}
export { ManagedIdentityRequestParameters };
//# sourceMappingURL=ManagedIdentityRequestParameters.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ManagedIdentityRequestParameters.mjs","sources":["../../src/config/ManagedIdentityRequestParameters.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;MAKU,gCAAgC,CAAA;IAOzC,WAAY,CAAA,UAAsB,EAAE,QAAgB,EAAA;AAChD,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,QAAA,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;AAC9B,QAAA,IAAI,CAAC,OAAO,GAAG,EAA4B,CAAC;AAC5C,QAAA,IAAI,CAAC,cAAc,GAAG,EAA4B,CAAC;AACnD,QAAA,IAAI,CAAC,eAAe,GAAG,EAA4B,CAAC;KACvD;IAEM,UAAU,GAAA;AACb,QAAA,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAEvD,IAAI,IAAI,CAAC,eAAe,EAAE;AACtB,YAAA,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAClE,SAAA;AAED,QAAA,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;QAEnE,OAAO,SAAS,CAAC,iBAAiB,CAC9B,IAAI,CAAC,aAAa,EAClB,qBAAqB,CACxB,CAAC;KACL;IAEM,2BAA2B,GAAA;AAC9B,QAAA,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAEvD,IAAI,IAAI,CAAC,cAAc,EAAE;AACrB,YAAA,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACjE,SAAA;AAED,QAAA,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;AACJ;;;;"}