@adcp/sdk 6.11.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/adcp-config.js +7 -1
- package/bin/adcp.js +191 -4
- package/dist/lib/adapters/index.d.ts +0 -2
- package/dist/lib/adapters/index.d.ts.map +1 -1
- package/dist/lib/adapters/index.js +1 -8
- package/dist/lib/adapters/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -7
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/mock-server/index.d.ts +2 -0
- package/dist/lib/mock-server/index.d.ts.map +1 -1
- package/dist/lib/mock-server/index.js +17 -0
- package/dist/lib/mock-server/index.js.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/recipe.d.ts +155 -0
- package/dist/lib/mock-server/sales-guaranteed/recipe.d.ts.map +1 -0
- package/dist/lib/mock-server/sales-guaranteed/recipe.js +107 -0
- package/dist/lib/mock-server/sales-guaranteed/recipe.js.map +1 -0
- package/dist/lib/mock-server/sales-guaranteed/server.d.ts.map +1 -1
- package/dist/lib/mock-server/sales-guaranteed/server.js +212 -0
- package/dist/lib/mock-server/sales-guaranteed/server.js.map +1 -1
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.d.ts +123 -0
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.d.ts.map +1 -0
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.js +81 -0
- package/dist/lib/mock-server/sales-non-guaranteed/recipe.js.map +1 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/ctx-metadata/index.d.ts +1 -1
- package/dist/lib/server/ctx-metadata/index.d.ts.map +1 -1
- package/dist/lib/server/ctx-metadata/index.js +3 -1
- package/dist/lib/server/ctx-metadata/index.js.map +1 -1
- package/dist/lib/server/ctx-metadata/wire-shape.d.ts +21 -0
- package/dist/lib/server/ctx-metadata/wire-shape.d.ts.map +1 -1
- package/dist/lib/server/ctx-metadata/wire-shape.js +111 -0
- package/dist/lib/server/ctx-metadata/wire-shape.js.map +1 -1
- package/dist/lib/server/decisioning/context.d.ts +19 -0
- package/dist/lib/server/decisioning/context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.d.ts +3 -0
- package/dist/lib/server/decisioning/index.d.ts.map +1 -1
- package/dist/lib/server/decisioning/index.js +16 -1
- package/dist/lib/server/decisioning/index.js.map +1 -1
- package/dist/lib/server/decisioning/platform.d.ts +17 -0
- package/dist/lib/server/decisioning/platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/platform.js.map +1 -1
- package/dist/lib/server/decisioning/proposal/dispatch.d.ts +203 -0
- package/dist/lib/server/decisioning/proposal/dispatch.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/dispatch.js +395 -0
- package/dist/lib/server/decisioning/proposal/dispatch.js.map +1 -0
- package/dist/lib/server/decisioning/proposal/index.d.ts +21 -0
- package/dist/lib/server/decisioning/proposal/index.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/index.js +37 -0
- package/dist/lib/server/decisioning/proposal/index.js.map +1 -0
- package/dist/lib/server/decisioning/proposal/lifecycle.d.ts +195 -0
- package/dist/lib/server/decisioning/proposal/lifecycle.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/lifecycle.js +366 -0
- package/dist/lib/server/decisioning/proposal/lifecycle.js.map +1 -0
- package/dist/lib/server/decisioning/proposal/mock-manager.d.ts +93 -0
- package/dist/lib/server/decisioning/proposal/mock-manager.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/mock-manager.js +109 -0
- package/dist/lib/server/decisioning/proposal/mock-manager.js.map +1 -0
- package/dist/lib/server/decisioning/proposal/store.d.ts +279 -0
- package/dist/lib/server/decisioning/proposal/store.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/store.js +291 -0
- package/dist/lib/server/decisioning/proposal/store.js.map +1 -0
- package/dist/lib/server/decisioning/proposal/types.d.ts +394 -0
- package/dist/lib/server/decisioning/proposal/types.d.ts.map +1 -0
- package/dist/lib/server/decisioning/proposal/types.js +58 -0
- package/dist/lib/server/decisioning/proposal/types.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +25 -0
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +198 -15
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/index.d.ts +1 -1
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js +3 -1
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/testing/client.d.ts.map +1 -1
- package/dist/lib/testing/client.js +7 -1
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/task-map.js +1 -0
- package/dist/lib/testing/storyboard/task-map.js.map +1 -1
- package/dist/lib/testing/storyboard/test-kit.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/test-kit.js +4 -0
- package/dist/lib/testing/storyboard/test-kit.js.map +1 -1
- package/dist/lib/testing/types.d.ts +10 -0
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/examples/hello_seller_adapter_guaranteed.ts +29 -2
- package/examples/hello_seller_adapter_proposal_mode.ts +575 -0
- package/package.json +1 -1
- package/dist/lib/adapters/proposal-manager.d.ts +0 -142
- package/dist/lib/adapters/proposal-manager.d.ts.map +0 -1
- package/dist/lib/adapters/proposal-manager.js +0 -184
- package/dist/lib/adapters/proposal-manager.js.map +0 -1
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proposal Manager
|
|
3
|
-
*
|
|
4
|
-
* Server-side adapter for managing media plan proposals in get_products.
|
|
5
|
-
* Publishers use this to generate, store, and refine proposals based on
|
|
6
|
-
* campaign briefs.
|
|
7
|
-
*
|
|
8
|
-
* This is a stub implementation that doesn't generate proposals.
|
|
9
|
-
* Publishers should extend or replace this with their recommendation logic.
|
|
10
|
-
*/
|
|
11
|
-
import type { Proposal, Product, ProductAllocation, BrandReference } from '../types/tools.generated';
|
|
12
|
-
/**
|
|
13
|
-
* Context for generating proposals
|
|
14
|
-
*/
|
|
15
|
-
export interface ProposalContext {
|
|
16
|
-
/** Original brief text */
|
|
17
|
-
brief?: string;
|
|
18
|
-
/** Available products to allocate */
|
|
19
|
-
products: Product[];
|
|
20
|
-
/** Brand reference if provided */
|
|
21
|
-
brand?: BrandReference;
|
|
22
|
-
/** Property list ID if filtering was applied */
|
|
23
|
-
propertyListId?: string;
|
|
24
|
-
/** Previous proposal being refined */
|
|
25
|
-
previousProposal?: Proposal;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Abstract interface for proposal managers.
|
|
29
|
-
* Publishers implement this to provide their proposal generation logic.
|
|
30
|
-
*/
|
|
31
|
-
export interface IProposalManager {
|
|
32
|
-
/**
|
|
33
|
-
* Check if proposal generation is supported by this server
|
|
34
|
-
*/
|
|
35
|
-
isSupported(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Generate proposals for a get_products request
|
|
38
|
-
*/
|
|
39
|
-
generateProposals(context: ProposalContext): Promise<Proposal[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Refine an existing proposal based on new instructions
|
|
42
|
-
*/
|
|
43
|
-
refineProposal(proposalId: string, refinementBrief: string, context: ProposalContext): Promise<Proposal | null>;
|
|
44
|
-
/**
|
|
45
|
-
* Get a stored proposal by ID
|
|
46
|
-
*/
|
|
47
|
-
getProposal(proposalId: string): Promise<Proposal | null>;
|
|
48
|
-
/**
|
|
49
|
-
* Store a proposal for later retrieval
|
|
50
|
-
*/
|
|
51
|
-
storeProposal(proposal: Proposal): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Clean up expired proposals
|
|
54
|
-
*/
|
|
55
|
-
cleanupExpiredProposals(): Promise<number>;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Error codes for proposal operations
|
|
59
|
-
*/
|
|
60
|
-
export declare const ProposalErrorCodes: {
|
|
61
|
-
readonly NOT_SUPPORTED: "UNSUPPORTED_FEATURE";
|
|
62
|
-
readonly PROPOSAL_NOT_FOUND: "REFERENCE_NOT_FOUND";
|
|
63
|
-
readonly PROPOSAL_EXPIRED: "PROPOSAL_EXPIRED";
|
|
64
|
-
readonly INVALID_ALLOCATION: "INVALID_REQUEST";
|
|
65
|
-
readonly GENERATION_FAILED: "SERVICE_UNAVAILABLE";
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Stub implementation of ProposalManager.
|
|
69
|
-
* Uses in-memory storage and doesn't generate proposals.
|
|
70
|
-
*
|
|
71
|
-
* Publishers should extend this class or provide their own implementation
|
|
72
|
-
* that integrates with their media planning systems or AI.
|
|
73
|
-
*/
|
|
74
|
-
export declare class ProposalManager implements IProposalManager {
|
|
75
|
-
private proposals;
|
|
76
|
-
private nextId;
|
|
77
|
-
/**
|
|
78
|
-
* Check if proposal generation is supported.
|
|
79
|
-
* Override this to return true when implementing real logic.
|
|
80
|
-
*/
|
|
81
|
-
isSupported(): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Generate proposals for a get_products request.
|
|
84
|
-
* Stub implementation returns empty array.
|
|
85
|
-
*
|
|
86
|
-
* Publishers should override this to implement:
|
|
87
|
-
* - AI-powered media planning based on brief
|
|
88
|
-
* - Rule-based allocation logic
|
|
89
|
-
* - Historical performance-based recommendations
|
|
90
|
-
*/
|
|
91
|
-
generateProposals(context: ProposalContext): Promise<Proposal[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Refine an existing proposal based on new instructions.
|
|
94
|
-
* Stub implementation returns null.
|
|
95
|
-
*
|
|
96
|
-
* Publishers should override this to implement:
|
|
97
|
-
* - Parse refinement instructions (e.g., "more mobile", "increase German reach")
|
|
98
|
-
* - Adjust allocations based on instructions
|
|
99
|
-
* - Re-validate and return updated proposal
|
|
100
|
-
*/
|
|
101
|
-
refineProposal(proposalId: string, refinementBrief: string, context: ProposalContext): Promise<Proposal | null>;
|
|
102
|
-
/**
|
|
103
|
-
* Get a stored proposal by ID.
|
|
104
|
-
*/
|
|
105
|
-
getProposal(proposalId: string): Promise<Proposal | null>;
|
|
106
|
-
/**
|
|
107
|
-
* Store a proposal for later retrieval.
|
|
108
|
-
*/
|
|
109
|
-
storeProposal(proposal: Proposal): Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Clean up expired proposals.
|
|
112
|
-
* Returns the number of proposals removed.
|
|
113
|
-
*/
|
|
114
|
-
cleanupExpiredProposals(): Promise<number>;
|
|
115
|
-
/**
|
|
116
|
-
* Generate a unique proposal ID.
|
|
117
|
-
*/
|
|
118
|
-
protected generateProposalId(): string;
|
|
119
|
-
/**
|
|
120
|
-
* Helper to validate that allocations sum to 100%.
|
|
121
|
-
*/
|
|
122
|
-
protected validateAllocations(allocations: ProductAllocation[]): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Helper to create a proposal with default expiration.
|
|
125
|
-
*/
|
|
126
|
-
protected createProposal(name: string, description: string, allocations: [ProductAllocation, ...ProductAllocation[]], expirationHours?: number): Proposal;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Example of an AI-powered proposal manager (stub).
|
|
130
|
-
* Shows how publishers might extend the base class.
|
|
131
|
-
*/
|
|
132
|
-
export declare class AIProposalManager extends ProposalManager {
|
|
133
|
-
private aiEndpoint?;
|
|
134
|
-
constructor(aiEndpoint?: string);
|
|
135
|
-
isSupported(): boolean;
|
|
136
|
-
generateProposals(context: ProposalContext): Promise<Proposal[]>;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Default singleton instance for servers that don't need proposals
|
|
140
|
-
*/
|
|
141
|
-
export declare const defaultProposalManager: ProposalManager;
|
|
142
|
-
//# sourceMappingURL=proposal-manager.d.ts.map
|
|
@@ -1 +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
-
* Proposal Manager
|
|
4
|
-
*
|
|
5
|
-
* Server-side adapter for managing media plan proposals in get_products.
|
|
6
|
-
* Publishers use this to generate, store, and refine proposals based on
|
|
7
|
-
* campaign briefs.
|
|
8
|
-
*
|
|
9
|
-
* This is a stub implementation that doesn't generate proposals.
|
|
10
|
-
* Publishers should extend or replace this with their recommendation logic.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.defaultProposalManager = exports.AIProposalManager = exports.ProposalManager = exports.ProposalErrorCodes = void 0;
|
|
14
|
-
/**
|
|
15
|
-
* Error codes for proposal operations
|
|
16
|
-
*/
|
|
17
|
-
exports.ProposalErrorCodes = {
|
|
18
|
-
NOT_SUPPORTED: 'UNSUPPORTED_FEATURE',
|
|
19
|
-
PROPOSAL_NOT_FOUND: 'REFERENCE_NOT_FOUND',
|
|
20
|
-
PROPOSAL_EXPIRED: 'PROPOSAL_EXPIRED',
|
|
21
|
-
INVALID_ALLOCATION: 'INVALID_REQUEST',
|
|
22
|
-
GENERATION_FAILED: 'SERVICE_UNAVAILABLE',
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Stub implementation of ProposalManager.
|
|
26
|
-
* Uses in-memory storage and doesn't generate proposals.
|
|
27
|
-
*
|
|
28
|
-
* Publishers should extend this class or provide their own implementation
|
|
29
|
-
* that integrates with their media planning systems or AI.
|
|
30
|
-
*/
|
|
31
|
-
class ProposalManager {
|
|
32
|
-
proposals = new Map();
|
|
33
|
-
nextId = 1;
|
|
34
|
-
/**
|
|
35
|
-
* Check if proposal generation is supported.
|
|
36
|
-
* Override this to return true when implementing real logic.
|
|
37
|
-
*/
|
|
38
|
-
isSupported() {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Generate proposals for a get_products request.
|
|
43
|
-
* Stub implementation returns empty array.
|
|
44
|
-
*
|
|
45
|
-
* Publishers should override this to implement:
|
|
46
|
-
* - AI-powered media planning based on brief
|
|
47
|
-
* - Rule-based allocation logic
|
|
48
|
-
* - Historical performance-based recommendations
|
|
49
|
-
*/
|
|
50
|
-
async generateProposals(context) {
|
|
51
|
-
if (!this.isSupported()) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
// Override in subclass to implement actual proposal generation
|
|
55
|
-
// Example implementation would:
|
|
56
|
-
// 1. Parse the brief to understand campaign objectives
|
|
57
|
-
// 2. Score products against the brief requirements
|
|
58
|
-
// 3. Generate optimal budget allocations
|
|
59
|
-
// 4. Create one or more proposal variants
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Refine an existing proposal based on new instructions.
|
|
64
|
-
* Stub implementation returns null.
|
|
65
|
-
*
|
|
66
|
-
* Publishers should override this to implement:
|
|
67
|
-
* - Parse refinement instructions (e.g., "more mobile", "increase German reach")
|
|
68
|
-
* - Adjust allocations based on instructions
|
|
69
|
-
* - Re-validate and return updated proposal
|
|
70
|
-
*/
|
|
71
|
-
async refineProposal(proposalId, refinementBrief, context) {
|
|
72
|
-
if (!this.isSupported()) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const existing = await this.getProposal(proposalId);
|
|
76
|
-
if (!existing) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
// Check expiration
|
|
80
|
-
if (existing.expires_at && new Date(existing.expires_at) < new Date()) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
// Override in subclass to implement actual refinement logic
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get a stored proposal by ID.
|
|
88
|
-
*/
|
|
89
|
-
async getProposal(proposalId) {
|
|
90
|
-
const proposal = this.proposals.get(proposalId);
|
|
91
|
-
if (!proposal) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
// Check expiration
|
|
95
|
-
if (proposal.expires_at && new Date(proposal.expires_at) < new Date()) {
|
|
96
|
-
this.proposals.delete(proposalId);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
return proposal;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Store a proposal for later retrieval.
|
|
103
|
-
*/
|
|
104
|
-
async storeProposal(proposal) {
|
|
105
|
-
this.proposals.set(proposal.proposal_id, proposal);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Clean up expired proposals.
|
|
109
|
-
* Returns the number of proposals removed.
|
|
110
|
-
*/
|
|
111
|
-
async cleanupExpiredProposals() {
|
|
112
|
-
const now = new Date();
|
|
113
|
-
let removed = 0;
|
|
114
|
-
for (const [id, proposal] of this.proposals) {
|
|
115
|
-
if (proposal.expires_at && new Date(proposal.expires_at) < now) {
|
|
116
|
-
this.proposals.delete(id);
|
|
117
|
-
removed++;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return removed;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Generate a unique proposal ID.
|
|
124
|
-
*/
|
|
125
|
-
generateProposalId() {
|
|
126
|
-
return `prop_${this.nextId++}_${Date.now()}`;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Helper to validate that allocations sum to 100%.
|
|
130
|
-
*/
|
|
131
|
-
validateAllocations(allocations) {
|
|
132
|
-
const sum = allocations.reduce((acc, a) => acc + a.allocation_percentage, 0);
|
|
133
|
-
return Math.abs(sum - 100) < 0.01; // Allow small floating point errors
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Helper to create a proposal with default expiration.
|
|
137
|
-
*/
|
|
138
|
-
createProposal(name, description, allocations, expirationHours = 24) {
|
|
139
|
-
const expiresAt = new Date();
|
|
140
|
-
expiresAt.setHours(expiresAt.getHours() + expirationHours);
|
|
141
|
-
return {
|
|
142
|
-
proposal_id: this.generateProposalId(),
|
|
143
|
-
name,
|
|
144
|
-
description,
|
|
145
|
-
allocations,
|
|
146
|
-
expires_at: expiresAt.toISOString(),
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.ProposalManager = ProposalManager;
|
|
151
|
-
/**
|
|
152
|
-
* Example of an AI-powered proposal manager (stub).
|
|
153
|
-
* Shows how publishers might extend the base class.
|
|
154
|
-
*/
|
|
155
|
-
class AIProposalManager extends ProposalManager {
|
|
156
|
-
aiEndpoint;
|
|
157
|
-
constructor(aiEndpoint) {
|
|
158
|
-
super();
|
|
159
|
-
this.aiEndpoint = aiEndpoint;
|
|
160
|
-
}
|
|
161
|
-
isSupported() {
|
|
162
|
-
return !!this.aiEndpoint;
|
|
163
|
-
}
|
|
164
|
-
async generateProposals(context) {
|
|
165
|
-
if (!this.isSupported() || !context.brief) {
|
|
166
|
-
return [];
|
|
167
|
-
}
|
|
168
|
-
// In a real implementation, this would call an AI service
|
|
169
|
-
// to generate recommendations based on the brief and products
|
|
170
|
-
//
|
|
171
|
-
// Example flow:
|
|
172
|
-
// 1. Send brief + product catalog to AI
|
|
173
|
-
// 2. AI returns recommended allocations with rationale
|
|
174
|
-
// 3. Validate allocations sum to 100%
|
|
175
|
-
// 4. Store and return proposals
|
|
176
|
-
return [];
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
exports.AIProposalManager = AIProposalManager;
|
|
180
|
-
/**
|
|
181
|
-
* Default singleton instance for servers that don't need proposals
|
|
182
|
-
*/
|
|
183
|
-
exports.defaultProposalManager = new ProposalManager();
|
|
184
|
-
//# sourceMappingURL=proposal-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proposal-manager.js","sourceRoot":"","sources":["../../../src/lib/adapters/proposal-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA8DH;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,aAAa,EAAE,qBAAqB;IACpC,kBAAkB,EAAE,qBAAqB;IACzC,gBAAgB,EAAE,kBAAkB;IACpC,kBAAkB,EAAE,iBAAiB;IACrC,iBA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