@vectoriox/iox-ui 5.91.1 → 5.93.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.
@@ -7643,9 +7643,16 @@ declare enum AiNextKind {
7643
7643
  /** Try again later, or with less. */
7644
7644
  Retry = "retry",
7645
7645
  /** Keep the plan there is: build it, or change it with a sentence. */
7646
- KeepPlan = "keepPlan"
7646
+ KeepPlan = "keepPlan",
7647
+ /** Buy a credit pack on the portal (P-D14) — `href` is the page that sells it for this studio; its owner pays. */
7648
+ BuyCredits = "buyCredits"
7647
7649
  }
7648
7650
  declare const AI_REFUSAL_NEXT: Readonly<Record<AiRefusalCode, AiNextKind>>;
7651
+ /**
7652
+ * What a refusal offers next: the table, except that credits run out on a plan that sells a pack — then the portal
7653
+ * page that sells it (P-D14). The ONE place that choice is made; the studio adds the href.
7654
+ */
7655
+ declare function aiRefusalNext(code: AiRefusalCode, buy?: AiBuyCredits | null): AiNextKind;
7649
7656
  interface AiRefusal {
7650
7657
  code: AiRefusalCode;
7651
7658
  planName?: string;
@@ -7660,6 +7667,13 @@ interface AiRefusal {
7660
7667
  href?: string;
7661
7668
  };
7662
7669
  }
7670
+ /** A credit pack the studio's plan sells, and the portal page that sells it for this studio (P-D14). */
7671
+ interface AiBuyCredits {
7672
+ credits: number;
7673
+ /** US dollars for one pack. */
7674
+ amount: number;
7675
+ url: string;
7676
+ }
7663
7677
  /** The studio's AI credits this period (the connector's meter, E4). `allowance: null` = unlimited. */
7664
7678
  interface AiMeter {
7665
7679
  used: number;
@@ -7667,6 +7681,8 @@ interface AiMeter {
7667
7681
  remaining: number | null;
7668
7682
  periodStart: string;
7669
7683
  periodEnd: string;
7684
+ /** Where more credits are bought; null/absent = the plan sells none here (ask IOX instead). */
7685
+ buy?: AiBuyCredits | null;
7670
7686
  }
7671
7687
  /** The plan entitlements AI reads (the control plane's `features` / `limits` keys) — ONE spelling. */
7672
7688
  declare enum AiFeature {
@@ -9558,5 +9574,5 @@ declare function applyLayoutEdits(page: LayoutPage, edits: ReadonlyArray<LayoutE
9558
9574
  /** The strict format a repair is asked in: `{ edits: [{ op, path, value }] }`, every key required. */
9559
9575
  declare function layoutRepairJsonSchema(): JsonSchema;
9560
9576
 
9561
- export { ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, 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_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, FilmUnplaced, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEBREW_PREFIXES, 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_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, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutMendKind, 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, PublishRefusalCode, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOWCASE_FILM, 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_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, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, 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, aiStepParts, applyLayoutEdits, applyOwnPhotoGalleries, applyPictureScrims, applyPlanEdits, applyStockItemPhotos, applyStockPhotos, archetypeIssues, areaLuminance, artDirectionFor, artDirectionIssues, artDirectionPreamble, aspectRatioOf, assertStyleSlots, assertValidSitePlan, auditLayoutMotion, auditSite, barIconForRoute, blocksPublish, brandHueWord, buildKeys, buildStepFacts, builtHomePageId, calmParts, calmUnder, checkLayout, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, describeInventoryForPrompt, describePlanData, describeShapeKey, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, frameWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutLookChanges, layoutLookOf, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, luminanceOf, measureLayout, mendLayout, modelCanDo, moveBarItem, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, shownTogether, signatureOf, siteNavPages, slotBudget, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, withDerivedSources, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
9562
- export type { AddBarItemResult, 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, ComposedRoute, ComposedSection, ComposedSite, ContentFieldPlan, ContentRoles, ContentSeedPlan, ContentTypePlan, CreateNodeOptions, CreatedRecord, DataSourcePlan, DriftBox, DriftLayer, DriftMeeting, DynamicKeysAsList, EntranceAction, EntranceActionOptions, EntranceInteraction, EntranceMark, EntranceSpec, EntranceStamp, FactKey, FilmPlacement, FilmTarget, FingerprintedPage, FrameRegion, JsonSchema, LayoutBandMove, LayoutColours, LayoutEdit, LayoutFingerprint, LayoutForm, LayoutGallery, LayoutGalleryList, LayoutGap, LayoutGivenAway, LayoutIssue, LayoutLayer, LayoutLook, LayoutMend, LayoutPage, LayoutPhotoAddress, LayoutReadyMade, LayoutRect, LayoutSection, LayoutSite, LayoutTrack, LayoutVoid, LayoutWire, LayoutWireLayer, LayoutWireSection, LayoutWireSlot, LayoutWireTrack, 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, PlanWireContext, PlanWireParts, PlanWordContext, PlanWordIssue, PreflightRefusal, PublishRefusal, RecipeListBinds, RelativeDataSourcePlan, ScrimChoice, SectionEntrances, SectionFallback, SectionInput, SectionJudge, SectionOptions, SectionSwap, SerializedBinding, SerializedNode, SerializedResponsive, ShapeEntry, ShapeIssueCodes, ShowcaseInput, SiteAudit, SiteAuditOptions, SiteAuditSnapshot, SiteBuildRun, SiteBusiness, SiteCheck, SiteFinding, SiteNeedId, SitePageRef, SitePattern, SitePlan, 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 };
9577
+ export { ACTION_START_SCALE, ACTIVE_BUILD_STATUSES, AI_REFUSAL_NEXT, AI_REFUSAL_STATUS, AI_STEPS, 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_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, FilmUnplaced, GRAMMAR_TOO_LARGE_MESSAGE, GlobalSlot, HEBREW_PREFIXES, 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_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, LayoutAlign, LayoutBleed, LayoutButtonVariant, LayoutColour, LayoutColourMode, LayoutDepth, LayoutDial, LayoutEase, LayoutEditOp, LayoutEnter, LayoutGalleryEffect, LayoutGapCode, LayoutIssueCode, LayoutLayerKind, LayoutMendKind, 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, PublishRefusalCode, RENDER_CHECK, REQUIRED_CONTENT_ROLES, RelativeOp, SAMPLE_IMAGE_REF, SCENE_LEVEL, SCENE_OTHER_PAGES, SCRIM_BACKGROUND, SCRIM_COVER, SCRIM_LEVELS, SHOWCASE_FILM, 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_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, STRICT_SCHEMA_BUDGET, STRICT_SCHEMA_LIMITS, STUDIO_TEMPLATE, ScrimLevel, SectionFallbackLastResort, SectionSwapAction, SectionSwapRule, 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, builtHomePageId, calmParts, calmUnder, checkLayout, chooseScrim, composeContextOf, composeLayout, composeNavHeader, composePresetForm, composeSection, composeSite, contentTypeOfSource, contentTypePreviewFields, contentTypeToWire, copyLengthOf, costUsd, coverCrop, createSerializedNode, creditsOfUsd, dataSourceToWire, derivedBeats, derivedDataSources, describeInventoryForPrompt, describePlanData, describeShapeKey, driftAt, driftOverlap, emptyAreaPhrase, entranceAction, entranceInteraction, estimatePictures, estimateStepCredits, expandLayoutWire, expandPlanWire, expandWireContentType, expandWireDataSource, expandWireEdit, expandWireField, expandWirePage, expandWireSection, failedBuildStep, fallBackBySection, fieldToWire, filmOfPlan, filmPlacement, findNavRoot, fingerprintOf, frameWords, isActiveBuild, isLayoutRule, isNonEmptyString, isPictureWorld, isPlainObject, isRtlLocale, jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonSchemaKeywords, jsonSchemaObjects, jsonShapedObject, jsonText, judgeLayoutRender, layerShownSpans, layoutBandScheme, layoutBoxPx, layoutColumnsVw, layoutDesignOf, layoutDialOf, layoutDriftPhoto, layoutElementStyle, layoutGalleryLists, layoutGallerySources, layoutGlideDepth, layoutHeldStill, layoutLookChanges, layoutLookOf, layoutMotionOf, layoutNodeClass, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutPathSteps, layoutPhotoIds, layoutPresetColours, layoutPresetOf, layoutRepairJsonSchema, layoutRoomPx, layoutRuleEdge, layoutShapeHasPurpose, layoutStillLine, layoutTextFits, layoutTextWidthEm, layoutToWire, layoutVoidScreens, layoutVoids, layoutWireJsonSchema, luminanceOf, measureLayout, mendLayout, modelCanDo, moveBarItem, navPages, navShapeBreakpoint, navShapeOf, nextSourceOf, nodeBindPaths, orientationOfRatio, ownPhotoFit, pageToWire, parseLayoutPhotoId, parsePatternPath, parseSampleImageRef, pathAt, patternById, patternHasForm, patternLinkSlots, patternListGap, patternManifest, patternNeedsBinding, patternNodes, patternOptionalParts, patternRoleNeeds, patternScopes, patternSlotBudgets, patternSlots, patternTakesBinding, phoneGapBefore, phoneMenuPages, phoneWordsColour, photoInventory, photoShapeOf, pictureAspect, picturePrompt, pictureRefusalOf, pictureRerolls, pictureReviewIssues, pictureReviewJsonSchema, pictureReviewPasses, pictureSlotKey, pictureTargets, pictureTryFits, pixelsUnder, placeFilm, planEditOps, planEditToWire, planEditWireGaps, planEditWireKeys, planEditWireOps, planEditWireShape, planEditsFromWire, planEditsJsonSchema, planEditsToWire, planEntrances, planFromTemplate, planLayoutPhotos, planNavShape, planOwnPhotos, planPartOfPath, planPartToWire, planPictures, planStockPhotos, planToWire, planWireGaps, planWirePartJsonSchema, planWirePartShape, planWordIssues, publishRefusal, publishVerdict, readyMadeColumn, recipeListBinds, recomposeAsks, releasedLayoutDefaults, removeBarItem, requiredAcknowledgements, requiredShapeKeys, roleField, routeMatches, routeParams, samenessIssues, sampleImageRef, scoreStockPhoto, screenFontSize, screenWordColumns, screenWordMisfit, screenWordOverflowPx, sectionEntrances, sectionPatternIds, sectionToWire, sectionsNamed, sequenceShare, sequenceTokenOf, setStyleProps, shapeKeys, showcaseGlobals, showcasePages, showcasePlans, showcaseScenes, shownTogether, signatureOf, siteNavPages, slotBudget, splitSide, stockCopyKey, stockCreditLine, stockCreditLines, stockCreditNode, stockCreditNodeId, stockFits, stockGroupOf, stockItemSlots, stockKept, stockPhotoRatio, stockPhotoSubject, stockPhotoUsable, stockPhotoWords, stockSlots, stockWord, stockWords, strictSchemaComplexity, strictSchemaRefusal, toneOf, typicalStepTokens, validatePlanEdits, validateSitePlan, walkSerialized, wireContentTypeJsonSchema, wireDataSourceJsonSchema, wireFieldJsonSchema, wirePageJsonSchema, wireSectionJsonSchema, withDerivedSources, wordPattern, wordsOverPhotos, wordsOverPicture, writtenTexts };
9578
+ 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, ComposedRoute, ComposedSection, ComposedSite, ContentFieldPlan, ContentRoles, ContentSeedPlan, ContentTypePlan, CreateNodeOptions, CreatedRecord, DataSourcePlan, DriftBox, DriftLayer, DriftMeeting, DynamicKeysAsList, EntranceAction, EntranceActionOptions, EntranceInteraction, EntranceMark, EntranceSpec, EntranceStamp, FactKey, FilmPlacement, FilmTarget, FingerprintedPage, FrameRegion, JsonSchema, LayoutBandMove, LayoutColours, LayoutEdit, LayoutFingerprint, LayoutForm, LayoutGallery, LayoutGalleryList, LayoutGap, LayoutGivenAway, LayoutIssue, LayoutLayer, LayoutLook, LayoutMend, LayoutPage, LayoutPhotoAddress, LayoutReadyMade, LayoutRect, LayoutSection, LayoutSite, LayoutTrack, LayoutVoid, LayoutWire, LayoutWireLayer, LayoutWireSection, LayoutWireSlot, LayoutWireTrack, 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, PlanWireContext, PlanWireParts, PlanWordContext, PlanWordIssue, PreflightRefusal, PublishRefusal, RecipeListBinds, RelativeDataSourcePlan, ScrimChoice, SectionEntrances, SectionFallback, SectionInput, SectionJudge, SectionOptions, SectionSwap, SerializedBinding, SerializedNode, SerializedResponsive, ShapeEntry, ShapeIssueCodes, ShowcaseInput, SiteAudit, SiteAuditOptions, SiteAuditSnapshot, SiteBuildRun, SiteBusiness, SiteCheck, SiteFinding, SiteNeedId, SitePageRef, SitePattern, SitePlan, 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.91.1",
3
+ "version": "5.93.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=20.0.0",
6
6
  "@angular/core": ">=20.0.0",
@@ -23,6 +23,10 @@
23
23
  "types": "./actions-core/index.d.ts",
24
24
  "default": "./fesm2022/vectoriox-iox-ui-actions-core.mjs"
25
25
  },
26
+ "./commerce-core": {
27
+ "types": "./commerce-core/index.d.ts",
28
+ "default": "./fesm2022/vectoriox-iox-ui-commerce-core.mjs"
29
+ },
26
30
  "./composite-core": {
27
31
  "types": "./composite-core/index.d.ts",
28
32
  "default": "./fesm2022/vectoriox-iox-ui-composite-core.mjs"
@@ -0,0 +1,99 @@
1
+ import { MoneyError, MoneyErrorCode } from './money-error';
2
+
3
+ export enum CurrencyCode {
4
+ ILS = 'ILS',
5
+ USD = 'USD',
6
+ EUR = 'EUR',
7
+ GBP = 'GBP',
8
+ CHF = 'CHF',
9
+ CAD = 'CAD',
10
+ AUD = 'AUD',
11
+ NZD = 'NZD',
12
+ SEK = 'SEK',
13
+ NOK = 'NOK',
14
+ DKK = 'DKK',
15
+ PLN = 'PLN',
16
+ CZK = 'CZK',
17
+ HUF = 'HUF',
18
+ RON = 'RON',
19
+ TRY = 'TRY',
20
+ AED = 'AED',
21
+ SAR = 'SAR',
22
+ QAR = 'QAR',
23
+ EGP = 'EGP',
24
+ MAD = 'MAD',
25
+ ZAR = 'ZAR',
26
+ INR = 'INR',
27
+ CNY = 'CNY',
28
+ HKD = 'HKD',
29
+ SGD = 'SGD',
30
+ THB = 'THB',
31
+ MXN = 'MXN',
32
+ BRL = 'BRL',
33
+ JPY = 'JPY',
34
+ KRW = 'KRW',
35
+ VND = 'VND',
36
+ CLP = 'CLP',
37
+ ISK = 'ISK',
38
+ BHD = 'BHD',
39
+ KWD = 'KWD',
40
+ JOD = 'JOD',
41
+ OMR = 'OMR',
42
+ TND = 'TND',
43
+ }
44
+
45
+ /** ISO-4217 minor units — our own table, never Intl's CLDR digits (they differ for some codes). */
46
+ export const CURRENCY_EXPONENTS: Readonly<Record<CurrencyCode, number>> = Object.freeze({
47
+ [CurrencyCode.ILS]: 2,
48
+ [CurrencyCode.USD]: 2,
49
+ [CurrencyCode.EUR]: 2,
50
+ [CurrencyCode.GBP]: 2,
51
+ [CurrencyCode.CHF]: 2,
52
+ [CurrencyCode.CAD]: 2,
53
+ [CurrencyCode.AUD]: 2,
54
+ [CurrencyCode.NZD]: 2,
55
+ [CurrencyCode.SEK]: 2,
56
+ [CurrencyCode.NOK]: 2,
57
+ [CurrencyCode.DKK]: 2,
58
+ [CurrencyCode.PLN]: 2,
59
+ [CurrencyCode.CZK]: 2,
60
+ [CurrencyCode.HUF]: 2,
61
+ [CurrencyCode.RON]: 2,
62
+ [CurrencyCode.TRY]: 2,
63
+ [CurrencyCode.AED]: 2,
64
+ [CurrencyCode.SAR]: 2,
65
+ [CurrencyCode.QAR]: 2,
66
+ [CurrencyCode.EGP]: 2,
67
+ [CurrencyCode.MAD]: 2,
68
+ [CurrencyCode.ZAR]: 2,
69
+ [CurrencyCode.INR]: 2,
70
+ [CurrencyCode.CNY]: 2,
71
+ [CurrencyCode.HKD]: 2,
72
+ [CurrencyCode.SGD]: 2,
73
+ [CurrencyCode.THB]: 2,
74
+ [CurrencyCode.MXN]: 2,
75
+ [CurrencyCode.BRL]: 2,
76
+ [CurrencyCode.JPY]: 0,
77
+ [CurrencyCode.KRW]: 0,
78
+ [CurrencyCode.VND]: 0,
79
+ [CurrencyCode.CLP]: 0,
80
+ [CurrencyCode.ISK]: 0,
81
+ [CurrencyCode.BHD]: 3,
82
+ [CurrencyCode.KWD]: 3,
83
+ [CurrencyCode.JOD]: 3,
84
+ [CurrencyCode.OMR]: 3,
85
+ [CurrencyCode.TND]: 3,
86
+ });
87
+
88
+ export const CURRENCY_CODES: readonly CurrencyCode[] = Object.freeze(Object.values(CurrencyCode));
89
+
90
+ export function isCurrencyCode(value: unknown): value is CurrencyCode {
91
+ return typeof value === 'string' && Object.prototype.hasOwnProperty.call(CURRENCY_EXPONENTS, value);
92
+ }
93
+
94
+ export function currencyExponent(currency: CurrencyCode): number {
95
+ if (!isCurrencyCode(currency)) {
96
+ throw new MoneyError(MoneyErrorCode.UnknownCurrency, `Unknown currency: ${String(currency)}`);
97
+ }
98
+ return CURRENCY_EXPONENTS[currency];
99
+ }
@@ -0,0 +1,78 @@
1
+ import { MoneyError, MoneyErrorCode } from './money-error';
2
+
3
+ export interface DecimalDigits {
4
+ negative: boolean;
5
+ int: string;
6
+ frac: string;
7
+ }
8
+
9
+ export enum DecimalRounding {
10
+ Exact = 'exact',
11
+ HalfEven = 'half-even',
12
+ }
13
+
14
+ const DECIMAL = /^([+-])?(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d{1,3}))?$/;
15
+
16
+ /** Plain decimal text, or the e-notation `String(number)` produces below 1e-6 and from 1e21. */
17
+ export function parseDecimal(text: string): DecimalDigits | null {
18
+ const match = DECIMAL.exec(text);
19
+ if (!match) return null;
20
+ const int = match[2] ?? '';
21
+ const frac = match[3] ?? '';
22
+ if (!int && !frac) return null;
23
+ const digits = int + frac;
24
+ const point = int.length + Number(match[4] ?? 0);
25
+ const shiftedInt = point <= 0 ? '' : point >= digits.length ? digits + '0'.repeat(point - digits.length) : digits.slice(0, point);
26
+ const shiftedFrac = point <= 0 ? '0'.repeat(-point) + digits : point >= digits.length ? '' : digits.slice(point);
27
+ return {
28
+ negative: match[1] === '-',
29
+ int: shiftedInt.replace(/^0+/, ''),
30
+ frac: shiftedFrac.replace(/0+$/, ''),
31
+ };
32
+ }
33
+
34
+ function safeFromDigits(digits: string): number {
35
+ const trimmed = digits.replace(/^0+/, '') || '0';
36
+ const value = trimmed.length > 16 ? Infinity : Number(trimmed);
37
+ if (!Number.isSafeInteger(value)) {
38
+ throw new MoneyError(MoneyErrorCode.Overflow, `${digits} is beyond the safe integer range`);
39
+ }
40
+ return value;
41
+ }
42
+
43
+ /** Scales a parsed decimal by 10^exponent into an integer, without ever touching a float. */
44
+ export function decimalToScaledInteger(decimal: DecimalDigits, exponent: number, rounding: DecimalRounding): number {
45
+ const kept = decimal.frac.slice(0, exponent);
46
+ const rest = decimal.frac.slice(exponent);
47
+ if (rest && rounding === DecimalRounding.Exact) {
48
+ throw new MoneyError(MoneyErrorCode.TooManyDecimals, `More than ${exponent} decimal digits`);
49
+ }
50
+ let magnitude = safeFromDigits(decimal.int + kept.padEnd(exponent, '0'));
51
+ if (rest) {
52
+ const first = Number(rest[0]);
53
+ const tie = first === 5 && /^5$/.test(rest);
54
+ const up = first > 5 || (first === 5 && !tie) || (tie && magnitude % 2 === 1);
55
+ if (up) magnitude += 1;
56
+ if (!Number.isSafeInteger(magnitude)) {
57
+ throw new MoneyError(MoneyErrorCode.Overflow, 'Rounded value is beyond the safe integer range');
58
+ }
59
+ }
60
+ return decimal.negative && magnitude !== 0 ? -magnitude : magnitude;
61
+ }
62
+
63
+ /** Integer division rounded half-to-even; numerator ≥ 0, denominator > 0, both safe integers. */
64
+ export function divideHalfEven(numerator: number, denominator: number): number {
65
+ let quotient = Math.trunc(numerator / denominator);
66
+ let remainder = numerator - quotient * denominator;
67
+ while (remainder < 0) {
68
+ quotient -= 1;
69
+ remainder += denominator;
70
+ }
71
+ while (remainder >= denominator) {
72
+ quotient += 1;
73
+ remainder -= denominator;
74
+ }
75
+ const twice = remainder * 2;
76
+ if (twice > denominator || (twice === denominator && quotient % 2 === 1)) quotient += 1;
77
+ return quotient;
78
+ }
@@ -0,0 +1,18 @@
1
+ export enum MoneyErrorCode {
2
+ UnknownCurrency = 'unknown-currency',
3
+ NotMoney = 'not-money',
4
+ NotInteger = 'not-integer',
5
+ NotANumber = 'not-a-number',
6
+ TooManyDecimals = 'too-many-decimals',
7
+ CurrencyMismatch = 'currency-mismatch',
8
+ NotWhole = 'not-whole',
9
+ Negative = 'negative',
10
+ Overflow = 'overflow',
11
+ }
12
+
13
+ export class MoneyError extends Error {
14
+ constructor(readonly code: MoneyErrorCode, message: string) {
15
+ super(message);
16
+ this.name = 'MoneyError';
17
+ }
18
+ }
@@ -0,0 +1,159 @@
1
+ import { CurrencyCode, currencyExponent, isCurrencyCode } from './currency';
2
+ import { DecimalRounding, decimalToScaledInteger, divideHalfEven, parseDecimal } from './decimal';
3
+ import { MoneyError, MoneyErrorCode } from './money-error';
4
+
5
+ export interface Money {
6
+ /** Integer minor units (agorot, cents, fils…). */
7
+ amount: number;
8
+ currency: CurrencyCode;
9
+ }
10
+
11
+ const MAX_PERCENT_DECIMALS = 6;
12
+
13
+ export function isMoney(value: unknown): value is Money {
14
+ if (typeof value !== 'object' || value === null) return false;
15
+ const record = value as Record<string, unknown>;
16
+ return Number.isSafeInteger(record['amount']) && isCurrencyCode(record['currency']);
17
+ }
18
+
19
+ function assertWhole(amount: number, what: string): void {
20
+ if (typeof amount !== 'number' || !Number.isSafeInteger(amount)) {
21
+ throw new MoneyError(MoneyErrorCode.NotInteger, `${what} must be a whole number of minor units, got ${String(amount)}`);
22
+ }
23
+ }
24
+
25
+ function assertMoney(value: Money): void {
26
+ if (typeof value !== 'object' || value === null) {
27
+ throw new MoneyError(MoneyErrorCode.NotMoney, `Not a Money value: ${String(value)}`);
28
+ }
29
+ currencyExponent(value.currency);
30
+ assertWhole(value.amount, 'Money.amount');
31
+ }
32
+
33
+ function assertSameCurrency(a: Money, b: Money): void {
34
+ assertMoney(a);
35
+ assertMoney(b);
36
+ if (a.currency !== b.currency) {
37
+ throw new MoneyError(MoneyErrorCode.CurrencyMismatch, `Cannot combine ${a.currency} with ${b.currency}`);
38
+ }
39
+ }
40
+
41
+ function safeResult(amount: number, currency: CurrencyCode): Money {
42
+ if (!Number.isSafeInteger(amount)) {
43
+ throw new MoneyError(MoneyErrorCode.Overflow, 'Result is beyond the safe integer range');
44
+ }
45
+ return { amount: amount === 0 ? 0 : amount, currency };
46
+ }
47
+
48
+ export function money(amount: number, currency: CurrencyCode): Money {
49
+ currencyExponent(currency);
50
+ assertWhole(amount, 'amount');
51
+ return { amount: amount === 0 ? 0 : amount, currency };
52
+ }
53
+
54
+ function decimalText(value: number | string): string | null {
55
+ if (typeof value === 'number') return Number.isFinite(value) ? String(value) : null;
56
+ if (typeof value === 'string') return value.trim();
57
+ return null;
58
+ }
59
+
60
+ /** Exact: `19.99` → 1999 by reading the digits, never `x * 100`; refuses digits the currency lacks. */
61
+ export function majorToMinor(major: number | string, currency: CurrencyCode): number {
62
+ const exponent = currencyExponent(currency);
63
+ const text = decimalText(major);
64
+ const decimal = text === null ? null : parseDecimal(text);
65
+ if (!decimal) {
66
+ throw new MoneyError(MoneyErrorCode.NotANumber, `Not a decimal amount: ${String(major)}`);
67
+ }
68
+ return decimalToScaledInteger(decimal, exponent, DecimalRounding.Exact);
69
+ }
70
+
71
+ export function minorToMajor(minor: number, currency: CurrencyCode): number {
72
+ const exponent = currencyExponent(currency);
73
+ assertWhole(minor, 'minor');
74
+ return exponent === 0 ? minor : minor / 10 ** exponent;
75
+ }
76
+
77
+ export function addMoney(a: Money, b: Money): Money {
78
+ assertSameCurrency(a, b);
79
+ return safeResult(a.amount + b.amount, a.currency);
80
+ }
81
+
82
+ export function subtractMoney(a: Money, b: Money): Money {
83
+ assertSameCurrency(a, b);
84
+ return safeResult(a.amount - b.amount, a.currency);
85
+ }
86
+
87
+ export function timesMoney(value: Money, quantity: number): Money {
88
+ assertMoney(value);
89
+ if (typeof quantity !== 'number' || !Number.isSafeInteger(quantity)) {
90
+ throw new MoneyError(MoneyErrorCode.NotWhole, `Quantity must be a whole number, got ${String(quantity)}`);
91
+ }
92
+ if (quantity < 0) {
93
+ throw new MoneyError(MoneyErrorCode.Negative, `Quantity cannot be negative, got ${quantity}`);
94
+ }
95
+ return safeResult(value.amount * quantity, value.currency);
96
+ }
97
+
98
+ /** `percent` of an amount, rounded ONCE to a minor unit, half-to-even (banker's). */
99
+ export function percentOf(value: Money, percent: number): Money {
100
+ assertMoney(value);
101
+ if (typeof percent !== 'number' || !Number.isFinite(percent)) {
102
+ throw new MoneyError(MoneyErrorCode.NotANumber, `Percent must be a finite number, got ${String(percent)}`);
103
+ }
104
+ if (percent < 0) {
105
+ throw new MoneyError(MoneyErrorCode.Negative, `Percent cannot be negative, got ${percent}`);
106
+ }
107
+ const decimal = parseDecimal(String(percent));
108
+ if (!decimal) {
109
+ throw new MoneyError(MoneyErrorCode.NotANumber, `Percent must be a finite number, got ${String(percent)}`);
110
+ }
111
+ if (decimal.frac.length > MAX_PERCENT_DECIMALS) {
112
+ throw new MoneyError(MoneyErrorCode.TooManyDecimals, `Percent has more than ${MAX_PERCENT_DECIMALS} decimal digits`);
113
+ }
114
+ const scale = decimal.frac.length;
115
+ const percentScaled = decimalToScaledInteger(decimal, scale, DecimalRounding.Exact);
116
+ const numerator = Math.abs(value.amount) * percentScaled;
117
+ if (!Number.isSafeInteger(numerator)) {
118
+ throw new MoneyError(MoneyErrorCode.Overflow, 'Percent of this amount is beyond the safe integer range');
119
+ }
120
+ const magnitude = divideHalfEven(numerator, 100 * 10 ** scale);
121
+ return safeResult(value.amount < 0 ? -magnitude : magnitude, value.currency);
122
+ }
123
+
124
+ const formatters = new Map<string, Intl.NumberFormat>();
125
+
126
+ export function formatMoney(value: Money, locale: string): string {
127
+ assertMoney(value);
128
+ const exponent = currencyExponent(value.currency);
129
+ const key = `${locale}|${value.currency}`;
130
+ let formatter = formatters.get(key);
131
+ if (!formatter) {
132
+ formatter = new Intl.NumberFormat(locale, {
133
+ style: 'currency',
134
+ currency: value.currency,
135
+ minimumFractionDigits: exponent,
136
+ maximumFractionDigits: exponent,
137
+ });
138
+ formatters.set(key, formatter);
139
+ }
140
+ return formatter.format(minorToMajor(value.amount, value.currency));
141
+ }
142
+
143
+ /**
144
+ * For the one boot migration of stored major-unit prices. A stored float may carry arithmetic noise
145
+ * (19.990000000000002), so extra digits round half-to-even instead of refusing. No usable price
146
+ * (null, '', NaN, text, a negative) → null; it never applies twice by itself — the caller marks rows.
147
+ */
148
+ export function migrateMajorPrice(value: unknown, currency: CurrencyCode): number | null {
149
+ const exponent = currencyExponent(currency);
150
+ if (typeof value !== 'number' && typeof value !== 'string') return null;
151
+ const text = decimalText(value);
152
+ const decimal = text ? parseDecimal(text) : null;
153
+ if (!decimal || (decimal.negative && (decimal.int || decimal.frac))) return null;
154
+ try {
155
+ return decimalToScaledInteger(decimal, exponent, DecimalRounding.HalfEven);
156
+ } catch {
157
+ return null;
158
+ }
159
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @vectoriox/iox-ui/commerce-core — the shared, FRAMEWORK-FREE core of selling (commerce plan C-D7).
3
+ *
4
+ * Money is integer minor units in one ISO-4217 currency, so the engine, the builder and iox-cms
5
+ * compute the same totals (trap T6: never a float). E0 ships Money and its helpers; priceCart,
6
+ * ORDER_TRANSITIONS and carts arrive with E1.
7
+ * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets,
8
+ * jest moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
9
+ */
10
+ export * from './money-error';
11
+ export * from './currency';
12
+ export * from './money';
@@ -229,6 +229,8 @@ export enum AiNextKind {
229
229
  Retry = 'retry',
230
230
  /** Keep the plan there is: build it, or change it with a sentence. */
231
231
  KeepPlan = 'keepPlan',
232
+ /** Buy a credit pack on the portal (P-D14) — `href` is the page that sells it for this studio; its owner pays. */
233
+ BuyCredits = 'buyCredits',
232
234
  }
233
235
 
234
236
  export const AI_REFUSAL_NEXT: Readonly<Record<AiRefusalCode, AiNextKind>> = {
@@ -241,6 +243,14 @@ export const AI_REFUSAL_NEXT: Readonly<Record<AiRefusalCode, AiNextKind>> = {
241
243
  [AiRefusalCode.PlanUnknown]: AiNextKind.Retry,
242
244
  };
243
245
 
246
+ /**
247
+ * What a refusal offers next: the table, except that credits run out on a plan that sells a pack — then the portal
248
+ * page that sells it (P-D14). The ONE place that choice is made; the studio adds the href.
249
+ */
250
+ export function aiRefusalNext(code: AiRefusalCode, buy?: AiBuyCredits | null): AiNextKind {
251
+ return code === AiRefusalCode.OutOfCredits && buy ? AiNextKind.BuyCredits : AI_REFUSAL_NEXT[code];
252
+ }
253
+
244
254
  export interface AiRefusal {
245
255
  code: AiRefusalCode;
246
256
  planName?: string;
@@ -253,6 +263,14 @@ export interface AiRefusal {
253
263
  next: { kind: AiNextKind; href?: string };
254
264
  }
255
265
 
266
+ /** A credit pack the studio's plan sells, and the portal page that sells it for this studio (P-D14). */
267
+ export interface AiBuyCredits {
268
+ credits: number;
269
+ /** US dollars for one pack. */
270
+ amount: number;
271
+ url: string;
272
+ }
273
+
256
274
  /** The studio's AI credits this period (the connector's meter, E4). `allowance: null` = unlimited. */
257
275
  export interface AiMeter {
258
276
  used: number;
@@ -260,6 +278,8 @@ export interface AiMeter {
260
278
  remaining: number | null;
261
279
  periodStart: string;
262
280
  periodEnd: string;
281
+ /** Where more credits are bought; null/absent = the plan sells none here (ask IOX instead). */
282
+ buy?: AiBuyCredits | null;
263
283
  }
264
284
 
265
285
  /** The plan entitlements AI reads (the control plane's `features` / `limits` keys) — ONE spelling. */