@wewear/virtual-try-on 1.1.0 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/widget.ts","../src/installer.ts"],"sourcesContent":["/**\n * WeWear Virtual Try-On Widget Implementation\n *\n * Core widget class that handles virtual try-on functionality integration.\n * Manages button creation, API communication, and modal display.\n */\n\nimport type { VirtualTryOnConfig, VirtualTryOnResult } from \"./index.js\";\n\n/** Default configuration constants */\nconst DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nconst CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nconst Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Retrieves a cookie value by name\n * @param name - Cookie name to retrieve\n * @returns Cookie value or null if not found\n */\n private getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n }\n\n /**\n * Makes API call to virtual try-on service\n * @param ww_access_token - Optional authentication token\n * @param ww_user_id - User identifier\n /**\n * Creates the virtual try-on button element\n * @param onClick - Click handler function\n * @returns Button container element\n */\n private createButton(onClick: () => void): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = CSS_CLASSES.BUTTON_CONTAINER;\n\n const positionStyles = this.getPositionStyles();\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 50%;\n background: #000000;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n `;\n\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = CSS_CLASSES.BUTTON;\n button.setAttribute(\"aria-label\", \"Virtual Try-On\");\n button.setAttribute(\"title\", \"Try this product virtually\");\n button.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n padding: 10px;\n border: none;\n background: transparent;\n color: #ffffff;\n `;\n\n // Add hover effects\n container.addEventListener(\"mouseenter\", () => {\n container.style.transform = \"scale(1.05)\";\n container.style.boxShadow = \"0 30px 60px -12px rgba(0, 0, 0, 0.35)\";\n });\n\n container.addEventListener(\"mouseleave\", () => {\n container.style.transform = \"scale(1)\";\n container.style.boxShadow = \"0 25px 50px -12px rgba(0, 0, 0, 0.25)\";\n });\n\n button.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n button.onclick = onClick;\n container.appendChild(button);\n return container;\n }\n\n /**\n * Gets CSS position styles based on button position configuration\n * @returns CSS position string\n */\n private getPositionStyles(): string {\n switch (this.config.buttonPosition) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n }\n\n /**\n * Displays the virtual try-on result in a modal\n * @param imageUrl - URL of the virtual try-on image\n */\n private showImageModal(imageUrl: string): void {\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create image container\n const imageContainer = document.createElement(\"div\");\n imageContainer.style.cssText = `\n position: relative;\n max-width: 90%;\n max-height: 90%;\n background-color: white;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n overflow: hidden;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Virtual Try-On Result\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: contain;\n display: block;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 10px;\n right: 10px;\n width: 30px;\n height: 30px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 20px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n closeButton.onclick = () => {\n modal.remove();\n };\n\n // Close on backdrop click\n modal.onclick = (e) => {\n if (e.target === modal) {\n modal.remove();\n }\n };\n\n // Close on Escape key\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n modal.remove();\n document.removeEventListener(\"keydown\", handleEscape);\n }\n };\n document.addEventListener(\"keydown\", handleEscape);\n\n imageContainer.appendChild(image);\n imageContainer.appendChild(closeButton);\n modal.appendChild(imageContainer);\n document.body.appendChild(modal);\n }\n\n /**\n * Shows the camera capture modal\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private showCameraModal(\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = `\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"white\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"white\" stroke-width=\"2\" fill=\"none\"/>\n <circle cx=\"12\" cy=\"12\" r=\"6\" fill=\"white\"/>\n </svg>\n `;\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: transparent;\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n this.stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = () => {\n this.captureImage(\n video,\n canvas,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n modal,\n );\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n this.startCamera(video, loadingIndicator, captureButton);\n } /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = this.createButton(async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = this.getCookie(\"ww_access_token\");\n const ww_user_id = this.getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_id,\n ww_access_token: !!ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n this.showError(\"Please sign in to use virtual try-on\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n this.showError(\"Product information not available\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModal(ww_access_token, ww_user_id, ww_product_id);\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n this.showError(\"An unexpected error occurred. Please try again.\");\n }\n }\n\n /**\n * Shows an error message to the user\n * @param message - Error message to display\n * @private\n */\n private showError(message: string): void {\n // Simple alert for now - could be enhanced with a custom modal\n alert(`WeWear Virtual Try-On: ${message}`);\n }\n\n /**\n * Starts the camera stream\n * @param video - Video element to display camera stream\n * @param loadingIndicator - Loading indicator element\n * @param captureButton - Capture button element\n */\n private async startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n ): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n const constraints = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n };\n\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream = await navigator.mediaDevices.getUserMedia(constraints);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n }\n\n /**\n * Stops the camera stream\n * @param video - Video element with camera stream\n */\n private stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n }\n\n /**\n * Captures an image from the video stream\n * @param video - Video element with camera stream\n * @param canvas - Canvas element for capturing\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n * @param modal - Modal element to close after processing\n */\n private async captureImage(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n modal: HTMLElement,\n ): Promise<void> {\n try {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n const blob = await new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n \"image/jpeg\",\n 0.8,\n );\n });\n\n // Stop camera and close camera modal\n this.stopCamera(video);\n modal.remove();\n\n // Show review modal instead of immediately processing\n this.showReviewModal(blob, ww_access_token, ww_user_id, ww_product_id);\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n this.showError(\"Failed to capture image. Please try again.\");\n }\n }\n\n /**\n * Shows the review modal for captured image\n * @param imageBlob - Captured image blob\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private showReviewModal(\n imageBlob: Blob,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container (same as camera modal)\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create review container (similar to camera container)\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element (replaces video element)\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button (same as camera modal)\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container positioned at bottom (similar to capture button position)\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n gap: 15px;\n width: calc(100% - 40px);\n max-width: 300px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: transparent;\n color: white;\n border: 2px solid white;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: white;\n color: black;\n border: 2px solid white;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Add hover effects\n retakeButton.addEventListener(\"mouseenter\", () => {\n retakeButton.style.backgroundColor = \"white\";\n retakeButton.style.color = \"black\";\n });\n retakeButton.addEventListener(\"mouseleave\", () => {\n retakeButton.style.backgroundColor = \"transparent\";\n retakeButton.style.color = \"white\";\n });\n\n usePhotoButton.addEventListener(\"mouseenter\", () => {\n usePhotoButton.style.backgroundColor = \"rgba(255, 255, 255, 0.9)\";\n });\n usePhotoButton.addEventListener(\"mouseleave\", () => {\n usePhotoButton.style.backgroundColor = \"white\";\n });\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n // Reopen camera modal\n this.showCameraModal(ww_access_token, ww_user_id, ww_product_id);\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n // Process the image\n await this.processAcceptedImage(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n };\n\n // Assemble the review modal (similar to camera modal)\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n reviewContainer.appendChild(buttonContainer);\n modal.appendChild(reviewContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n }\n\n /**\n * Processes the accepted image by calling the API\n * @param imageBlob - Accepted image blob\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Call the API with the accepted image\n const result = await this.callVirtualTryOnApiWithImage(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n imageBlob,\n );\n\n if (result?.imageUrl) {\n this.showImageModal(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n this.showError(\"Failed to process image. Please try again.\");\n }\n }\n\n /**\n * Makes API call to virtual try-on service with captured image\n * @param ww_access_token - Optional authentication token\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n * @param imageBlob - Captured image blob\n * @returns Promise with virtual try-on result or null if failed\n */\n private async callVirtualTryOnApiWithImage(\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n imageBlob: Blob,\n ): Promise<VirtualTryOnResult | null> {\n try {\n // Create form data for multipart upload\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_id\", ww_product_id);\n formData.append(\"image\", imageBlob, \"captured-image.jpg\");\n\n if (ww_access_token) {\n formData.append(\"ww_access_token\", ww_access_token);\n }\n\n const response = await fetch(\n `${this.config.baseUrl}/api/virtual-try-on`,\n {\n method: \"POST\",\n body: formData,\n },\n );\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n const buttons = document.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n buttons.forEach((button) => {\n button.remove();\n });\n\n // Remove all modals\n const modals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n modals.forEach((modal) => {\n modal.remove();\n });\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","/**\n * WeWear Virtual Try-On Widget Auto-Installer\n *\n * Provides automatic initialization and management of the virtual try-on widget.\n * Handles DOM ready states and widget lifecycle management.\n */\n\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\n/**\n * Initializes the virtual try-on widget with optional configuration\n * @param config - Widget configuration options\n */\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\n/**\n * Destroys the current widget instance and cleans up resources\n */\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\n/**\n * Gets the current widget instance (for debugging purposes)\n * @returns Current widget instance or null\n */\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\n// Auto-initialize if window object exists (browser environment)\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAIH;AACA,MAAM,cAAc,GAAG;AACrB,IAAA,QAAQ,EAAE,0CAA0C;AACpD,IAAA,qBAAqB,EAAE,WAAW;AAClC,IAAA,gBAAgB,EAAE,qCAAqC;AACvD,IAAA,YAAY,EAAE,MAAM;AACpB,IAAA,eAAe,EAAE,cAAuB;CAChC;AAEV;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,gBAAgB,EAAE,6BAA6B;AAC/C,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,KAAK,EAAE,kBAAkB;CACjB;AAEV;AACA,MAAM,OAAO,GAAG;AACd,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,KAAK;CACJ;MAEG,kBAAkB,CAAA;AAG7B,IAAA,WAAA,CAAY,SAA6B,EAA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ACjC,IAAA,gBAAgB,EAAE;AACpB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/api.ts","../src/constants.ts","../src/camera.ts","../src/utils.ts","../src/components/button.ts","../src/components/camera-modal.ts","../src/components/image-modal.ts","../src/components/review-modal.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["import type { VirtualTryOnResult } from \"./index.js\";\n\nexport async function callVirtualTryOnApi(\n baseUrl: string,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ww_image: Blob,\n): Promise<VirtualTryOnResult | null> {\n try {\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_id\", ww_product_id);\n formData.append(\"ww_image\", ww_image, \"captured-image.jpg\");\n formData.append(\"ww_access_token\", ww_access_token);\n\n const response = await fetch(`${baseUrl}/api/virtual-try-on`, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n}\n","/** Default configuration constants */\nexport const DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\n/** Camera constraints for optimal capture */\nexport const CAMERA_CONSTRAINTS = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n} as const;\n\n/** Image capture settings */\nexport const IMAGE_SETTINGS = {\n FORMAT: \"image/jpeg\",\n QUALITY: 0.8,\n} as const;\n","import { CAMERA_CONSTRAINTS, IMAGE_SETTINGS } from \"./constants.js\";\n\nexport async function startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream =\n await navigator.mediaDevices.getUserMedia(CAMERA_CONSTRAINTS);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n}\n\nexport function stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n}\n\nexport async function captureImageFromVideo(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n): Promise<Blob> {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n IMAGE_SETTINGS.FORMAT,\n IMAGE_SETTINGS.QUALITY,\n );\n });\n}\n","export function getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n}\n\nexport function getPositionStyles(position: string): string {\n switch (position) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n}\n\nexport function removeElements(selector: string): void {\n const elements = document.querySelectorAll(selector);\n elements.forEach((element) => {\n element.remove();\n });\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { getPositionStyles } from \"../utils.js\";\n\nexport function createButton(\n buttonPosition: string,\n onClick: () => void,\n): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = CSS_CLASSES.BUTTON_CONTAINER;\n\n const positionStyles = getPositionStyles(buttonPosition);\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 50%;\n background: #000000;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n `;\n\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = CSS_CLASSES.BUTTON;\n button.setAttribute(\"aria-label\", \"Virtual Try-On\");\n button.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n padding: 10px;\n border: none;\n background: transparent;\n color: #ffffff;\n `;\n\n button.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-camera-icon lucide-camera\"><path d=\"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z\"/><circle cx=\"12\" cy=\"13\" r=\"3\"/></svg>\n `;\n\n button.onclick = onClick;\n container.appendChild(button);\n return container;\n}\n","import { startCamera, stopCamera } from \"../camera.js\";\nimport { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface CameraModalCallbacks {\n onCapture: (\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ) => Promise<void>;\n}\n\nexport function showCameraModal(callbacks: CameraModalCallbacks): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = \"\";\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: rgba(0, 0, 0, 0.7);\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = async () => {\n await callbacks.onCapture(video, canvas);\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n startCamera(video, loadingIndicator, captureButton);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport function showImageModal(imageUrl: string): void {\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create image container\n const imageContainer = document.createElement(\"div\");\n imageContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Virtual Try-On Result\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n closeButton.onclick = () => {\n modal.remove();\n };\n\n // Close on backdrop click\n modal.onclick = (e) => {\n if (e.target === modal) {\n modal.remove();\n }\n };\n\n // Close on Escape key\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n modal.remove();\n document.removeEventListener(\"keydown\", handleEscape);\n }\n };\n document.addEventListener(\"keydown\", handleEscape);\n\n imageContainer.appendChild(image);\n imageContainer.appendChild(closeButton);\n modal.appendChild(imageContainer);\n document.body.appendChild(modal);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface ReviewModalCallbacks {\n onRetake: () => void;\n onAccept: (imageBlob: Blob) => Promise<void>;\n}\n\nexport function showReviewModal(\n imageBlob: Blob,\n callbacks: ReviewModalCallbacks,\n): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create review container\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n gap: 15px;\n width: calc(100% - 40px);\n max-width: 300px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n callbacks.onRetake();\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n await callbacks.onAccept(imageBlob);\n };\n\n // Assemble the review modal\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n reviewContainer.appendChild(buttonContainer);\n modal.appendChild(reviewContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n}\n","import { callVirtualTryOnApi } from \"./api.js\";\nimport { captureImageFromVideo, stopCamera } from \"./camera.js\";\nimport {\n type CameraModalCallbacks,\n createButton,\n type ReviewModalCallbacks,\n showCameraModal,\n showImageModal,\n showReviewModal,\n} from \"./components/index.js\";\nimport { CSS_CLASSES, DEFAULT_CONFIG } from \"./constants.js\";\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { getCookie, removeElements } from \"./utils.js\";\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = createButton(this.config.buttonPosition, async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_id,\n ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n return;\n }\n\n if (!ww_access_token) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_access_token\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n }\n }\n\n /**\n * Shows camera modal with appropriate callbacks\n * @private\n */\n private showCameraModalWithCallbacks(\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: CameraModalCallbacks = {\n onCapture: async (video: HTMLVideoElement, canvas: HTMLCanvasElement) => {\n try {\n // Capture image from video\n const imageBlob = await captureImageFromVideo(video, canvas);\n\n // Stop camera and show review modal\n stopCamera(video);\n\n // Show review modal instead of immediately processing\n this.showReviewModalWithCallbacks(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n }\n },\n };\n\n showCameraModal(callbacks);\n }\n\n /**\n * Shows review modal with appropriate callbacks\n * @private\n */\n private showReviewModalWithCallbacks(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: ReviewModalCallbacks = {\n onRetake: () => {\n // Reopen camera modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n onAccept: async (acceptedImageBlob: Blob) => {\n await this.processAcceptedImage(\n acceptedImageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n };\n\n showReviewModal(imageBlob, callbacks);\n }\n\n /**\n * Processes the accepted image by calling the API\n * @private\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Call the API with the accepted image\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n imageBlob,\n );\n\n if (result?.imageUrl) {\n showImageModal(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n }\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\n\n // Remove all modals\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAEO,eAAe,mBAAmB,CACrC,OAAe,EACf,eAAuB,EACvB,UAAkB,EAClB,aAAqB,EACrB,QAAc,EAAA;AAEd,IAAA,IAAI;AACA,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;AAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC;AACzC,QAAA,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC;QAC/C,QAAQ,CAAC,M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