@vectoriox/iox-ui 5.117.0 → 5.119.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.
@@ -11270,5 +11270,59 @@ declare function applyLayoutEdits(page: LayoutPage, edits: ReadonlyArray<LayoutE
11270
11270
  /** The strict format a repair is asked in: `{ edits: [{ op, path, value }] }`, every key required. */
11271
11271
  declare function layoutRepairJsonSchema(): JsonSchema;
11272
11272
 
11273
- export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderIngredient, HeaderMixError, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerMeaning, headerMix, headerMixOfNavKind, headerMixOfPlan, headerReferences, headerTokenOf, headerTokenWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
11274
- export type { AddBarItemResult, AiBuyCredits, AiEntitlementsView, AiMeter, AiModelEntry, AiRefusal, AiTokenCounts, AiTokenPrice, AreaLuminance, ArtDirection, AuditPage, AuditPlaceholder, BarItemsEditResult, BuildNotice, BuildStepError, BuildStepFacts, BuildStepRecord, CalmReading, CheckLayoutContext, CmsDataSourcePlan, ComposeContext, ComposeIssue, ComposeLayoutOptions, ComposedDataSource, ComposedItem, ComposedLayout, ComposedNavHeader, ComposedPage, ComposedPlaceholder, ComposedProduct, ComposedRoute, ComposedSection, ComposedShop, ComposedSite, ContentFieldPlan, ContentRoles, ContentSeedPlan, ContentTypePlan, CreateNodeOptions, CreatedRecord, DataSourcePlan, DriftBox, DriftLayer, DriftMeeting, DynamicKeysAsList, EntranceAction, EntranceActionOptions, EntranceInteraction, EntranceMark, EntranceSpec, EntranceStamp, FactKey, FilmPlacement, FilmTarget, FingerprintedPage, FooterContext, FooterMix, FooterRepair, FrameRegion, HeaderGap, HeaderMix, JsonSchema, LayoutBandMove, LayoutColours, LayoutEdit, LayoutFingerprint, LayoutForm, LayoutGallery, LayoutGalleryList, LayoutGap, LayoutGivenAway, LayoutIssue, LayoutLayer, LayoutListBinding, LayoutListMix, LayoutListNever, LayoutListShape, LayoutLook, LayoutMend, LayoutPage, LayoutPhotoAddress, LayoutReadyMade, LayoutRect, LayoutSection, LayoutSite, LayoutTrack, LayoutVoid, LayoutWire, LayoutWireLayer, LayoutWireList, LayoutWireOptions, LayoutWireSection, LayoutWireSlot, LayoutWireTrack, ListIngredient, ListWait, MeasuredLayer, MeasuredLayout, NavHeaderInput, NavHeaderOptions, NavPage, NavShapeOptions, NavShapeResult, NodeBaseline, OwnPhoto, OwnPhotoPlacement, PageArchetype, PageArchetypeId, PageArchetypeSlot, PageData, PageDataLine, PagePlan, PageSectionPlan, PageSeoPlan, PathIssue, PatternManifestEntry, PatternManifestOptions, PatternNode, PatternPath, PatternRoleNeed, PatternTrack, PhotoInventory, PhotoWordsArea, PicturePlan, PicturePlanOptions, PicturePromptContext, PictureReview, PictureSlot, PictureTryBudget, PictureWorldSpec, PicturesEstimate, PixelReading, PlacedFilm, PlainObject, PlanChange, PlanDirection, PlanEdit, PlanEditIssue, PlanEditResult, PlanEditsAnswer, PlanEntrancesInput, PlanFilm, PlanMixes, PlanWireContext, PlanWireParts, PlanWordContext, PlanWordIssue, PreflightRefusal, PublishRefusal, RecipeListBinds, RelativeDataSourcePlan, ScrimChoice, SectionEntrances, SectionFallback, SectionInput, SectionJudge, SectionOptions, SectionSwap, SerializedBinding, SerializedNode, SerializedResponsive, ShapeEntry, ShapeIssueCodes, ShopDataSourcePlan, ShopOptionPlan, ShopPlan, ShopProductPlan, ShowcaseInput, SiteAudit, SiteAuditOptions, SiteAuditSnapshot, SiteBuildRun, SiteBusiness, SiteCheck, SiteFinding, SiteNeedId, SitePageRef, SitePattern, SitePlan, SitePlanContext, SitePlanIssue, SitePlanSource, SitePlanValidation, SiteTemplate, StockCredit, StockItemSlot, StockLink, StockNeed, StockPhoto, StockPhotoTraits, StockPlacement, StockPlanOptions, StockProviderTerms, StockReview, StockSlot, StockTarget, StrictSchemaComplexity, StrictSchemaRefusal, TemplatePlanInput, UndoKept, UndoPreview, UndoRecord, WireOptions, WordsArea, WrittenText };
11273
+ /**
11274
+ * `ADJUSTMENTS` — the size and spacing STEPS an element may take by asking (ai-session-panel-plan `adjust`, ai-assist-plan
11275
+ * AI2c). "Make the hero taller" is a row of this table, never a number: the model picks an axis and a step, this file is
11276
+ * the ONLY place their style literals come from, and every value is a token of the look wherever a token exists (the
11277
+ * section rhythm `--iox-space-section`, a framed box's padding `--iox-space-pad`) — so a re-themed site keeps its steps in
11278
+ * proportion. The same pure functions read the current step (`adjustStepOf`) and write a new one (`adjustStyleProps`) on
11279
+ * the server's check and in the builder's trial.
11280
+ *
11281
+ * Every value is a desktop-first BASE value: a width the author (or the composer) set on its own keeps its own value.
11282
+ */
11283
+ /** What a step changes. */
11284
+ declare enum AdjustAxis {
11285
+ /** How tall a section stands: fit its content · tall · one screen. */
11286
+ Height = "height",
11287
+ /** The space inside: a section's rhythm above and below, a card's or panel's padding all round. */
11288
+ Spacing = "spacing",
11289
+ /** Where words sit on their line: start · centre · end (logical — follows the page's direction). */
11290
+ Align = "align"
11291
+ }
11292
+ /** Which kind of element an axis acts on — a section's spacing is its rhythm, a card's is its padding. */
11293
+ declare enum AdjustKind {
11294
+ Section = "section",
11295
+ Box = "box",
11296
+ Words = "words"
11297
+ }
11298
+ /** What a node holds when its value is none of the steps — the author's (or the composer's) own. */
11299
+ declare const ADJUST_OWN = "own";
11300
+ interface AdjustStep {
11301
+ readonly id: string;
11302
+ /** How the owner reads it on a change card. */
11303
+ readonly label: string;
11304
+ }
11305
+ /** The steps of each axis, smallest first. */
11306
+ declare const ADJUST_STEPS: Readonly<Record<AdjustAxis, ReadonlyArray<AdjustStep>>>;
11307
+ declare const ADJUST_AXIS_LABELS: Readonly<Record<AdjustAxis, string>>;
11308
+ /**
11309
+ * THE table: per axis and kind, the style props each step writes. Spacing on a section writes only the block (top and
11310
+ * bottom) half of its padding — the sides stay the section's own (`adjustStyleProps`).
11311
+ */
11312
+ declare const ADJUSTMENTS: Readonly<Record<AdjustAxis, Partial<Record<AdjustKind, Readonly<Record<string, Readonly<Record<string, string>>>>>>>>;
11313
+ /** Split a CSS value on its top-level spaces (a `calc(a * b)` stays one part). */
11314
+ declare function splitCssValue(value: string): string[];
11315
+ /**
11316
+ * The style props a step writes on a node holding `styleProps` (merged by the caller), or null when the axis does not act
11317
+ * on that kind or the step is not one of its rows. Section spacing keeps the node's own sides.
11318
+ */
11319
+ declare function adjustStyleProps(axis: AdjustAxis, kind: AdjustKind, step: string, styleProps?: Readonly<Record<string, unknown>>): Record<string, string> | null;
11320
+ /** The step a node's current values are, or {@link ADJUST_OWN} when they are none of the rows. */
11321
+ declare function adjustStepOf(axis: AdjustAxis, kind: AdjustKind, styleProps?: Readonly<Record<string, unknown>>): string;
11322
+ /** How the owner reads a step id ("own" → "As set"). */
11323
+ declare function adjustStepLabel(axis: AdjustAxis, step: string): string;
11324
+ /** Every step id of every axis — the strict format's enum (which axis takes which step is the check's). */
11325
+ declare const ADJUST_STEP_IDS: ReadonlyArray<string>;
11326
+
11327
+ export { ACCOUNT_ENTRY_ID, ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, ADJUSTMENTS, ADJUST_AXIS_LABELS, ADJUST_OWN, ADJUST_STEPS, ADJUST_STEP_IDS, AI_COMPOSED_PAGES_ESTIMATED, AI_PLAN_REASKED_PART, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, AI_STEP_FEATURE, AI_STEP_LABELS, AI_STEP_NEEDS, AI_STEP_PART_TOKENS, AI_STEP_TYPICAL_TOKENS, ART_DIRECTION_PARTS, AdjustAxis, AdjustKind, AiCallStatus, AiCapability, AiFeature, AiGenerationStage, AiKeyMode, AiLimit, AiNextKind, AiProviderId, AiRefusalCode, AiStep, BAR_ITEMS_MAX, BAR_ITEMS_MIN, BASELINE_ROLES, BUILD_STEPS, BaselineRole, BindScope, BuildNoticeCode, BuildStep, CONTENT_ROLE_MEANINGS, CREDITS_PER_USD, CardBindTarget, CheckSeverity, ComposeError, ComposeIssueCode, ContentFieldControl, ContentFieldType, ContentRole, ContentTypeAction, CreatedKind, DANGLING_LINK_CODES, DEFAULT_FOOTER_PATTERN, DEFAULT_PHONE_MENU_BREAKPOINT, DEFAULT_SITE_LOCALE, ENTRANCE_EASING, ENTRANCE_ORIGIN_LOOK, ENTRANCE_TRIGGER, EntrancePart, EntranceSide, FACT_KEYS, FIELD_TYPE_OF_CONTROL, FILL_ASPECT, FILM_PATTERN, FINAL_GENERATION_STAGES, FINDING_SEVERITY, FOOTER_TOKEN, FilmUnplaced, FooterArrange, FooterClosing, FooterGround, FooterHold, FooterIngredient, FooterMixError, FooterRepairCode, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEADER_TOKEN, HEBREW_PREFIXES, HeaderIngredient, HeaderMixError, JSON_SCHEMA_BANNED_KEYWORDS, JsonSchemaShapeError, KeptReason, LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_CHECK_VIEWPORT, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_DRIFT, LAYOUT_EASING, LAYOUT_ENTRANCE_MAX_MS, LAYOUT_FONT_SIZE, LAYOUT_GUTTER, LAYOUT_HIDDEN_OPACITY, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, LAYOUT_LIST_TOKEN, LAYOUT_MIX_OFFERED, LAYOUT_MIX_WORDS, LAYOUT_OPERATED, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHONE_PADDING, LAYOUT_PHOTO_ASPECT, LAYOUT_READY_MADE_TOKEN, LAYOUT_RISE, LAYOUT_SCREEN_PX, LAYOUT_TEXT_KINDS, LAYOUT_TOOLTIP_TRAIT, LAYOUT_VIEWPORTS, LAYOUT_WIRE_AUTOPLAY_MS, LIST_CARD_PART, LIST_INGREDIENTS, LIST_LONG_WORDS, LIST_ROLE_WORDS, LIST_TABLE, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMove, LayoutListPhone, LayoutListRole, LayoutListWho, LayoutMendKind, LayoutMixIngredient, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutPhotoSource, LayoutRole, LayoutSectionKind, LayoutSequenceToken, LayoutSide, LayoutSignatureId, LayoutSize, LayoutSourceChoice, LayoutTrackProp, LayoutTransition, LayoutViewport, MAX_SITE_PICTURES, NAV_PART_LABELS, NAV_SHAPE_COPY, NEUTRAL_STYLE_PROPS, NODE_BASELINES, NO_TOKENS, NavPagesSource, NavRole, NavShape, NavShapeError, PAGE_ARCHETYPES, PHOTO_ANALYSIS_WIDTH, PHOTO_CALM_DETAIL, PHOTO_GRID, PHOTO_LIGHT_LUMINANCE, PICTURE_ASPECTS, PICTURE_NEVER, PICTURE_REAL_PLACE_FAMILIES, PICTURE_REROLL_EVERY, PICTURE_REVIEW_FORMAT, PICTURE_REVIEW_SHAPE, PICTURE_TEXT_CONTRAST, PICTURE_WORLDS, PICTURE_WORLD_IDS, PLAN_EDITS_ANSWER_SHAPES, PLAN_EDITS_PART_SCHEMA_NAMES, PLAN_EDIT_OP_PART, PLAN_EDIT_SHAPE, PLAN_EDIT_WIRE_KEYS, PLAN_PARTS, PLAN_PART_KEYS, PLAN_WIRE_DERIVED, PLAN_WIRE_PART_SCHEMA_NAMES, PLAN_WIRE_SHAPE, PRICING_PATTERN, PROOF_FINGERPRINTS, PUBLISH_BLOCKING_PLACEHOLDERS, PageDataKind, PathIssueCollector, PatternDirective, PatternGlobalPosition, PatternOpens, PatternPlaceholder, PatternRecipe, PhoneMenuBreakpoint, PhotoTone, PictureRefusal, PictureWorld, PlaceholderKind, PlanChangeAction, PlanChangeKind, PlanDataSourceMode, PlanDataSourceType, PlanEditIssueCode, PlanEditOp, PlanEditsOutcome, PlanPart, PlanWireEntry, PlanWireShapeError, PlanWordIssueCode, PreflightRefusalCode, PriceBindTarget, PublishRefusalCode, PublishScope, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOP_CART_BUTTON_ID, SHOP_CART_DRAWER_ID, SHOP_FIELDS, SHOP_LATEST_LIMIT, SHOP_LIST_LIMIT, SHOP_NEED, SHOP_ONLY_CONTENT_ROLES, SHOP_PRODUCTS_MAX, SHOP_ROLES, SHOP_SLUG_FIELD, SHOWCASE_FILM, SHOWCASE_SHOP, SIGN_IN_DIALOG_ID, SITE_CHECKS, SITE_FACT_LABELS, SITE_HEADER_PATTERN, SITE_LIBRARY, SITE_LOCALES, SITE_NEED_IDS, SITE_PATTERNS, SITE_PLAN_VERSION, SITE_TEMPLATES, SPEC_SITE_ARCHETYPES, SPEC_SITE_COPY_LENGTHS, SPEC_SITE_DENSITY_COPY, SPEC_SITE_FACTS, SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT, SPEC_SITE_LIBRARY, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_PATTERNS, SPEC_SITE_PICTURE_NEVER, SPEC_SITE_PICTURE_WORLDS, SPEC_SITE_PLAN_SHAPE, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES, SPEC_SITE_TEMPLATES, STOCK_FAMILIES, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_ITEM_ASPECT, STOCK_MIN_KEPT, STOCK_PROVIDER_TERMS, STOCK_SEED_MARGIN, STOCK_SUBJECT_WORDS, STORE_CONTACT_CODES, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, ShopResource, ShopSourceRole, SiteBuildKind, SiteBuildStatus, SiteCheckId, SiteFindingCode, SiteLocale, SitePlanError, SitePlanIssueCode, SitePlanSourceKind, SiteTemplateError, SiteTemplateId, StepState, StockIntent, StockOrientation, StockProviderId, StockReviewFlag, StockReviewVerdict, StockSlotKind, StockSubject, WORDS_AREA_DEFAULT_SHARE, WordsEdge, addBarItem, addStockCredits, adjustStepLabel, adjustStepOf, adjustStyleProps, aiRefusalNext, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, buildStepsOf, builtHomePageId, calmParts, calmUnder, checkFooter, checkLayout, checkList, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, derivedShopSources, describeInventoryForPrompt, describeListShape, describePlanData, describeShapeKey, distinctFooter, drawnHeaderMix, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, expandWireShop, factIssues, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, fingerprintOfPlanPage, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPattern, footerPatternIdOf, footerReferences, footerTokenOf, footerTokenWords, footerWireWords, footerWords, frameWords, headerMeaning, headerMix, headerMixOfNavKind, headerMixOfPlan, headerReferences, headerTokenOf, headerTokenWords, headerWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, isShopResource, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutListBinding, layoutListShapes, layoutLookChanges, layoutLookOf, layoutMixOffered, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, layoutWirePartWords, listBuiltWords, listIngredientWords, listMeaning, listNeverIsEmpty, listTokenOf, listTokensOf, listWait, listWords, luminanceOf, measureLayout, mendLayout, menuAtEveryWidth, modelCanDo, moveBarItem, namedFooterMix, namedHeaderMix, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageListIssues, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, pictureItemsOf, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planHasShopSource, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planSells, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, pricesIn, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionTokenOf, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, shopCategoriesOf, shopContentType, shopSourceAliases, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, showcaseStorePages, shownTogether, signatureOf, siteNavPages, siteSells, slotBudget, splitCssValue, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, variantNamesOf, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, wireShopProductJsonSchema, withDerivedSources, withDistinctFooter, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
11328
+ export type { AddBarItemResult, AdjustStep, AiBuyCredits, AiEntitlementsView, AiMeter, AiModelEntry, AiRefusal, AiTokenCounts, AiTokenPrice, AreaLuminance, ArtDirection, AuditPage, AuditPlaceholder, BarItemsEditResult, BuildNotice, BuildStepError, BuildStepFacts, BuildStepRecord, CalmReading, CheckLayoutContext, CmsDataSourcePlan, ComposeContext, ComposeIssue, ComposeLayoutOptions, ComposedDataSource, ComposedItem, ComposedLayout, ComposedNavHeader, ComposedPage, ComposedPlaceholder, ComposedProduct, ComposedRoute, ComposedSection, ComposedShop, ComposedSite, ContentFieldPlan, ContentRoles, ContentSeedPlan, ContentTypePlan, CreateNodeOptions, CreatedRecord, DataSourcePlan, DriftBox, DriftLayer, DriftMeeting, DynamicKeysAsList, EntranceAction, EntranceActionOptions, EntranceInteraction, EntranceMark, EntranceSpec, EntranceStamp, FactKey, FilmPlacement, FilmTarget, FingerprintedPage, FooterContext, FooterMix, FooterRepair, FrameRegion, HeaderGap, HeaderMix, JsonSchema, LayoutBandMove, LayoutColours, LayoutEdit, LayoutFingerprint, LayoutForm, LayoutGallery, LayoutGalleryList, LayoutGap, LayoutGivenAway, LayoutIssue, LayoutLayer, LayoutListBinding, LayoutListMix, LayoutListNever, LayoutListShape, LayoutLook, LayoutMend, LayoutPage, LayoutPhotoAddress, LayoutReadyMade, LayoutRect, LayoutSection, LayoutSite, LayoutTrack, LayoutVoid, LayoutWire, LayoutWireLayer, LayoutWireList, LayoutWireOptions, LayoutWireSection, LayoutWireSlot, LayoutWireTrack, ListIngredient, ListWait, MeasuredLayer, MeasuredLayout, NavHeaderInput, NavHeaderOptions, NavPage, NavShapeOptions, NavShapeResult, NodeBaseline, OwnPhoto, OwnPhotoPlacement, PageArchetype, PageArchetypeId, PageArchetypeSlot, PageData, PageDataLine, PagePlan, PageSectionPlan, PageSeoPlan, PathIssue, PatternManifestEntry, PatternManifestOptions, PatternNode, PatternPath, PatternRoleNeed, PatternTrack, PhotoInventory, PhotoWordsArea, PicturePlan, PicturePlanOptions, PicturePromptContext, PictureReview, PictureSlot, PictureTryBudget, PictureWorldSpec, PicturesEstimate, PixelReading, PlacedFilm, PlainObject, PlanChange, PlanDirection, PlanEdit, PlanEditIssue, PlanEditResult, PlanEditsAnswer, PlanEntrancesInput, PlanFilm, PlanMixes, PlanWireContext, PlanWireParts, PlanWordContext, PlanWordIssue, PreflightRefusal, PublishRefusal, RecipeListBinds, RelativeDataSourcePlan, ScrimChoice, SectionEntrances, SectionFallback, SectionInput, SectionJudge, SectionOptions, SectionSwap, SerializedBinding, SerializedNode, SerializedResponsive, ShapeEntry, ShapeIssueCodes, ShopDataSourcePlan, ShopOptionPlan, ShopPlan, ShopProductPlan, ShowcaseInput, SiteAudit, SiteAuditOptions, SiteAuditSnapshot, SiteBuildRun, SiteBusiness, SiteCheck, SiteFinding, SiteNeedId, SitePageRef, SitePattern, SitePlan, SitePlanContext, SitePlanIssue, SitePlanSource, SitePlanValidation, SiteTemplate, StockCredit, StockItemSlot, StockLink, StockNeed, StockPhoto, StockPhotoTraits, StockPlacement, StockPlanOptions, StockProviderTerms, StockReview, StockSlot, StockTarget, StrictSchemaComplexity, StrictSchemaRefusal, TemplatePlanInput, UndoKept, UndoPreview, UndoRecord, WireOptions, WordsArea, WrittenText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriox/iox-ui",
3
- "version": "5.117.0",
3
+ "version": "5.119.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=20.0.0",
6
6
  "@angular/core": ">=20.0.0",
@@ -4,6 +4,7 @@ import type { SerializedNode } from '@vectoriox/iox-ui/generation-core';
4
4
 
5
5
  import { FieldChange } from './field-edits';
6
6
  import { FieldEdit } from './fields-schema';
7
+ import { PageChangeOp, SchemeEdit, SizeEdit, StyleChange, StyleEdit } from './page-style';
7
8
  import { WordChange, WordEdit } from './page-words';
8
9
  import { ContentRecord, clipText } from './summarize-item';
9
10
  import { AssistScope, AssistSurface, CommitKind, EditFamily, SURFACES, SurfaceStatus } from './surfaces';
@@ -63,11 +64,13 @@ export interface AssistTurnRequest {
63
64
  readonly page?: { readonly name: string; readonly route: string };
64
65
  }
65
66
 
66
- /** What a turn proposes, per family: a field's value (`fields`) or a part's words (`words`). */
67
- export type AssistEdit = FieldEdit | WordEdit;
67
+ /** What a turn proposes, per family: a field's value (`fields`), a part's words (`words`), an element's style or a section's scheme (`style`). */
68
+ export type AssistEdit = FieldEdit | WordEdit | StyleEdit | SchemeEdit | SizeEdit;
68
69
 
69
70
  /** What a turn changed, as the card says it. */
70
- export type AssistChange = FieldChange | WordChange;
71
+ export type AssistChange = FieldChange | WordChange | StyleChange;
72
+
73
+ const isLookChange = (c: AssistChange): c is StyleChange => 'op' in c && (c.op === PageChangeOp.Style || c.op === PageChangeOp.Scheme || c.op === PageChangeOp.Size);
71
74
 
72
75
  /** POST's 202 answer. */
73
76
  export interface AssistTurnAccepted {
@@ -184,7 +187,7 @@ const SENTENCE_IN_MEMORY_CHARS = 80;
184
187
 
185
188
  function outcome(turn: AssistTurn): string {
186
189
  const named = (list: ReadonlyArray<AssistChange> | undefined) =>
187
- (list ?? []).map(c => ('locale' in c && c.locale ? `${c.label} (${c.locale})` : c.label)).join(', ');
190
+ (list ?? []).map(c => (isLookChange(c) ? `${c.label} → ${c.after}` : 'locale' in c && c.locale ? `${c.label} (${c.locale})` : c.label)).join(', ');
188
191
  switch (turn.status) {
189
192
  case AssistTurnStatus.Refused: return `refused: ${turn.refusal?.message ?? ''}`.trim();
190
193
  case AssistTurnStatus.Failed: return 'failed';
@@ -0,0 +1,40 @@
1
+ import { SerializedNode } from '@vectoriox/iox-ui/generation-core';
2
+
3
+ import { AssistIssue } from './brief';
4
+ import { applyWordEdits, SummarizedPage, WordChange, WordEdit, WordEditContext } from './page-words';
5
+ import { applyStyleEdits, BaselineStyles, isSchemeEdit, isSizeEdit, isStyleEdit, LookEdit, SchemeEdit, SizeEdit, StyleChange, StyleEdit } from './page-style';
6
+
7
+ /**
8
+ * Surface S1's answer as ONE thing (AI2b, AI2c): the edits of every family a page turn routed to — words (`{ handle, value }`),
9
+ * styles (`{ handle, style }`), schemes (`{ handle, scheme }`), size steps (`{ handle, axis, step }`) — applied in that
10
+ * order on a copy, all or none. The server
11
+ * checks each family as it is asked; the builder's trial applies the turn's edits through this, so both read one rule.
12
+ */
13
+ export type PageEdit = WordEdit | StyleEdit | SchemeEdit | SizeEdit;
14
+ export type PageChange = WordChange | StyleChange;
15
+
16
+ export interface PageEditContext extends Omit<WordEditContext, 'handles' | 'never'> {
17
+ readonly summary: Pick<SummarizedPage, 'handles' | 'looks'> & { readonly brief: { readonly rules: { readonly never: WordEditContext['never'] } } };
18
+ /** The builder's registry baseline; default the saved shape's (`serializedBaselineStyles`). */
19
+ readonly baseline?: BaselineStyles;
20
+ }
21
+
22
+ export interface PageEditsOutcome {
23
+ readonly ok: boolean;
24
+ readonly result: SerializedNode[];
25
+ readonly changes: ReadonlyArray<PageChange>;
26
+ readonly issues: ReadonlyArray<AssistIssue>;
27
+ }
28
+
29
+ const isWordEdit = (e: PageEdit): e is WordEdit => 'value' in e;
30
+
31
+ export function applyPageEdits(layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<PageEdit>, ctx: PageEditContext): PageEditsOutcome {
32
+ const words = applyWordEdits(layout, edits.filter(isWordEdit), {
33
+ handles: ctx.summary.handles, never: ctx.summary.brief.rules.never, sentence: ctx.sentence, words: ctx.words,
34
+ });
35
+ const looks = edits.filter((e): e is LookEdit => !isWordEdit(e) && (isStyleEdit(e) || isSchemeEdit(e) || isSizeEdit(e)));
36
+ const style = applyStyleEdits(words.result, looks, { looks: ctx.summary.looks, baseline: ctx.baseline });
37
+ const issues = [...words.issues, ...style.issues];
38
+ if (issues.length) return { ok: false, result: JSON.parse(JSON.stringify(layout)) as SerializedNode[], changes: [], issues };
39
+ return { ok: true, result: style.result, changes: [...words.changes, ...style.changes], issues: [] };
40
+ }
@@ -0,0 +1,448 @@
1
+ import {
2
+ COLOR_SCHEME_TYPES, COLOR_SCHEMES, ColorScheme, colorSchemeOf, elementStyleById, elementStylesFor, ElementStyleTarget, NEW_NODE_STYLE_DEFAULTS,
3
+ setColorScheme, switchElementStyle,
4
+ } from '@vectoriox/iox-ui/design-core';
5
+ import {
6
+ ADJUST_AXIS_LABELS, ADJUST_STEPS, AdjustAxis, AdjustKind, adjustStepLabel, adjustStepOf, adjustStyleProps, jsonClosedObject, jsonListOf, jsonOneOf,
7
+ JsonSchema, jsonText, NODE_BASELINES, SerializedNode, walkSerialized,
8
+ } from '@vectoriox/iox-ui/generation-core';
9
+
10
+ import { assertAssistBudget } from './budget';
11
+ import { AssistIssue, AssistIssueCode } from './brief';
12
+
13
+ /**
14
+ * Surface S1 (the builder, this page), family `style` (ai-assist-plan §4, AI2b; ai-session-panel-plan `setStyle` /
15
+ * `setScheme`): an element takes ANOTHER of the look's element styles, a section (or a box) another colour scheme — never
16
+ * a CSS value, a colour or a size. What a node may take is a closed list: the other members of the swap set its current
17
+ * style is in that its type may wear ({@link ASK_STYLE_SETS}). The SAME pure functions run on the server (the check on a
18
+ * copy) and in the builder (the trial): `pageLooks` (the targets and their handles), `styleJsonSchema`,
19
+ * `decodeStyleAnswers`, `applyStyleEdits` — design-core's `switchElementStyle` (the author's own changes are kept) and
20
+ * `setColorScheme` (the ONE scheme writer), all or none.
21
+ *
22
+ * AI2c adds SIZE STEPS to the same family: a section's height and spacing, a card's or panel's padding, where words sit
23
+ * — each a row of generation-core `ADJUSTMENTS` (the only place their values come from), never a number the model wrote.
24
+ */
25
+
26
+ /**
27
+ * The styles an owner may swap between by asking — each set is ONE kind of thing (a button, a heading, words, a box, a
28
+ * badge). Every other element style (a tab, an accordion part, a cart button, the navigation bar) belongs to the recipe
29
+ * that stamped it and is never offered. A node wearing a style is offered the union of the sets that style is in, kept
30
+ * to the styles its type may wear (design-core `elementStylesFor`).
31
+ */
32
+ export const ASK_STYLE_SETS: ReadonlyArray<ReadonlyArray<string>> = [
33
+ ['button-primary', 'button-secondary', 'button-ghost'],
34
+ ['display', 'h1', 'h2', 'h3', 'eyebrow'],
35
+ ['lead', 'body', 'small', 'eyebrow'],
36
+ ['section', 'box', 'card', 'panel'],
37
+ ['badge-neutral', 'badge-success', 'badge-warning', 'badge-accent'],
38
+ ];
39
+
40
+ /** A box that only holds things — offered a style only when it is the selection ("make this a card"). */
41
+ const PLAIN_BOX_STYLE = 'box';
42
+
43
+ /** A box wearing one of these paints its own ground — a colour scheme shows on it. */
44
+ const SURFACE_STYLES: ReadonlySet<string> = new Set(['section', 'card', 'panel']);
45
+
46
+ const paintsGround = (style: string | null | undefined): boolean => SURFACE_STYLES.has(style ?? '');
47
+
48
+ /** A Text wearing this is a ButtonBlock's words: the button is the style target. */
49
+ const BUTTON_LABEL_STYLE = 'button-label';
50
+
51
+ /** The words types whose line alignment may be asked for (a button's or a link's words sit as their button does). */
52
+ const ALIGNABLE_TYPES: ReadonlySet<string> = new Set(['Heading', 'Text']);
53
+
54
+ /** Boxes whose padding is a framed box's (`--iox-space-pad`). */
55
+ const PADDED_STYLES: ReadonlySet<string> = new Set(['card', 'panel']);
56
+
57
+ /** A Scene, or a section holding a pinned (sticky) part, owns its height — it plays over the scroll it is given. */
58
+ function ownsItsHeight(root: SerializedNode): boolean {
59
+ let owns = false;
60
+ walkSerialized([root], n => { if (n.role === 'scene' || n.styleProps?.['position'] === 'sticky') owns = true; });
61
+ return owns;
62
+ }
63
+
64
+ /**
65
+ * The size axes a node may be stepped on, and which kind each acts as (AI2c): a section root its height and rhythm, a
66
+ * card or panel its padding, a heading or text its alignment. A node that is none of these takes no step.
67
+ */
68
+ export function adjustAxesOf(node: SerializedNode, isRoot: boolean, carriesWords: boolean): Partial<Record<AdjustAxis, AdjustKind>> {
69
+ const axes: Partial<Record<AdjustAxis, AdjustKind>> = {};
70
+ if (isRoot) {
71
+ if (!ownsItsHeight(node)) axes[AdjustAxis.Height] = AdjustKind.Section;
72
+ axes[AdjustAxis.Spacing] = AdjustKind.Section;
73
+ } else if (PADDED_STYLES.has(node.elementStyle ?? '')) {
74
+ axes[AdjustAxis.Spacing] = AdjustKind.Box;
75
+ }
76
+ if (carriesWords && ALIGNABLE_TYPES.has(node.type) && node.elementStyle !== BUTTON_LABEL_STYLE) axes[AdjustAxis.Align] = AdjustKind.Words;
77
+ return axes;
78
+ }
79
+
80
+ /** The styles a node may take by asking — its own among them — or [] when it is not a target. */
81
+ export function askableStyles(node: Pick<SerializedNode, 'type' | 'elementStyle'>): string[] {
82
+ const current = node.elementStyle;
83
+ if (!current) return [];
84
+ const wears = new Set(elementStylesFor(node.type).map(s => s.id));
85
+ const offered = new Set(ASK_STYLE_SETS.filter(set => set.includes(current)).flat().filter(id => wears.has(id)));
86
+ return offered.size > 1 ? [...offered] : [];
87
+ }
88
+
89
+ /** A target of family `style` — what the brief says, and what the check needs (the node id is never sent). */
90
+ export interface PageLook {
91
+ readonly handle: string;
92
+ /** "Hero" (a section root), "Box 2", "Heading 1" — how the change card names it. */
93
+ readonly label: string;
94
+ /** The element style it wears, and the styles it may take (its own among them); absent when only its scheme is offered. */
95
+ readonly style?: string;
96
+ readonly styles?: ReadonlyArray<string>;
97
+ /** Its colour scheme, when it takes one. */
98
+ readonly scheme?: string;
99
+ /** The size axes it may be stepped on, each with the step it holds now (`own` = a value of its own). */
100
+ readonly sizes?: Readonly<Partial<Record<AdjustAxis, string>>>;
101
+ }
102
+
103
+ export interface WalkedLook {
104
+ readonly look: PageLook;
105
+ /** Which kind each of its size axes acts as — what the check writes with (never sent). */
106
+ readonly axes: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
107
+ readonly section: number;
108
+ readonly nodeId: string;
109
+ readonly type: string;
110
+ readonly lineage: ReadonlyArray<string>;
111
+ }
112
+
113
+ const isRecipePart = (node: SerializedNode) => !!node.role && node.role.includes('.');
114
+
115
+ /**
116
+ * Every style / scheme target of the page in reading order. A node that carries words keeps its words handle
117
+ * (`wordHandles`: node id → `s0.heading1`); a ButtonBlock is named by its words' handle (`s0.button1`); a section root is
118
+ * `s{i}`; any other box is `s{i}.box{n}`. `selectedId` lets a plain box that is the selection be a target.
119
+ */
120
+ export function pageLooks(
121
+ layout: ReadonlyArray<SerializedNode>, wordHandles: ReadonlyMap<string, string>, selectedId?: string | null,
122
+ ): WalkedLook[] {
123
+ const out: WalkedLook[] = [];
124
+ layout.forEach((root, index) => {
125
+ let boxes = 0;
126
+ const visit = (node: SerializedNode, lineage: string[]) => {
127
+ const here = [...lineage, node.id];
128
+ const styles = askableStyles(node);
129
+ const isRoot = node === root;
130
+ const plain = node.elementStyle === PLAIN_BOX_STYLE && !isRoot && node.id !== selectedId;
131
+ const takesStyle = styles.length > 0 && !plain && !(isRecipePart(node) && !wordHandles.has(node.id) && node.type !== 'ButtonBlock');
132
+ const scheme = colorSchemeOf(node as never) ?? ColorScheme.Default;
133
+ // A scheme re-declares tokens: only a node that paints a ground of its own (a section, card or panel style) shows
134
+ // it — on any other the words take the scheme's ink over the page's ground (white on white). A node that may
135
+ // TAKE such a style is offered one too; the check refuses the scheme unless the turn gives it that style.
136
+ const takesScheme = COLOR_SCHEME_TYPES.includes(node.type) && !isRecipePart(node)
137
+ && (paintsGround(node.elementStyle) || scheme !== ColorScheme.Default || (takesStyle && styles.some(paintsGround)));
138
+ const axes = adjustAxesOf(node, isRoot, wordHandles.has(node.id));
139
+ const sized = Object.entries(axes) as Array<[AdjustAxis, AdjustKind]>;
140
+ if (takesStyle || takesScheme || sized.length) {
141
+ const handle = lookHandle(node, index, isRoot, wordHandles, () => ++boxes);
142
+ if (handle) {
143
+ out.push({
144
+ look: {
145
+ handle,
146
+ label: lookLabel(handle, root, index),
147
+ ...(takesStyle ? { style: node.elementStyle!, styles } : {}),
148
+ ...(takesScheme ? { scheme } : {}),
149
+ ...(sized.length ? { sizes: Object.fromEntries(sized.map(([axis, kind]) => [axis, adjustStepOf(axis, kind, node.styleProps)])) } : {}),
150
+ },
151
+ axes, section: index, nodeId: node.id, type: node.type, lineage: here,
152
+ });
153
+ }
154
+ }
155
+ for (const child of node.children ?? []) visit(child, here);
156
+ };
157
+ visit(root, []);
158
+ });
159
+ return out;
160
+ }
161
+
162
+ function lookHandle(node: SerializedNode, section: number, isRoot: boolean, wordHandles: ReadonlyMap<string, string>, nextBox: () => number): string | null {
163
+ if (isRoot) return `s${section}`;
164
+ const own = wordHandles.get(node.id);
165
+ if (own) return own;
166
+ if (node.type === 'ButtonBlock') {
167
+ const label = (node.children ?? []).find(c => c.type === 'Text' && c.elementStyle === BUTTON_LABEL_STYLE);
168
+ return label ? wordHandles.get(label.id) ?? null : null;
169
+ }
170
+ return `s${section}.box${nextBox()}`;
171
+ }
172
+
173
+ const capitalise = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
174
+
175
+ /** "Hero · ground" → "Hero"; a composed section's id label ("hero-1") reads as words; else "Section 3". */
176
+ export function sectionLabel(node: SerializedNode, index: number): string {
177
+ const own = (node.label ?? '').split(' · ')[0].trim();
178
+ return own ? capitalise(own.replace(/[-_]+/g, ' ')) : `Section ${index + 1}`;
179
+ }
180
+
181
+ /** `s0` → the section's own name; `s0.box2` → "Box 2"; `s1.heading1` → "Heading 1". */
182
+ function lookLabel(handle: string, root: SerializedNode, index: number): string {
183
+ const tail = handle.split('.').slice(1).join(' ');
184
+ if (!tail) return sectionLabel(root, index);
185
+ return tail.replace(/^([a-z]+)(\d+)/, (_, k: string, n: string) => `${capitalise(k)} ${n}`);
186
+ }
187
+
188
+ /** The labels of the styles and schemes a brief mentions — the model reads ids, the owner reads these. */
189
+ export function lookNames(looks: ReadonlyArray<PageLook>): { styles: Record<string, string>; schemes: Record<string, string> } {
190
+ const styles: Record<string, string> = {};
191
+ for (const look of looks) for (const id of look.styles ?? []) styles[id] = elementStyleById(id)?.label ?? id;
192
+ const schemes: Record<string, string> = looks.some(l => l.scheme) ? Object.fromEntries(COLOR_SCHEMES.map(s => [s.id, s.label])) : {};
193
+ return { styles, schemes };
194
+ }
195
+
196
+ /** A focus target the check may write: its node and what it takes. */
197
+ export interface LookTarget {
198
+ readonly id: string;
199
+ readonly type: string;
200
+ readonly label: string;
201
+ readonly styles: ReadonlyArray<string>;
202
+ readonly scheme: boolean;
203
+ /** The size axes it may be stepped on, and the kind each acts as. */
204
+ readonly sizes?: Readonly<Partial<Record<AdjustAxis, AdjustKind>>>;
205
+ }
206
+
207
+ export type LookMap = Readonly<Record<string, LookTarget>>;
208
+
209
+ export enum StyleAnswerKey {
210
+ Styles = 'styles',
211
+ Schemes = 'schemes',
212
+ Sizes = 'sizes',
213
+ Note = 'note',
214
+ }
215
+
216
+ export interface StyleSchemas {
217
+ readonly parts: JsonSchema[];
218
+ readonly handles: string[][];
219
+ }
220
+
221
+ /**
222
+ * The strict format of family `style` for the focus — ONE request: a list of `{ handle, style }` and a list of
223
+ * `{ handle, scheme }`, each handle an enum of the focus's targets ([] leaves everything as it is). A list whose enum
224
+ * would be empty is left out. The pairing (does THIS handle take THAT style) is the check's, so the format stays small
225
+ * whatever the page holds.
226
+ */
227
+ export function styleJsonSchema(looks: LookMap): StyleSchemas {
228
+ const styled = Object.entries(looks).filter(([, t]) => t.styles.length);
229
+ const schemed = Object.entries(looks).filter(([, t]) => t.scheme);
230
+ const sized = Object.entries(looks).filter(([, t]) => Object.keys(t.sizes ?? {}).length);
231
+ if (!styled.length && !schemed.length && !sized.length) return { parts: [], handles: [] };
232
+ const properties: Record<string, JsonSchema> = {};
233
+ if (styled.length) {
234
+ const ids = [...new Set(styled.flatMap(([, t]) => t.styles))];
235
+ properties[StyleAnswerKey.Styles] = {
236
+ ...jsonListOf(jsonClosedObject({
237
+ handle: jsonOneOf(styled.map(([h]) => h)),
238
+ style: jsonOneOf(ids),
239
+ }, ['handle', 'style'])),
240
+ description: 'An element taking another of the styles the focus lists for it; [] changes no style.',
241
+ };
242
+ }
243
+ if (schemed.length) {
244
+ properties[StyleAnswerKey.Schemes] = {
245
+ ...jsonListOf(jsonClosedObject({
246
+ handle: jsonOneOf(schemed.map(([h]) => h)),
247
+ scheme: jsonOneOf(COLOR_SCHEMES.map(s => s.id)),
248
+ }, ['handle', 'scheme'])),
249
+ description: 'A section or box taking another colour scheme; [] changes no colours.',
250
+ };
251
+ }
252
+ if (sized.length) {
253
+ const axes = [...new Set(sized.flatMap(([, t]) => Object.keys(t.sizes ?? {})))] as AdjustAxis[];
254
+ properties[StyleAnswerKey.Sizes] = {
255
+ ...jsonListOf(jsonClosedObject({
256
+ handle: jsonOneOf(sized.map(([h]) => h)),
257
+ axis: jsonOneOf(axes),
258
+ step: jsonOneOf([...new Set(axes.flatMap(a => ADJUST_STEPS[a].map(s => s.id)))]),
259
+ }, ['handle', 'axis', 'step'])),
260
+ description: 'An element stepped on one of the size axes the focus lists for it; [] changes no size.',
261
+ };
262
+ }
263
+ properties[StyleAnswerKey.Note] = { ...jsonText(), description: 'One short line for the owner on what changed, or what needs them.' };
264
+ const part = jsonClosedObject(properties, Object.keys(properties));
265
+ assertAssistBudget('style', [part]);
266
+ return { parts: [part], handles: [[...new Set([...styled, ...schemed, ...sized].map(([h]) => h))]] };
267
+ }
268
+
269
+ /** An element taking another element style. */
270
+ export interface StyleEdit {
271
+ readonly handle: string;
272
+ readonly style: string;
273
+ }
274
+
275
+ /** A section or box taking another colour scheme. */
276
+ export interface SchemeEdit {
277
+ readonly handle: string;
278
+ readonly scheme: string;
279
+ }
280
+
281
+ /** An element stepped on a size axis — a row of generation-core `ADJUSTMENTS`. */
282
+ export interface SizeEdit {
283
+ readonly handle: string;
284
+ readonly axis: string;
285
+ readonly step: string;
286
+ }
287
+
288
+ /** Any edit of family `style`. */
289
+ export type LookEdit = StyleEdit | SchemeEdit | SizeEdit;
290
+
291
+ const listOf = (answer: unknown, key: StyleAnswerKey): Array<Record<string, unknown>> => {
292
+ const list = answer && typeof answer === 'object' ? (answer as Record<string, unknown>)[key] : undefined;
293
+ return Array.isArray(list) ? list.filter((x): x is Record<string, unknown> => !!x && typeof x === 'object') : [];
294
+ };
295
+
296
+ /** The answer → the edits it makes. */
297
+ export function decodeStyleAnswers(answers: ReadonlyArray<unknown>): LookEdit[] {
298
+ return answers.flatMap(answer => [
299
+ ...listOf(answer, StyleAnswerKey.Styles).map(x => ({ handle: String(x['handle'] ?? ''), style: String(x['style'] ?? '') })),
300
+ ...listOf(answer, StyleAnswerKey.Schemes).map(x => ({ handle: String(x['handle'] ?? ''), scheme: String(x['scheme'] ?? '') })),
301
+ ...listOf(answer, StyleAnswerKey.Sizes).map(x => ({ handle: String(x['handle'] ?? ''), axis: String(x['axis'] ?? ''), step: String(x['step'] ?? '') })),
302
+ ]);
303
+ }
304
+
305
+ export const isStyleEdit = (e: object): e is StyleEdit => typeof (e as StyleEdit).style === 'string';
306
+ export const isSchemeEdit = (e: object): e is SchemeEdit => typeof (e as SchemeEdit).scheme === 'string';
307
+ export const isSizeEdit = (e: object): e is SizeEdit => typeof (e as SizeEdit).axis === 'string' && typeof (e as SizeEdit).step === 'string';
308
+
309
+ /** Which kind of change a change card shows. */
310
+ export enum PageChangeOp {
311
+ Words = 'words',
312
+ Style = 'style',
313
+ Scheme = 'scheme',
314
+ Size = 'size',
315
+ }
316
+
317
+ export interface StyleChange {
318
+ readonly op: PageChangeOp.Style | PageChangeOp.Scheme | PageChangeOp.Size;
319
+ /** A size step's axis. */
320
+ readonly axis?: AdjustAxis;
321
+ readonly handle: string;
322
+ readonly nodeId: string;
323
+ readonly label: string;
324
+ /** The style / scheme / step ids, and how the owner reads them. */
325
+ readonly from: string;
326
+ readonly to: string;
327
+ readonly before: string;
328
+ readonly after: string;
329
+ /** Values the author had set by hand on it, kept (`switchElementStyle`). */
330
+ readonly keptOwn?: number;
331
+ }
332
+
333
+ /** A type's unstyled values (what a released trait goes back to) — the builder passes its registry's; this is the saved shape's. */
334
+ export type BaselineStyles = (type: string) => Readonly<Record<string, unknown>>;
335
+
336
+ /** The serialized baseline: the type's constructor values, its text colour released as a new node's is (generation-core `createSerializedNode`). */
337
+ export const serializedBaselineStyles: BaselineStyles = type => {
338
+ const own = { ...(NODE_BASELINES[type]?.styleProps ?? {}) } as Record<string, unknown>;
339
+ for (const [name, value] of Object.entries(NEW_NODE_STYLE_DEFAULTS)) if (name in own) own[name] = value;
340
+ return own;
341
+ };
342
+
343
+ export interface StyleEditContext {
344
+ /** The focus's targets (`summarizePage(…).looks`). */
345
+ readonly looks: LookMap;
346
+ readonly baseline?: BaselineStyles;
347
+ }
348
+
349
+ export interface StyleEditsOutcome {
350
+ readonly ok: boolean;
351
+ readonly result: SerializedNode[];
352
+ readonly changes: ReadonlyArray<StyleChange>;
353
+ readonly issues: ReadonlyArray<AssistIssue>;
354
+ }
355
+
356
+ const schemeLabel = (id: string) => COLOR_SCHEMES.find(s => s.id === id)?.label ?? id;
357
+ const styleLabel = (id: string) => elementStyleById(id)?.label ?? id;
358
+
359
+ /**
360
+ * Family `style`, applied — the SAME check on the server and in the builder. All or none; never mutates its input. A
361
+ * handle not in the focus, a style the target may not take, a scheme on a target that takes none are refused (re-asked
362
+ * once by the server, never repaired here); an edit that changes nothing is dropped.
363
+ */
364
+ export function applyStyleEdits(
365
+ layout: ReadonlyArray<SerializedNode>, edits: ReadonlyArray<LookEdit>, ctx: StyleEditContext,
366
+ ): StyleEditsOutcome {
367
+ const result = JSON.parse(JSON.stringify(layout)) as SerializedNode[];
368
+ const byId = new Map<string, SerializedNode>();
369
+ walkSerialized(result, n => byId.set(n.id, n));
370
+ const baseline = ctx.baseline ?? serializedBaselineStyles;
371
+ const issues: AssistIssue[] = [];
372
+ const changes: StyleChange[] = [];
373
+ const seen = new Set<string>();
374
+
375
+ // Styles first: a scheme may need the style the same turn gives its node (a plain box made a panel, then darkened);
376
+ // size steps last, over what the style switch released.
377
+ const ordered = [
378
+ ...edits.filter(e => !isSchemeEdit(e) && !isSizeEdit(e)), ...edits.filter(isSchemeEdit), ...edits.filter(isSizeEdit),
379
+ ];
380
+ for (const edit of ordered) {
381
+ const scheme = isSchemeEdit(edit);
382
+ const size = isSizeEdit(edit);
383
+ const key = size ? `size:${edit.handle}:${edit.axis}` : `${scheme ? 'scheme' : 'style'}:${edit.handle}`;
384
+ const refuse = (code: AssistIssueCode, message: string) => issues.push({ code, handle: edit.handle, message });
385
+ if (seen.has(key)) {
386
+ refuse(AssistIssueCode.Duplicate, `"${edit.handle}" is given two ${size ? `${edit.axis} steps` : scheme ? 'schemes' : 'styles'}`);
387
+ continue;
388
+ }
389
+ seen.add(key);
390
+ const target = Object.prototype.hasOwnProperty.call(ctx.looks, edit.handle) ? ctx.looks[edit.handle] : undefined;
391
+ const node = target ? byId.get(target.id) : undefined;
392
+ if (!target || !node) { refuse(AssistIssueCode.UnknownHandle, `"${edit.handle}" is not an element of the focus`); continue; }
393
+
394
+ if (size) {
395
+ const axis = edit.axis as AdjustAxis;
396
+ const kind = Object.prototype.hasOwnProperty.call(target.sizes ?? {}, axis) ? target.sizes![axis] : undefined;
397
+ if (!kind) {
398
+ const takes = Object.keys(target.sizes ?? {});
399
+ refuse(AssistIssueCode.NotAnOption, `${target.label} takes no ${edit.axis} step${takes.length ? ` — only ${takes.join(', ')}` : ''}`);
400
+ continue;
401
+ }
402
+ const props = adjustStyleProps(axis, kind, edit.step, node.styleProps);
403
+ if (!props) {
404
+ refuse(AssistIssueCode.NotAnOption, `${ADJUST_AXIS_LABELS[axis].toLowerCase()} takes ${ADJUST_STEPS[axis].map(s => `"${s.id}"`).join(', ')} — not "${edit.step}"`);
405
+ continue;
406
+ }
407
+ const from = adjustStepOf(axis, kind, node.styleProps);
408
+ if (from === edit.step) continue;
409
+ node.styleProps = { ...(node.styleProps ?? {}), ...props };
410
+ changes.push({
411
+ op: PageChangeOp.Size, axis, handle: edit.handle, nodeId: node.id, label: `${target.label} · ${ADJUST_AXIS_LABELS[axis].toLowerCase()}`,
412
+ from, to: edit.step, before: adjustStepLabel(axis, from), after: adjustStepLabel(axis, edit.step),
413
+ });
414
+ continue;
415
+ }
416
+
417
+ if (scheme) {
418
+ const to = (edit as SchemeEdit).scheme;
419
+ if (!target.scheme) { refuse(AssistIssueCode.NotAnOption, `${target.label} takes no colour scheme`); continue; }
420
+ if (!COLOR_SCHEMES.some(s => s.id === to)) { refuse(AssistIssueCode.NotAnOption, `"${to}" is not a colour scheme`); continue; }
421
+ const from = colorSchemeOf(node as never) ?? ColorScheme.Default;
422
+ if (to !== ColorScheme.Default && !paintsGround(node.elementStyle)) {
423
+ refuse(AssistIssueCode.NotAnOption, `${target.label} paints no ground of its own — give it the section, card or panel style in the same answer, or leave its colours`);
424
+ continue;
425
+ }
426
+ if (!setColorScheme(node, to)) continue;
427
+ changes.push({ op: PageChangeOp.Scheme, handle: edit.handle, nodeId: node.id, label: target.label, from, to, before: schemeLabel(from), after: schemeLabel(to) });
428
+ continue;
429
+ }
430
+
431
+ const to = (edit as StyleEdit).style;
432
+ if (!target.styles.includes(to)) {
433
+ refuse(AssistIssueCode.NotAnOption, `${target.label} may take ${target.styles.map(s => `"${s}"`).join(', ')} — not "${to}"`);
434
+ continue;
435
+ }
436
+ const from = node.elementStyle ?? '';
437
+ if (from === to) continue;
438
+ const switched = switchElementStyle(node as ElementStyleTarget, from, to, baseline(node.type));
439
+ if (!switched.applied) { refuse(AssistIssueCode.NotAnOption, `"${to}" is not an element style`); continue; }
440
+ changes.push({
441
+ op: PageChangeOp.Style, handle: edit.handle, nodeId: node.id, label: target.label, from, to,
442
+ before: styleLabel(from), after: styleLabel(to), ...(switched.kept.length ? { keptOwn: switched.kept.length } : {}),
443
+ });
444
+ }
445
+
446
+ if (issues.length) return { ok: false, result: JSON.parse(JSON.stringify(layout)) as SerializedNode[], changes: [], issues };
447
+ return { ok: true, result, changes, issues: [] };
448
+ }