/*! * Nuva Product Recommendation — Live Integration (Phase 6C, ADVANCED FLOW) * --------------------------------------------------------------------------- * PURPOSE * Wires the already-built, already-tested Phase 6A matching engine and * Phase 6B product recommendation system into the LIVE "Advanced Skin * Scan" results page (/ai-skin-scan/, WordPress page 199, customer-facing * title "Advanced Skin Scan"). * * Unlike the Free flow's Phase 3B script, the Advanced flow's Phase 5D * "Results UI" script does not pre-declare a product placeholder * container - it renders a single HTML string * (renderNormalResults()/renderSafetyResults()) directly into its mount * element (#nuvaAdvancedScanRoot) as one atomic innerHTML assignment. This * file therefore observes that mount element the same non-invasive way * Phase 5D itself observes Phase 5A (see Phase 5D's own patchSubmit() * comment: "Isolated module... without editing a single line of the * [earlier] source file") and appends its own container once real * (non-safety) results are present - it never edits Phase 5D's source. * * REQUIRED LOAD ORDER on this page (all already present except the last two): * 1. Phase 5A - Advanced Skin Scan questionnaire * 2. Phase 5B - Advanced assessment engine (window.NuvaAdvancedAssessmentEngine) * 3. Phase 5C - Advanced ingredient recommendation (window.NuvaAdvancedIngredientRecommendationEngine) * 4. Phase 5D - Advanced "Results UI" (window.NuvaAdvancedResultsUI) * 5. Phase 6A - Product matching engine (window.NuvaProductMatchingEngine) [ADDED] * 6. Phase 6B - Product catalog admin (window.NuvaProductCatalogAdmin) [ADDED] * 7. Phase 6B - Product recommendation UI (window.NuvaProductRecommendationUI) [ADDED] * 8. Phase 6B - Product detail UI (window.NuvaProductDetailUI) [ADDED] * 9. Phase 6B - Cart (window.NuvaCart) [ADDED] * 10. Phase 6B - Checkout foundation (window.NuvaCheckout) [ADDED] * 11. THIS FILE - Advanced flow integration glue [ADDED] * * NOTE: nuva_dev_placeholder_products.js is intentionally NOT loaded on * this live page, for the same reason as the Free flow (see the Free * integration file's header comment). * * ASSESSMENT / RECOMMENDATION SOURCE * Uses ONLY the existing, published, public methods that Phase 5D's own * internal resolveAssessment()/resolveRecommendation() helpers use * (confirmed from the live Phase 5D source): * window.NuvaAdvancedAssessmentEngine.runAdvancedAssessment() (falls * back to .loadAdvancedAssessment()) * window.NuvaAdvancedIngredientRecommendationEngine.runAdvancedRecommendation() * (falls back to .loadAdvancedRecommendation()) * Both "run" methods are side-effect-limited: they only (re)compute from * whatever completed submission is already stored, and are safe to call * more than once (Phase 5B/5C's own documented behavior) - this file does * not add any new computation of its own. * * SAFETY * Phase 5D's own renderSafetyResults() path never includes primaryDirection * / supportingDirections / ingredientGuidance / routineGuidance, and this * file additionally never even attempts to find or create a product * container when a ".nar-safety-shell" element is present in the results - * the safety-results render stays 100% product-free, on top of (not * instead of) NuvaProductCatalogAdmin's own unconditional safety-first * check inside getRecommendations(). * * WHAT THIS FILE DOES NOT DO * - Does not modify nuva_product_matching_engine.js, the Advanced * assessment engine, or the Advanced ingredient recommendation engine. * - Does not modify the Phase 5D Results UI script's source. * - Does not re-implement product cards, product detail, cart, or * checkout. * - Does not add a product-count limit of any kind. */ (function (root, document) { 'use strict'; var MOUNT_ID = 'nuvaAdvancedScanRoot'; var CONTAINER_ID = 'nuvaAdvancedProductRecommendations'; var DONE_ATTR = 'data-nuva-6c-integrated'; var STYLE_ID = 'nuvaProductRecommendationStyles'; /** * Identical stylesheet to the Free flow's integration file (see that * file's header comment for rationale) - kept as a literal duplicate * rather than a shared import so each page remains a single, * self-contained set of