( paramId: string, subBlocks: BlockSubBlockConfig[], valuesWithOperation: Record<string, unknown>, paramType: string )
| 207 | } |
| 208 | |
| 209 | function resolveSubBlockForParam( |
| 210 | paramId: string, |
| 211 | subBlocks: BlockSubBlockConfig[], |
| 212 | valuesWithOperation: Record<string, unknown>, |
| 213 | paramType: string |
| 214 | ): BlockSubBlockConfig | undefined { |
| 215 | const blockSubBlocks = subBlocks |
| 216 | |
| 217 | // First pass: find subblock with matching condition |
| 218 | let fallbackMatch: BlockSubBlockConfig | undefined |
| 219 | |
| 220 | for (const sb of blockSubBlocks) { |
| 221 | const matches = sb.id === paramId || sb.canonicalParamId === paramId |
| 222 | if (!matches) continue |
| 223 | |
| 224 | // Remember first match as fallback (for condition-based filtering in UI) |
| 225 | if (!fallbackMatch) fallbackMatch = sb |
| 226 | |
| 227 | if ( |
| 228 | !sb.condition || |
| 229 | evaluateSubBlockCondition(sb.condition as SubBlockCondition, valuesWithOperation) |
| 230 | ) { |
| 231 | return sb |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // Return fallback so its condition can be used for UI filtering |
| 236 | if (fallbackMatch) return fallbackMatch |
| 237 | |
| 238 | // Check if boolean param is part of a checkbox-list |
| 239 | if (paramType === 'boolean') { |
| 240 | return blockSubBlocks.find( |
| 241 | (sb) => |
| 242 | sb.type === 'checkbox-list' && |
| 243 | Array.isArray(sb.options) && |
| 244 | (sb.options as Array<{ id?: string }>).some((opt) => opt.id === paramId) |
| 245 | ) |
| 246 | } |
| 247 | |
| 248 | return undefined |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Gets all parameters for a tool, categorized by their usage |
no test coverage detected