@vizbl/shopify-room-viewer 0.0.29 → 0.0.30
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.
|
@@ -7577,7 +7577,7 @@ canvas {
|
|
|
7577
7577
|
font-style: normal;
|
|
7578
7578
|
font-display: swap;
|
|
7579
7579
|
}
|
|
7580
|
-
`,""]);let o=s.toString()},"../../node_modules/.pnpm/@rsbuild+core@1.7.1/node_modules/@rsbuild/core/compiled/css-loader/api.js"(e){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r}).join("")},t.i=function(e,r,n,i,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var o=0;o<this.length;o++){var l=this[o][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),r&&(u[2]&&(u[1]="@media ".concat(u[2]," {").concat(u[1],"}")),u[2]=r),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),t.push(u))}},t}},"../../node_modules/.pnpm/@rsbuild+core@1.7.1/node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js"(e){e.exports=function(e){return e[1]}}},VC={};function VE(e){var t=VC[e];if(void 0!==t)return t.exports;var r=VC[e]={id:e,exports:{}};return Vx[e](r,r.exports,VE),r.exports}VE.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return VE.d(t,{a:t}),t},VE.d=(e,t)=>{for(var r in t)VE.o(t,r)&&!VE.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},VE.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),VE.nc=void 0;let VS=(0,rx.createContext)({theme:"system",setTheme:()=>null});function VM({children:e,defaultTheme:t="system",storageKey:r="v-theme",root:n=window.document.documentElement,enableStorage:i=!1,...a}){let[s,o]=(0,rx.useState)(()=>i&&localStorage.getItem(r)||t);return(0,rx.useEffect)(()=>{if(n.classList.remove("light","dark"),"system"===s){let e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";n.classList.add(e);return}n.classList.add(s)},[s,n]),(0,rE.jsx)(VS,{...a,value:{theme:s,setTheme:e=>{i&&localStorage.setItem(r,e),o(e)}},children:e})}var VI=VE("../ui/src/styles/fonts.css?inline");let VB={en:{translation:{matting:"Matting",material:"Material",chooseMaterial:"Choose material",frameWidth:"Frame width",close:"Close",uploadOwnPhoto:"Upload your photo",previousSlide:"Previous slide",nextSlide:"Next slide",mattingOptions:{none:"None"},units:{cm:"cm",in:"in"},ar:{viewInPlace:"View in place",scanQrCode:"Scan this QR code with your phone's camera to view the object in Augmented Reality",deviceRequirementsDisclaimer:"*Requires AR-supported device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome."},legal:{termsOfUse:"Terms of Use",conjunction:"and",privacyPolicy:"Privacy Policy"},shareMessage:{"wall-panel":"Preview wall panels",wallart:"Preview wall art",rugs:"Preview rug",flooring:"Preview flooring"},rooms:{"room-example-11":"Room Example 11","room-example-12":"Room Example 12","room-example-13":"Room Example 13","room-example-14":"Room Example 14","room-example-15":"Room Example 15","carpet-bathroom":"Bathroom","carpet-bedroom":"Bedroom","carpet-entryway":"Entryway","carpet-living-room":"Living Room"},scene:{tunePosition:"Tune position",share:"Share",angle:"Angle",rotation:"Rotation",reset:"Reset"},accessError:{unauthorized:"Invalid API key","payment-required":"Viewer temporarily unavailable"},loadError:{"viewer-load-failed":"We could not load the viewer. Please try again.","artwork-load-failed":"The image could not be loaded — its link is missing or incorrect in the widget settings.","room-load-failed":"The room photo could not be loaded. Please try again."},wallPanel:{loading:"Loading material",panelActions:"Panel {{number}} actions",retry:"Could not load. Select again to retry.",actions:"Panel actions",materials:"Materials",materialFallback:"Material {{number}}",rotate:"Rotate panel",delete:"Delete panel"},resourceType:{"wall-panel":{productCategory:"Wall panel",productCardTitle:"Selected panel",replaceProduct:"Replace panel",replaceProductShort:"Replace"},rugs:{productCategory:"Rug",productCardTitle:"Selected rug",replaceProduct:"Replace rug",replaceProductShort:"Replace"},flooring:{productCategory:"Flooring",productCardTitle:"Selected flooring",replaceProduct:"Replace flooring",replaceProductShort:"Replace"}},floor:{scene:{companyFallback:"Company name",share:"Share",download:"Download",hideCatalog:"Hide catalog",description:"Description",interiorCardTitle:"Interior",tryAtHome:"Try at home",tryAtHomeBody:"Through your phone camera"},materialSelection:{flooring:"Choose flooring",rugs:"Choose a rug","wall-panel":"Choose a panel",title:"Material Selection"},interiorSelection:{title:"Choose interior",uploadPhoto:"Upload your photo",invalidFile:"Could not upload photo, please try again",customTitle:"Your photos",presetsTitle:"Preset interiors",currentInterior:"Current interior",chooseInterior:"Choose interior",chooseInteriorShort:"Choose"},processing:{title:"Preparing your room",progressLabel:"Room preparation progress",stages:{reading:"Reading your photo...",mapping:"Finding floors and walls...",lighting:"Balancing light and perspective...",finalizing:"Building your preview...",ready:"Room is ready..."}},error:{title:"Something went wrong",processingBody:"This time we could not upload and process the photo",loadBody:"We could not load the viewer. Please try again.",tryAgain:"Try again",cancel:"Cancel"}}}},ru:{translation:{matting:"Паспарту",material:"Материал",chooseMaterial:"Выберите материал",frameWidth:"Ширина рамки",close:"Закрыть",uploadOwnPhoto:"Загрузить свое фото",previousSlide:"Предыдущий слайд",nextSlide:"Следующий слайд",mattingOptions:{none:"Нет"},units:{cm:"см",in:"in"},ar:{viewInPlace:"Примерить в комнате",scanQrCode:"Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности",deviceRequirementsDisclaimer:"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome."},legal:{termsOfUse:"Условия использования",conjunction:"и",privacyPolicy:"Политика конфиденциальности"},shareMessage:{"wall-panel":"Примерить стеновые панели",wallart:"Примерить настенный декор",rugs:"Примерить ковер",flooring:"Примерить напольное покрытие"},rooms:{"room-example-11":"Пример комнаты 11","room-example-12":"Пример комнаты 12","room-example-13":"Пример комнаты 13","room-example-14":"Пример комнаты 14","room-example-15":"Пример комнаты 15","carpet-bathroom":"Ванная","carpet-bedroom":"Спальня","carpet-entryway":"Прихожая","carpet-living-room":"Гостиная"},scene:{tunePosition:"Настроить положение",share:"Поделиться",angle:"Угол",rotation:"Поворот",reset:"Сбросить"},accessError:{unauthorized:"Неверный API-ключ","payment-required":"Просмотр временно недоступен"},loadError:{"viewer-load-failed":"Не удалось загрузить просмотр. Попробуйте ещё раз.","artwork-load-failed":"Не удалось загрузить изображение — ссылка на него отсутствует или указана неверно в настройках виджета.","room-load-failed":"Не удалось загрузить фото комнаты. Попробуйте ещё раз."},wallPanel:{loading:"Загрузка материала",panelActions:"Действия с панелью {{number}}",retry:"Не удалось загрузить. Нажмите ещё раз.",actions:"Действия с панелью",materials:"Материалы",materialFallback:"Материал {{number}}",rotate:"Повернуть панель",delete:"Удалить панель"},resourceType:{"wall-panel":{productCategory:"Стеновая панель",productCardTitle:"Выбранная панель",replaceProduct:"Заменить панель",replaceProductShort:"Заменить"},rugs:{productCategory:"Ковер",productCardTitle:"Выбранный ковер",replaceProduct:"Заменить ковер",replaceProductShort:"Заменить"},flooring:{productCategory:"Напольное покрытие",productCardTitle:"Выбранное напольное покрытие",replaceProduct:"Заменить",replaceProductShort:"Заменить"}},floor:{scene:{companyFallback:"Компания",share:"Поделиться",download:"Скачать",hideCatalog:"Скрыть каталог",description:"Описание",interiorCardTitle:"Интерьер",tryAtHome:"Примерить дома",tryAtHomeBody:"Через камеру телефона"},materialSelection:{flooring:"Выберите покрытие",rugs:"Выберите ковёр","wall-panel":"Выберите панель",title:"Выбор материала"},interiorSelection:{title:"Выберите интерьер",uploadPhoto:"Загрузить свое фото",invalidFile:"Не получилось загрузить фото, попробуйте еще раз",customTitle:"Ваши фото",presetsTitle:"Готовые интерьеры",currentInterior:"Текущий интерьер",chooseInterior:"Выбрать интерьер",chooseInteriorShort:"Выбрать"},processing:{title:"Готовим вашу комнату",progressLabel:"Прогресс подготовки комнаты",stages:{reading:"Читаем ваше фото...",mapping:"Ищем пол и стены...",lighting:"Настраиваем свет и перспективу...",finalizing:"Собираем превью...",ready:"Комната готова..."}},error:{title:"Что-то пошло не так",processingBody:"В этот раз не получилось загрузить обработать фотографию",loadBody:"Не удалось загрузить просмотр. Попробуйте снова.",tryAgain:"Попробовать еще раз",cancel:"Отменить"}}}}},Vk=a4.createInstance();Vk.use(s1).use({type:"3rdParty",init(t){((e={})=>{a7={...a7,...e}})(t.options.react),e=t}}).init({debug:!1,detection:{caches:[]},fallbackLng:"en",resources:VB,interpolation:{escapeValue:!1}});let VT=/initial-value:([^;}]+)/i,VR=/inherits:\s*false(?:\s*;|\s*$)/i,VD=(eb=(ej=VE("./src/style.css?inline").A).replace(/:root\s*,\s*:host|:root/g,":host"),(ey=Array.from(ej.matchAll(/@property\s+(--[^{\s]+)\s*\{([^}]*)\}/g)).map(([,e,t])=>{if(!VR.test(t))return null;let r=t.match(VT)?.[1].trim()??"initial";return` ${e}: ${r};`}).filter(e=>null!==e).join("\n"))?`${eb}
|
|
7580
|
+
`,""]);let o=s.toString()},"../../node_modules/.pnpm/@rsbuild+core@1.7.1/node_modules/@rsbuild/core/compiled/css-loader/api.js"(e){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r}).join("")},t.i=function(e,r,n,i,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var o=0;o<this.length;o++){var l=this[o][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),r&&(u[2]&&(u[1]="@media ".concat(u[2]," {").concat(u[1],"}")),u[2]=r),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),t.push(u))}},t}},"../../node_modules/.pnpm/@rsbuild+core@1.7.1/node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js"(e){e.exports=function(e){return e[1]}}},VC={};function VE(e){var t=VC[e];if(void 0!==t)return t.exports;var r=VC[e]={id:e,exports:{}};return Vx[e](r,r.exports,VE),r.exports}VE.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return VE.d(t,{a:t}),t},VE.d=(e,t)=>{for(var r in t)VE.o(t,r)&&!VE.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},VE.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),VE.nc=void 0;let VS=(0,rx.createContext)({theme:"system",setTheme:()=>null});function VM({children:e,defaultTheme:t="system",storageKey:r="v-theme",root:n=window.document.documentElement,enableStorage:i=!1,...a}){let[s,o]=(0,rx.useState)(()=>i&&localStorage.getItem(r)||t);return(0,rx.useEffect)(()=>{if(n.classList.remove("light","dark"),"system"===s){let e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";n.classList.add(e);return}n.classList.add(s)},[s,n]),(0,rE.jsx)(VS,{...a,value:{theme:s,setTheme:e=>{i&&localStorage.setItem(r,e),o(e)}},children:e})}var VI=VE("../ui/src/styles/fonts.css?inline");let VB={en:{translation:{matting:"Matting",material:"Material",chooseMaterial:"Choose material",frameWidth:"Frame width",close:"Close",uploadOwnPhoto:"Upload your photo",previousSlide:"Previous slide",nextSlide:"Next slide",mattingOptions:{none:"None"},units:{cm:"cm",in:"in"},ar:{viewInPlace:"View in place",scanQrCode:"Scan this QR code with your phone's camera to view the object in Augmented Reality",deviceRequirementsDisclaimer:"*Requires AR-supported device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.",appClipScanTitle:"Scan with your phone camera",appClipRequirement:"AR view works on iOS 18 or later"},legal:{termsOfUse:"Terms of Use",conjunction:"and",privacyPolicy:"Privacy Policy"},shareMessage:{"wall-panel":"Preview wall panels",wallart:"Preview wall art",rugs:"Preview rug",flooring:"Preview flooring"},rooms:{"room-example-11":"Room Example 11","room-example-12":"Room Example 12","room-example-13":"Room Example 13","room-example-14":"Room Example 14","room-example-15":"Room Example 15","carpet-bathroom":"Bathroom","carpet-bedroom":"Bedroom","carpet-entryway":"Entryway","carpet-living-room":"Living Room"},scene:{tunePosition:"Tune position",share:"Share",angle:"Angle",rotation:"Rotation",reset:"Reset"},accessError:{unauthorized:"Invalid API key","payment-required":"Viewer temporarily unavailable"},loadError:{"viewer-load-failed":"We could not load the viewer. Please try again.","artwork-load-failed":"The image could not be loaded — its link is missing or incorrect in the widget settings.","room-load-failed":"The room photo could not be loaded. Please try again."},wallPanel:{loading:"Loading material",panelActions:"Panel {{number}} actions",retry:"Could not load. Select again to retry.",actions:"Panel actions",materials:"Materials",materialFallback:"Material {{number}}",rotate:"Rotate panel",delete:"Delete panel"},resourceType:{"wall-panel":{productCategory:"Wall panel",productCardTitle:"Selected panel",replaceProduct:"Replace panel",replaceProductShort:"Replace"},rugs:{productCategory:"Rug",productCardTitle:"Selected rug",replaceProduct:"Replace rug",replaceProductShort:"Replace"},flooring:{productCategory:"Flooring",productCardTitle:"Selected flooring",replaceProduct:"Replace flooring",replaceProductShort:"Replace"}},floor:{scene:{companyFallback:"Company name",share:"Share",download:"Download",hideCatalog:"Hide catalog",description:"Description",interiorCardTitle:"Interior",tryAtHome:"Try at home",tryAtHomeBody:"Through your phone camera"},materialSelection:{flooring:"Choose flooring",rugs:"Choose a rug","wall-panel":"Choose a panel",title:"Material Selection"},interiorSelection:{title:"Choose interior",uploadPhoto:"Upload your photo",invalidFile:"Could not upload photo, please try again",customTitle:"Your photos",presetsTitle:"Preset interiors",currentInterior:"Current interior",chooseInterior:"Choose interior",chooseInteriorShort:"Choose"},processing:{title:"Preparing your room",progressLabel:"Room preparation progress",stages:{reading:"Reading your photo...",mapping:"Finding floors and walls...",lighting:"Balancing light and perspective...",finalizing:"Building your preview...",ready:"Room is ready..."}},error:{title:"Something went wrong",processingBody:"This time we could not upload and process the photo",loadBody:"We could not load the viewer. Please try again.",tryAgain:"Try again",cancel:"Cancel"}}}},ru:{translation:{matting:"Паспарту",material:"Материал",chooseMaterial:"Выберите материал",frameWidth:"Ширина рамки",close:"Закрыть",uploadOwnPhoto:"Загрузить свое фото",previousSlide:"Предыдущий слайд",nextSlide:"Следующий слайд",mattingOptions:{none:"Нет"},units:{cm:"см",in:"in"},ar:{viewInPlace:"Примерить в комнате",scanQrCode:"Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности",deviceRequirementsDisclaimer:"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.",appClipScanTitle:"Наведите камеру телефона",appClipRequirement:"AR-просмотр работает на iOS 18 и новее"},legal:{termsOfUse:"Условия использования",conjunction:"и",privacyPolicy:"Политика конфиденциальности"},shareMessage:{"wall-panel":"Примерить стеновые панели",wallart:"Примерить настенный декор",rugs:"Примерить ковер",flooring:"Примерить напольное покрытие"},rooms:{"room-example-11":"Пример комнаты 11","room-example-12":"Пример комнаты 12","room-example-13":"Пример комнаты 13","room-example-14":"Пример комнаты 14","room-example-15":"Пример комнаты 15","carpet-bathroom":"Ванная","carpet-bedroom":"Спальня","carpet-entryway":"Прихожая","carpet-living-room":"Гостиная"},scene:{tunePosition:"Настроить положение",share:"Поделиться",angle:"Угол",rotation:"Поворот",reset:"Сбросить"},accessError:{unauthorized:"Неверный API-ключ","payment-required":"Просмотр временно недоступен"},loadError:{"viewer-load-failed":"Не удалось загрузить просмотр. Попробуйте ещё раз.","artwork-load-failed":"Не удалось загрузить изображение — ссылка на него отсутствует или указана неверно в настройках виджета.","room-load-failed":"Не удалось загрузить фото комнаты. Попробуйте ещё раз."},wallPanel:{loading:"Загрузка материала",panelActions:"Действия с панелью {{number}}",retry:"Не удалось загрузить. Нажмите ещё раз.",actions:"Действия с панелью",materials:"Материалы",materialFallback:"Материал {{number}}",rotate:"Повернуть панель",delete:"Удалить панель"},resourceType:{"wall-panel":{productCategory:"Стеновая панель",productCardTitle:"Выбранная панель",replaceProduct:"Заменить панель",replaceProductShort:"Заменить"},rugs:{productCategory:"Ковер",productCardTitle:"Выбранный ковер",replaceProduct:"Заменить ковер",replaceProductShort:"Заменить"},flooring:{productCategory:"Напольное покрытие",productCardTitle:"Выбранное напольное покрытие",replaceProduct:"Заменить",replaceProductShort:"Заменить"}},floor:{scene:{companyFallback:"Компания",share:"Поделиться",download:"Скачать",hideCatalog:"Скрыть каталог",description:"Описание",interiorCardTitle:"Интерьер",tryAtHome:"Примерить дома",tryAtHomeBody:"Через камеру телефона"},materialSelection:{flooring:"Выберите покрытие",rugs:"Выберите ковёр","wall-panel":"Выберите панель",title:"Выбор материала"},interiorSelection:{title:"Выберите интерьер",uploadPhoto:"Загрузить свое фото",invalidFile:"Не получилось загрузить фото, попробуйте еще раз",customTitle:"Ваши фото",presetsTitle:"Готовые интерьеры",currentInterior:"Текущий интерьер",chooseInterior:"Выбрать интерьер",chooseInteriorShort:"Выбрать"},processing:{title:"Готовим вашу комнату",progressLabel:"Прогресс подготовки комнаты",stages:{reading:"Читаем ваше фото...",mapping:"Ищем пол и стены...",lighting:"Настраиваем свет и перспективу...",finalizing:"Собираем превью...",ready:"Комната готова..."}},error:{title:"Что-то пошло не так",processingBody:"В этот раз не получилось загрузить обработать фотографию",loadBody:"Не удалось загрузить просмотр. Попробуйте снова.",tryAgain:"Попробовать еще раз",cancel:"Отменить"}}}}},Vk=a4.createInstance();Vk.use(s1).use({type:"3rdParty",init(t){((e={})=>{a7={...a7,...e}})(t.options.react),e=t}}).init({debug:!1,detection:{caches:[]},fallbackLng:"en",resources:VB,interpolation:{escapeValue:!1}});let VT=/initial-value:([^;}]+)/i,VR=/inherits:\s*false(?:\s*;|\s*$)/i,VD=(eb=(ej=VE("./src/style.css?inline").A).replace(/:root\s*,\s*:host|:root/g,":host"),(ey=Array.from(ej.matchAll(/@property\s+(--[^{\s]+)\s*\{([^}]*)\}/g)).map(([,e,t])=>{if(!VR.test(t))return null;let r=t.match(VT)?.[1].trim()??"initial";return` ${e}: ${r};`}).filter(e=>null!==e).join("\n"))?`${eb}
|
|
7581
7581
|
|
|
7582
7582
|
@layer base {
|
|
7583
7583
|
:host,
|
|
@@ -7627,10 +7627,10 @@ ${ey}
|
|
|
7627
7627
|
}
|
|
7628
7628
|
if (coverage < 0.01) discard;
|
|
7629
7629
|
diffuseColor = vec4(1.0, 1.0, 1.0, coverage);
|
|
7630
|
-
`)},o.customProgramCacheKey=()=>"wall-panel-exterior-outline-v1",{mask:t,maskMaterial:r,maskModel:n,maskScene:i,material:o,resolution:a,radius:s,clearColor:new mJ}},[e]);return(0,rx.useLayoutEffect)(()=>ZK(r.material,t,{shading:!1}),[r,t]),(0,rx.useLayoutEffect)(()=>()=>{r.mask.dispose(),r.maskMaterial.dispose(),r.material.dispose()},[r]),(0,rE.jsx)("mesh",{material:r.material,frustumCulled:!1,renderOrder:3,raycast:()=>{},onBeforeRender:(t,n,i)=>{let a=t.getRenderTarget(),s=t.getActiveCubeFace(),o=t.getActiveMipmapLevel(),l=t.autoClear,c=t.getClearAlpha();t.getClearColor(r.clearColor),t.getDrawingBufferSize(r.resolution);let{x:u,y:d}=r.resolution;(r.mask.width!==u||r.mask.height!==d)&&r.mask.setSize(u,d),r.radius.value=2*t.getPixelRatio(),e.updateWorldMatrix(!0,!0),r.maskModel.matrix.copy(e.matrixWorld);try{t.autoClear=!0,t.setClearColor(0,0),t.setRenderTarget(r.mask),t.render(r.maskScene,i)}finally{t.setRenderTarget(a,s,o),t.setClearColor(r.clearColor,c),t.autoClear=l}},children:(0,rE.jsx)("planeGeometry",{args:[2,2]})})}function Z7({source:e,patch:t,isPointVisible:r,outlined:n}){let{model:i,materials:a}=(0,rx.useMemo)(()=>{let t=e.clone(!0),r=ZJ(t);return{model:t,materials:r}},[e]);return(0,rx.useLayoutEffect)(()=>{let e=a.map(e=>ZK(e,t));return i.traverse(e=>{e instanceof bI&&(e.raycast=function(e,t){let n=[];bI.prototype.raycast.call(this,e,n),t.push(...n.filter(e=>!r||r(e.point)))})}),()=>e.forEach(e=>e())},[r,a,i,t]),(0,rx.useLayoutEffect)(()=>()=>a.forEach(e=>e.dispose()),[a]),(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("primitive",{object:i,dispose:null}),n&&(0,rE.jsx)(Z6,{model:i,patch:t})]})}function $e({size:e,patch:t,isPointVisible:r,onClick:n}){let[i,a]=(0,rx.useState)(!1),s=(0,rx.useMemo)(()=>{let e=document.createElement("canvas");e.width=e.height=256;let t=e.getContext("2d");if(t.lineJoin="miter",t.lineCap="round",t.beginPath(),i)t.rect(16,16,224,224);else for(let[e,r,n,i]of[[16,16,1,1],[240,16,-1,1],[16,240,1,-1],[240,240,-1,-1]])t.moveTo(e+22*n,r),t.lineTo(e,r),t.lineTo(e,r+22*i);t.strokeStyle="rgba(255,255,255,.80)",t.lineWidth=5,t.stroke(),t.strokeStyle=i?"#59636d":"rgba(70,80,90,.60)",t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(128,128,29,0,2*Math.PI),t.fillStyle=i?"#ffffff":"#f5f6f7",t.fill(),t.strokeStyle="rgba(35,45,55,.32)",t.lineWidth=2,t.stroke(),t.beginPath(),t.moveTo(117,128),t.lineTo(139,128),t.moveTo(128,117),t.lineTo(128,139),t.strokeStyle="#35414d",t.lineWidth=3,t.stroke();let r=new yH(e);return r.colorSpace="srgb",r},[i]),o=(0,rx.useMemo)(()=>new bA({map:s,transparent:!0,depthWrite:!1,toneMapped:!1}),[s]);return(0,rx.useLayoutEffect)(()=>{let e=ZK(o,t,{shading:!1});return o.alphaToCoverage=!1,e},[o,t]),(0,rx.useLayoutEffect)(()=>()=>{o.dispose(),s.dispose()},[o,s]),(0,rE.jsx)("mesh",{material:o,renderOrder:2,onPointerOver:()=>a(!0),onPointerOut:()=>a(!1),raycast:function(e,t){let n=[];bI.prototype.raycast.call(this,e,n),t.push(...n.filter(e=>!r||r(e.point)))},onPointerDown:e=>{e.stopPropagation(),e.nativeEvent.stopPropagation()},onClick:e=>{e.stopPropagation(),n()},children:(0,rE.jsx)("planeGeometry",{args:[e,e]})})}function $t({isPointVisible:e,visible:t,dragging:r,panelKey:n,number:i,size:a,depth:s,patch:o}){let l=ZB(),{t:c}=sf(),{camera:u,gl:d}=IY(),h=(0,rx.useRef)(null),p=(0,rx.useRef)(null),f=(0,rx.useMemo)(()=>new g0,[]),A=(0,rx.useMemo)(()=>{let e=document.createElement("canvas");e.width=e.height=128;let t=e.getContext("2d");for(let e of(t.beginPath(),t.arc(64,64,61,0,2*Math.PI),t.fillStyle="#f5f6f7",t.fill(),t.strokeStyle="rgba(35,45,55,.32)",t.lineWidth=2,t.stroke(),t.fillStyle="#35414d",[40,64,88]))t.beginPath(),t.arc(e,64,5,0,2*Math.PI),t.fill();let r=new yH(e);return r.colorSpace="srgb",r},[]),g=(0,rx.useMemo)(()=>new bA({map:A,transparent:!0,depthWrite:!1,toneMapped:!1}),[A]);(0,rx.useLayoutEffect)(()=>{let e=ZK(g,o,{shading:!1});return g.alphaToCoverage=!1,e},[g,o]),(0,rx.useLayoutEffect)(()=>()=>{g.dispose(),A.dispose()},[g,A]),IX(()=>{h.current&&p.current&&(h.current.getWorldPosition(f),p.current.tabIndex=!r&&(!e||e(f))?0:-1)});let m=()=>{if(!h.current)return;f.set(.05,-.05,0),h.current.localToWorld(f).project(u);let e=d.domElement.getBoundingClientRect();l.openMenu(n,{x:e.left+(f.x+1)*e.width/2,y:e.top+(1-f.y)*e.height/2})};return(0,rE.jsxs)("group",{ref:h,position:[a/2-a/12-.05,-a/2+a/20+.05,s+.002],children:[(0,rE.jsx)("mesh",{name:"panel-actions",material:g,visible:t&&!r,renderOrder:3,raycast:function(n,i){if(!t||r)return;let a=[];bI.prototype.raycast.call(this,n,a),i.push(...a.filter(t=>t.uv&&.48>=Math.hypot(t.uv.x-.5,t.uv.y-.5)&&(!e||e(t.point))))},onPointerDown:e=>{e.stopPropagation(),e.nativeEvent.stopPropagation()},onPointerUp:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m()},children:(0,rE.jsx)("planeGeometry",{args:[.1,.1]})}),(0,rE.jsx)(TL,{style:{pointerEvents:"none"},children:(0,rE.jsx)("button",{ref:p,type:"button","data-panel-key":n,className:"sr-only","aria-label":c("wallPanel.panelActions",{number:i}),"aria-haspopup":"menu",onFocus:()=>l.select(n),onClick:e=>{e.stopPropagation(),m()}})})]})}function $r({glbUrl:e,position:t,quaternion:r,materialPatch:n,isPointVisible:i,onDragStart:a,onDrag:s,onDragEnd:o}){let{data:l}=od({...ZC(e),enabled:!0,suspense:!0,throwOnError:oi,placeholderData:void 0},s2,void 0),c=ZB(),{room:u}=qe(),[d,h]=(0,rx.useState)(null),{resourceRef:p,isDragging:f,setIsDragging:A}=qr(),{gl:g}=IY(),m=f?"grabbing":d?.action?"pointer":d?"grab":"auto";(0,rx.useLayoutEffect)(()=>{let e=g.domElement.style.cursor;return g.domElement.style.cursor=m,()=>{g.domElement.style.cursor=e}},[g,m]);let v=(e,t)=>h(r=>r?.key===e&&r.action===t?r:{key:e,action:t}),b=(0,rx.useRef)(null),y=l.width,w=`${u.id}:${c.generation}`,[x,C]=(0,rx.useState)({size:y,roomKey:w,x:0,y:0});if(x.roomKey!==w)C({size:y,roomKey:w,x:0,y:0});else if(x.size!==y){let e=c.panels.reduce((e,t)=>({minX:Math.min(e.minX,t.x),maxX:Math.max(e.maxX,t.x),minY:Math.min(e.minY,t.y),maxY:Math.max(e.maxY,t.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),t=x.size-y;C({size:y,roomKey:w,x:x.x+(e.minX+e.maxX)/2*t,y:x.y+(e.minY+e.maxY)/2*t})}(0,rx.useLayoutEffect)(()=>()=>A(!1),[A]);let E=(e,t=!1)=>{let r=b.current;r&&r.pointerId===e.pointerId&&(e.stopPropagation(),b.current=null,e.target.releasePointerCapture(e.pointerId),A(!1),o(),t||r.moved||(c.select(r.key),c.closeMenu()))};return(0,rE.jsx)("group",{ref:p,position:t,quaternion:r,onPointerMissed:c.clearSelection,children:(0,rE.jsxs)("group",{position:[x.x,x.y,0],children:[c.panels.map((e,t)=>{let r=c.options.find(t=>t.material.hid===e.materialId)?.model??l;return(0,rE.jsxs)("group",{position:[e.x*y,e.y*y,0],onPointerOver:t=>{t.stopPropagation(),v(ZE(e),"panel-actions"===t.object.name)},onPointerOut:()=>h(null),onPointerDown:t=>{0===t.button&&!b.current&&(t.stopPropagation(),t.nativeEvent.stopPropagation(),b.current={x:t.clientX,y:t.clientY,key:ZE(e),moved:!1,pointerId:t.pointerId},t.target.setPointerCapture(t.pointerId),A(!0),a())},onPointerMove:t=>{v(ZE(e),"panel-actions"===t.object.name);let r=b.current;r&&r.pointerId===t.pointerId&&(t.stopPropagation(),!r.moved&&Math.hypot(t.clientX-r.x,t.clientY-r.y)>4&&(r.moved=!0,c.select(r.key),c.closeMenu()),r.moved&&s())},onPointerUp:e=>E(e),onPointerCancel:e=>E(e,!0),children:[(0,rE.jsx)($t,{panelKey:ZE(e),number:t+1,size:y,depth:r.depth,patch:n,isPointVisible:i,dragging:f,visible:c.selected===ZE(e)||d?.key===ZE(e)}),(0,rE.jsx)("group",{"rotation-z":-e.turns*Math.PI/2,children:(0,rE.jsx)("group",{position:r.mountingOffset,children:(0,rE.jsx)(Z7,{outlined:c.selected===ZE(e)||d?.key===ZE(e),source:r.scene,patch:n,isPointVisible:i})})})]},ZE(e))}),c.selected&&c.neighbors.map(e=>(0,rE.jsx)("group",{position:[e.x*y,e.y*y,.002],children:(0,rE.jsx)($e,{size:y,patch:n,isPointVisible:i,onClick:()=>c.add(e)})},ZE(e)))]})})}function $n(e){let{glbUrl:t}=qt();return t?(0,rE.jsx)($r,{...e,glbUrl:t}):null}let $i={"modelled-resource":function({position:e,quaternion:t,materialPatch:r,onDrag:n,onDragEnd:i,onDragStart:a}){let{type:s}=W6(),{glbUrl:o}=qt();return o?"rotate-on-floor"===Ww[s].manipulation?(0,rE.jsx)(Z1,{glbUrl:o,position:e,quaternion:t,materialPatch:r}):(0,rE.jsx)(TC,{autoTransform:!1,onDrag:n,onDragEnd:i,onDragStart:a,children:(0,rE.jsx)(Z1,{glbUrl:o,position:e,quaternion:t,materialPatch:r})}):null},"textured-resource":function({position:e,quaternion:t,materialPatch:r,onDrag:n,onDragEnd:i,onDragStart:a}){let{src:s,setLoadError:o}=qt();return s?(0,rE.jsx)(Z_,{onError:()=>o("artwork-load-failed"),children:(0,rE.jsx)(TC,{autoTransform:!1,onDrag:n,onDragEnd:i,onDragStart:a,children:(0,rE.jsx)(Z8,{src:s,position:e,quaternion:t,materialPatch:r})})}):null}};function $a(){let{room:e}=qe(),t=IY(e=>e.scene),r=I0(xH,q9(e),e=>{e.setCrossOrigin("anonymous")});return(0,rx.useLayoutEffect)(()=>(r.colorSpace="srgb",t.background=r,()=>{t.background===r&&(t.background=null)}),[t,r]),null}function $s({plane:e,geometry:t,setPlaneRef:r}){let n={planeId:e.id,kind:e.kind};return(0,rE.jsx)("mesh",{ref:t=>r(e,t),geometry:t,userData:n,children:(0,rE.jsx)("meshBasicMaterial",{visible:!1,side:2})})}function $o(){let e,{type:t}=W6(),r=ZB(),{setLoadError:n}=qt(),i="panel-group"===(e=Ww[t]).manipulation?$n:$i[e.identity],{room:a}=qe(),{patchSceneLoad:s}=qr(),{gl:o,size:l,camera:c,invalidate:u,raycaster:d,pointer:h}=IY(),p=(0,rx.useMemo)(()=>a.scene??qk(),[a.scene]),[f,A]=I0(xH,[p.planeIds.dataPng,p.shading?.dataPng??"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNoaGgAAAMEAYFL09IQAAAAAElFTkSuQmCC"]),g=function({camera:e,invalidate:t,pointer:r,raycaster:n,roomId:i,scene:a,surfaces:s}){let o=`${i}:${[...s].sort().join(",")}`,l=(0,rx.useMemo)(()=>({value:null}),[]),[c,u]=(0,rx.useReducer)(ZV,o,ZH),d=(0,rx.useRef)(null),h=(0,rx.useRef)(new Map),p=(0,rx.useRef)(new Map),f=(0,rx.useRef)(null),A=c.placementKey===o,g=A?c.planeIdMap:null,m=A&&c.planeIdMapFailed,v=A?c.resourcePose:null,b=(0,rx.useMemo)(()=>ZG(a,s),[a,s]),y=(0,rx.useMemo)(()=>b.map(e=>e.id),[b]),w=(0,rx.useMemo)(()=>new Map(a.planes.map(e=>{let t,r;return[e.id,(t=e.polygon3D.flatMap(e=>(function(e,t){let[r,n,i]=e;return[r*(Zk(t)*(t.camera.fx/t.camera.fy)),i,-n]})(e,a)),(r=new vq).setAttribute("position",new vL(t,3)),e.polygon3D.length>=4&&r.setIndex([0,1,2,0,2,3]),r)]})),[a]),x=(0,rx.useMemo)(()=>({artifactsReady:null!==g,placementReady:null!==v,prepareReady:null!==v}),[g,v]),C=0===b.length?"no-allowed-surface":m?"plane-id-map-decode":null,E=(0,rx.useCallback)((e,t)=>{t?p.current.set(e.id,t):p.current.delete(e.id)},[]);(0,rx.useEffect)(()=>{let e=!1;return u({type:"reset-plane-id-map",placementKey:o}),ZR(a.planeIds.dataPng,a.planeIds.width,a.planeIds.height).then(t=>{if(e)return;let r=new Map;try{for(let e of a.planes)s.includes(e.kind)&&e.id>0&&r.set(e.id,function(e,t){let r=2*e.width,n=2*e.height,i=new Float32Array(r*n),a=new Float32Array(r*n),s=new Uint8Array(r*n),o=e.width,l=e.height,c=-1,u=-1;for(let r=0;r<e.height;r++)for(let n=0;n<e.width;n++)e.data[r*e.width+n]===t&&(o=Math.min(o,n),l=Math.min(l,r),c=Math.max(c,n),u=Math.max(u,r));let d=c<0?r:Math.max(0,2*o-11),h=u<0?n:Math.max(0,2*l-11),p=c<0?-1:Math.min(r-1,(c+1)*2+11),f=u<0?-1:Math.min(n-1,(u+1)*2+11);for(let n=h;n<=f;n++){let a=(n+.5)/2-.5,s=Math.floor(a),o=ZF(s,e.height-1),l=ZF(s+1,e.height-1),c=a-s;for(let a=d;a<=p;a++){let s=(a+.5)/2-.5,u=Math.floor(s),d=ZF(u,e.width-1),h=ZF(u+1,e.width-1),p=s-u,f=(e.data[o*e.width+d]===t?1-p:0)+(e.data[o*e.width+h]===t?p:0),A=(e.data[l*e.width+d]===t?1-p:0)+(e.data[l*e.width+h]===t?p:0);i[n*r+a]=f*(1-c)+A*c}}for(let e=h;e<=f;e++)for(let t=d;t<=p;t++){let n=0;for(let a=-9;a<=9;a++)n+=i[e*r+ZF(t+a,r-1)]*ZL[a+9];a[e*r+t]=n}for(let e=h;e<=f;e++)for(let t=d;t<=p;t++){let i=0;for(let s=-9;s<=9;s++)i+=a[ZF(e+s,n-1)*r+t]*ZL[s+9];s[e*r+t]=Math.round(255*i)}let A=new bU(s,r,n,1028);return A.minFilter=1006,A.magFilter=1006,A.wrapS=1001,A.wrapT=1001,A.generateMipmaps=!1,A.unpackAlignment=1,A.needsUpdate=!0,{data:s,width:r,height:n,texture:A}}(t,e.id))}catch(e){throw r.forEach(e=>e.texture.dispose()),e}h.current=r,u({type:"set-plane-id-map",placementKey:o,planeIdMap:t})}).catch(t=>{console.error(t),e||u({type:"fail-plane-id-map",placementKey:o})}),()=>{e=!0,h.current.forEach(e=>e.texture.dispose()),h.current=new Map,l.value=null}},[l,o,a.planeIds,a.planes,s]),(0,rx.useEffect)(()=>{u({type:"reset-placement",placementKey:o}),d.current=null,l.value=null,f.current=null},[l,o]);let S=(0,rx.useCallback)((r,n,i=null)=>{let a,s=Zj(r,n,e),c=i?(a=new g0(...i).applyQuaternion(new g$(...s.quaternion)).add(new g0(...s.position)),{...s,position:a.toArray()}):s;d.current=c.activePlaneId,l.value=h.current.get(c.activePlaneId)?.texture??null,u({type:"set-resource-pose",placementKey:o,resourcePose:c}),t()},[l,e,t,o]),M=(0,rx.useCallback)(t=>g?function({activePlaneId:e,allowedPlaneIds:t,camera:r,planeIdMap:n,planeMap:i,pointer:a,raycaster:s}){let o=new Set(t),l=[],c=new Set,u=e=>{!(null===e||c.has(e))&&o.has(e)&&(c.add(e),l.push(e))};for(let o of(u(ZT(a,n)),u(e),t.forEach(u),s.setFromCamera(a,r),l)){let e=i.get(o),t=e?s.intersectObject(e,!1)[0]:null;if(t)return t}return null}({activePlaneId:d.current,allowedPlaneIds:y,camera:e,planeIdMap:g,planeMap:p.current,pointer:t,raycaster:n}):null,[y,e,g,n]);(0,rx.useEffect)(()=>{if(!g||null!==v)return;let r=function({allowedPlanes:e,camera:t,planeMap:r}){let n=e[0],i=n?r.get(n.id):null;return i?Zj(i,function(e){let t=e.geometry.attributes.position,r=new g0;for(let e=0;e<t.count;e++)r.add(new g0(t.getX(e),t.getY(e),t.getZ(e)));return r.divideScalar(Math.max(1,t.count))}(i),t):null}({allowedPlanes:b,camera:e,planeMap:p.current});r&&(d.current=r.activePlaneId,l.value=h.current.get(r.activePlaneId)?.texture??null,u({type:"set-resource-pose",placementKey:o,resourcePose:r}),t())},[l,b,e,t,o,g,v]);let I=(0,rx.useCallback)(()=>{let t,n=M(r);if(!n||!v){f.current=null;return}let i=Zj(n.object,n.point,e);t=new g$(...i.quaternion).invert(),f.current=new g0(...v.position).sub(new g0(...i.position)).applyQuaternion(t).toArray()},[e,M,r,v]),B=(0,rx.useCallback)(()=>{let e=M(r);e&&S(e.object,e.point,f.current)},[M,r,S]),k=(0,rx.useCallback)(()=>{f.current=null},[]),T=(0,rx.useCallback)(t=>{let r,n=d.current,i=null===n?null:h.current.get(n);if(!i)return!1;let a=t.clone().project(e),s=function(e,t,r){if(t<0||t>1||r<0||r>1)return 0;let n=t*e.width-.5,i=r*e.height-.5,a=Math.floor(n),s=Math.floor(i),o=ZF(a,e.width-1),l=ZF(s,e.height-1),c=ZF(a+1,e.width-1),u=ZF(s+1,e.height-1),d=n-Math.floor(n),h=i-Math.floor(i);return((e.data[l*e.width+o]*(1-d)+e.data[l*e.width+c]*d)*(1-h)+(e.data[u*e.width+o]*(1-d)+e.data[u*e.width+c]*d)*h)/255}(i,(a.x+1)*.5,(1-a.y)*.5);return(r=ZF((s-.4)/.29999999999999993,1))*r*(3-2*r)>.001},[e]);return{isPointerOnSurface:(0,rx.useCallback)(e=>{let t=g?ZT(e,g):null;return null!==t&&y.includes(t)},[y,g]),activeMaskTextureUniform:l,isPointVisible:T,failure:C,handleDrag:B,handleDragEnd:k,handleDragStart:I,planeGeometries:w,readiness:x,resourcePose:v,setPlaneRef:E}}({camera:c,invalidate:u,pointer:h,raycaster:d,roomId:`${a.id}:${r?.generation??0}`,scene:p,surfaces:Wx(t)});!function(e,t,r){let{gl:n}=IY(),{setRotation:i,setIsDragging:a}=qr();(0,rx.useEffect)(()=>{if(!e)return;let r=n.domElement,s=null,o=e=>{e.preventDefault(),e.stopImmediatePropagation()},l=()=>{let e=s;s=null,e&&r.hasPointerCapture(e.id)&&r.releasePointerCapture(e.id),e&&a(!1)},c=e=>{if(s)return void o(e);if(!e.isPrimary||0!==e.button)return;let n=r.getBoundingClientRect();t(new gZ((e.clientX-n.left)/n.width*2-1,1-(e.clientY-n.top)/n.height*2))&&(o(e),s={id:e.pointerId,startX:e.clientX,lastX:e.clientX,rotating:!1},r.setPointerCapture(e.pointerId),a(!0))},u=e=>{if(!s||s.id!==e.pointerId||(o(e),!s.rotating&&5>Math.abs(e.clientX-s.startX)))return;s.rotating=!0;let t=e.clientX-s.lastX;s.lastX=e.clientX,i(e=>e+.5*t)},d=e=>{s?.id===e.pointerId&&(o(e),l())};return r.addEventListener("pointerdown",c,!0),r.addEventListener("pointermove",u,!0),r.addEventListener("pointerup",d,!0),r.addEventListener("pointercancel",d,!0),r.addEventListener("lostpointercapture",d,!0),window.addEventListener("blur",l),()=>{r.removeEventListener("pointerdown",c,!0),r.removeEventListener("pointermove",u,!0),r.removeEventListener("pointerup",d,!0),r.removeEventListener("pointercancel",d,!0),r.removeEventListener("lostpointercapture",d,!0),window.removeEventListener("blur",l),l()}},[e,n,t,r,a,i])}("rotate-on-floor"===Ww[t].manipulation,g.isPointerOnSurface,a.id);let m=(0,rx.useMemo)(()=>new gZ(1,1),[]),v=(0,rx.useMemo)(()=>(function(e,t,r=128){let n=ZW(t),i=function(e,t,r=128){let{width:n,height:i}=t,a=n*i,s=Number.isFinite(r)&&r>0?r:128,o=new Uint8Array(a),l=new Float64Array(a);for(let r=0;r<i;r++)for(let a=0;a<n;a++){let c=r*n+a,u=Math.min(e.width-1,Math.floor((a+.5)*e.width/n)),d=Math.min(e.height-1,Math.floor((r+.5)*e.height/i));o[c]=e.data[(d*e.width+u)*4]??0,l[c]=(t.data[4*c]??s)/(2*s)}let c=l.slice();function u(e,t){let r=Math.ceil(3*t),s=Array.from({length:r+1},(e,r)=>Math.exp(-r*r/(2*t*t))),l=e;for(let e of[!0,!1]){let t=new Float64Array(a);for(let a=0;a<i;a++)for(let c=0;c<n;c++){let u=a*n+c,d=0,h=0;for(let t=-r;t<=r;t++){let r=e?c+t:c,p=e?a:a+t;if(r<0||r>=n||p<0||p>=i)continue;let f=p*n+r;if(o[u]!==o[f])continue;let A=s[Math.abs(t)];d+=l[f]*A,h+=A}t[u]=d/h}l=t}return l}for(let e=0;e<4;e++){let t=new Float64Array(a),r=new Float64Array(a);for(let e=0;e<a;e++)e%n<n-1&&o[e]===o[e+1]&&(t[e]=c[e+1]-c[e]),e<a-n&&o[e]===o[e+n]&&(r[e]=c[e+n]-c[e]);let i=Math.max(.5,1/2**e),s=u(t,i),d=u(r,i);for(let e=0;e<a;e++)s[e]=1/(Math.abs(s[e])+.001),d[e]=1/(Math.abs(d[e])+.001);let h=u(s,i),p=u(d,i),f=new Float64Array(a).fill(1);for(let e=0;e<a;e++)h[e]=e%n<n-1&&o[e]&&o[e]===o[e+1]?.004*h[e]/(Math.abs(t[e])+.02):0,p[e]=e<a-n&&o[e]&&o[e]===o[e+n]?.004*p[e]/(Math.abs(r[e])+.02):0,f[e]+=h[e]+p[e],h[e]&&(f[e+1]+=h[e]),p[e]&&(f[e+n]+=p[e]);let A=(e,t)=>{for(let r=0;r<a;r++){let i=f[r]*e[r];r%n&&(i-=h[r-1]*e[r-1]),r%n<n-1&&(i-=h[r]*e[r+1]),r>=n&&(i-=p[r-n]*e[r-n]),r<a-n&&(i-=p[r]*e[r+n]),t[r]=i}},g=new Float64Array(a),m=new Float64Array(a),v=new Float64Array(a);A(c,v);let b=0;for(let e=0;e<a;e++)g[e]=l[e]-v[e],m[e]=g[e]/f[e],b+=g[e]*m[e];for(let e=0;e<200&&b>1e-12;e++){A(m,v);let e=0;for(let t=0;t<a;t++)e+=m[t]*v[t];if(e<=0)break;let t=b/e,r=0;for(let e=0;e<a;e++)c[e]+=t*m[e],g[e]-=t*v[e],r+=g[e]*g[e]/f[e];let n=r/b;for(let e=0;e<a;e++)m[e]=g[e]/f[e]+n*m[e];b=r}}let d=new Float32Array(4*a);for(let e=0;e<a;e++)d.set([2*c[e],0,0,1],4*e);return d}(ZW(e),n,r),a=new Uint8Array(i.length);for(let e=0;e<i.length;e+=4)a.set([Math.max(0,Math.min(255,Math.round(128*i[e]))),0,0,255],e);let s=new bU(a,n.width,n.height,1023);return s.minFilter=1006,s.magFilter=1006,s.generateMipmaps=!1,s.needsUpdate=!0,s})(f,A,p.shading?.neutral),[f,A,p.shading?.neutral]);(0,rx.useLayoutEffect)(()=>()=>v.dispose(),[v]);let b=(0,rx.useMemo)(()=>({lightingTexture:v,viewport:m,activeMaskTextureUniform:g.activeMaskTextureUniform,maxRoomGain:1.1}),[g.activeMaskTextureUniform,v,m]);(0,rx.useLayoutEffect)(()=>{c instanceof x9&&(c.fov=p.camera.fovYDeg),c.position.set(0,0,0),c.up.set(0,0,1),c.lookAt(0,1,0),c.updateProjectionMatrix(),u()},[c,u,p.camera.fovYDeg]),(0,rx.useLayoutEffect)(()=>{o.getDrawingBufferSize(m),m.set(Math.max(1,m.x),Math.max(1,m.y))},[o,l.height,l.width,m]);let{artifactsReady:y,placementReady:w,prepareReady:x}=g.readiness,C=g.failure;return(0,rx.useEffect)(()=>{s({artifactsReady:y,placementReady:w,prepareReady:x})},[y,s,w,x]),(0,rx.useEffect)(()=>{C&&(!function({failure:e,planes:t,resourceType:r}){let n,i;(i=(n=t.map(e=>e.kind)).filter((e,t)=>n.indexOf(e)===t)).length>0&&i.join(", ")}({failure:C,planes:p.planes,resourceType:t}),n("room-load-failed"))},[C,p.planes,n,t]),(0,rE.jsxs)(rE.Fragment,{children:[g.resourcePose&&(0,rE.jsx)(i,{position:g.resourcePose.position,quaternion:g.resourcePose.quaternion,materialPatch:b,isPointVisible:g.isPointVisible,onDrag:g.handleDrag,onDragEnd:g.handleDragEnd,onDragStart:g.handleDragStart}),p.planes.map(e=>(0,rE.jsx)($s,{plane:e,geometry:g.planeGeometries.get(e.id),setPlaneRef:g.setPlaneRef},e.id)),(0,rE.jsx)(Z_,{onError:()=>n("room-load-failed"),children:(0,rE.jsx)($a,{})})]})}let $l=["room-viewer","layout-config"],$c=[Math.PI/2,0,0];function $u(){var e;let t=od({queryKey:$l,queryFn:()=>V1(),staleTime:1/0},s2,void 0);if(t.isPending)return null;let r=(e=t.data,e?.internal?.links?.find(e=>"hdr_neutral"===e.type)?.url?.trim()||void 0);return(0,rE.jsx)(R_,{files:r?[r]:void 0,preset:r?void 0:"warehouse",environmentRotation:$c,environmentIntensity:r?.5:.9})}function $d(){return(0,rE.jsx)(R_,{files:["https://cdn.neurodyn.ai/assets/hdr/neutral.hdr"],environmentRotation:$c})}function $h({lighting:e}){return"remote-neutral-hdr"===e?(0,rE.jsx)($u,{}):(0,rE.jsx)($d,{})}function $p({ref:e,target:t}){let{camera:r,gl:n}=IY();return(0,rx.useImperativeHandle)(e,()=>({getScreenPoint(){if(!t.current)return null;let e=t.current.getWorldPosition(new g0).project(r),i=n.domElement.getBoundingClientRect();return{x:i.left+(e.x+1)*i.width/2,y:i.top+(1-e.y)*i.height/2}}}),[r,n,t]),null}let $f={position:[0,0,0],up:[0,0,1],near:.01,far:100};function $A({className:e,ref:t,captureRef:r,introductionTarget:n,focusRef:i,onSizeChange:a,...s}){let{type:o}=W6(),{glbUrl:l}=qt(),c=ZB(),u=c?.isBaseModelReady??!0,{materialSource:d}=qU(o),{room:h}=qe(),{patchSceneLoad:p}=qr(),{active:f}=RF(),A=Zk((0,rx.useMemo)(()=>h.scene??qk(),[h.scene])),g=(0,rx.useRef)(null),m=(0,rx.useRef)(!1),v=(0,rx.useCallback)(e=>{(g.current=e,"function"==typeof t)?t(e):t&&(t.current=e)},[t]),b=Kt("(max-width: 639px)"),{width:y,height:w}=function(e){let t,{ref:r,box:n="content-box"}=e,[{width:i,height:a},s]=rx.useState(Kr),o=(t=rx.useRef(!1),rx.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),rx.useCallback(()=>t.current,[])),l=rx.useRef({...Kr}),c=rx.useRef(void 0);return c.current=e.onResize,rx.useEffect(()=>{if(!r.current||"u"<typeof window||!("ResizeObserver"in window))return;let e=new ResizeObserver(([e])=>{let t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=Kn(e,t,"inlineSize"),i=Kn(e,t,"blockSize");if(l.current.width!==r||l.current.height!==i){let e={width:r,height:i};l.current.width=r,l.current.height=i,c.current?c.current(e):o()&&s(e)}});return e.observe(r.current,{box:n}),()=>{e.disconnect()}},[n,r,o]),{width:i,height:a}}({ref:g}),x=(0,rx.useMemo)(()=>{if(!y||!w||!A)return null;let e=y,t=w;return b?e=(t=w)*A:y/w>A?e=w*A:t=y/A,{width:e,height:t}},[y,w,A,b]);return(0,rx.useLayoutEffect)(()=>{x&&a?.(x.width,x.height)},[x,a]),(0,rx.useEffect)(()=>{if(!x||m.current)return;m.current=!0;let e=window.setTimeout(()=>{window.dispatchEvent(new Event("resize"))},250);return()=>{window.clearTimeout(e)}},[x]),(0,rx.useEffect)(()=>{p({layoutReady:null!==x})},[p,x]),(0,rx.useEffect)(()=>{"object-glb"===d&&p({materialReady:!!l&&u})},[l,d,u,p]),(0,rx.useEffect)(()=>{p({assetsReady:!f})},[f,p]),(0,rE.jsx)("div",{ref:v,className:WC("size-full flex items-center justify-center sm:pt-21 sm:pb-12",e),...s,children:x&&(0,rE.jsx)(Rz,{className:"touch-none bg-transparent",frameloop:"demand",camera:$f,gl:{toneMapping:4,toneMappingExposure:1.2,alpha:!0,preserveDrawingBuffer:!0},style:{width:`${x.width}px`,height:`${x.height}px`},children:(0,rE.jsxs)(rx.Suspense,{fallback:null,children:[(0,rE.jsx)(ZP,{ref:r}),(0,rE.jsx)($h,{lighting:Ww[o].lighting}),(0,rE.jsx)($o,{}),n&&i&&(0,rE.jsx)($p,{ref:i,target:n})]})})})}function $g({captureRef:e,introduction:t,className:r,canvasWrapperClassName:n,controls:i,...a}){let s,o,l,c,{isDragging:u}=qr(),d=(0,rx.useRef)(null),h=(0,rx.useRef)(null),p=(0,rx.useRef)(null),f=(s=(0,rx.useRef)(null),o=(0,rx.useRef)(!1),l=(0,rx.useCallback)(()=>{null!==s.current&&cancelAnimationFrame(s.current),s.current=null},[]),c=(0,rx.useCallback)(()=>{t&&(l(),t.onCancel())},[t,l]),(0,rx.useEffect)(()=>{if(!t){o.current=!1;return}if(!t.ready){o.current&&t.onCancel();return}return s.current=requestAnimationFrame(()=>{let e=d.current,r=p.current?.getScreenPoint(),n=e?.instance.wrapperComponent,i=e?.instance.contentComponent;if(!e||!r||!n||!i)return void t.onCancel();let{scale:a,positionX:l,positionY:c}=e.instance.transformState,u=n.getBoundingClientRect(),h=Math.min(e.instance.setup.maxScale,1.28*a),f=(e,t,r)=>r<t?(t-r)/2:Math.max(t-r,Math.min(0,e)),A=f(u.width/2-(r.x-u.left-l)/a*h,u.width,i.offsetWidth*h),g=f(u.height/2-(r.y-u.top-c)/a*h,u.height,i.offsetHeight*h);o.current=!0;let m=window.matchMedia("(prefers-reduced-motion: reduce)").matches,v=performance.now(),b=r=>{let n=m?1:Math.min(1,(r-v)/700),i=(1-Math.cos(Math.PI*n))/2;e.setTransform(l+(A-l)*i,c+(g-c)*i,a+(h-a)*i,0),n<1?s.current=requestAnimationFrame(b):(s.current=null,t.onComplete())};b(v)}),()=>{l()}},[p,t,l,d]),c),A=Kt("(max-width: 639px)"),g=(0,rx.useRef)(!!t);g.current=!!t;let m=(0,rx.useCallback)(()=>{A&&d.current?.centerView(void 0,g.current?0:void 0)},[A]);return(0,rE.jsxs)("div",{className:WC("relative flex items-center justify-center overflow-hidden",r),...a,onPointerDownCapture:e=>{f(),a.onPointerDownCapture?.(e)},onTouchStartCapture:e=>{f(),a.onTouchStartCapture?.(e)},onWheelCapture:e=>{f(),a.onWheelCapture?.(e)},children:[(0,rE.jsx)(gd,{ref:d,disabled:u,children:(0,rE.jsx)(gh,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,rE.jsx)($A,{captureRef:e??h,introductionTarget:t?.target,focusRef:p,className:n,onSizeChange:m})})}),i]})}function $m({...e}){return(0,rE.jsx)(hK,{"data-slot":"popover",...e})}function $v({...e}){return(0,rE.jsx)(hX,{"data-slot":"popover-trigger",...e})}function $b({className:e,align:t="center",sideOffset:r=4,portalContainer:n,...i}){return(0,rE.jsx)(h1,{container:n,children:(0,rE.jsx)(h3,{"data-slot":"popover-content",align:t,sideOffset:r,className:WC("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}function $y({className:e,defaultValue:t,value:r,min:n=0,max:i=100,variant:a="default","aria-label":s,"aria-labelledby":o,...l}){let c=rx.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n],[r,t,n]);return(0,rE.jsxs)(pd,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:i,"data-variant":a,"aria-label":s,"aria-labelledby":o,className:WC("relative flex w-full touch-none cursor-pointer items-center select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...l,children:[(0,rE.jsx)(pv,{"data-slot":"slider-track",className:WC("relative grow overflow-hidden rounded-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5","editor"===a?"bg-border-light data-[orientation=horizontal]:h-0.5":"bg-muted data-[orientation=horizontal]:h-1.5"),children:(0,rE.jsx)(py,{"data-slot":"slider-range",className:WC("absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full","editor"===a?"bg-background-blue":"bg-primary")})}),Array.from({length:c.length},(e,t)=>(0,rE.jsx)(px,{"data-slot":"slider-thumb","aria-label":s,"aria-labelledby":o,className:WC("ring-ring/50 block shrink-0 rounded-full border bg-white transition-[color,box-shadow] focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50","editor"===a?"size-3 border-background-blue shadow-none hover:ring-2 focus-visible:ring-2":"size-4 border-primary shadow-sm hover:ring-4 focus-visible:ring-4")},t))]})}let $w=/oklch\(([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\)/;function $x(e,t){let r=e.match($w);return r?{l:Number.parseFloat(r[1]),c:Number.parseFloat(r[2]),h:Number.parseFloat(r[3])}:{l:t[0],c:t[1],h:t[2]}}function $C({data:e,foreground:t,background:r,robustness:n="M",className:i,...a}){let[s,o]=(0,rx.useState)(null);return((0,rx.useEffect)(()=>{(async()=>{try{let i=getComputedStyle(document.documentElement),a=t??i.getPropertyValue("--foreground"),s=r??i.getPropertyValue("--background"),l=$x(a,[.21,.006,285.885]),c=$x(s,[.985,0,0]),u=await Lr.toString(e,{type:"svg",color:{dark:Le(Lt({mode:"oklch",...l})),light:Le(Lt({mode:"oklch",...c}))},width:200,errorCorrectionLevel:n,margin:0});o(u)}catch(e){console.error(e)}})()},[e,t,r,n]),s)?(0,rE.jsx)("div",{className:WC("size-full","[&_svg]:size-full",i),dangerouslySetInnerHTML:{__html:s},...a}):null}let $E=new F0,$S=$E.getDevice(),$M=$E.getOS(),$I="iOS"===$M.name,$B="Android"===$M.name,$k="mobile"===$S.type;function $T({className:e,buttonClassName:t,buttonLeadingIcon:r,buttonLabel:n,buttonSize:i,buttonVariant:a="contrast",...s}){let{type:o,width:l,height:c,name:u}=W6(),{handoff:d}=Ww[o],{src:h,tinuuid:p,widgetSession:f}=qt(),{containerRef:A,resourceRef:g}=qr(),{t:m,i18n:v}=sf(),b=function(){let{i18n:e}=sf();return"ru"===(e.resolvedLanguage??e.language)?"arizo":"vizbl"}(),[y,w]=(0,rx.useState)(""),[x,C]=(0,rx.useState)(""),[E,S]=(0,rx.useState)(()=>f?.token),[M,I]=(0,rx.useState)(!1),[B,k]=(0,rx.useState)(!1),T=(0,rx.useRef)(null),R=v.resolvedLanguage??v.language,D=qI[b],P=(0,rx.useMemo)(()=>(function({height:e,language:t,name:r,src:n,tenantConfig:i,tinuuid:a,handoff:s,type:o,width:l,widgetSessionToken:c,pageUrl:u}){if(!s)return null;if("floor"===s.destination&&a){let e=new URL(i.ROOM_URL);return e.searchParams.set("type",o),e.searchParams.set("tinuuid",a),e.searchParams.set("name",r),e.searchParams.set("language",t),c&&e.searchParams.set("widgetSessionToken",c),e.toString()}let d=new URL(i.POSTER_URL);return n&&d.searchParams.set("texture",function(e,t){if(!t||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//"))return e;try{return new URL(e,t).href}catch{return e}}(n,u)),d.searchParams.set("texture_width",(100*l).toString()),d.searchParams.set("texture_height",(100*e).toString()),c&&d.searchParams.set("widgetSessionToken",c),d.toString()})({height:c,language:R,name:u,src:h,tenantConfig:D,tinuuid:p,handoff:d,type:o,width:l,widgetSessionToken:E,pageUrl:"u"<typeof window?void 0:window.location.href}),[h,p,d,o,l,c,u,R,D,E]),_=(0,rx.useMemo)(()=>{if(!p)return null;let e=new URL("https://appclip.apple.com/id");return e.searchParams.set("p","com.us.vizbl.Clip"),e.searchParams.set("tinuuid",p),e.toString()},[p]);async function L(){S(await f?.getTokenForRequest().catch(()=>f.token))}let N=async()=>{if(d?.ar==="appclip"){if(!p)return;if($I&&_){Wd(f,"appclip"),window.location.assign(_);return}await L(),I(!0);return}let e=T.current,t=g.current;if(e&&t)if(e.canActivateAR)try{k(!0);let e=t.clone(!0);if(e.position.set(0,0,0),e.quaternion.identity(),e.updateMatrix(),e.updateMatrixWorld(!0),$I){e.rotation.set(-Math.PI/2,0,0),e.updateMatrix(),e.updateMatrixWorld(!0);let t=new Nh,r=await t.parseAsync(e,{ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"vertical"}}}),n=new File([r],"scene.usdz",{type:"model/vnd.usdz+zip"});w(URL.createObjectURL(n))}else{let t=new Li,r=await t.parseAsync(e,{binary:!0}),n=new File([r],"scene.glb",{type:"model/gltf-binary"});C(URL.createObjectURL(n))}}finally{k(!1)}else await L(),I(!0)};return((0,rx.useEffect)(()=>((""!==y||""!==x)&&T.current?.activateAR(),()=>{""!==y&&URL.revokeObjectURL(y),""!==x&&URL.revokeObjectURL(x)}),[y,x]),!d||$B&&$k||"floor"===d.destination&&!p)?null:(0,rE.jsxs)("div",{className:WC(e),...s,children:[(0,rE.jsxs)(WS,{variant:a,size:i,disabled:B,onClick:N,className:t,children:[r,n??m("ar.viewInPlace")]}),(0,rE.jsx)(WM,{open:M,onOpenChange:I,children:(0,rE.jsxs)(WT,{className:"gap-6 sm:max-w-120",showCloseButton:!1,portalContainer:A,children:[(0,rE.jsx)("div",{className:"flex items-center justify-center p-10 bg-constant-white rounded-2xl",children:(0,rE.jsx)($C,{className:"size-48",robustness:"H",data:P??""})}),(0,rE.jsx)("p",{className:"text-lg text-center text-text-sub font-medium",children:m("ar.scanQrCode")}),(0,rE.jsxs)("p",{className:"text-xs text-center text-text-light",children:[m("ar.deviceRequirementsDisclaimer"),(0,rE.jsx)("br",{}),(0,rE.jsx)("a",{href:D.TERMS_URL,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 transition-colors duration-300 hover:text-text-dark",style:{textDecoration:"underline",textUnderlineOffset:"2px"},children:m("legal.termsOfUse")})," ",m("legal.conjunction")," ",(0,rE.jsx)("a",{href:D.PRIVACY_URL,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 transition-colors duration-300 hover:text-text-dark",style:{textDecoration:"underline",textUnderlineOffset:"2px"},children:m("legal.privacyPolicy")})]}),(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"contrast",size:"lg",children:m("close")})})]})}),(0,rE.jsx)("model-viewer",{ref:T,className:"fixed w-px h-px opacity-0 pointer-events-none",src:x,iosSrc:y,reveal:"manual",ar:!0,cameraControls:!0,arPlacement:"wall",arModes:"webxr",arScale:"fixed",shadowIntensity:1,interactionPromptThreshold:100})]})}async function $R(e){await navigator.clipboard.writeText(e)}function $D({captureRef:e,fallbackToClipboard:t=!1,fileName:r="room-scene.png",shareMessage:n}){let[i,a]=(0,rx.useState)(!1),[s,o]=(0,rx.useState)(!1),l=(0,rx.useMemo)(()=>"u">typeof navigator&&"function"==typeof navigator.share||t&&"u">typeof navigator&&"function"==typeof navigator.clipboard?.writeText,[t]),c=(0,rx.useCallback)(async()=>{if(!l)return;let i="u">typeof navigator&&"function"==typeof navigator.share,s=window.location.href,o=`${n}
|
|
7631
|
-
${s}`;a(!0);try{if(!i&&t)return void await $R(o);let n=e.current;if(n)try{let e=await n.capture(),t=new File([e],r,{type:e.type||"image/png"});if(navigator.canShare?.({files:[t]}))return void await navigator.share({text:o,files:[t]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:o,url:s})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{a(!1)}},[l,e,t,r,n]);return{canShare:l,download:(0,rx.useCallback)(async()=>{let t=e.current;if(t){o(!0);try{var n;let e,i;n=await t.capture(),e=URL.createObjectURL(n),(i=document.createElement("a")).href=e,i.download=r,document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(e)}catch(e){console.error("Failed to download scene screenshot",e)}finally{o(!1)}}},[e,r]),isDownloading:s,isSharing:i,share:c}}function $P({captureRef:e}){let{type:t}=W6(),{containerRef:r,angle:n,rotation:i,setAngle:a,setRotation:s}=qr(),{t:o}=sf(),l=Kt("(max-width: 639px)"),{canShare:c,isSharing:u,share:d}=$D({captureRef:e,shareMessage:o(`shareMessage.${t}`)});return(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)($T,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),(0,rE.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[(0,rE.jsxs)($m,{children:[(0,rE.jsx)($v,{asChild:!0,children:(0,rE.jsxs)(WS,{variant:"contrast",size:l?"icon":"default",children:[(0,rE.jsx)(WW,{className:"size-5"}),(0,rE.jsx)("span",{className:"sr-only sm:not-sr-only",children:o("scene.tunePosition")})]})}),(0,rE.jsx)($b,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,rE.jsxs)(qa,{children:[(0,rE.jsxs)(qo,{orientation:"horizontal",children:[(0,rE.jsx)(qc,{children:o("scene.rotation")}),(0,rE.jsx)($y,{value:[i],onValueChange:([e])=>s(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":o("scene.rotation")})]}),(0,rE.jsxs)(qo,{orientation:"horizontal",children:[(0,rE.jsx)(qc,{children:o("scene.angle")}),(0,rE.jsx)($y,{value:[n],onValueChange:([e])=>a(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":o("scene.angle")})]})]})})]}),(0,rE.jsxs)(WS,{variant:"contrast",size:l?"icon":"default",disabled:!c||u,onClick:d,children:[(0,rE.jsx)(WJ,{className:"size-5"}),(0,rE.jsx)("span",{className:"sr-only sm:not-sr-only",children:o("scene.share")})]}),l&&(0,rE.jsxs)($m,{children:[(0,rE.jsx)($v,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"contrast",size:"icon",children:(0,rE.jsx)(Wq,{})})}),(0,rE.jsxs)($b,{className:"grid gap-5",portalContainer:r,children:[(0,rE.jsx)(qG,{}),(0,rE.jsx)(q0,{})]})]})]})]})}function $_({variant:e,open:t,portalContainer:r,showDialogCloseButton:n=!1,onOpenChange:i,onTryAgain:a,onCancel:s}){let{t:o}=sf(),l=e?o("custom-interior-processing"===e?"floor.error.processingBody":"viewer-load-failed"===e?"floor.error.loadBody":"artwork-load-failed"===e||"room-load-failed"===e?`loadError.${e}`:`accessError.${e}`):"";return(0,rE.jsx)(WM,{open:t,onOpenChange:i,children:(0,rE.jsxs)(WT,{portalContainer:r,showCloseButton:!1,className:"w-full max-w-85 gap-4 rounded-2xl p-6 text-center sm:max-w-85 sm:p-6",onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsxs)("div",{className:"grid gap-1",children:[(0,rE.jsx)(WP,{children:o("floor.error.title")}),(0,rE.jsx)(W_,{className:"typo-base-14 font-medium text-text-base",children:l})]}),(0,rE.jsxs)("div",{className:"grid gap-2",children:[a&&(0,rE.jsxs)(WS,{variant:"contrast",onClick:a,children:[(0,rE.jsx)(Wz,{"aria-hidden":"true"}),o("floor.error.tryAgain")]}),s&&(0,rE.jsx)(WS,{variant:"outline",onClick:s,children:o("floor.error.cancel")}),n&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"outline",children:o("close")})})]})]})})}function $L({rooms:e,customRooms:t,selectedRoomId:r,isInvalidFile:n,uploadRetryRequestId:i=0,showCloseButton:a=!1,onSelectRoom:s,onUploadFile:o}){let l,{t:c}=sf(),u=(0,rx.useId)(),d=(0,rx.useRef)(null);function h(e){return e.map(e=>(0,rE.jsxs)("button",{type:"button",className:"group relative aspect-[4/3] overflow-hidden rounded-2xl bg-background-base text-left transition focus-visible:ring-2 focus-visible:ring-icons-normal focus-visible:outline-hidden","aria-pressed":e.id===r,onClick:()=>s(e.id),children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(e),alt:"",decoding:"async",className:"size-full scale-[1.02] transform-gpu object-cover transition duration-200 group-hover:scale-105"}),(0,rE.jsx)("span",{className:"typo-base-12 absolute inset-x-0 bottom-0 truncate bg-linear-to-t from-black/45 via-black/10 to-transparent px-3 py-2 text-constant-white",children:c(`rooms.${e.id}`,{defaultValue:e.name})})]},e.id))}return(0,rx.useEffect)(()=>{i>0&&d.current?.click()},[i]),(0,rE.jsxs)("section",{"aria-labelledby":"floor-interior-selection-title",className:"relative mx-auto grid h-auto min-h-0 max-h-[calc(100svh-8px)] w-full max-w-151 grid-rows-[auto_auto_minmax(0,1fr)_auto] gap-4 overflow-hidden rounded-t-2xl rounded-b-none bg-background-containers p-4 shadow-[var(--shadow-login)] sm:my-4 sm:max-h-[calc(100svh-32px)] sm:rounded-2xl sm:p-6","data-testid":"floor-interior-selection-panel","data-room-selection-panel":!0,children:[a&&(l=(0,rE.jsx)(WS,{type:"button",variant:"outline",size:"icon",className:"absolute top-4 right-4 sm:top-6 sm:right-6","aria-label":c("close"),"data-testid":"floor-interior-selection-icon-close",children:(0,rE.jsx)(WO,{})}),(0,rE.jsx)(WB,{asChild:!0,children:l})),(0,rE.jsx)("h2",{id:"floor-interior-selection-title",className:"typo-base-16 font-medium sm:typo-base-18 text-text-dark",children:c("floor.interiorSelection.title")}),(0,rE.jsxs)("div",{className:"grid gap-2","data-testid":"floor-interior-selection-upload",children:[(0,rE.jsxs)("label",{htmlFor:u,className:"flex min-h-15 cursor-pointer items-center justify-center gap-2 rounded-xl border border-dashed border-background-blue bg-background-blue-transparent px-4 text-center typo-button-normal text-background-blue opacity-80 transition hover:bg-background-blue-transparent/80",onDragOver:e=>e.preventDefault(),onDrop:function(e){e.preventDefault();let t=e.dataTransfer.files[0];t&&o(t)},children:[(0,rE.jsx)(WN,{className:"size-5 text-background-blue"}),c("floor.interiorSelection.uploadPhoto"),(0,rE.jsx)("input",{ref:d,id:u,type:"file",accept:"image/*",className:"sr-only",onChange:function(e){let t=e.target.files?.[0];e.target.value="",t&&o(t)}})]}),n&&(0,rE.jsx)("p",{className:"typo-base-12 font-medium text-destructive",children:c("floor.interiorSelection.invalidFile")})]}),(0,rE.jsx)("div",{className:"grid min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain pr-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden","data-testid":"floor-interior-selection-scroll-content",children:(0,rE.jsxs)("div",{className:"grid min-h-max gap-4",children:[t.length>0&&(0,rE.jsxs)("div",{className:"grid gap-3",children:[(0,rE.jsx)("h3",{className:"typo-base-16 font-medium text-text-light",children:c("floor.interiorSelection.customTitle")}),(0,rE.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3","data-testid":"floor-custom-interior-selection-grid",children:h(t)})]}),(0,rE.jsxs)("div",{className:"grid gap-3",children:[(0,rE.jsx)("h3",{className:"typo-base-16 font-medium text-text-light",children:c("floor.interiorSelection.presetsTitle")}),(0,rE.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3","data-testid":"floor-preset-interior-selection-grid",children:h(e)})]})]})}),a&&(0,rE.jsx)(WD,{className:"-mt-2 shrink-0 p-0 sm:mt-0",children:(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"outline",className:"w-full",children:c("close")})})})]})}function $N(e){return(0,rE.jsx)("div",{className:"absolute inset-0 z-20 grid items-end p-0 sm:items-center sm:p-4","data-testid":"floor-interior-selection-overlay",children:(0,rE.jsx)($L,{...e})})}function $F({open:e,showCloseButton:t=!0,portalContainer:r,onOpenChange:n,...i}){let{t:a}=sf();return(0,rE.jsx)(WM,{open:e,onOpenChange:n,children:(0,rE.jsxs)(WT,{contentInsideOverlay:!0,portalContainer:r,showCloseButton:!1,"data-testid":"floor-interior-selection-overlay",className:"top-auto bottom-0 grid max-h-[calc(100svh-8px)] w-[calc(100%-16px)] min-w-0 max-w-none translate-y-0 overflow-hidden rounded-t-2xl rounded-b-none border-none bg-transparent p-0 shadow-none sm:top-[50%] sm:bottom-auto sm:w-full sm:max-w-none sm:translate-y-[-50%] sm:rounded-none sm:p-4",children:[(0,rE.jsx)(WP,{className:"sr-only",children:a("floor.interiorSelection.title")}),(0,rE.jsx)(W_,{className:"sr-only"}),(0,rE.jsx)($L,{...i,showCloseButton:t})]})})}let $O="data-material-selection-action",$Q="data-material-selection-panel";function $U(){let{t:e}=sf(),{type:t}=W6();return e(`floor.materialSelection.${Ww[t].catalogTitle}`)}function $z({className:e,gridClassName:t,titleClassName:r,onOpenChange:n,...i}){let a=$U(),s=(0,rx.useRef)(null),{fetchNextMaterialsPage:o,hasNextPage:l,isFetchingNextPage:c,isLoading:u,materialItems:d,selectMaterial:h,selectedMaterialId:p}=function({includeEmbeddedObject:e=!1}={}){var t;let{material:r,tinuuid:n,embeddedObject:i,selectedObject:a,setMaterial:s,setTinuuid:o,apiKey:l,baseURL:c,language:u,source:d,widgetSession:h,setAccessError:p,setLoadError:f}=qt(),{type:A,name:g}=W6(),m=i?.owner?.uuid,{data:v,error:b,isFetchingNextPage:y,fetchNextPage:w,hasNextPage:x,isLoading:C}=od({queryKey:["room-viewer","public-objects",{apiKey:(t={apiKey:l,baseURL:c,language:u,source:d,resourceType:A}).apiKey??null,language:t.language??null,ownerUuid:m??null,resourceType:t.resourceType??null,source:t.source}],enabled:!!m,queryFn:({pageParam:e,signal:t})=>{if(!m)throw Error("Owner uuid is required.");return Wm(m,e,{apiKey:l,baseURL:c,language:u,signal:t,source:d,widgetSession:h,resourceType:A})},initialPageParam:1,getNextPageParam:(e,t,r)=>void 0!==e.pages_count?r<e.pages_count?r+1:void 0:e.objs?.length?r+1:void 0,getPreviousPageParam:(e,t,r)=>r>1?r-1:void 0},ou,void 0),{requiresMaterialModel:E}=qU(A),{getCollapseKey:S}=qO(A),{catalogsEveryMaterial:M}=qF[Ww[A].materialRole],{composition:I,productNameSource:B}=Ww[A],k=(0,rx.useMemo)(()=>v?.pages.flatMap(e=>e.objs??[])??[],[v]),T=(0,rx.useMemo)(()=>"material"===B?[]:k.filter(e=>e.tinuuid&&(!e.kit?.uuid||!e.kit.name?.trim())&&(!E||e.materials?.[0]?.native?.glbUrl)),[k,B,E]),R=oc({queries:T.map(e=>({queryKey:Wf(e.tinuuid,{apiKey:l,baseURL:c,language:u,source:d,resourceType:A}),queryFn:({signal:t})=>Wg(e.tinuuid,{apiKey:l,baseURL:c,language:u,signal:t,source:d,widgetSession:h,resourceType:A})}))}),D=k.flatMap(e=>{let t=R[T.indexOf(e)];return t?.isPending||t?.isError?[]:[{...e,kit:t?.data?.kit?{...e.kit,...t.data.kit}:e.kit}]}),P=(0,rx.useMemo)(()=>{let t={requiresMaterialModel:E,getCollapseKey:S};if(e)return qP([...i?.tinuuid&&i.materials?.[0]?[i]:[],...D],null,t);return qP(D,i,t)},[i,D,S,e,E]),_=(0,rx.useMemo)(()=>P.flatMap(e=>{if(!e.tinuuid)return[];let t="color-design"===I&&e.kit?.uuid,r=M&&!t?e.materials:e.materials?.slice(0,1);return r?.map(t=>{let r=qj(t);return r&&e.tinuuid?{materialId:r,productName:qz(A,e,t,g),material:t,tinuuid:e.tinuuid}:null}).filter(e=>null!==e)??[]}),[M,I,P,A,g]),L="color-design"===I&&a?.tinuuid===n&&a?.kit?.uuid?P.find(e=>S(e)===S(a)):void 0,N=L?.tinuuid!==n&&L?qj(L.materials?.[0]??{}):r?qj(r):"",F=b??R.find(e=>e.error)?.error,O=P.find(e=>e.tinuuid===n),Q=P.find(e=>e.tinuuid&&e.materials?.[0]);(0,rx.useEffect)(()=>{let e=VO(F);e?p(e):F&&f("viewer-load-failed")},[F,p,f]),(0,rx.useEffect)(()=>{v&&0===P.length&&x&&!y&&w()},[v,w,x,y,P.length]),(0,rx.useEffect)(()=>{if(null!==r)return;let e=O??Q,t=e?.materials?.[0];e&&t&&e.tinuuid&&(s(t),o(e.tinuuid))},[Q,O,r,s,o]);let U=(0,rx.useCallback)(()=>{!1===x||y||w()},[w,x,y]),z=(0,rx.useCallback)(e=>{let t=P.find(t=>t.materials?.some(t=>qj(t)===e)),r=t?.materials?.find(t=>qj(t)===e);return!!t&&!!r&&!!t.tinuuid&&(s(r),o(t.tinuuid),!0)},[P,s,o]);return{fetchNextMaterialsPage:U,hasNextPage:x,isFetchingNextPage:y,isLoading:C||R.some(e=>e.isPending),materialItems:_,selectMaterial:z,selectedMaterialId:N}}({includeEmbeddedObject:!0});(0,rx.useEffect)(()=>{let e=s.current;e&&!u&&!c&&l&&0!==d.length&&e.scrollHeight<=e.clientHeight&&o()},[o,l,c,u,d.length]);let f=(0,rx.useCallback)(e=>{let{clientHeight:t,scrollHeight:r,scrollTop:n}=e.currentTarget;n+t>=r-64&&o()},[o]),A=(0,rx.useCallback)(e=>{h(e)&&n(!1)},[n,h]);return(0,rE.jsxs)("div",{...i,className:WC("flex min-h-0 flex-col gap-3 overflow-hidden text-text-dark outline-none",e),"data-testid":"material-selection-panel",onPointerDownCapture:e=>{e.stopPropagation(),i.onPointerDownCapture?.(e)},onMouseDownCapture:e=>{e.stopPropagation(),i.onMouseDownCapture?.(e)},children:[(0,rE.jsx)("h2",{className:WC("typo-base-16 font-medium sm:typo-base-14 sm:font-semibold text-text-dark",r),children:a}),(0,rE.jsx)("div",{"data-testid":"material-selection-grid",ref:s,className:WC("min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain pr-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",t),onScroll:f,children:(0,rE.jsxs)("div",{className:"grid min-h-max grid-cols-3 gap-x-2 gap-y-2","data-testid":"material-selection-grid-items",children:[d.map(({materialId:e,material:t,tinuuid:r,productName:n})=>{let i,a=e===p,s=(i=t.previews?.[0],i?.subRes?.small??i?.url);return(0,rE.jsxs)("button",{type:"button","data-selected":a,"aria-pressed":a,className:"group flex min-w-0 flex-col gap-1 rounded-lg bg-background-containers text-left focus-visible:ring-2 focus-visible:ring-icons-normal focus-visible:outline-hidden",onClick:()=>A(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),A(e))},children:[(0,rE.jsxs)("span",{className:"relative grid aspect-square w-full shrink-0 place-items-center overflow-hidden rounded-lg border border-border p-1 transition group-hover:border-icons-normal",children:[s?(0,rE.jsx)("img",{src:s,alt:"",className:"size-full rounded-md object-cover"}):(0,rE.jsx)(WG,{className:"size-6 text-icons-normal"}),a&&(0,rE.jsx)("span",{className:"absolute top-1 right-1 grid size-6 place-items-center rounded-full bg-icons-blue text-icons-white","data-testid":"material-selection-selected-check",children:(0,rE.jsx)(WF,{className:"size-4"})})]}),(0,rE.jsx)("span",{className:"typo-base-12 line-clamp-3 w-full wrap-anywhere text-text-base",children:n})]},`${r}-${e}`)}),(u||c)&&(0,rE.jsx)("div",{className:"col-span-3 grid h-16 place-items-center",children:(0,rE.jsx)(WZ,{className:"size-6"})})]})})]})}function $j({open:e,portalContainer:t,onOpenChange:r}){let{t:n}=sf(),i=$U();return(0,rE.jsx)(WM,{open:e,onOpenChange:r,children:(0,rE.jsxs)(WT,{contentInsideOverlay:!0,"data-testid":"material-selection-mobile-overlay","data-material-selection-panel":"",className:"top-auto bottom-0 flex max-h-[calc(100svh-8px)] w-[calc(100%-16px)] !max-w-none translate-y-0 flex-col gap-2 overflow-hidden rounded-t-2xl rounded-b-none p-4 sm:hidden",portalContainer:t,showCloseButton:!1,children:[(0,rE.jsx)(WP,{className:"sr-only",children:i}),(0,rE.jsx)(W_,{className:"sr-only"}),(0,rE.jsx)($z,{className:"min-h-0",gridClassName:"max-h-none",onOpenChange:r}),(0,rE.jsx)(WD,{className:"shrink-0 p-0",children:(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{type:"button",variant:"outline",className:"w-full",children:n("close")})})})]})})}var $G="Progress",[$H,$V]=Kl($G),[$W,$q]=$H($G),$K=rx.forwardRef((e,t)=>{var r,n;let{__scopeProgress:i,value:a=null,max:s,getValueLabel:o=$X,...l}=e;(s||0===s)&&!$0(s)&&console.error((r=`${s}`,`Invalid prop \`max\` of value \`${r}\` supplied to \`Progress\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`));let c=$0(s)?s:100;null===a||$1(a,c)||console.error((n=`${a}`,`Invalid prop \`value\` of value \`${n}\` supplied to \`Progress\`. The \`value\` prop must be:
|
|
7630
|
+
`)},o.customProgramCacheKey=()=>"wall-panel-exterior-outline-v1",{mask:t,maskMaterial:r,maskModel:n,maskScene:i,material:o,resolution:a,radius:s,clearColor:new mJ}},[e]);return(0,rx.useLayoutEffect)(()=>ZK(r.material,t,{shading:!1}),[r,t]),(0,rx.useLayoutEffect)(()=>()=>{r.mask.dispose(),r.maskMaterial.dispose(),r.material.dispose()},[r]),(0,rE.jsx)("mesh",{material:r.material,frustumCulled:!1,renderOrder:3,raycast:()=>{},onBeforeRender:(t,n,i)=>{let a=t.getRenderTarget(),s=t.getActiveCubeFace(),o=t.getActiveMipmapLevel(),l=t.autoClear,c=t.getClearAlpha();t.getClearColor(r.clearColor),t.getDrawingBufferSize(r.resolution);let{x:u,y:d}=r.resolution;(r.mask.width!==u||r.mask.height!==d)&&r.mask.setSize(u,d),r.radius.value=2*t.getPixelRatio(),e.updateWorldMatrix(!0,!0),r.maskModel.matrix.copy(e.matrixWorld);try{t.autoClear=!0,t.setClearColor(0,0),t.setRenderTarget(r.mask),t.render(r.maskScene,i)}finally{t.setRenderTarget(a,s,o),t.setClearColor(r.clearColor,c),t.autoClear=l}},children:(0,rE.jsx)("planeGeometry",{args:[2,2]})})}function Z7({source:e,patch:t,isPointVisible:r,outlined:n}){let{model:i,materials:a}=(0,rx.useMemo)(()=>{let t=e.clone(!0),r=ZJ(t);return{model:t,materials:r}},[e]);return(0,rx.useLayoutEffect)(()=>{let e=a.map(e=>ZK(e,t));return i.traverse(e=>{e instanceof bI&&(e.raycast=function(e,t){let n=[];bI.prototype.raycast.call(this,e,n),t.push(...n.filter(e=>!r||r(e.point)))})}),()=>e.forEach(e=>e())},[r,a,i,t]),(0,rx.useLayoutEffect)(()=>()=>a.forEach(e=>e.dispose()),[a]),(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("primitive",{object:i,dispose:null}),n&&(0,rE.jsx)(Z6,{model:i,patch:t})]})}function $e({size:e,patch:t,isPointVisible:r,onClick:n}){let[i,a]=(0,rx.useState)(!1),s=(0,rx.useMemo)(()=>{let e=document.createElement("canvas");e.width=e.height=256;let t=e.getContext("2d");if(t.lineJoin="miter",t.lineCap="round",t.beginPath(),i)t.rect(16,16,224,224);else for(let[e,r,n,i]of[[16,16,1,1],[240,16,-1,1],[16,240,1,-1],[240,240,-1,-1]])t.moveTo(e+22*n,r),t.lineTo(e,r),t.lineTo(e,r+22*i);t.strokeStyle="rgba(255,255,255,.80)",t.lineWidth=5,t.stroke(),t.strokeStyle=i?"#59636d":"rgba(70,80,90,.60)",t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(128,128,29,0,2*Math.PI),t.fillStyle=i?"#ffffff":"#f5f6f7",t.fill(),t.strokeStyle="rgba(35,45,55,.32)",t.lineWidth=2,t.stroke(),t.beginPath(),t.moveTo(117,128),t.lineTo(139,128),t.moveTo(128,117),t.lineTo(128,139),t.strokeStyle="#35414d",t.lineWidth=3,t.stroke();let r=new yH(e);return r.colorSpace="srgb",r},[i]),o=(0,rx.useMemo)(()=>new bA({map:s,transparent:!0,depthWrite:!1,toneMapped:!1}),[s]);return(0,rx.useLayoutEffect)(()=>{let e=ZK(o,t,{shading:!1});return o.alphaToCoverage=!1,e},[o,t]),(0,rx.useLayoutEffect)(()=>()=>{o.dispose(),s.dispose()},[o,s]),(0,rE.jsx)("mesh",{material:o,renderOrder:2,onPointerOver:()=>a(!0),onPointerOut:()=>a(!1),raycast:function(e,t){let n=[];bI.prototype.raycast.call(this,e,n),t.push(...n.filter(e=>!r||r(e.point)))},onPointerDown:e=>{e.stopPropagation(),e.nativeEvent.stopPropagation()},onClick:e=>{e.stopPropagation(),n()},children:(0,rE.jsx)("planeGeometry",{args:[e,e]})})}function $t({isPointVisible:e,visible:t,dragging:r,panelKey:n,number:i,size:a,depth:s,patch:o}){let l=ZB(),{t:c}=sf(),{camera:u,gl:d}=IY(),h=(0,rx.useRef)(null),p=(0,rx.useRef)(null),f=(0,rx.useMemo)(()=>new g0,[]),A=(0,rx.useMemo)(()=>{let e=document.createElement("canvas");e.width=e.height=128;let t=e.getContext("2d");for(let e of(t.beginPath(),t.arc(64,64,61,0,2*Math.PI),t.fillStyle="#f5f6f7",t.fill(),t.strokeStyle="rgba(35,45,55,.32)",t.lineWidth=2,t.stroke(),t.fillStyle="#35414d",[40,64,88]))t.beginPath(),t.arc(e,64,5,0,2*Math.PI),t.fill();let r=new yH(e);return r.colorSpace="srgb",r},[]),g=(0,rx.useMemo)(()=>new bA({map:A,transparent:!0,depthWrite:!1,toneMapped:!1}),[A]);(0,rx.useLayoutEffect)(()=>{let e=ZK(g,o,{shading:!1});return g.alphaToCoverage=!1,e},[g,o]),(0,rx.useLayoutEffect)(()=>()=>{g.dispose(),A.dispose()},[g,A]),IX(()=>{h.current&&p.current&&(h.current.getWorldPosition(f),p.current.tabIndex=!r&&(!e||e(f))?0:-1)});let m=()=>{if(!h.current)return;f.set(.05,-.05,0),h.current.localToWorld(f).project(u);let e=d.domElement.getBoundingClientRect();l.openMenu(n,{x:e.left+(f.x+1)*e.width/2,y:e.top+(1-f.y)*e.height/2})};return(0,rE.jsxs)("group",{ref:h,position:[a/2-a/12-.05,-a/2+a/20+.05,s+.002],children:[(0,rE.jsx)("mesh",{name:"panel-actions",material:g,visible:t&&!r,renderOrder:3,raycast:function(n,i){if(!t||r)return;let a=[];bI.prototype.raycast.call(this,n,a),i.push(...a.filter(t=>t.uv&&.48>=Math.hypot(t.uv.x-.5,t.uv.y-.5)&&(!e||e(t.point))))},onPointerDown:e=>{e.stopPropagation(),e.nativeEvent.stopPropagation()},onPointerUp:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m()},children:(0,rE.jsx)("planeGeometry",{args:[.1,.1]})}),(0,rE.jsx)(TL,{style:{pointerEvents:"none"},children:(0,rE.jsx)("button",{ref:p,type:"button","data-panel-key":n,className:"sr-only","aria-label":c("wallPanel.panelActions",{number:i}),"aria-haspopup":"menu",onFocus:()=>l.select(n),onClick:e=>{e.stopPropagation(),m()}})})]})}function $r({glbUrl:e,position:t,quaternion:r,materialPatch:n,isPointVisible:i,onDragStart:a,onDrag:s,onDragEnd:o}){let{data:l}=od({...ZC(e),enabled:!0,suspense:!0,throwOnError:oi,placeholderData:void 0},s2,void 0),c=ZB(),{room:u}=qe(),[d,h]=(0,rx.useState)(null),{resourceRef:p,isDragging:f,setIsDragging:A}=qr(),{gl:g}=IY(),m=f?"grabbing":d?.action?"pointer":d?"grab":"auto";(0,rx.useLayoutEffect)(()=>{let e=g.domElement.style.cursor;return g.domElement.style.cursor=m,()=>{g.domElement.style.cursor=e}},[g,m]);let v=(e,t)=>h(r=>r?.key===e&&r.action===t?r:{key:e,action:t}),b=(0,rx.useRef)(null),y=l.width,w=`${u.id}:${c.generation}`,[x,C]=(0,rx.useState)({size:y,roomKey:w,x:0,y:0});if(x.roomKey!==w)C({size:y,roomKey:w,x:0,y:0});else if(x.size!==y){let e=c.panels.reduce((e,t)=>({minX:Math.min(e.minX,t.x),maxX:Math.max(e.maxX,t.x),minY:Math.min(e.minY,t.y),maxY:Math.max(e.maxY,t.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),t=x.size-y;C({size:y,roomKey:w,x:x.x+(e.minX+e.maxX)/2*t,y:x.y+(e.minY+e.maxY)/2*t})}(0,rx.useLayoutEffect)(()=>()=>A(!1),[A]);let E=(e,t=!1)=>{let r=b.current;r&&r.pointerId===e.pointerId&&(e.stopPropagation(),b.current=null,e.target.releasePointerCapture(e.pointerId),A(!1),o(),t||r.moved||(c.select(r.key),c.closeMenu()))};return(0,rE.jsx)("group",{ref:p,position:t,quaternion:r,onPointerMissed:c.clearSelection,children:(0,rE.jsxs)("group",{position:[x.x,x.y,0],children:[c.panels.map((e,t)=>{let r=c.options.find(t=>t.material.hid===e.materialId)?.model??l;return(0,rE.jsxs)("group",{position:[e.x*y,e.y*y,0],onPointerOver:t=>{t.stopPropagation(),v(ZE(e),"panel-actions"===t.object.name)},onPointerOut:()=>h(null),onPointerDown:t=>{0===t.button&&!b.current&&(t.stopPropagation(),t.nativeEvent.stopPropagation(),b.current={x:t.clientX,y:t.clientY,key:ZE(e),moved:!1,pointerId:t.pointerId},t.target.setPointerCapture(t.pointerId),A(!0),a())},onPointerMove:t=>{v(ZE(e),"panel-actions"===t.object.name);let r=b.current;r&&r.pointerId===t.pointerId&&(t.stopPropagation(),!r.moved&&Math.hypot(t.clientX-r.x,t.clientY-r.y)>4&&(r.moved=!0,c.select(r.key),c.closeMenu()),r.moved&&s())},onPointerUp:e=>E(e),onPointerCancel:e=>E(e,!0),children:[(0,rE.jsx)($t,{panelKey:ZE(e),number:t+1,size:y,depth:r.depth,patch:n,isPointVisible:i,dragging:f,visible:c.selected===ZE(e)||d?.key===ZE(e)}),(0,rE.jsx)("group",{"rotation-z":-e.turns*Math.PI/2,children:(0,rE.jsx)("group",{position:r.mountingOffset,children:(0,rE.jsx)(Z7,{outlined:c.selected===ZE(e)||d?.key===ZE(e),source:r.scene,patch:n,isPointVisible:i})})})]},ZE(e))}),c.selected&&c.neighbors.map(e=>(0,rE.jsx)("group",{position:[e.x*y,e.y*y,.002],children:(0,rE.jsx)($e,{size:y,patch:n,isPointVisible:i,onClick:()=>c.add(e)})},ZE(e)))]})})}function $n(e){let{glbUrl:t}=qt();return t?(0,rE.jsx)($r,{...e,glbUrl:t}):null}let $i={"modelled-resource":function({position:e,quaternion:t,materialPatch:r,onDrag:n,onDragEnd:i,onDragStart:a}){let{type:s}=W6(),{glbUrl:o}=qt();return o?"rotate-on-floor"===Ww[s].manipulation?(0,rE.jsx)(Z1,{glbUrl:o,position:e,quaternion:t,materialPatch:r}):(0,rE.jsx)(TC,{autoTransform:!1,onDrag:n,onDragEnd:i,onDragStart:a,children:(0,rE.jsx)(Z1,{glbUrl:o,position:e,quaternion:t,materialPatch:r})}):null},"textured-resource":function({position:e,quaternion:t,materialPatch:r,onDrag:n,onDragEnd:i,onDragStart:a}){let{src:s,setLoadError:o}=qt();return s?(0,rE.jsx)(Z_,{onError:()=>o("artwork-load-failed"),children:(0,rE.jsx)(TC,{autoTransform:!1,onDrag:n,onDragEnd:i,onDragStart:a,children:(0,rE.jsx)(Z8,{src:s,position:e,quaternion:t,materialPatch:r})})}):null}};function $a(){let{room:e}=qe(),t=IY(e=>e.scene),r=I0(xH,q9(e),e=>{e.setCrossOrigin("anonymous")});return(0,rx.useLayoutEffect)(()=>(r.colorSpace="srgb",t.background=r,()=>{t.background===r&&(t.background=null)}),[t,r]),null}function $s({plane:e,geometry:t,setPlaneRef:r}){let n={planeId:e.id,kind:e.kind};return(0,rE.jsx)("mesh",{ref:t=>r(e,t),geometry:t,userData:n,children:(0,rE.jsx)("meshBasicMaterial",{visible:!1,side:2})})}function $o(){let e,{type:t}=W6(),r=ZB(),{setLoadError:n}=qt(),i="panel-group"===(e=Ww[t]).manipulation?$n:$i[e.identity],{room:a}=qe(),{patchSceneLoad:s}=qr(),{gl:o,size:l,camera:c,invalidate:u,raycaster:d,pointer:h}=IY(),p=(0,rx.useMemo)(()=>a.scene??qk(),[a.scene]),[f,A]=I0(xH,[p.planeIds.dataPng,p.shading?.dataPng??"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNoaGgAAAMEAYFL09IQAAAAAElFTkSuQmCC"]),g=function({camera:e,invalidate:t,pointer:r,raycaster:n,roomId:i,scene:a,surfaces:s}){let o=`${i}:${[...s].sort().join(",")}`,l=(0,rx.useMemo)(()=>({value:null}),[]),[c,u]=(0,rx.useReducer)(ZV,o,ZH),d=(0,rx.useRef)(null),h=(0,rx.useRef)(new Map),p=(0,rx.useRef)(new Map),f=(0,rx.useRef)(null),A=c.placementKey===o,g=A?c.planeIdMap:null,m=A&&c.planeIdMapFailed,v=A?c.resourcePose:null,b=(0,rx.useMemo)(()=>ZG(a,s),[a,s]),y=(0,rx.useMemo)(()=>b.map(e=>e.id),[b]),w=(0,rx.useMemo)(()=>new Map(a.planes.map(e=>{let t,r;return[e.id,(t=e.polygon3D.flatMap(e=>(function(e,t){let[r,n,i]=e;return[r*(Zk(t)*(t.camera.fx/t.camera.fy)),i,-n]})(e,a)),(r=new vq).setAttribute("position",new vL(t,3)),e.polygon3D.length>=4&&r.setIndex([0,1,2,0,2,3]),r)]})),[a]),x=(0,rx.useMemo)(()=>({artifactsReady:null!==g,placementReady:null!==v,prepareReady:null!==v}),[g,v]),C=0===b.length?"no-allowed-surface":m?"plane-id-map-decode":null,E=(0,rx.useCallback)((e,t)=>{t?p.current.set(e.id,t):p.current.delete(e.id)},[]);(0,rx.useEffect)(()=>{let e=!1;return u({type:"reset-plane-id-map",placementKey:o}),ZR(a.planeIds.dataPng,a.planeIds.width,a.planeIds.height).then(t=>{if(e)return;let r=new Map;try{for(let e of a.planes)s.includes(e.kind)&&e.id>0&&r.set(e.id,function(e,t){let r=2*e.width,n=2*e.height,i=new Float32Array(r*n),a=new Float32Array(r*n),s=new Uint8Array(r*n),o=e.width,l=e.height,c=-1,u=-1;for(let r=0;r<e.height;r++)for(let n=0;n<e.width;n++)e.data[r*e.width+n]===t&&(o=Math.min(o,n),l=Math.min(l,r),c=Math.max(c,n),u=Math.max(u,r));let d=c<0?r:Math.max(0,2*o-11),h=u<0?n:Math.max(0,2*l-11),p=c<0?-1:Math.min(r-1,(c+1)*2+11),f=u<0?-1:Math.min(n-1,(u+1)*2+11);for(let n=h;n<=f;n++){let a=(n+.5)/2-.5,s=Math.floor(a),o=ZF(s,e.height-1),l=ZF(s+1,e.height-1),c=a-s;for(let a=d;a<=p;a++){let s=(a+.5)/2-.5,u=Math.floor(s),d=ZF(u,e.width-1),h=ZF(u+1,e.width-1),p=s-u,f=(e.data[o*e.width+d]===t?1-p:0)+(e.data[o*e.width+h]===t?p:0),A=(e.data[l*e.width+d]===t?1-p:0)+(e.data[l*e.width+h]===t?p:0);i[n*r+a]=f*(1-c)+A*c}}for(let e=h;e<=f;e++)for(let t=d;t<=p;t++){let n=0;for(let a=-9;a<=9;a++)n+=i[e*r+ZF(t+a,r-1)]*ZL[a+9];a[e*r+t]=n}for(let e=h;e<=f;e++)for(let t=d;t<=p;t++){let i=0;for(let s=-9;s<=9;s++)i+=a[ZF(e+s,n-1)*r+t]*ZL[s+9];s[e*r+t]=Math.round(255*i)}let A=new bU(s,r,n,1028);return A.minFilter=1006,A.magFilter=1006,A.wrapS=1001,A.wrapT=1001,A.generateMipmaps=!1,A.unpackAlignment=1,A.needsUpdate=!0,{data:s,width:r,height:n,texture:A}}(t,e.id))}catch(e){throw r.forEach(e=>e.texture.dispose()),e}h.current=r,u({type:"set-plane-id-map",placementKey:o,planeIdMap:t})}).catch(t=>{console.error(t),e||u({type:"fail-plane-id-map",placementKey:o})}),()=>{e=!0,h.current.forEach(e=>e.texture.dispose()),h.current=new Map,l.value=null}},[l,o,a.planeIds,a.planes,s]),(0,rx.useEffect)(()=>{u({type:"reset-placement",placementKey:o}),d.current=null,l.value=null,f.current=null},[l,o]);let S=(0,rx.useCallback)((r,n,i=null)=>{let a,s=Zj(r,n,e),c=i?(a=new g0(...i).applyQuaternion(new g$(...s.quaternion)).add(new g0(...s.position)),{...s,position:a.toArray()}):s;d.current=c.activePlaneId,l.value=h.current.get(c.activePlaneId)?.texture??null,u({type:"set-resource-pose",placementKey:o,resourcePose:c}),t()},[l,e,t,o]),M=(0,rx.useCallback)(t=>g?function({activePlaneId:e,allowedPlaneIds:t,camera:r,planeIdMap:n,planeMap:i,pointer:a,raycaster:s}){let o=new Set(t),l=[],c=new Set,u=e=>{!(null===e||c.has(e))&&o.has(e)&&(c.add(e),l.push(e))};for(let o of(u(ZT(a,n)),u(e),t.forEach(u),s.setFromCamera(a,r),l)){let e=i.get(o),t=e?s.intersectObject(e,!1)[0]:null;if(t)return t}return null}({activePlaneId:d.current,allowedPlaneIds:y,camera:e,planeIdMap:g,planeMap:p.current,pointer:t,raycaster:n}):null,[y,e,g,n]);(0,rx.useEffect)(()=>{if(!g||null!==v)return;let r=function({allowedPlanes:e,camera:t,planeMap:r}){let n=e[0],i=n?r.get(n.id):null;return i?Zj(i,function(e){let t=e.geometry.attributes.position,r=new g0;for(let e=0;e<t.count;e++)r.add(new g0(t.getX(e),t.getY(e),t.getZ(e)));return r.divideScalar(Math.max(1,t.count))}(i),t):null}({allowedPlanes:b,camera:e,planeMap:p.current});r&&(d.current=r.activePlaneId,l.value=h.current.get(r.activePlaneId)?.texture??null,u({type:"set-resource-pose",placementKey:o,resourcePose:r}),t())},[l,b,e,t,o,g,v]);let I=(0,rx.useCallback)(()=>{let t,n=M(r);if(!n||!v){f.current=null;return}let i=Zj(n.object,n.point,e);t=new g$(...i.quaternion).invert(),f.current=new g0(...v.position).sub(new g0(...i.position)).applyQuaternion(t).toArray()},[e,M,r,v]),B=(0,rx.useCallback)(()=>{let e=M(r);e&&S(e.object,e.point,f.current)},[M,r,S]),k=(0,rx.useCallback)(()=>{f.current=null},[]),T=(0,rx.useCallback)(t=>{let r,n=d.current,i=null===n?null:h.current.get(n);if(!i)return!1;let a=t.clone().project(e),s=function(e,t,r){if(t<0||t>1||r<0||r>1)return 0;let n=t*e.width-.5,i=r*e.height-.5,a=Math.floor(n),s=Math.floor(i),o=ZF(a,e.width-1),l=ZF(s,e.height-1),c=ZF(a+1,e.width-1),u=ZF(s+1,e.height-1),d=n-Math.floor(n),h=i-Math.floor(i);return((e.data[l*e.width+o]*(1-d)+e.data[l*e.width+c]*d)*(1-h)+(e.data[u*e.width+o]*(1-d)+e.data[u*e.width+c]*d)*h)/255}(i,(a.x+1)*.5,(1-a.y)*.5);return(r=ZF((s-.4)/.29999999999999993,1))*r*(3-2*r)>.001},[e]);return{isPointerOnSurface:(0,rx.useCallback)(e=>{let t=g?ZT(e,g):null;return null!==t&&y.includes(t)},[y,g]),activeMaskTextureUniform:l,isPointVisible:T,failure:C,handleDrag:B,handleDragEnd:k,handleDragStart:I,planeGeometries:w,readiness:x,resourcePose:v,setPlaneRef:E}}({camera:c,invalidate:u,pointer:h,raycaster:d,roomId:`${a.id}:${r?.generation??0}`,scene:p,surfaces:Wx(t)});!function(e,t,r){let{gl:n}=IY(),{setRotation:i,setIsDragging:a}=qr();(0,rx.useEffect)(()=>{if(!e)return;let r=n.domElement,s=null,o=e=>{e.preventDefault(),e.stopImmediatePropagation()},l=()=>{let e=s;s=null,e&&r.hasPointerCapture(e.id)&&r.releasePointerCapture(e.id),e&&a(!1)},c=e=>{if(s)return void o(e);if(!e.isPrimary||0!==e.button)return;let n=r.getBoundingClientRect();t(new gZ((e.clientX-n.left)/n.width*2-1,1-(e.clientY-n.top)/n.height*2))&&(o(e),s={id:e.pointerId,startX:e.clientX,lastX:e.clientX,rotating:!1},r.setPointerCapture(e.pointerId),a(!0))},u=e=>{if(!s||s.id!==e.pointerId||(o(e),!s.rotating&&5>Math.abs(e.clientX-s.startX)))return;s.rotating=!0;let t=e.clientX-s.lastX;s.lastX=e.clientX,i(e=>e+.5*t)},d=e=>{s?.id===e.pointerId&&(o(e),l())};return r.addEventListener("pointerdown",c,!0),r.addEventListener("pointermove",u,!0),r.addEventListener("pointerup",d,!0),r.addEventListener("pointercancel",d,!0),r.addEventListener("lostpointercapture",d,!0),window.addEventListener("blur",l),()=>{r.removeEventListener("pointerdown",c,!0),r.removeEventListener("pointermove",u,!0),r.removeEventListener("pointerup",d,!0),r.removeEventListener("pointercancel",d,!0),r.removeEventListener("lostpointercapture",d,!0),window.removeEventListener("blur",l),l()}},[e,n,t,r,a,i])}("rotate-on-floor"===Ww[t].manipulation,g.isPointerOnSurface,a.id);let m=(0,rx.useMemo)(()=>new gZ(1,1),[]),v=(0,rx.useMemo)(()=>(function(e,t,r=128){let n=ZW(t),i=function(e,t,r=128){let{width:n,height:i}=t,a=n*i,s=Number.isFinite(r)&&r>0?r:128,o=new Uint8Array(a),l=new Float64Array(a);for(let r=0;r<i;r++)for(let a=0;a<n;a++){let c=r*n+a,u=Math.min(e.width-1,Math.floor((a+.5)*e.width/n)),d=Math.min(e.height-1,Math.floor((r+.5)*e.height/i));o[c]=e.data[(d*e.width+u)*4]??0,l[c]=(t.data[4*c]??s)/(2*s)}let c=l.slice();function u(e,t){let r=Math.ceil(3*t),s=Array.from({length:r+1},(e,r)=>Math.exp(-r*r/(2*t*t))),l=e;for(let e of[!0,!1]){let t=new Float64Array(a);for(let a=0;a<i;a++)for(let c=0;c<n;c++){let u=a*n+c,d=0,h=0;for(let t=-r;t<=r;t++){let r=e?c+t:c,p=e?a:a+t;if(r<0||r>=n||p<0||p>=i)continue;let f=p*n+r;if(o[u]!==o[f])continue;let A=s[Math.abs(t)];d+=l[f]*A,h+=A}t[u]=d/h}l=t}return l}for(let e=0;e<4;e++){let t=new Float64Array(a),r=new Float64Array(a);for(let e=0;e<a;e++)e%n<n-1&&o[e]===o[e+1]&&(t[e]=c[e+1]-c[e]),e<a-n&&o[e]===o[e+n]&&(r[e]=c[e+n]-c[e]);let i=Math.max(.5,1/2**e),s=u(t,i),d=u(r,i);for(let e=0;e<a;e++)s[e]=1/(Math.abs(s[e])+.001),d[e]=1/(Math.abs(d[e])+.001);let h=u(s,i),p=u(d,i),f=new Float64Array(a).fill(1);for(let e=0;e<a;e++)h[e]=e%n<n-1&&o[e]&&o[e]===o[e+1]?.004*h[e]/(Math.abs(t[e])+.02):0,p[e]=e<a-n&&o[e]&&o[e]===o[e+n]?.004*p[e]/(Math.abs(r[e])+.02):0,f[e]+=h[e]+p[e],h[e]&&(f[e+1]+=h[e]),p[e]&&(f[e+n]+=p[e]);let A=(e,t)=>{for(let r=0;r<a;r++){let i=f[r]*e[r];r%n&&(i-=h[r-1]*e[r-1]),r%n<n-1&&(i-=h[r]*e[r+1]),r>=n&&(i-=p[r-n]*e[r-n]),r<a-n&&(i-=p[r]*e[r+n]),t[r]=i}},g=new Float64Array(a),m=new Float64Array(a),v=new Float64Array(a);A(c,v);let b=0;for(let e=0;e<a;e++)g[e]=l[e]-v[e],m[e]=g[e]/f[e],b+=g[e]*m[e];for(let e=0;e<200&&b>1e-12;e++){A(m,v);let e=0;for(let t=0;t<a;t++)e+=m[t]*v[t];if(e<=0)break;let t=b/e,r=0;for(let e=0;e<a;e++)c[e]+=t*m[e],g[e]-=t*v[e],r+=g[e]*g[e]/f[e];let n=r/b;for(let e=0;e<a;e++)m[e]=g[e]/f[e]+n*m[e];b=r}}let d=new Float32Array(4*a);for(let e=0;e<a;e++)d.set([2*c[e],0,0,1],4*e);return d}(ZW(e),n,r),a=new Uint8Array(i.length);for(let e=0;e<i.length;e+=4)a.set([Math.max(0,Math.min(255,Math.round(128*i[e]))),0,0,255],e);let s=new bU(a,n.width,n.height,1023);return s.minFilter=1006,s.magFilter=1006,s.generateMipmaps=!1,s.needsUpdate=!0,s})(f,A,p.shading?.neutral),[f,A,p.shading?.neutral]);(0,rx.useLayoutEffect)(()=>()=>v.dispose(),[v]);let b=(0,rx.useMemo)(()=>({lightingTexture:v,viewport:m,activeMaskTextureUniform:g.activeMaskTextureUniform,maxRoomGain:1.1}),[g.activeMaskTextureUniform,v,m]);(0,rx.useLayoutEffect)(()=>{c instanceof x9&&(c.fov=p.camera.fovYDeg),c.position.set(0,0,0),c.up.set(0,0,1),c.lookAt(0,1,0),c.updateProjectionMatrix(),u()},[c,u,p.camera.fovYDeg]),(0,rx.useLayoutEffect)(()=>{o.getDrawingBufferSize(m),m.set(Math.max(1,m.x),Math.max(1,m.y))},[o,l.height,l.width,m]);let{artifactsReady:y,placementReady:w,prepareReady:x}=g.readiness,C=g.failure;return(0,rx.useEffect)(()=>{s({artifactsReady:y,placementReady:w,prepareReady:x})},[y,s,w,x]),(0,rx.useEffect)(()=>{C&&(!function({failure:e,planes:t,resourceType:r}){let n,i;(i=(n=t.map(e=>e.kind)).filter((e,t)=>n.indexOf(e)===t)).length>0&&i.join(", ")}({failure:C,planes:p.planes,resourceType:t}),n("room-load-failed"))},[C,p.planes,n,t]),(0,rE.jsxs)(rE.Fragment,{children:[g.resourcePose&&(0,rE.jsx)(i,{position:g.resourcePose.position,quaternion:g.resourcePose.quaternion,materialPatch:b,isPointVisible:g.isPointVisible,onDrag:g.handleDrag,onDragEnd:g.handleDragEnd,onDragStart:g.handleDragStart}),p.planes.map(e=>(0,rE.jsx)($s,{plane:e,geometry:g.planeGeometries.get(e.id),setPlaneRef:g.setPlaneRef},e.id)),(0,rE.jsx)(Z_,{onError:()=>n("room-load-failed"),children:(0,rE.jsx)($a,{})})]})}let $l=["room-viewer","layout-config"],$c=[Math.PI/2,0,0];function $u(){var e;let t=od({queryKey:$l,queryFn:()=>V1(),staleTime:1/0},s2,void 0);if(t.isPending)return null;let r=(e=t.data,e?.internal?.links?.find(e=>"hdr_neutral"===e.type)?.url?.trim()||void 0);return(0,rE.jsx)(R_,{files:r?[r]:void 0,preset:r?void 0:"warehouse",environmentRotation:$c,environmentIntensity:r?.5:.9})}function $d(){return(0,rE.jsx)(R_,{files:["https://cdn.neurodyn.ai/assets/hdr/neutral.hdr"],environmentRotation:$c})}function $h({lighting:e}){return"remote-neutral-hdr"===e?(0,rE.jsx)($u,{}):(0,rE.jsx)($d,{})}function $p({ref:e,target:t}){let{camera:r,gl:n}=IY();return(0,rx.useImperativeHandle)(e,()=>({getScreenPoint(){if(!t.current)return null;let e=t.current.getWorldPosition(new g0).project(r),i=n.domElement.getBoundingClientRect();return{x:i.left+(e.x+1)*i.width/2,y:i.top+(1-e.y)*i.height/2}}}),[r,n,t]),null}let $f={position:[0,0,0],up:[0,0,1],near:.01,far:100};function $A({className:e,ref:t,captureRef:r,introductionTarget:n,focusRef:i,onSizeChange:a,...s}){let{type:o}=W6(),{glbUrl:l}=qt(),c=ZB(),u=c?.isBaseModelReady??!0,{materialSource:d}=qU(o),{room:h}=qe(),{patchSceneLoad:p}=qr(),{active:f}=RF(),A=Zk((0,rx.useMemo)(()=>h.scene??qk(),[h.scene])),g=(0,rx.useRef)(null),m=(0,rx.useRef)(!1),v=(0,rx.useCallback)(e=>{(g.current=e,"function"==typeof t)?t(e):t&&(t.current=e)},[t]),b=Kt("(max-width: 639px)"),{width:y,height:w}=function(e){let t,{ref:r,box:n="content-box"}=e,[{width:i,height:a},s]=rx.useState(Kr),o=(t=rx.useRef(!1),rx.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),rx.useCallback(()=>t.current,[])),l=rx.useRef({...Kr}),c=rx.useRef(void 0);return c.current=e.onResize,rx.useEffect(()=>{if(!r.current||"u"<typeof window||!("ResizeObserver"in window))return;let e=new ResizeObserver(([e])=>{let t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=Kn(e,t,"inlineSize"),i=Kn(e,t,"blockSize");if(l.current.width!==r||l.current.height!==i){let e={width:r,height:i};l.current.width=r,l.current.height=i,c.current?c.current(e):o()&&s(e)}});return e.observe(r.current,{box:n}),()=>{e.disconnect()}},[n,r,o]),{width:i,height:a}}({ref:g}),x=(0,rx.useMemo)(()=>{if(!y||!w||!A)return null;let e=y,t=w;return b?e=(t=w)*A:y/w>A?e=w*A:t=y/A,{width:e,height:t}},[y,w,A,b]);return(0,rx.useLayoutEffect)(()=>{x&&a?.(x.width,x.height)},[x,a]),(0,rx.useEffect)(()=>{if(!x||m.current)return;m.current=!0;let e=window.setTimeout(()=>{window.dispatchEvent(new Event("resize"))},250);return()=>{window.clearTimeout(e)}},[x]),(0,rx.useEffect)(()=>{p({layoutReady:null!==x})},[p,x]),(0,rx.useEffect)(()=>{"object-glb"===d&&p({materialReady:!!l&&u})},[l,d,u,p]),(0,rx.useEffect)(()=>{p({assetsReady:!f})},[f,p]),(0,rE.jsx)("div",{ref:v,className:WC("size-full flex items-center justify-center sm:pt-21 sm:pb-12",e),...s,children:x&&(0,rE.jsx)(Rz,{className:"touch-none bg-transparent",frameloop:"demand",camera:$f,gl:{toneMapping:4,toneMappingExposure:1.2,alpha:!0,preserveDrawingBuffer:!0},style:{width:`${x.width}px`,height:`${x.height}px`},children:(0,rE.jsxs)(rx.Suspense,{fallback:null,children:[(0,rE.jsx)(ZP,{ref:r}),(0,rE.jsx)($h,{lighting:Ww[o].lighting}),(0,rE.jsx)($o,{}),n&&i&&(0,rE.jsx)($p,{ref:i,target:n})]})})})}function $g({captureRef:e,introduction:t,className:r,canvasWrapperClassName:n,controls:i,...a}){let s,o,l,c,{isDragging:u}=qr(),d=(0,rx.useRef)(null),h=(0,rx.useRef)(null),p=(0,rx.useRef)(null),f=(s=(0,rx.useRef)(null),o=(0,rx.useRef)(!1),l=(0,rx.useCallback)(()=>{null!==s.current&&cancelAnimationFrame(s.current),s.current=null},[]),c=(0,rx.useCallback)(()=>{t&&(l(),t.onCancel())},[t,l]),(0,rx.useEffect)(()=>{if(!t){o.current=!1;return}if(!t.ready){o.current&&t.onCancel();return}return s.current=requestAnimationFrame(()=>{let e=d.current,r=p.current?.getScreenPoint(),n=e?.instance.wrapperComponent,i=e?.instance.contentComponent;if(!e||!r||!n||!i)return void t.onCancel();let{scale:a,positionX:l,positionY:c}=e.instance.transformState,u=n.getBoundingClientRect(),h=Math.min(e.instance.setup.maxScale,1.28*a),f=(e,t,r)=>r<t?(t-r)/2:Math.max(t-r,Math.min(0,e)),A=f(u.width/2-(r.x-u.left-l)/a*h,u.width,i.offsetWidth*h),g=f(u.height/2-(r.y-u.top-c)/a*h,u.height,i.offsetHeight*h);o.current=!0;let m=window.matchMedia("(prefers-reduced-motion: reduce)").matches,v=performance.now(),b=r=>{let n=m?1:Math.min(1,(r-v)/700),i=(1-Math.cos(Math.PI*n))/2;e.setTransform(l+(A-l)*i,c+(g-c)*i,a+(h-a)*i,0),n<1?s.current=requestAnimationFrame(b):(s.current=null,t.onComplete())};b(v)}),()=>{l()}},[p,t,l,d]),c),A=Kt("(max-width: 639px)"),g=(0,rx.useRef)(!!t);g.current=!!t;let m=(0,rx.useCallback)(()=>{A&&d.current?.centerView(void 0,g.current?0:void 0)},[A]);return(0,rE.jsxs)("div",{className:WC("relative flex items-center justify-center overflow-hidden",r),...a,onPointerDownCapture:e=>{f(),a.onPointerDownCapture?.(e)},onTouchStartCapture:e=>{f(),a.onTouchStartCapture?.(e)},onWheelCapture:e=>{f(),a.onWheelCapture?.(e)},children:[(0,rE.jsx)(gd,{ref:d,disabled:u,children:(0,rE.jsx)(gh,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,rE.jsx)($A,{captureRef:e??h,introductionTarget:t?.target,focusRef:p,className:n,onSizeChange:m})})}),i]})}function $m({...e}){return(0,rE.jsx)(hK,{"data-slot":"popover",...e})}function $v({...e}){return(0,rE.jsx)(hX,{"data-slot":"popover-trigger",...e})}function $b({className:e,align:t="center",sideOffset:r=4,portalContainer:n,...i}){return(0,rE.jsx)(h1,{container:n,children:(0,rE.jsx)(h3,{"data-slot":"popover-content",align:t,sideOffset:r,className:WC("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}function $y({className:e,defaultValue:t,value:r,min:n=0,max:i=100,variant:a="default","aria-label":s,"aria-labelledby":o,...l}){let c=rx.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n],[r,t,n]);return(0,rE.jsxs)(pd,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:i,"data-variant":a,"aria-label":s,"aria-labelledby":o,className:WC("relative flex w-full touch-none cursor-pointer items-center select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...l,children:[(0,rE.jsx)(pv,{"data-slot":"slider-track",className:WC("relative grow overflow-hidden rounded-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5","editor"===a?"bg-border-light data-[orientation=horizontal]:h-0.5":"bg-muted data-[orientation=horizontal]:h-1.5"),children:(0,rE.jsx)(py,{"data-slot":"slider-range",className:WC("absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full","editor"===a?"bg-background-blue":"bg-primary")})}),Array.from({length:c.length},(e,t)=>(0,rE.jsx)(px,{"data-slot":"slider-thumb","aria-label":s,"aria-labelledby":o,className:WC("ring-ring/50 block shrink-0 rounded-full border bg-white transition-[color,box-shadow] focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50","editor"===a?"size-3 border-background-blue shadow-none hover:ring-2 focus-visible:ring-2":"size-4 border-primary shadow-sm hover:ring-4 focus-visible:ring-4")},t))]})}let $w=/oklch\(([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\)/;function $x(e,t){let r=e.match($w);return r?{l:Number.parseFloat(r[1]),c:Number.parseFloat(r[2]),h:Number.parseFloat(r[3])}:{l:t[0],c:t[1],h:t[2]}}function $C({data:e,foreground:t,background:r,robustness:n="M",className:i,...a}){let[s,o]=(0,rx.useState)(null);return((0,rx.useEffect)(()=>{(async()=>{try{let i=getComputedStyle(document.documentElement),a=t??i.getPropertyValue("--foreground"),s=r??i.getPropertyValue("--background"),l=$x(a,[.21,.006,285.885]),c=$x(s,[.985,0,0]),u=await Lr.toString(e,{type:"svg",color:{dark:Le(Lt({mode:"oklch",...l})),light:Le(Lt({mode:"oklch",...c}))},width:200,errorCorrectionLevel:n,margin:0});o(u)}catch(e){console.error(e)}})()},[e,t,r,n]),s)?(0,rE.jsx)("div",{className:WC("size-full","[&_svg]:size-full",i),dangerouslySetInnerHTML:{__html:s},...a}):null}let $E=new F0,$S=$E.getDevice(),$M=$E.getOS(),$I="iOS"===$M.name,$B="Android"===$M.name,$k="mobile"===$S.type;function $T(e,t){return!!e&&(!$B||!$k)&&(!$B||"appclip"!==e.ar)&&("floor"!==e.destination||!!t)}function $R({className:e,buttonClassName:t,buttonLeadingIcon:r,buttonLabel:n,buttonSize:i,buttonVariant:a="contrast",...s}){let{type:o,width:l,height:c,name:u}=W6(),{handoff:d}=Ww[o],{src:h,tinuuid:p,widgetSession:f}=qt(),{containerRef:A,resourceRef:g}=qr(),{t:m,i18n:v}=sf(),b=function(){let{i18n:e}=sf();return"ru"===(e.resolvedLanguage??e.language)?"arizo":"vizbl"}(),[y,w]=(0,rx.useState)(""),[x,C]=(0,rx.useState)(""),[E,S]=(0,rx.useState)(()=>f?.token),[M,I]=(0,rx.useState)(!1),[B,k]=(0,rx.useState)(!1),T=(0,rx.useRef)(null),R=v.resolvedLanguage??v.language,D=qI[b],P=(0,rx.useMemo)(()=>(function({height:e,language:t,name:r,src:n,tenantConfig:i,tinuuid:a,handoff:s,type:o,width:l,widgetSessionToken:c,pageUrl:u}){if(!s)return null;if("floor"===s.destination&&a){let e=new URL(i.ROOM_URL);return e.searchParams.set("type",o),e.searchParams.set("tinuuid",a),e.searchParams.set("name",r),e.searchParams.set("language",t),c&&e.searchParams.set("widgetSessionToken",c),e.toString()}let d=new URL(i.POSTER_URL);return n&&d.searchParams.set("texture",function(e,t){if(!t||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//"))return e;try{return new URL(e,t).href}catch{return e}}(n,u)),d.searchParams.set("texture_width",(100*l).toString()),d.searchParams.set("texture_height",(100*e).toString()),c&&d.searchParams.set("widgetSessionToken",c),d.toString()})({height:c,language:R,name:u,src:h,tenantConfig:D,tinuuid:p,handoff:d,type:o,width:l,widgetSessionToken:E,pageUrl:"u"<typeof window?void 0:window.location.href}),[h,p,d,o,l,c,u,R,D,E]),_=(0,rx.useMemo)(()=>{if(!p)return null;let e=new URL("https://appclip.apple.com/id");return e.searchParams.set("p","com.us.vizbl.Clip"),e.searchParams.set("tinuuid",p),e.toString()},[p]);async function L(){S(await f?.getTokenForRequest().catch(()=>f.token))}let N=async()=>{if(d?.ar==="appclip"){if(!p)return;if($I&&_){Wd(f,"appclip"),window.location.assign(_);return}await L(),I(!0);return}let e=T.current,t=g.current;if(e&&t)if(e.canActivateAR)try{k(!0);let e=t.clone(!0);if(e.position.set(0,0,0),e.quaternion.identity(),e.updateMatrix(),e.updateMatrixWorld(!0),$I){e.rotation.set(-Math.PI/2,0,0),e.updateMatrix(),e.updateMatrixWorld(!0);let t=new Nh,r=await t.parseAsync(e,{ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"vertical"}}}),n=new File([r],"scene.usdz",{type:"model/vnd.usdz+zip"});w(URL.createObjectURL(n))}else{let t=new Li,r=await t.parseAsync(e,{binary:!0}),n=new File([r],"scene.glb",{type:"model/gltf-binary"});C(URL.createObjectURL(n))}}finally{k(!1)}else await L(),I(!0)};if((0,rx.useEffect)(()=>((""!==y||""!==x)&&T.current?.activateAR(),()=>{""!==y&&URL.revokeObjectURL(y),""!==x&&URL.revokeObjectURL(x)}),[y,x]),!$T(d,p))return null;let F="appclip"===d.ar;return(0,rE.jsxs)("div",{className:WC(e),...s,children:[(0,rE.jsxs)(WS,{variant:a,size:i,disabled:B,onClick:N,className:t,children:[r,n??m("ar.viewInPlace")]}),(0,rE.jsx)(WM,{open:M,onOpenChange:I,children:(0,rE.jsxs)(WT,{className:"gap-6 sm:max-w-120",showCloseButton:!1,portalContainer:A,children:[(0,rE.jsx)("div",{className:"flex items-center justify-center p-10 bg-constant-white rounded-2xl",children:(0,rE.jsx)($C,{className:"size-48",robustness:"H",data:P??""})}),F?(0,rE.jsxs)("div",{className:"grid gap-2 text-center",children:[(0,rE.jsx)("p",{className:"text-lg text-text-sub font-medium",children:m("ar.appClipScanTitle")}),(0,rE.jsx)("p",{className:"text-sm text-text-light",children:m("ar.appClipRequirement")})]}):(0,rE.jsx)("p",{className:"text-lg text-center text-text-sub font-medium",children:m("ar.scanQrCode")}),(0,rE.jsxs)("p",{className:"text-xs text-center text-text-light",children:[!F&&(0,rE.jsxs)(rE.Fragment,{children:[m("ar.deviceRequirementsDisclaimer"),(0,rE.jsx)("br",{})]}),(0,rE.jsx)("a",{href:D.TERMS_URL,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 transition-colors duration-300 hover:text-text-dark",style:{textDecoration:"underline",textUnderlineOffset:"2px"},children:m("legal.termsOfUse")})," ",m("legal.conjunction")," ",(0,rE.jsx)("a",{href:D.PRIVACY_URL,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 transition-colors duration-300 hover:text-text-dark",style:{textDecoration:"underline",textUnderlineOffset:"2px"},children:m("legal.privacyPolicy")})]}),(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"contrast",size:"lg",children:m("close")})})]})}),(0,rE.jsx)("model-viewer",{ref:T,className:"fixed w-px h-px opacity-0 pointer-events-none",src:x,iosSrc:y,reveal:"manual",ar:!0,cameraControls:!0,arPlacement:"wall",arModes:"webxr",arScale:"fixed",shadowIntensity:1,interactionPromptThreshold:100})]})}async function $D(e){await navigator.clipboard.writeText(e)}function $P({captureRef:e,fallbackToClipboard:t=!1,fileName:r="room-scene.png",shareMessage:n}){let[i,a]=(0,rx.useState)(!1),[s,o]=(0,rx.useState)(!1),l=(0,rx.useMemo)(()=>"u">typeof navigator&&"function"==typeof navigator.share||t&&"u">typeof navigator&&"function"==typeof navigator.clipboard?.writeText,[t]),c=(0,rx.useCallback)(async()=>{if(!l)return;let i="u">typeof navigator&&"function"==typeof navigator.share,s=window.location.href,o=`${n}
|
|
7631
|
+
${s}`;a(!0);try{if(!i&&t)return void await $D(o);let n=e.current;if(n)try{let e=await n.capture(),t=new File([e],r,{type:e.type||"image/png"});if(navigator.canShare?.({files:[t]}))return void await navigator.share({text:o,files:[t]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:o,url:s})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{a(!1)}},[l,e,t,r,n]);return{canShare:l,download:(0,rx.useCallback)(async()=>{let t=e.current;if(t){o(!0);try{var n;let e,i;n=await t.capture(),e=URL.createObjectURL(n),(i=document.createElement("a")).href=e,i.download=r,document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(e)}catch(e){console.error("Failed to download scene screenshot",e)}finally{o(!1)}}},[e,r]),isDownloading:s,isSharing:i,share:c}}function $_({captureRef:e}){let{type:t}=W6(),{containerRef:r,angle:n,rotation:i,setAngle:a,setRotation:s}=qr(),{t:o}=sf(),l=Kt("(max-width: 639px)"),{canShare:c,isSharing:u,share:d}=$P({captureRef:e,shareMessage:o(`shareMessage.${t}`)});return(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)($R,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),(0,rE.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[(0,rE.jsxs)($m,{children:[(0,rE.jsx)($v,{asChild:!0,children:(0,rE.jsxs)(WS,{variant:"contrast",size:l?"icon":"default",children:[(0,rE.jsx)(WW,{className:"size-5"}),(0,rE.jsx)("span",{className:"sr-only sm:not-sr-only",children:o("scene.tunePosition")})]})}),(0,rE.jsx)($b,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,rE.jsxs)(qa,{children:[(0,rE.jsxs)(qo,{orientation:"horizontal",children:[(0,rE.jsx)(qc,{children:o("scene.rotation")}),(0,rE.jsx)($y,{value:[i],onValueChange:([e])=>s(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":o("scene.rotation")})]}),(0,rE.jsxs)(qo,{orientation:"horizontal",children:[(0,rE.jsx)(qc,{children:o("scene.angle")}),(0,rE.jsx)($y,{value:[n],onValueChange:([e])=>a(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":o("scene.angle")})]})]})})]}),(0,rE.jsxs)(WS,{variant:"contrast",size:l?"icon":"default",disabled:!c||u,onClick:d,children:[(0,rE.jsx)(WJ,{className:"size-5"}),(0,rE.jsx)("span",{className:"sr-only sm:not-sr-only",children:o("scene.share")})]}),l&&(0,rE.jsxs)($m,{children:[(0,rE.jsx)($v,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"contrast",size:"icon",children:(0,rE.jsx)(Wq,{})})}),(0,rE.jsxs)($b,{className:"grid gap-5",portalContainer:r,children:[(0,rE.jsx)(qG,{}),(0,rE.jsx)(q0,{})]})]})]})]})}function $L({variant:e,open:t,portalContainer:r,showDialogCloseButton:n=!1,onOpenChange:i,onTryAgain:a,onCancel:s}){let{t:o}=sf(),l=e?o("custom-interior-processing"===e?"floor.error.processingBody":"viewer-load-failed"===e?"floor.error.loadBody":"artwork-load-failed"===e||"room-load-failed"===e?`loadError.${e}`:`accessError.${e}`):"";return(0,rE.jsx)(WM,{open:t,onOpenChange:i,children:(0,rE.jsxs)(WT,{portalContainer:r,showCloseButton:!1,className:"w-full max-w-85 gap-4 rounded-2xl p-6 text-center sm:max-w-85 sm:p-6",onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsxs)("div",{className:"grid gap-1",children:[(0,rE.jsx)(WP,{children:o("floor.error.title")}),(0,rE.jsx)(W_,{className:"typo-base-14 font-medium text-text-base",children:l})]}),(0,rE.jsxs)("div",{className:"grid gap-2",children:[a&&(0,rE.jsxs)(WS,{variant:"contrast",onClick:a,children:[(0,rE.jsx)(Wz,{"aria-hidden":"true"}),o("floor.error.tryAgain")]}),s&&(0,rE.jsx)(WS,{variant:"outline",onClick:s,children:o("floor.error.cancel")}),n&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"outline",children:o("close")})})]})]})})}function $N({rooms:e,customRooms:t,selectedRoomId:r,isInvalidFile:n,uploadRetryRequestId:i=0,showCloseButton:a=!1,onSelectRoom:s,onUploadFile:o}){let l,{t:c}=sf(),u=(0,rx.useId)(),d=(0,rx.useRef)(null);function h(e){return e.map(e=>(0,rE.jsxs)("button",{type:"button",className:"group relative aspect-[4/3] overflow-hidden rounded-2xl bg-background-base text-left transition focus-visible:ring-2 focus-visible:ring-icons-normal focus-visible:outline-hidden","aria-pressed":e.id===r,onClick:()=>s(e.id),children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(e),alt:"",decoding:"async",className:"size-full scale-[1.02] transform-gpu object-cover transition duration-200 group-hover:scale-105"}),(0,rE.jsx)("span",{className:"typo-base-12 absolute inset-x-0 bottom-0 truncate bg-linear-to-t from-black/45 via-black/10 to-transparent px-3 py-2 text-constant-white",children:c(`rooms.${e.id}`,{defaultValue:e.name})})]},e.id))}return(0,rx.useEffect)(()=>{i>0&&d.current?.click()},[i]),(0,rE.jsxs)("section",{"aria-labelledby":"floor-interior-selection-title",className:"relative mx-auto grid h-auto min-h-0 max-h-[calc(100svh-8px)] w-full max-w-151 grid-rows-[auto_auto_minmax(0,1fr)_auto] gap-4 overflow-hidden rounded-t-2xl rounded-b-none bg-background-containers p-4 shadow-[var(--shadow-login)] sm:my-4 sm:max-h-[calc(100svh-32px)] sm:rounded-2xl sm:p-6","data-testid":"floor-interior-selection-panel","data-room-selection-panel":!0,children:[a&&(l=(0,rE.jsx)(WS,{type:"button",variant:"outline",size:"icon",className:"absolute top-4 right-4 sm:top-6 sm:right-6","aria-label":c("close"),"data-testid":"floor-interior-selection-icon-close",children:(0,rE.jsx)(WO,{})}),(0,rE.jsx)(WB,{asChild:!0,children:l})),(0,rE.jsx)("h2",{id:"floor-interior-selection-title",className:"typo-base-16 font-medium sm:typo-base-18 text-text-dark",children:c("floor.interiorSelection.title")}),(0,rE.jsxs)("div",{className:"grid gap-2","data-testid":"floor-interior-selection-upload",children:[(0,rE.jsxs)("label",{htmlFor:u,className:"flex min-h-15 cursor-pointer items-center justify-center gap-2 rounded-xl border border-dashed border-background-blue bg-background-blue-transparent px-4 text-center typo-button-normal text-background-blue opacity-80 transition hover:bg-background-blue-transparent/80",onDragOver:e=>e.preventDefault(),onDrop:function(e){e.preventDefault();let t=e.dataTransfer.files[0];t&&o(t)},children:[(0,rE.jsx)(WN,{className:"size-5 text-background-blue"}),c("floor.interiorSelection.uploadPhoto"),(0,rE.jsx)("input",{ref:d,id:u,type:"file",accept:"image/*",className:"sr-only",onChange:function(e){let t=e.target.files?.[0];e.target.value="",t&&o(t)}})]}),n&&(0,rE.jsx)("p",{className:"typo-base-12 font-medium text-destructive",children:c("floor.interiorSelection.invalidFile")})]}),(0,rE.jsx)("div",{className:"grid min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain pr-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden","data-testid":"floor-interior-selection-scroll-content",children:(0,rE.jsxs)("div",{className:"grid min-h-max gap-4",children:[t.length>0&&(0,rE.jsxs)("div",{className:"grid gap-3",children:[(0,rE.jsx)("h3",{className:"typo-base-16 font-medium text-text-light",children:c("floor.interiorSelection.customTitle")}),(0,rE.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3","data-testid":"floor-custom-interior-selection-grid",children:h(t)})]}),(0,rE.jsxs)("div",{className:"grid gap-3",children:[(0,rE.jsx)("h3",{className:"typo-base-16 font-medium text-text-light",children:c("floor.interiorSelection.presetsTitle")}),(0,rE.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3","data-testid":"floor-preset-interior-selection-grid",children:h(e)})]})]})}),a&&(0,rE.jsx)(WD,{className:"-mt-2 shrink-0 p-0 sm:mt-0",children:(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{variant:"outline",className:"w-full",children:c("close")})})})]})}function $F(e){return(0,rE.jsx)("div",{className:"absolute inset-0 z-20 grid items-end p-0 sm:items-center sm:p-4","data-testid":"floor-interior-selection-overlay",children:(0,rE.jsx)($N,{...e})})}function $O({open:e,showCloseButton:t=!0,portalContainer:r,onOpenChange:n,...i}){let{t:a}=sf();return(0,rE.jsx)(WM,{open:e,onOpenChange:n,children:(0,rE.jsxs)(WT,{contentInsideOverlay:!0,portalContainer:r,showCloseButton:!1,"data-testid":"floor-interior-selection-overlay",className:"top-auto bottom-0 grid max-h-[calc(100svh-8px)] w-[calc(100%-16px)] min-w-0 max-w-none translate-y-0 overflow-hidden rounded-t-2xl rounded-b-none border-none bg-transparent p-0 shadow-none sm:top-[50%] sm:bottom-auto sm:w-full sm:max-w-none sm:translate-y-[-50%] sm:rounded-none sm:p-4",children:[(0,rE.jsx)(WP,{className:"sr-only",children:a("floor.interiorSelection.title")}),(0,rE.jsx)(W_,{className:"sr-only"}),(0,rE.jsx)($N,{...i,showCloseButton:t})]})})}let $Q="data-material-selection-action",$U="data-material-selection-panel";function $z(){let{t:e}=sf(),{type:t}=W6();return e(`floor.materialSelection.${Ww[t].catalogTitle}`)}function $j({className:e,gridClassName:t,titleClassName:r,onOpenChange:n,...i}){let a=$z(),s=(0,rx.useRef)(null),{fetchNextMaterialsPage:o,hasNextPage:l,isFetchingNextPage:c,isLoading:u,materialItems:d,selectMaterial:h,selectedMaterialId:p}=function({includeEmbeddedObject:e=!1}={}){var t;let{material:r,tinuuid:n,embeddedObject:i,selectedObject:a,setMaterial:s,setTinuuid:o,apiKey:l,baseURL:c,language:u,source:d,widgetSession:h,setAccessError:p,setLoadError:f}=qt(),{type:A,name:g}=W6(),m=i?.owner?.uuid,{data:v,error:b,isFetchingNextPage:y,fetchNextPage:w,hasNextPage:x,isLoading:C}=od({queryKey:["room-viewer","public-objects",{apiKey:(t={apiKey:l,baseURL:c,language:u,source:d,resourceType:A}).apiKey??null,language:t.language??null,ownerUuid:m??null,resourceType:t.resourceType??null,source:t.source}],enabled:!!m,queryFn:({pageParam:e,signal:t})=>{if(!m)throw Error("Owner uuid is required.");return Wm(m,e,{apiKey:l,baseURL:c,language:u,signal:t,source:d,widgetSession:h,resourceType:A})},initialPageParam:1,getNextPageParam:(e,t,r)=>void 0!==e.pages_count?r<e.pages_count?r+1:void 0:e.objs?.length?r+1:void 0,getPreviousPageParam:(e,t,r)=>r>1?r-1:void 0},ou,void 0),{requiresMaterialModel:E}=qU(A),{getCollapseKey:S}=qO(A),{catalogsEveryMaterial:M}=qF[Ww[A].materialRole],{composition:I,productNameSource:B}=Ww[A],k=(0,rx.useMemo)(()=>v?.pages.flatMap(e=>e.objs??[])??[],[v]),T=(0,rx.useMemo)(()=>"material"===B?[]:k.filter(e=>e.tinuuid&&(!e.kit?.uuid||!e.kit.name?.trim())&&(!E||e.materials?.[0]?.native?.glbUrl)),[k,B,E]),R=oc({queries:T.map(e=>({queryKey:Wf(e.tinuuid,{apiKey:l,baseURL:c,language:u,source:d,resourceType:A}),queryFn:({signal:t})=>Wg(e.tinuuid,{apiKey:l,baseURL:c,language:u,signal:t,source:d,widgetSession:h,resourceType:A})}))}),D=k.flatMap(e=>{let t=R[T.indexOf(e)];return t?.isPending||t?.isError?[]:[{...e,kit:t?.data?.kit?{...e.kit,...t.data.kit}:e.kit}]}),P=(0,rx.useMemo)(()=>{let t={requiresMaterialModel:E,getCollapseKey:S};if(e)return qP([...i?.tinuuid&&i.materials?.[0]?[i]:[],...D],null,t);return qP(D,i,t)},[i,D,S,e,E]),_=(0,rx.useMemo)(()=>P.flatMap(e=>{if(!e.tinuuid)return[];let t="color-design"===I&&e.kit?.uuid,r=M&&!t?e.materials:e.materials?.slice(0,1);return r?.map(t=>{let r=qj(t);return r&&e.tinuuid?{materialId:r,productName:qz(A,e,t,g),material:t,tinuuid:e.tinuuid}:null}).filter(e=>null!==e)??[]}),[M,I,P,A,g]),L="color-design"===I&&a?.tinuuid===n&&a?.kit?.uuid?P.find(e=>S(e)===S(a)):void 0,N=L?.tinuuid!==n&&L?qj(L.materials?.[0]??{}):r?qj(r):"",F=b??R.find(e=>e.error)?.error,O=P.find(e=>e.tinuuid===n),Q=P.find(e=>e.tinuuid&&e.materials?.[0]);(0,rx.useEffect)(()=>{let e=VO(F);e?p(e):F&&f("viewer-load-failed")},[F,p,f]),(0,rx.useEffect)(()=>{v&&0===P.length&&x&&!y&&w()},[v,w,x,y,P.length]),(0,rx.useEffect)(()=>{if(null!==r)return;let e=O??Q,t=e?.materials?.[0];e&&t&&e.tinuuid&&(s(t),o(e.tinuuid))},[Q,O,r,s,o]);let U=(0,rx.useCallback)(()=>{!1===x||y||w()},[w,x,y]),z=(0,rx.useCallback)(e=>{let t=P.find(t=>t.materials?.some(t=>qj(t)===e)),r=t?.materials?.find(t=>qj(t)===e);return!!t&&!!r&&!!t.tinuuid&&(s(r),o(t.tinuuid),!0)},[P,s,o]);return{fetchNextMaterialsPage:U,hasNextPage:x,isFetchingNextPage:y,isLoading:C||R.some(e=>e.isPending),materialItems:_,selectMaterial:z,selectedMaterialId:N}}({includeEmbeddedObject:!0});(0,rx.useEffect)(()=>{let e=s.current;e&&!u&&!c&&l&&0!==d.length&&e.scrollHeight<=e.clientHeight&&o()},[o,l,c,u,d.length]);let f=(0,rx.useCallback)(e=>{let{clientHeight:t,scrollHeight:r,scrollTop:n}=e.currentTarget;n+t>=r-64&&o()},[o]),A=(0,rx.useCallback)(e=>{h(e)&&n(!1)},[n,h]);return(0,rE.jsxs)("div",{...i,className:WC("flex min-h-0 flex-col gap-3 overflow-hidden text-text-dark outline-none",e),"data-testid":"material-selection-panel",onPointerDownCapture:e=>{e.stopPropagation(),i.onPointerDownCapture?.(e)},onMouseDownCapture:e=>{e.stopPropagation(),i.onMouseDownCapture?.(e)},children:[(0,rE.jsx)("h2",{className:WC("typo-base-16 font-medium sm:typo-base-14 sm:font-semibold text-text-dark",r),children:a}),(0,rE.jsx)("div",{"data-testid":"material-selection-grid",ref:s,className:WC("min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain pr-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",t),onScroll:f,children:(0,rE.jsxs)("div",{className:"grid min-h-max grid-cols-3 gap-x-2 gap-y-2","data-testid":"material-selection-grid-items",children:[d.map(({materialId:e,material:t,tinuuid:r,productName:n})=>{let i,a=e===p,s=(i=t.previews?.[0],i?.subRes?.small??i?.url);return(0,rE.jsxs)("button",{type:"button","data-selected":a,"aria-pressed":a,className:"group flex min-w-0 flex-col gap-1 rounded-lg bg-background-containers text-left focus-visible:ring-2 focus-visible:ring-icons-normal focus-visible:outline-hidden",onClick:()=>A(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),A(e))},children:[(0,rE.jsxs)("span",{className:"relative grid aspect-square w-full shrink-0 place-items-center overflow-hidden rounded-lg border border-border p-1 transition group-hover:border-icons-normal",children:[s?(0,rE.jsx)("img",{src:s,alt:"",className:"size-full rounded-md object-cover"}):(0,rE.jsx)(WG,{className:"size-6 text-icons-normal"}),a&&(0,rE.jsx)("span",{className:"absolute top-1 right-1 grid size-6 place-items-center rounded-full bg-icons-blue text-icons-white","data-testid":"material-selection-selected-check",children:(0,rE.jsx)(WF,{className:"size-4"})})]}),(0,rE.jsx)("span",{className:"typo-base-12 line-clamp-3 w-full wrap-anywhere text-text-base",children:n})]},`${r}-${e}`)}),(u||c)&&(0,rE.jsx)("div",{className:"col-span-3 grid h-16 place-items-center",children:(0,rE.jsx)(WZ,{className:"size-6"})})]})})]})}function $G({open:e,portalContainer:t,onOpenChange:r}){let{t:n}=sf(),i=$z();return(0,rE.jsx)(WM,{open:e,onOpenChange:r,children:(0,rE.jsxs)(WT,{contentInsideOverlay:!0,"data-testid":"material-selection-mobile-overlay","data-material-selection-panel":"",className:"top-auto bottom-0 flex max-h-[calc(100svh-8px)] w-[calc(100%-16px)] !max-w-none translate-y-0 flex-col gap-2 overflow-hidden rounded-t-2xl rounded-b-none p-4 sm:hidden",portalContainer:t,showCloseButton:!1,children:[(0,rE.jsx)(WP,{className:"sr-only",children:i}),(0,rE.jsx)(W_,{className:"sr-only"}),(0,rE.jsx)($j,{className:"min-h-0",gridClassName:"max-h-none",onOpenChange:r}),(0,rE.jsx)(WD,{className:"shrink-0 p-0",children:(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsx)(WS,{type:"button",variant:"outline",className:"w-full",children:n("close")})})})]})})}var $H="Progress",[$V,$W]=Kl($H),[$q,$K]=$V($H),$J=rx.forwardRef((e,t)=>{var r,n;let{__scopeProgress:i,value:a=null,max:s,getValueLabel:o=$Z,...l}=e;(s||0===s)&&!$1(s)&&console.error((r=`${s}`,`Invalid prop \`max\` of value \`${r}\` supplied to \`Progress\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`));let c=$1(s)?s:100;null===a||$2(a,c)||console.error((n=`${a}`,`Invalid prop \`value\` of value \`${n}\` supplied to \`Progress\`. The \`value\` prop must be:
|
|
7632
7632
|
- a positive number
|
|
7633
7633
|
- less than the value passed to \`max\` (or 100 if no \`max\` prop is set)
|
|
7634
7634
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
7635
7635
|
|
|
7636
|
-
Defaulting to \`null\`.`));let u=$1(a,c)?a:null,d=$$(u)?o(u,c):void 0;return(0,rE.jsx)($W,{scope:i,value:u,max:c,children:(0,rE.jsx)(Kh.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":$$(u)?u:void 0,"aria-valuetext":d,role:"progressbar","data-state":$Z(u,c),"data-value":u??void 0,"data-max":c,...l,ref:t})})});$K.displayName=$G;var $J="ProgressIndicator",$Y=rx.forwardRef((e,t)=>{let{__scopeProgress:r,...n}=e,i=$q($J,r);return(0,rE.jsx)(Kh.div,{"data-state":$Z(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...n,ref:t})});function $X(e,t){return`${Math.round(e/t*100)}%`}function $Z(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function $$(e){return"number"==typeof e}function $0(e){return $$(e)&&!isNaN(e)&&e>0}function $1(e,t){return $$(e)&&!isNaN(e)&&e<=t&&e>=0}function $2({className:e,value:t,max:r=100,...n}){let i=r>0?r:100,a="number"==typeof t?Math.min(Math.max(t/i*100,0),100):0;return(0,rE.jsx)($K,{"data-slot":"progress",className:WC("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),value:t,max:i,...n,children:(0,rE.jsx)($Y,{"data-slot":"progress-indicator",className:"h-full bg-primary transition-[width]",style:{width:`${a}%`}})})}$Y.displayName=$J;let $3=[{minimumProgress:0,translationKey:"floor.processing.stages.reading"},{minimumProgress:28,translationKey:"floor.processing.stages.mapping"},{minimumProgress:56,translationKey:"floor.processing.stages.lighting"},{minimumProgress:82,translationKey:"floor.processing.stages.finalizing"},{minimumProgress:100,translationKey:"floor.processing.stages.ready"}];function $9({isComplete:e,open:t,onCloseAnimationEnd:r,onOpenChange:n,portalContainer:i}){let{t:a}=sf(),s=(0,rx.useRef)(t),[o,l]=(0,rx.useState)(8),c=e?100:o,u=function(e){for(let t=$3.length-1;t>=0;t-=1){let r=$3[t];if(r&&e>=r.minimumProgress)return r}return $3[0]}(c);(0,rx.useEffect)(()=>{t&&!s.current&&l(8),s.current=t},[t]),(0,rx.useEffect)(()=>{if(!t||e)return;let r=window.setInterval(()=>{l(e=>Math.min(92,e+Math.max(2,Math.round((92-e)/8))))},650);return()=>window.clearInterval(r)},[e,t]);let d=(0,rE.jsxs)("div",{role:"status","aria-live":"polite",className:"grid content-start gap-4",children:[(0,rE.jsx)("h2",{className:"typo-base-18 font-medium text-text-dark",children:a("floor.processing.title")}),(0,rE.jsxs)("div",{"data-testid":"floor-processing-progress-panel",className:"grid min-h-[97px] min-w-0 content-center gap-2 overflow-hidden rounded-xl bg-background-base px-6 py-8",children:[(0,rE.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,rE.jsx)("span",{className:"typo-base-14 min-w-0 flex-1 truncate text-left font-medium text-text-light",children:a(u.translationKey)}),(0,rE.jsxs)("span",{className:"typo-base-14 shrink-0 font-medium text-text-dark",children:[c,"%"]})]}),(0,rE.jsx)($2,{value:c,"aria-label":a("floor.processing.progressLabel"),className:"h-1 bg-background-base-3 [&_[data-slot=progress-indicator]]:bg-button-dark [&_[data-slot=progress-indicator]]:duration-500 [&_[data-slot=progress-indicator]]:ease-out"})]})]});return(0,rE.jsx)(WM,{open:t,onOpenChange:n,children:(0,rE.jsxs)(WT,{portalContainer:i,showCloseButton:!1,"data-testid":"floor-processing-card",className:"top-auto bottom-2 w-[calc(100%-16px)] !max-w-none translate-y-0 gap-4 overflow-hidden rounded-2xl p-6 text-center sm:top-[50%] sm:bottom-auto sm:w-full sm:!max-w-[377px] sm:translate-y-[-50%] sm:p-6",onInteractOutside:e=>{e.preventDefault()},onAnimationEnd:e=>{e.currentTarget===e.target&&"closed"===e.currentTarget.getAttribute("data-state")&&r?.()},children:[(0,rE.jsx)(WP,{className:"sr-only",children:a("floor.processing.title")}),(0,rE.jsx)(W_,{className:"sr-only",children:a(u.translationKey)}),d]})})}let $4={desktop:[{slot:"product-card",container:"leading",appearance:"card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"leading",appearance:"card",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"card",actionVariant:"secondary",actionSize:"sm"}],tablet:[{slot:"product-card",container:"leading",appearance:"compact-card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"framed-row",actionLabelKey:"floor.interiorSelection.chooseInteriorShort",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"inline-compact",actionVariant:"secondary",actionSize:"default"}],phone:[{slot:"product-card",container:"leading",appearance:"flow-card",actionLabelResourceTypeKey:"replaceProductShort",actionVariant:"outline",actionSize:"sm",actionWidth:"fixed"},{slot:"room-card",container:"trailing",appearance:"plain-row",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"inline-large",actionVariant:"secondary",actionSize:"lg"}]},$5={desktop:[{slot:"product-card",container:"leading",appearance:"card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"leading",appearance:"card",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"}],tablet:[{slot:"product-card",container:"leading",appearance:"compact-card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"framed-row",actionLabelKey:"floor.interiorSelection.chooseInteriorShort",actionVariant:"outline",actionSize:"sm"}],phone:[{slot:"product-card",container:"leading",appearance:"flow-card",actionLabelResourceTypeKey:"replaceProductShort",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"plain-row",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"}]},$8={"inline-compact":"h-9 w-full rounded-xl","inline-large":"h-11 w-full rounded-xl"},$6={"inline-compact":"size-5","inline-large":"size-6"},$7={desktop:"floor-ar-card",tablet:void 0,phone:void 0},eee=/^[a-z][a-z\d+.-]*:/i,eet={card:"flex min-h-24 w-fit max-w-100 items-center gap-4 rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","compact-card":"flex min-h-[116px] w-fit max-w-[421px] items-center gap-4 rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","flow-card":"flex items-center justify-start gap-4 border-b border-border-light bg-background-containers p-4 text-left"},eer={card:"size-6 text-icons-normal","compact-card":"size-6 text-icons-normal","flow-card":"size-5 text-icons-normal"},een={desktop:"floor-desktop-product-card",tablet:"floor-tablet-product-card",phone:"floor-mobile-product-card"},eei={card:"flex h-24 w-[254px] items-center gap-4 overflow-hidden rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","framed-row":"flex h-[72px] items-center justify-between gap-3 overflow-hidden rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","plain-row":"flex w-full items-center justify-between gap-3 rounded-full bg-background-containers text-left"},eea={desktop:"floor-room-card",tablet:"floor-tablet-room-card",phone:void 0},ees={desktop:"floor-desktop-room-name",tablet:"floor-tablet-room-name",phone:"floor-mobile-room-name"},eeo={"product-card":function({actions:e,band:t,slot:r,presentation:n}){let i,{t:a}=sf(),{displayUnit:s,name:o,type:l}=W6(),{containerRef:c}=qr(),{material:u,selectedObject:d,tinuuid:h}=qt(),{variantItems:p,selectedTinuuid:f,selectVariant:A}=function(){let{tinuuid:e,selectedObject:t,selectResourceVariant:r,apiKey:n,baseURL:i,language:a,source:s,widgetSession:o}=qt(),{type:l}=W6(),{decodeVariant:c}=qO(l),u=t?.kit?.uuid,d=t?.owner?.uuid,{data:h,fetchNextPage:p,hasNextPage:f,isFetchingNextPage:A,isFetchNextPageError:g}=od({queryKey:WA(u,d,{apiKey:n,baseURL:i,language:a,source:s,resourceType:l}),enabled:!!c&&!!u&&!!d,queryFn:({pageParam:e,signal:t})=>{if(!u||!d)throw Error("Kit uuid and owner uuid are required.");return Wv(u,d,e,{apiKey:n,baseURL:i,language:a,signal:t,source:s,widgetSession:o,resourceType:l})},initialPageParam:0,getNextPageParam:(e,t,r)=>void 0!==e.pages_count?r+1<e.pages_count?r+1:void 0:e.objs?.length?r+1:void 0},ou,void 0);(0,rx.useEffect)(()=>{!f||A||g||p({cancelRefetch:!1})},[p,f,A,g]);let m=(0,rx.useMemo)(()=>h?.pages.flatMap(e=>e.objs??[])??[],[h]),v=(0,rx.useMemo)(()=>m.flatMap(e=>{let t=c?.(e.description);return e.tinuuid&&e.materials?.[0]&&t?[{tinuuid:e.tinuuid,...t}]:[]}),[m,c]);return{variantItems:v,selectedTinuuid:e,selectVariant:e=>!!v.some(t=>t.tinuuid===e)&&(r(e),!0)}}(),g=een[t],m=a(`units.${s}`),v=e.isMaterialSelectionOpen,b=a(v?"floor.scene.hideCatalog":`resourceType.${l}.${n.actionLabelResourceTypeKey}`),y=qz(l,d,u,o),w=(i=u?.previews?.[0],i?.subRes?.small??i?.url??d?.preview?.subRes?.small??d?.preview?.url??d?.mainPreview),x=p.find(e=>e.tinuuid===f),C=function(e){let t=e?.trim();if(!t||eee.test(t)&&!/^https?:/i.test(t)||/^[./?#]/.test(t)&&!t.startsWith("//"))return;let r=t.startsWith("//")?`https:${t}`:/^https?:/i.test(t)?t:`https://${t}`;try{let e=new URL(r);if("http:"!==e.protocol&&"https:"!==e.protocol||!e.hostname)return;return e.href}catch{return}}(d?.tinuuid===h?d.destinationUrl:void 0),E=v?e.onMaterialSelectionActionPointerDown:void 0;return(0,rE.jsxs)("div",{className:eet[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-product":"","data-testid":g,children:[(0,rE.jsx)("div",{className:"grid size-16 shrink-0 place-items-center overflow-hidden bg-background-base",children:w?(0,rE.jsx)("img",{src:w,alt:"",className:"size-full object-cover"}):(0,rE.jsx)(WG,{className:eer[n.appearance]})}),(0,rE.jsxs)("div",{className:"grid min-h-16 min-w-0 flex-1 grid-cols-1 content-center gap-2",children:[(0,rE.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[(0,rE.jsxs)("div",{className:"min-w-0",children:[(0,rE.jsx)("div",{className:"sr-only",children:a(`resourceType.${l}.productCardTitle`)}),(0,rE.jsx)("div",{className:"typo-button-normal truncate text-text-dark",children:y})]}),C&&(0,rE.jsx)("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"typo-base-12 shrink-0 text-button-primary underline-offset-2 hover:underline","data-testid":`${g}-description-link`,children:a("floor.scene.description")})]}),(0,rE.jsxs)("div",{className:"flex flex-nowrap items-center gap-2",children:[(0,rE.jsxs)(WS,{type:"button",variant:n.actionVariant,size:n.actionSize,[$O]:!0,"aria-expanded":v,className:WC("w-fit shrink-0","fixed"===n.actionWidth&&"w-[137px]"),onPointerDown:E?e=>{e.preventDefault(),e.stopPropagation(),E()}:void 0,onClick:v?e.closeMaterialSelection:e.openMaterialSelection,children:[v?(0,rE.jsx)(WO,{className:"size-4"}):(0,rE.jsx)(WV,{className:"size-4"}),b]}),p.length>1&&!!x&&(0,rE.jsxs)(qu,{value:f??void 0,onValueChange:A,children:[(0,rE.jsx)(qh,{size:"sm",className:"w-fit min-w-0 shrink *:data-[slot=select-value]:block *:data-[slot=select-value]:truncate","data-testid":`${g}-variant-select`,children:(0,rE.jsx)(qd,{})}),(0,rE.jsx)(qp,{portalContainer:c,children:p.map(e=>{var t;let r;return(0,rE.jsx)(qf,{value:e.tinuuid,children:"color"in e?e.color:(t=e.size,r=t.split("\xd7").map(e=>"cm"===s?e:Math.round(qZ(Number(e)/100,s)).toString()).join("\xd7"),`${r} ${m}`)},e.tinuuid)})})]})]})]})]})},"room-card":function({actions:e,band:t,slot:r,presentation:n}){let{t:i}=sf(),{room:a}=qe(),s=i(`rooms.${a.id}`,{defaultValue:a.name}),o=(0,rE.jsx)(WS,{type:"button",variant:n.actionVariant,size:n.actionSize,className:"card"===n.appearance?"w-fit":"shrink-0",onClick:e.openInteriorSelection,children:i(n.actionLabelKey)});return"card"===n.appearance?(0,rE.jsxs)("div",{className:eei[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-room":"","data-testid":eea[t],children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(a),alt:"",className:"size-16 shrink-0 rounded-lg object-cover"}),(0,rE.jsxs)("span",{className:"grid min-w-0 flex-1 content-center gap-2",children:[(0,rE.jsx)("span",{className:"typo-button-normal block min-h-[1.35em] truncate !leading-[1.35] text-text-dark","data-testid":ees[t],children:s}),o]})]}):(0,rE.jsxs)("div",{className:eei[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-room":"","data-testid":eea[t],children:[(0,rE.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(a),alt:"",className:"size-10 shrink-0 rounded-full object-cover"}),(0,rE.jsxs)("span",{className:"grid min-w-0",children:[(0,rE.jsx)("span",{className:"typo-base-12 truncate text-text-light",children:i("floor.scene.interiorCardTitle")}),(0,rE.jsx)("span",{className:"typo-button-normal min-h-[1.35em] truncate !leading-[1.35] text-text-dark","data-testid":ees[t],children:s})]})]}),o]})},"ar-card":function({band:e,slot:t,presentation:r}){let{t:n}=sf(),{room:i}=qe(),{tinuuid:a}=qt();return!a||$B&&$k?null:"card"===r.appearance?(0,rE.jsxs)("div",{className:"flex h-24 w-[280px] items-center gap-4 overflow-hidden rounded-2xl bg-background-containers p-4 text-text-dark shadow-[var(--shadow-login)]","data-chrome-slot":t,"data-neurodyn-room-viewer-try-at-home":"","data-testid":$7[e],children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(i),alt:"",className:"size-16 shrink-0 rounded-lg object-cover"}),(0,rE.jsxs)("div",{className:"grid min-w-0 flex-1 content-center gap-2",children:[(0,rE.jsx)($T,{buttonLabel:n("floor.scene.tryAtHome"),buttonVariant:r.actionVariant,buttonSize:r.actionSize,buttonClassName:"w-fit"}),(0,rE.jsx)("div",{className:"typo-base-12 truncate font-medium text-text-light",children:n("floor.scene.tryAtHomeBody")})]})]}):(0,rE.jsx)($T,{className:"w-full","data-chrome-slot":t,"data-neurodyn-room-viewer-try-at-home":"",buttonLabel:n("floor.scene.tryAtHome"),buttonLeadingIcon:(0,rE.jsx)(WY,{className:$6[r.appearance]}),buttonVariant:r.actionVariant,buttonSize:r.actionSize,buttonClassName:$8[r.appearance]})}};function eel({actions:e,band:t,entry:r}){let n=eeo[r.slot];return(0,rE.jsx)(n,{actions:e,band:t,slot:r.slot,presentation:r})}function eec({actions:e,band:t,container:r}){let{type:n}=W6(),i="immersive-panels"===Ww[n].presentation?$5:$4;return(0,rE.jsx)(rE.Fragment,{children:i[t].filter(e=>e.container===r).map(r=>(0,rE.jsx)(eel,{actions:e,band:t,entry:r},r.slot))})}async function eeu(e,t={}){let r=t.source??"default",n={image:e};if(VL({apiKey:t.apiKey,source:r})){let e=await t.widgetSession?.getTokenForRequest();return V6(n,{baseURL:t.baseURL,headers:{"x-api-key":t.apiKey,...e?{[Wo]:e}:{}},signal:t.signal,timeout:0,params:{productType:VN({apiKey:t.apiKey,source:r,resourceType:t.resourceType})}})}return t.signal?V0(n,{signal:t.signal,timeout:0}):V0(n,{timeout:0})}let eed=[{id:0,label:"empty",rgb:[0,0,0]},{id:1,label:"floor",rgb:[32,208,96]},{id:2,label:"wall-1",rgb:[255,59,48]},{id:3,label:"wall-2",rgb:[10,132,255]},{id:4,label:"ceiling",rgb:[255,214,10]},{id:5,label:"plane-5",rgb:[191,90,242]},{id:6,label:"plane-6",rgb:[255,159,10]},{id:7,label:"plane-7",rgb:[100,210,255]},{id:8,label:"plane-8",rgb:[255,45,85]}];function eeh(){try{return"1"===window.localStorage.getItem("neurodyn-room-viewer:debug-mask-export")}catch{return!1}}async function eep(e,t){var r,n,i;let a,s,o,l,c=await (r=e.planeIds.dataPng,new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error("Failed to load room plane id mask image.")),n.crossOrigin="anonymous",n.src=r})),u=e.planeIds.width||c.naturalWidth||c.width,d=e.planeIds.height||c.naturalHeight||c.height,h=document.createElement("canvas"),p=h.getContext("2d",{willReadFrequently:!0});if(!p)throw Error("Failed to prepare room plane mask canvas.");h.width=u,h.height=d,p.drawImage(c,0,0,u,d);let f=p.getImageData(0,0,u,d),A=document.createElement("canvas"),g=A.getContext("2d");if(!g)throw Error("Failed to prepare room debug mask canvas.");A.width=u,A.height=d;for(let e=0;e<u*d;e++){let t=4*e,r=function(e){return eed.find(t=>t.id===e)??{id:e,label:`plane-${e}`,rgb:[73*e%255,151*e%255,211*e%255]}}(f.data[t]??0);f.data[t]=r.rgb[0],f.data[t+1]=r.rgb[1],f.data[t+2]=r.rgb[2],f.data[t+3]=255}g.putImageData(f,0,0),n=await new Promise((e,t)=>{A.toBlob(r=>{r?e(r):t(Error("Failed to export room plane mask image."))},"image/png")}),s=Array.from((a=t.lastIndexOf("."))>0?t.slice(0,a):t).map(e=>{let t=e.charCodeAt(0),r="."===e||"_"===e||"-"===e;return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||r?e:"-"}).join("").split("-").filter(Boolean).join("-"),i=`${s||"room"}.debug-mask.colors.png`,o=URL.createObjectURL(n),(l=document.createElement("a")).href=o,l.download=i,l.style.display="none",document.body.append(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),1e3)}let eef="custom-interiors";function eeA(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?`custom-interior-${crypto.randomUUID()}`:`custom-interior-${Date.now()}-${Math.random().toString(36).slice(2)}`}function eeg(){let e="u"<typeof indexedDB?null:indexedDB;return e?new Promise((t,r)=>{let n=e.open("neurodyn-floor-custom-interiors",1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(eef)||e.createObjectStore(eef,{keyPath:"id"})},n.onerror=()=>r(n.error??Error("Failed to open Custom Interior store.")),n.onsuccess=()=>t(n.result)}):Promise.resolve(null)}async function eem(e,t,r=new Date){let n=await eeg();if(!n)return null;let i={id:eeA(),schemaVersion:1,name:e.name,fileName:e.name,createdAt:r.toISOString(),imageBlob:e,scene:t};try{let e=n.transaction(eef,"readwrite");return e.objectStore(eef).put(i),await new Promise((t,r)=>{e.oncomplete=()=>t(),e.onerror=()=>r(e.error??Error("Custom Interior transaction failed.")),e.onabort=()=>r(e.error??Error("Custom Interior transaction aborted."))}),i}finally{n.close()}}async function eev(){let e=await eeg();if(!e)return[];try{return await new Promise((t,r)=>{let n=e.transaction(eef,"readonly").objectStore(eef).getAll();n.onerror=()=>r(n.error??Error("Failed to read Custom Interiors.")),n.onsuccess=()=>{let e=n.result.filter(e=>1===e.schemaVersion).sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt));t(e)}})}finally{e.close()}}function eeb(e){let t=[];return{rooms:e.map(e=>{let r=URL.createObjectURL(e.imageBlob);return t.push(r),{id:e.id,name:e.name,image_url:r,scene:e.scene}}),revokeObjectUrls:()=>{for(let e of t)URL.revokeObjectURL(e);t.length=0}}}let eey={placementReady:!1,prepareReady:!1,artifactsReady:!1,assetsReady:!1};function eew(e){let t="dialog"===e?"interior-selection":"scene";return{step:t,hasSceneSelection:"scene"===t,sceneResetKey:0}}function eex(e,t){switch(t.type){case"clear-interior-selection":return{...e,step:"interior-selection",hasSceneSelection:!1,automaticRoomId:t.automaticRoomId};case"select-initial-room":return{step:"scene",hasSceneSelection:!0,sceneResetKey:e.sceneResetKey+1,automaticRoomId:t.roomId};case"open-interior-selection":case"return-to-interior-selection":return{...e,step:"interior-selection"};case"dismiss-interior-selection":case"recover-to-scene":return e.hasSceneSelection?{...e,step:"scene"}:e;case"start-custom-interior-processing":return{...e,step:"processing-custom-interior"};case"commit-interior-selection":return{step:"scene",hasSceneSelection:!0,sceneResetKey:e.sceneResetKey+1}}}function eeC(e,t){return!e.aborted&&t()}async function eeE({abortSignal:e,apiOptions:t,commitCustomInteriorSelection:r,downloadDebugMask:n,file:i,isActive:a,isDebugMaskExportEnabled:s,onDebugMaskError:o,onPersistenceError:l,onProcessingComplete:c,predictRoomScene:u,saveCustomInterior:d,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p}){let f=await u(i,{...t,signal:e});if(!eeC(e,a))return null;s()&&n(f,i.name).catch(o);let A=h(i,f);return eeC(e,a)&&A&&(d(i,f).catch(l),c(),await p(),eeC(e,a))?(r(A),A):null}function eeS(){return new Promise(e=>window.setTimeout(e,250))}function eeM(e){console.error("Failed to export room debug mask",e)}function eeI(e){console.error("Failed to persist Custom Interior",e)}function eeB(e){console.error("Failed to prepare Custom Interior",e)}let eek={"immersive-room":function({showDialogCloseButton:e=!1}){var t;let{t:r}=sf(),{name:n,type:i}=W6(),{accessError:a,glbUrl:s,apiKey:o,baseURL:l,hasRooms:c,source:u,widgetSession:d,isViewerAccessPending:h,loadError:p,selectedObject:f,tinuuid:A}=qt(),{clearActiveError:g,handleAccessError:m}=function(){let{setAccessError:e,setLoadError:t}=qt();return{clearActiveError:(0,rx.useCallback)(()=>{e(null),t(null)},[e,t]),handleAccessError:e}}(),{room:v,sourceRooms:b}=qe(),{resourceRef:y,containerRef:w,setContainerRef:x,sceneLoad:C,isRoomScenePending:E}=qr(),{dialogPortalContainer:S,viewerSurface:M,viewerDialogOpen:I,onViewerDialogOpenChange:B}=W7(),[k,T]=(0,rx.useState)(!1),[R,D]=(0,rx.useState)(!1),P=(0,rx.useRef)(null),_=(0,rx.useRef)(!1),L=a??p,N=!!L,F=(t=r("floor.scene.companyFallback"),f?.owner?.name??f?.brand??t),{canShare:O,download:Q,isDownloading:U,isSharing:z,share:j}=$D({captureRef:P,fallbackToClipboard:!0,shareMessage:r(`shareMessage.${i}`)}),G=(0,rx.useCallback)(()=>{T(!1),D(!1)},[]),H=(0,rx.useCallback)(()=>{if(_.current){_.current=!1;return}T(!0),D(!1)},[]),V=(0,rx.useCallback)(()=>{_.current=!0,G()},[G]),W=(0,rx.useCallback)(()=>{D(!0),T(!1)},[]),q=function({activeError:e,apiKey:t,baseURL:r,clearActiveError:n,closeMaterialSelection:i,glbUrl:a,handleAccessError:s,hasDialogPortalContainer:o,hasRooms:l,isRoomScenePending:c,isViewerAccessPending:u,onViewerDialogOpenChange:d,resourceType:h,sceneLoad:p,source:f,sourceRooms:A,viewerDialogOpen:g,viewerSurface:m,widgetSession:v}){let b=function(e){let{initialRoomId:t,room:r,sourceRooms:n}=qe(),{isViewerAccessPending:i,loadError:a,setLoadError:s}=qt(),{type:o}=W6(),{patchSceneLoad:l,setAngle:c,setRotation:u}=qr(),d=(0,rx.useMemo)(()=>({patchSceneLoad:l,setAngle:c,setRotation:u}),[l,c,u]),h=n.find(e=>e.id===t),p=!!h&&(!h?.scene||ZG(h.scene,Wx(o)).length>0),f=function(e,t,r){let[n,i]=(0,rx.useReducer)(eex,e,eew),[a,s]=(0,rx.useState)();!r?.isPending&&a!==r?.roomId&&(s(r?.roomId),r&&i(r.isAvailable?{type:"select-initial-room",roomId:r.roomId}:{type:"clear-interior-selection"}));let o=(0,rx.useCallback)(e=>{e(),function({patchSceneLoad:e,setAngle:t,setRotation:r}){t(0),r(0),e(eey)}(t),i({type:"commit-interior-selection"})},[t]),l=(0,rx.useCallback)(()=>{i({type:"dismiss-interior-selection"})},[]),c=(0,rx.useCallback)(()=>{i({type:"open-interior-selection"})},[]),u=(0,rx.useCallback)(()=>{i({type:"recover-to-scene"})},[]),d=(0,rx.useCallback)(()=>{i({type:"return-to-interior-selection"})},[]),h=(0,rx.useCallback)(()=>{i({type:"clear-interior-selection",automaticRoomId:n.automaticRoomId})},[n.automaticRoomId]),p=(0,rx.useCallback)(()=>{i({type:"start-custom-interior-processing"})},[]);return(0,rx.useMemo)(()=>({...n,commitInteriorSelection:o,dismissInteriorSelection:l,openInteriorSelection:c,recoverToScene:u,returnToInteriorSelection:d,clearInteriorSelection:h,startCustomInteriorProcessing:p}),[o,l,c,u,d,h,p,n])}(e,d,t?{roomId:t,isAvailable:p,isPending:i}:void 0),{automaticRoomId:A,clearInteriorSelection:g}=f;return(0,rx.useEffect)(()=>{A&&r.id===A&&"room-load-failed"===a&&(g(),s(null))},[A,g,a,r.id,s]),f}(m),{appendRuntimeCustomInterior:y,customRooms:w}=function({listCustomInteriors:e}){let{appendRuntimeCustomInterior:t,customRooms:r,replaceRuntimeCustomInteriors:n}=function(){let[e,t]=(0,rx.useState)(()=>[]),r=(0,rx.useRef)(null),n=(0,rx.useCallback)(e=>{r.current?.revokeObjectUrls();let n=eeb(e);return r.current=n,t(n.rooms),n.rooms},[]),i=(0,rx.useCallback)((e,n)=>{let i=eeb([{id:eeA(),schemaVersion:1,name:e.name,fileName:e.name,createdAt:new Date().toISOString(),imageBlob:e,scene:n}]),a=i.rooms[0];if(!a)return i.revokeObjectUrls(),null;let s=r.current;return r.current={rooms:[],revokeObjectUrls:()=>{s?.revokeObjectUrls(),i.revokeObjectUrls()}},t(e=>[a,...e.filter(e=>e.id!==a.id)]),a},[]);return(0,rx.useEffect)(()=>()=>{r.current?.revokeObjectUrls()},[]),(0,rx.useMemo)(()=>({appendRuntimeCustomInterior:i,customRooms:e,replaceRuntimeCustomInteriors:n}),[i,e,n])}(),i=(0,rx.useRef)(!0);(0,rx.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=(0,rx.useCallback)(async()=>{let t=await e();i.current&&n(t)},[e,n]);return(0,rx.useEffect)(()=>{a()},[a]),(0,rx.useMemo)(()=>({appendRuntimeCustomInterior:t,customRooms:r,replaceRuntimeCustomInteriors:n,refreshCustomInteriors:a}),[t,r,a,n])}({listCustomInteriors:eev}),x=(0,rx.useMemo)(()=>new Set(A.map(e=>e.id)),[A]),{commitCustomInteriorSelection:C,selectInterior:E}=function(e){let{room:t,setRoomId:r,setRooms:n}=qe(),{widgetSession:i}=qt();return function({floorFlow:e,customRooms:t,selectedRoomId:r,onInteriorSelected:n,restoreSourceRooms:i,setRoomId:a,setRooms:s}){let o=(0,rx.useCallback)(t=>{e.commitInteriorSelection(()=>{s(e=>[t,...i(e).filter(e=>e.id!==t.id)]),a(t.id)}),n?.()},[e,n,i,a,s]),l=(0,rx.useCallback)(t=>{let o=t===r;o&&e.hasSceneSelection||(e.commitInteriorSelection(()=>{s(i),a(t)}),o||n?.())},[e,n,i,r,a,s]),c=(0,rx.useCallback)(n=>{if(n===r&&e.hasSceneSelection)return;let i=t.find(e=>e.id===n);i&&o(i)},[e.hasSceneSelection,o,t,r]),u=(0,rx.useCallback)(e=>{t.some(t=>t.id===e)?c(e):l(e)},[t,c,l]);return(0,rx.useMemo)(()=>({commitCustomInteriorSelection:o,selectInterior:u}),[o,u])}({...e,selectedRoomId:t.id,onInteriorSelected:()=>Wd(i,"interior_selected"),setRoomId:r,setRooms:n})}({floorFlow:b,customRooms:w,restoreSourceRooms:(0,rx.useCallback)(e=>[...A,...e.filter(e=>!x.has(e.id))],[x,A])}),S=function(e){let{setIsRoomScenePending:t}=qr();return function({apiOptions:e,floorFlow:t,commitCustomInteriorSelection:r,downloadDebugMask:n,isDebugMaskExportEnabled:i,onAccessError:a,onDebugMaskError:s,onPersistenceError:o,onProcessingError:l,predictRoomScene:c,saveCustomInterior:u,setIsRoomScenePending:d,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p}){let[f,A]=(0,rx.useState)(!1),[g,m]=(0,rx.useState)(!1),[v,b]=(0,rx.useState)(null),[y,w]=(0,rx.useState)(null),[x,C]=(0,rx.useState)(!1),[E,S]=(0,rx.useState)(0),M=(0,rx.useRef)(null),I=(0,rx.useRef)(!1),B=(0,rx.useRef)(!0),k=(0,rx.useRef)(v);v&&(k.current=v),(0,rx.useEffect)(()=>(B.current=!0,()=>{B.current=!1,M.current?.abort()}),[]);let T=(0,rx.useCallback)(()=>{b(null),w(null),C(!1)},[]),R=(0,rx.useCallback)(e=>{T(),A(!1),e()},[T]),D=(0,rx.useCallback)(async f=>{if(T(),!f.type.startsWith("image/"))return void A(!0);A(!1),m(!1),t.startCustomInteriorProcessing(),I.current=!0;let g=new AbortController;M.current?.abort(),M.current=g,d(!0);try{await eeE({abortSignal:g.signal,apiOptions:e,commitCustomInteriorSelection:r,downloadDebugMask:n,file:f,isActive:()=>B.current,isDebugMaskExportEnabled:i,onDebugMaskError:s,onPersistenceError:o,onProcessingComplete:()=>{m(!0)},predictRoomScene:c,saveCustomInterior:u,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p})}catch(t){if(g.signal.aborted)return;let e=VO(t);if(e){I.current&&C(!0),a(e);return}if(l(t),I.current){w("custom-interior-processing"),C(!0);return}b("custom-interior-processing")}finally{M.current===g&&(M.current=null,B.current&&d(!1))}},[e,t,r,n,i,a,s,o,l,c,T,u,d,h,p]),P=(0,rx.useCallback)(()=>{T(),A(!1),t.returnToInteriorSelection(),S(e=>e+1)},[t,T]),_=(0,rx.useCallback)(()=>{T(),t.returnToInteriorSelection()},[t,T]),L=(0,rx.useCallback)(({clearError:e,closeMaterialSelection:r})=>{e(),r(),t.hasSceneSelection&&t.recoverToScene()},[t]),N=(0,rx.useCallback)(()=>{I.current=!1,C(!1),y&&(b(y),w(null))},[y]),F=(0,rx.useCallback)(()=>B.current,[]);return(0,rx.useMemo)(()=>({displayedUploadError:v??k.current,isCustomInteriorProcessingComplete:g,isInvalidFile:f,isMounted:F,isProcessingDialogClosingForError:x,pendingUploadError:y,uploadError:v,uploadRetryRequestId:E,cancelUploadError:_,handleProcessingDialogCloseAnimationEnd:N,openInteriorSelection:R,processUploadFile:D,recoverFromActiveError:L,resetUploadErrorPresentation:T,tryUploadAgain:P}),[_,N,g,f,F,x,R,y,D,L,T,P,v,E])}({...e,setIsRoomScenePending:t})}({apiOptions:(0,rx.useMemo)(()=>({resourceType:h,apiKey:t,baseURL:r,source:f,widgetSession:v}),[t,r,h,f,v]),floorFlow:b,commitCustomInteriorSelection:C,downloadDebugMask:eep,isDebugMaskExportEnabled:eeh,onAccessError:s,onDebugMaskError:eeM,onPersistenceError:eeI,onProcessingError:eeB,predictRoomScene:eeu,saveCustomInterior:eem,trackRuntimeCustomInterior:y,waitForProcessingCompletion:eeS}),{dismissInteriorSelection:M,hasSceneSelection:I,openInteriorSelection:B,sceneResetKey:k,step:T}=b,{cancelUploadError:R,displayedUploadError:D,handleProcessingDialogCloseAnimationEnd:P,isCustomInteriorProcessingComplete:_,isInvalidFile:L,isProcessingDialogClosingForError:N,openInteriorSelection:F,pendingUploadError:O,processUploadFile:Q,recoverFromActiveError:U,resetUploadErrorPresentation:z,tryUploadAgain:j,uploadError:G,uploadRetryRequestId:H}=S,V=l&&I,W=(0,rx.useRef)(e),q=!!(e&&V&&a);e&&(W.current=e);let K=(0,rx.useCallback)(()=>{V&&(z(),M())},[M,V,z]),J=(0,rx.useCallback)(()=>{i(),F(B)},[i,B,F]),Y=(0,rx.useCallback)(()=>{U({clearError:n,closeMaterialSelection:i})},[n,i,U]),X=(0,rx.useCallback)(e=>{if(!e){if(V)return void K();d?.(!1)}},[K,V,d]),Z=(0,rx.useCallback)(e=>{if(!e){if(q)return void Y();d?.(!1)}},[q,Y,d]),$=(0,rx.useCallback)(e=>{e||R()},[R]);!function({fallbackMs:e,handleProcessingDialogCloseAnimationEnd:t,isProcessingDialogClosingForError:r}){(0,rx.useEffect)(()=>{if(!r)return;let n=window.setTimeout(t,e);return()=>window.clearTimeout(n)},[e,t,r])}({fallbackMs:220,handleProcessingDialogCloseAnimationEnd:P,isProcessingDialogClosingForError:N});let ee=function({activeError:e,canRecoverFromActiveError:t,floorFlow:r,hasDialogPortalContainer:n,hasRooms:i,isProcessingDialogClosingForError:a,isRoomScenePending:s,isViewerAccessPending:o,pendingUploadError:l,sceneLoad:c,uploadError:u,viewerDialogOpen:d,viewerSurface:h}){let p="dialog"===h&&n,f=!p||d,A=i&&r.hasSceneSelection,g=i||"scene"!==r.step?r.step:"interior-selection",m=!o&&A&&(!e||t),v=A||p,b=!o&&!e&&v,y=!o&&!e&&!v&&"interior-selection"===g;return{activeErrorDialog:{open:!a&&!!e&&f,showCloseButton:!t},interiorSelection:{open:b&&"interior-selection"===g&&f,presentation:b?"dialog":y?"screen":null,shouldRender:b||y},processingDialog:{open:!e&&!u&&!l&&s&&"processing-custom-interior"===r.step&&f},scene:{isLoading:s||!Object.values(c).every(Boolean),resetKey:r.sceneResetKey,shouldRender:m,shouldRenderDialog:m},surface:{usesSiblingDialogFlow:p},uploadErrorDialog:{open:!a&&!e&&!!u&&f}}}({activeError:e,canRecoverFromActiveError:q,floorFlow:{hasSceneSelection:I,sceneResetKey:k,step:T},hasDialogPortalContainer:o,hasRooms:l,isProcessingDialogClosingForError:N,isRoomScenePending:c,isViewerAccessPending:u,pendingUploadError:O,sceneLoad:p,uploadError:G,viewerDialogOpen:g,viewerSurface:m});return{...ee,activeErrorDialog:{...ee.activeErrorDialog,onCancel:q?Y:void 0,onOpenChange:Z,onTryAgain:q?Y:void 0,variant:e??W.current},customRooms:w,interiorSelection:{...ee.interiorSelection,isInvalidFile:L,onOpenChange:X,onSelectRoom:E,onUploadFile:Q,openFromScene:J,uploadRetryRequestId:H},sourceRooms:A,processingDialog:{...ee.processingDialog,isComplete:_,onCloseAnimationEnd:P,onOpenChange:ee.surface.usesSiblingDialogFlow?d:void 0},step:T,uploadErrorDialog:{...ee.uploadErrorDialog,onCancel:R,onOpenChange:$,onTryAgain:j,variant:D}}}({activeError:L,apiKey:o,baseURL:l,clearActiveError:g,closeMaterialSelection:G,glbUrl:s,handleAccessError:m,hasDialogPortalContainer:null!==S,hasRooms:c,isRoomScenePending:E,isViewerAccessPending:h,onViewerDialogOpenChange:B,resourceType:i,sceneLoad:C,source:u,sourceRooms:b,viewerDialogOpen:I,viewerSurface:M,widgetSession:d}),K=(0,rx.useRef)(null),J=function(e,t){let[r,n]=(0,rx.useState)(!1);return e&&r&&n(!1),(0,rx.useEffect)(()=>{let r;if(e)return;let i=()=>{t.current&&(0===Number(getComputedStyle(t.current).opacity)?n(!0):r=requestAnimationFrame(i))};return r=requestAnimationFrame(i),()=>cancelAnimationFrame(r)},[e,t]),!e&&r}(q.scene.isLoading||!q.scene.shouldRender||!I,K),Y=ZB(),{pending:X,finish:Z}=function(e,t,r){let[n,i]=(0,rx.useState)({open:e,pending:e&&t,sceneKey:r});n.open!==e?i({open:e,pending:e&&t,sceneKey:r}):n.sceneKey!==r?i({...n,sceneKey:r,pending:n.pending&&null===n.sceneKey}):n.pending&&!t&&i({...n,pending:!1});let a=(0,rx.useCallback)(()=>i(e=>({...e,pending:!1})),[]);return{pending:e&&n.pending,finish:a}}(I,Kt("(max-width: 639px)")&&"focus-resource"===Ww[i].introduction,q.scene.shouldRender?`${q.scene.resetKey}:${A??""}`:null),$=Y?.select,ee=(0,rx.useCallback)(()=>{Z(),$?.("0,0")},[Z,$]),et=(0,rx.useMemo)(()=>X?{ready:J,target:y,onComplete:ee,onCancel:Z}:void 0,[X,ee,Z,J,y]),er=q.interiorSelection.openFromScene,en=(0,rx.useCallback)(()=>{G(),er()},[G,er]),ei=(0,rx.useMemo)(()=>({isMaterialSelectionOpen:k,openMaterialSelection:H,closeMaterialSelection:G,onMaterialSelectionActionPointerDown:V,openInteriorSelection:en}),[G,V,en,H,k]),ea=(0,rx.useMemo)(()=>({isMaterialSelectionOpen:R,openMaterialSelection:W,closeMaterialSelection:G,openInteriorSelection:en}),[G,en,W,R]);(0,rx.useEffect)(()=>{if(k)return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)};function e(e){var t;(t=e.target)instanceof Element&&t.closest(`[${$O}], [${$Q}]`)||T(!1)}function t(e){"Escape"===e.key&&T(!1)}},[k]);let es=q.surface.usesSiblingDialogFlow?S:w,eo=(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("div",{className:"absolute inset-0 bg-constant-black","data-testid":"floor-scene-background-base"}),(0,rE.jsx)("div",{"aria-hidden":!0,className:"absolute top-[-52px] right-[-1.36%] bottom-[-52px] left-[-1.36%] blur-[40px]","data-testid":"floor-blur-background",children:(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(v),alt:"",className:"block size-full max-w-none object-cover object-center opacity-50"})}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute top-0 right-0 left-0 z-20 flex min-h-22 items-start justify-between gap-4 bg-linear-to-b from-black/75 via-black/35 to-transparent px-4 pt-4 pb-8 text-constant-white sm:px-6 lg:min-h-25 lg:pt-6",children:[(0,rE.jsx)("div",{className:"min-w-0 pt-1",children:(0,rE.jsx)("h1",{"data-testid":"floor-scene-header-company",className:"typo-base-16 truncate font-medium lg:typo-base-18",children:F})}),(0,rE.jsxs)("div",{className:"pointer-events-auto inline-flex shrink-0 items-center gap-2",children:[(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("floor.scene.share"),"data-neurodyn-room-viewer-share":"",disabled:!O||z,onClick:j,className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)(WJ,{className:"size-5"}),(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("floor.scene.share")})]}),(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("floor.scene.download"),"data-neurodyn-room-viewer-download":"",disabled:U,onClick:Q,className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)(WQ,{className:"size-5"}),(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("floor.scene.download")})]}),e&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("close"),className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("close")}),(0,rE.jsx)(WO,{className:"!size-5"})]})})]})]}),(0,rE.jsxs)("div",{className:"relative z-10 size-full min-h-0 min-w-0","data-testid":"floor-scene-viewport",children:[(0,rE.jsx)($g,{introduction:et,captureRef:P,className:"relative z-10 size-full min-h-0",canvasWrapperClassName:"p-0 sm:pt-0 sm:pb-0"},q.scene.resetKey),(0,rE.jsx)("div",{"aria-hidden":!q.scene.isLoading,className:WC("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",q.scene.isLoading?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),ref:K,"data-testid":"floor-scene-loader",style:{transitionDuration:q.scene.isLoading?"0ms":"250ms"},children:(0,rE.jsx)(WZ,{variant:"logo"})})]}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute right-6 bottom-6 left-6 z-20 hidden items-end justify-between gap-4 lg:flex","data-testid":"floor-desktop-cards",children:[(0,rE.jsx)("div",{className:"pointer-events-auto flex min-w-0 items-stretch gap-3",children:(0,rE.jsx)(eec,{actions:ei,band:"desktop",container:"leading"})}),(0,rE.jsx)("div",{className:"pointer-events-auto",children:(0,rE.jsx)(eec,{actions:ei,band:"desktop",container:"trailing"})})]}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute right-6 bottom-6 left-6 z-20 hidden items-end justify-between gap-2 sm:flex lg:hidden","data-testid":"floor-tablet-cards",children:[(0,rE.jsx)("div",{className:"pointer-events-auto flex min-w-0 items-stretch gap-3",children:(0,rE.jsx)(eec,{actions:ei,band:"tablet",container:"leading"})}),(0,rE.jsx)("div",{className:"pointer-events-auto grid w-[254px] gap-2",children:(0,rE.jsx)(eec,{actions:ei,band:"tablet",container:"trailing"})})]}),(0,rE.jsxs)("div",{className:"relative z-20 grid bg-background-containers text-text-dark shadow-[var(--shadow-login)] sm:hidden","data-testid":"floor-mobile-cards",children:[(0,rE.jsx)("div",{className:"grid",children:(0,rE.jsx)(eec,{actions:ea,band:"phone",container:"leading"})}),(0,rE.jsx)("div",{className:"grid gap-4 bg-background-containers px-6 pt-4 pb-6","data-testid":"floor-mobile-bottom-actions",children:(0,rE.jsx)(eec,{actions:ea,band:"phone",container:"trailing"})})]}),k&&!N&&(0,rE.jsx)($z,{[$Q]:!0,className:"absolute bottom-[152px] left-6 z-30 hidden max-h-[calc(100%-252px)] w-[348px] rounded-2xl bg-background-containers sm:flex lg:bottom-[132px] lg:max-h-[calc(100%-232px)]",gridClassName:"px-4 pb-4",titleClassName:"px-4 pt-4",onOpenChange:G}),(0,rE.jsx)($j,{open:R&&!N,portalContainer:es,onOpenChange:D})]}),el=q.interiorSelection.shouldRender?"dialog"===q.interiorSelection.presentation?(0,rE.jsx)($F,{open:q.interiorSelection.open,showCloseButton:e||q.scene.shouldRender,portalContainer:es,rooms:q.sourceRooms,customRooms:q.customRooms,selectedRoomId:v.id,isInvalidFile:q.interiorSelection.isInvalidFile,uploadRetryRequestId:q.interiorSelection.uploadRetryRequestId,onOpenChange:q.interiorSelection.onOpenChange,onSelectRoom:q.interiorSelection.onSelectRoom,onUploadFile:q.interiorSelection.onUploadFile}):"screen"===q.interiorSelection.presentation?(0,rE.jsx)($N,{rooms:q.sourceRooms,customRooms:q.customRooms,selectedRoomId:v.id,isInvalidFile:q.interiorSelection.isInvalidFile,uploadRetryRequestId:q.interiorSelection.uploadRetryRequestId,showCloseButton:e,onSelectRoom:q.interiorSelection.onSelectRoom,onUploadFile:q.interiorSelection.onUploadFile}):null:null,ec=(0,rE.jsx)($9,{isComplete:q.processingDialog.isComplete,open:q.processingDialog.open,portalContainer:es,onCloseAnimationEnd:q.processingDialog.onCloseAnimationEnd,onOpenChange:q.processingDialog.onOpenChange}),eu=(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)($_,{variant:q.activeErrorDialog.variant,open:q.activeErrorDialog.open,portalContainer:es,showDialogCloseButton:e&&q.activeErrorDialog.showCloseButton,onOpenChange:q.activeErrorDialog.onOpenChange,onTryAgain:q.activeErrorDialog.onTryAgain,onCancel:q.activeErrorDialog.onCancel}),(0,rE.jsx)($_,{variant:q.uploadErrorDialog.variant,open:q.uploadErrorDialog.open,portalContainer:es,onOpenChange:q.uploadErrorDialog.onOpenChange,onTryAgain:q.uploadErrorDialog.onTryAgain,onCancel:q.uploadErrorDialog.onCancel})]}),ed=(0,rE.jsxs)("div",{ref:x,className:"relative grid size-full grid-rows-[minmax(0,1fr)_auto] overflow-hidden text-foreground sm:block","data-neurodyn-room-viewer-container":"","data-testid":"floor-viewer-root",children:[h?(0,rE.jsx)("div",{className:"flex size-full items-center justify-center bg-radial from-background-containers to-background-base-2",children:(0,rE.jsx)(WZ,{variant:"logo"})}):q.scene.shouldRender?eo:null,!q.surface.usesSiblingDialogFlow&&el,!q.surface.usesSiblingDialogFlow&&ec]});return q.surface.usesSiblingDialogFlow?(0,rE.jsxs)(rE.Fragment,{children:[(q.scene.shouldRenderDialog||h)&&(0,rE.jsx)(WM,{open:I,onOpenChange:B,children:(0,rE.jsxs)(WT,{className:W$,contentInsideOverlay:!0,portalContainer:S,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsx)(WP,{className:"sr-only",children:n}),(0,rE.jsx)(W_,{className:"sr-only"}),ed]})}),el,ec,eu]}):(0,rE.jsxs)(rE.Fragment,{children:[ed,eu]})},"framed-scene":function({showDialogCloseButton:e=!1}){let{name:t}=W6(),{isViewerAccessPending:r,accessError:n,loadError:i,setLoadError:a,hasRooms:s}=qt(),{setContainerRef:o,sceneLoad:l,isRoomScenePending:c}=qr(),{dialogPortalContainer:u,viewerSurface:d,viewerDialogOpen:h,onViewerDialogOpenChange:p}=W7(),{t:f}=sf(),A=(0,rx.useRef)(null),g=r||c||s&&!Object.values(l).every(Boolean),m=n??i,v=m?(0,rE.jsx)("div",{ref:o,"data-neurodyn-room-viewer-container":"",className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,rE.jsx)(q7,{variant:m,showDialogCloseButton:e})}):(0,rE.jsxs)("div",{ref:o,"data-neurodyn-room-viewer-container":"",className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsxs)(WS,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[f("close"),(0,rE.jsx)(uc,{})]})}),!r&&(s?(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)(q6,{className:"absolute top-0 right-0 left-0 z-15"}),(0,rE.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,rE.jsx)(Z_,{onError:()=>a("viewer-load-failed"),children:(0,rE.jsx)($g,{captureRef:A,className:"size-full min-h-0",controls:(0,rE.jsx)($P,{captureRef:A})})}),(0,rE.jsx)(q8,{className:"bg-background"})]})]}):(0,rE.jsx)(q5,{className:"absolute inset-x-0 bottom-0 bg-background"})),(0,rE.jsx)("div",{"aria-hidden":!g,className:WC("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",g?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,rE.jsx)(WZ,{variant:"logo"})})]});return"dialog"!==d?v:(0,rE.jsx)(WM,{open:h,onOpenChange:p,children:(0,rE.jsxs)(WT,{className:W$,contentInsideOverlay:!0,portalContainer:u,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsxs)(WR,{className:"sr-only",children:[(0,rE.jsx)(WP,{children:t}),(0,rE.jsx)(W_,{})]}),v]})})}};function eeT({showDialogCloseButton:e=!1}){let{type:t}=W6(),r=eek[Ww[t].chrome];return(0,rE.jsx)(r,{showDialogCloseButton:e})}let eeR=0;function eeD(e){return{layoutReady:!1,placementReady:!1,materialReady:"artwork-src"===e.materialSource,artifactsReady:!1,assetsReady:!1,prepareReady:!1}}let eeP=[];function ee_(e,t,r){if(t===r)return e;let n=new Set(t.map(e=>e.id)),i=new Set(r.map(e=>e.id)),a=e.filter(e=>!n.has(e.id)&&!i.has(e.id));return a.length>0?[...a,...r]:r}function eeL({children:e,src:t,tinuuid:r,roomId:n,type:i,viewerSurface:a,dialogPortalContainer:s=null,viewerDialogOpen:o=!0,onViewerDialogOpenChange:l,width:c,height:u,displayUnit:d,name:h,apiKey:p,baseURL:f,source:A,externalWidgetSession:g}){var m,v;let b=function(){let{t:e}=sf();return(0,rx.useMemo)(()=>[{value:.025,label:`2.5 ${e("units.cm")}`},{value:.05,label:`5 ${e("units.cm")}`}],[e])}(),y=q$(d),w=function(){let{i18n:e}=sf();return"ru"===(e.resolvedLanguage??e.language)?"ru":"en"}(),x=qU(i),C="immersive-room"===Ww[i].chrome&&n?.trim()||void 0,E="finish"===Ww[i].materialRole,{offersSizeVariants:S}=qO(i),M="floor-room-presets"===Ww[i].roomPresets?qR:qT,I=VL({apiKey:p,baseURL:f,source:A}),[B,k]=(0,rx.useState)(r),[T,R]=(0,rx.useState)(null),D=(0,rx.useCallback)(e=>{R(null),k(e)},[]),P=(0,rx.useCallback)(e=>{R(e),k(e)},[]),[_,L]=(0,rx.useState)(null),[N,F]=(0,rx.useState)(b[0].value),[O,Q]=(0,rx.useState)(y[0].value),[U,z]=(0,rx.useState)(0),[j,G]=(0,rx.useState)(0),[H,V]=(0,rx.useState)(!1),[W,q]=(0,rx.useState)(null),[K,J]=(0,rx.useState)(()=>eeD(x)),[Y,X]=(0,rx.useState)(!1),[Z,$]=(0,rx.useState)(null),[ee,et]=(0,rx.useState)(null),er=(0,rx.useRef)(null),en=(0,rx.useRef)(new Set),ei=(0,rx.useRef)(null),ea=(0,rx.useRef)(!0),es=(0,rx.useRef)(!1),eo="object-glb"===x.materialSource,el="default"===A&&void 0!==p,ec=VF("wall-panel"===(m={apiKey:p,baseURL:f,source:A,resourceType:i}).resourceType?m:{...m,resourceType:void 0}),eu=od({queryKey:["room-viewer","activate",{apiKey:p??null,source:A,resourceType:i}],enabled:el,queryFn:({signal:e})=>V2(ec.query,{...ec.config,baseURL:f,headers:{"x-api-key":p},signal:e})},s2,void 0),ed=VO(eu.error),eh=(0,rx.useMemo)(()=>{let e=eu.data;return Wu(e?.widgetSession,{apiConfig:{baseURL:f,headers:{"x-api-key":p}}})},[eu.data,p,f]),ep=(0,rx.useMemo)(()=>g instanceof Wc?g:Wu(g,{apiConfig:{baseURL:f,headers:{"x-api-key":p}}})??eh,[eh,p,f,g]),ef="shopify"===A?null!==ep:el&&eu.isSuccess,eA=od({queryKey:["room-viewer","rooms",{apiKey:(v={apiKey:p,baseURL:f,language:w,source:A,widgetSession:ep,resourceType:i}).apiKey??null,language:v.language??null,source:v.source,resourceType:v.resourceType??null,widgetSessionId:v.widgetSession?.sid??null}],enabled:I&&ef,queryFn:async({signal:e})=>{try{return await Wb({apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}catch(e){if(VO(e))throw e;return[]}}},s2,void 0),eg=I?eA.data??eeP:M,[em,ev]=(0,rx.useState)(()=>({rooms:eg,sourceRooms:eg})),eb=(0,rx.useMemo)(()=>ee_(em.rooms,em.sourceRooms,eg),[em.rooms,em.sourceRooms,eg]),ey=(0,rx.useCallback)(e=>{ev(t=>{let r=ee_(t.rooms,t.sourceRooms,eg);return{rooms:"function"==typeof e?e(r):e,sourceRooms:eg}})},[eg]),[ew,ex]=(0,rx.useState)(()=>C??M[0].id),[eC,eE]=(0,rx.useState)(C);eC!==C&&(eE(C),C&&(ex(C),z(0),G(0),J(eeD(x)),et(e=>"room-load-failed"===e?null:e)));let eS=eb.find(e=>e.id===ew),eM=eS??eb[0]??M[0],eI="rotate-on-floor"===Ww[i].manipulation;(0,rx.useEffect)(()=>{eI&&G(0)},[eI,eM.id]);let eB=eb.length>0;!eS&&eb[0]&&ew!==eb[0].id&&ex(eb[0].id);let ek=!el||eu.isSuccess||eu.isError&&null===ed,eT=od({queryKey:Wf(r??void 0,{apiKey:p,baseURL:f,language:w,source:A,resourceType:i}),enabled:ek&&eo&&null===_&&!!r,queryFn:async({signal:e})=>{if(!r)throw Error("Tinuuid is required.");return Wg(r,{apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}},s2,void 0),eR=od({queryKey:Wf(B??void 0,{apiKey:p,baseURL:f,language:w,source:A,resourceType:i}),enabled:ek&&eo&&!!B,placeholderData:t4,queryFn:async({signal:e})=>{if(!B)throw Error("Tinuuid is required.");return Wg(B,{apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}},s2,void 0),eD=eT.data??null,eP=eR.data??null,e_=eD?.materials?.[0]??null,eL=_?.native?.glbUrl??null,eN=VO(eT.error),eF=VO(eA.error),eO=I&&("shopify"===A?null===ep||eA.isLoading:eu.isSuccess&&eA.isLoading),eQ=el&&eu.isLoading||eO,eU=eu.error&&null===ed?"viewer-load-failed":null,ez=eT.error&&null===eN?"viewer-load-failed":null,ej="artwork-src"===x.materialSource&&("string"!=typeof t||0===t.trim().length)?"artwork-load-failed":null,eG=eo&&!eQ&&(!r||eT.isSuccess&&null===e_||null!==_&&null===eL)?"viewer-load-failed":null,eH=null!==T&&T===B&&(eR.isError||eR.isSuccess&&eP?.tinuuid===B&&!eP.materials?.[0]?.native?.glbUrl)?"viewer-load-failed":null,eV=Z??ed??eF??eN,eW=ee??eH??eU??ez??eG??ej,eq=(0,rx.useCallback)(e=>{J(t=>Object.assign({},t,e))},[]);(0,rx.useEffect)(()=>{let e=new Set(eb.map(e=>e.image_url));for(let t of Array.from(en.current))e.has(t)||(URL.revokeObjectURL(t),en.current.delete(t))},[eb]),(0,rx.useEffect)(()=>{let e=en.current;return ea.current=!0,()=>{for(let t of(ea.current=!1,ei.current?.abort(),Array.from(e)))URL.revokeObjectURL(t);e.clear()}},[]);let eK=(0,rx.useCallback)(async e=>{let t=null,r=new AbortController;ei.current?.abort(),ei.current=r,X(!0);try{t=URL.createObjectURL(e);let n=await eeu(e,{resourceType:i,apiKey:p,baseURL:f,source:A,signal:r.signal,widgetSession:ep});if(r.signal.aborted||!ea.current)return void URL.revokeObjectURL(t);eeh()&&eep(n,e.name).catch(e=>{console.error("Failed to export room debug mask",e)});let a={id:(eeR+=1,`room-custom-${eeR}`),name:e.name,image_url:t,scene:n};en.current.add(t),eq({placementReady:!1,prepareReady:!1,artifactsReady:!1,assetsReady:!1}),ey(e=>[a,...e]),ex(a.id)}catch(n){if(t&&URL.revokeObjectURL(t),r.signal.aborted)return;let e=VO(n);if(e)return void $(e);console.error("Failed to prepare custom room scene",n)}finally{ei.current===r&&(ei.current=null,ea.current&&X(!1))}},[p,f,eq,ey,A,i,ep]);(0,rx.useEffect)(()=>{if("dialog"!==a||!o){es.current=!1;return}es.current||ep&&(Wd(ep,"widget_opened"),es.current=!0)},[o,a,ep]),(0,rx.useEffect)(()=>{eo&&(D(r),L(null),$(null),et(null))},[r,D,eo]),(0,rx.useEffect)(()=>{$(null),et(null)},[p,A]),(0,rx.useEffect)(()=>{eo&&eD&&null===_&&L(e_)},[_,e_,eD,eo]),(0,rx.useEffect)(()=>{if(!eo||!S&&!E&&T!==B||null===eP||eP.tinuuid!==B)return;let e=eP.materials?.[0];if(!e)return;let t=eP.materials?.some(e=>e===_||!!e.hid&&e.hid===_?.hid);if(T===B){R(null),L(e);return}(!t||E)&&_!==e&&L(e)},[E,_,S,eP,B,eo,T]);let eJ=(0,rx.useMemo)(()=>({type:i,name:h,width:c,height:u,displayUnit:d}),[i,h,c,u,d]),eY=(0,rx.useMemo)(()=>({viewerSurface:a,dialogPortalContainer:s,viewerDialogOpen:o,onViewerDialogOpenChange:l}),[a,s,o,l]),eX=(0,rx.useMemo)(()=>({rooms:eb,sourceRooms:eg,setRooms:ey,room:eM,initialRoomId:C,setRoomId:ex}),[eb,eM,C,ey,eg]),eZ=(0,rx.useMemo)(()=>({src:t,glbUrl:eL,tinuuid:B,embeddedObject:eD,selectedObject:eP,material:_,setTinuuid:D,selectResourceVariant:P,setMaterial:L,apiKey:p,baseURL:f,language:w,source:A,widgetSession:ep,hasRooms:eB,isViewerAccessPending:eQ,accessError:eV,setAccessError:$,loadError:eW,setLoadError:et}),[t,eL,B,eD,eP,_,D,P,p,f,w,A,ep,eB,eQ,eV,eW]),e$=(0,rx.useMemo)(()=>({containerRef:W,setContainerRef:q,resourceRef:er,angle:U,setAngle:z,rotation:j,setRotation:G,isDragging:H,setIsDragging:V,sceneLoad:K,patchSceneLoad:eq,isRoomScenePending:Y,setIsRoomScenePending:X}),[W,U,j,H,K,eq,Y]),e0=(0,rx.useMemo)(()=>({frameWidth:N,setFrameWidth:F,matting:O,setMatting:Q}),[N,O]),e1=(0,rx.useMemo)(()=>({isRoomScenePending:Y,selectCustomRoomFile:eK}),[Y,eK]);return(0,rE.jsx)(W0,{value:eJ,children:(0,rE.jsx)(W1,{value:eY,children:(0,rE.jsx)(W2,{value:eX,children:(0,rE.jsx)(W3,{value:eZ,children:(0,rE.jsx)(W9,{value:e$,children:(0,rE.jsx)(W4,{value:e0,children:(0,rE.jsx)(W5,{value:e1,children:(0,rE.jsx)(ZI,{children:e})})})})})})})})}let eeN={poster:"wallart",carpet:"rugs"};function eeF(e){return"poster"===e||"carpet"===e}let eeO=new rw({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(ix(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function eeQ({type:e,src:t,tinuuid:r,roomId:n,name:i,height:a,width:s,language:o,dimensionUnit:l="m",displayUnit:c="cm",apiKey:u,source:d="default",showDialogCloseButton:h=!1,viewerSurface:p="inline",dialogPortalContainer:f=null,viewerDialogOpen:A=!0,onViewerDialogOpenChange:g,widgetSession:m}){let{i18n:v}=sf(),b=u?.trim()||void 0,y=r?.trim()||void 0,w=eeF(e)?eeN[e]:e,x=qU(w).takesDimensionProps?function(e,t,r="m"){return{width:qX(e??0,r),height:qX(t??0,r)}}(s,a,l):null;return(0,rx.useEffect)(()=>{eeF(e)&&eeN[e]},[e]),(0,rx.useEffect)(()=>{"string"==typeof o&&v.changeLanguage(o)},[v,o]),(0,rE.jsx)(rI,{client:eeO,children:(0,rE.jsx)(eeL,{src:t??null,tinuuid:y??null,roomId:n,type:w,viewerSurface:p,dialogPortalContainer:f,viewerDialogOpen:A,onViewerDialogOpenChange:g,name:i,width:x?.width??0,height:x?.height??0,displayUnit:c,apiKey:b,baseURL:"shopify"===d?V_:void 0,source:d,externalWidgetSession:m,children:(0,rE.jsx)(eeT,{showDialogCloseButton:h})})})}function eeU({type:e,src:t,tinuuid:r,roomId:n,width:i,height:a,dimensionUnit:s,displayUnit:o,name:l,language:c,apiKey:u,source:d,widgetSession:h,disableClose:p=!1,open:f,defaultOpen:A,onOpenChange:g}){let[m,v]=(0,rx.useState)(null),b="immersive-room"===Ww[eeF(e)?eeN[e]:e].chrome&&p,[y,w]=(0,rx.useState)(A??!1),x=f??y,[C,E]=(0,rx.useState)(x),S=x||C;(0,rx.useEffect)(()=>{x&&E(!0)},[x]);let M=(0,rE.jsx)(eeQ,{type:e,src:t,tinuuid:r,roomId:n,name:l,height:a,width:i,dimensionUnit:s,displayUnit:o,language:c,apiKey:u,source:d,widgetSession:h,showDialogCloseButton:!b,viewerSurface:"dialog",dialogPortalContainer:m,viewerDialogOpen:x,onViewerDialogOpenChange:function(e){(e||!b)&&(void 0===f&&w(e),g?.(e))}});return(0,rE.jsxs)(rE.Fragment,{children:[(0,am.createPortal)((0,rE.jsx)("style",{children:VI.A}),document.head),(0,am.createPortal)((0,rE.jsxs)(s_.div,{"data-neurodyn-room-viewer-root":"",style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,rE.jsx)("style",{children:":host{display:block!important;visibility:visible!important}"}),(0,rE.jsx)("style",{children:VD}),(0,rE.jsx)("div",{ref:v}),m&&(0,rE.jsx)(VM,{root:m,storageKey:"neurodyn-theme",defaultTheme:"light",children:(0,rE.jsx)(sA,{i18n:Vk,children:S&&M})})]}),document.body)]})}Wt({baseURL:"https://api.neurodyn.ai/v1/"}),VY({baseURL:"https://api.neurodyn.ai/"});let eez=iQ({clientName:"API node client",configureFunctionName:"configureNodeApiClient",defaultBaseURL:"https://api.vizbl.com"});eez.configureClientRuntime,eez.configureAccessTokenResolverRuntime,eez.configureHeadersResolverRuntime,eez.configureUnauthorizedHandlerRuntime,eez.isClientConfiguredRuntime,eez.assertClientConfiguredRuntime,eez.resetClientForTestsRuntime;let eej=eez.requestRuntime;async function eeG(e){return eej(e)}async function eeH(e,t={}){let{client:r=eeG,...n}=t;return(await r({method:"POST",url:"/public/widget/activate-wallart",params:e,...n})).data}eez.requestWithoutUnauthorizedRecovery,eez.addResponseInterceptorRuntime,(eJ=tP||(tP={})).assertEqual=e=>{},eJ.assertIs=function(e){},eJ.assertNever=function(e){throw Error()},eJ.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},eJ.getValidEnumValues=e=>{let t=eJ.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let n of t)r[n]=e[n];return eJ.objectValues(r)},eJ.objectValues=e=>eJ.objectKeys(e).map(function(t){return e[t]}),eJ.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},eJ.find=(e,t)=>{for(let r of e)if(t(r))return r},eJ.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,eJ.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},eJ.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(t_||(t_={})).mergeShapes=(e,t)=>({...e,...t});let eeV=tP.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),eeW=e=>{switch(typeof e){case"undefined":return eeV.undefined;case"string":return eeV.string;case"number":return Number.isNaN(e)?eeV.nan:eeV.number;case"boolean":return eeV.boolean;case"function":return eeV.function;case"bigint":return eeV.bigint;case"symbol":return eeV.symbol;case"object":if(Array.isArray(e))return eeV.array;if(null===e)return eeV.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return eeV.promise;if("u">typeof Map&&e instanceof Map)return eeV.map;if("u">typeof Set&&e instanceof Set)return eeV.set;if("u">typeof Date&&e instanceof Date)return eeV.date;return eeV.object;default:return eeV.unknown}},eeq=tP.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class eeK extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;n<i.path.length;){let r=i.path[n];n===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof eeK))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tP.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}eeK.create=e=>new eeK(e);let eeJ=(e,t)=>{let r;switch(e.code){case eeq.invalid_type:r=e.received===eeV.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case eeq.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,tP.jsonStringifyReplacer)}`;break;case eeq.unrecognized_keys:r=`Unrecognized key(s) in object: ${tP.joinValues(e.keys,", ")}`;break;case eeq.invalid_union:r="Invalid input";break;case eeq.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${tP.joinValues(e.options)}`;break;case eeq.invalid_enum_value:r=`Invalid enum value. Expected ${tP.joinValues(e.options)}, received '${e.received}'`;break;case eeq.invalid_arguments:r="Invalid function arguments";break;case eeq.invalid_return_type:r="Invalid function return type";break;case eeq.invalid_date:r="Invalid date";break;case eeq.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:tP.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case eeq.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case eeq.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case eeq.custom:r="Invalid input";break;case eeq.invalid_intersection_types:r="Intersection results could not be merged";break;case eeq.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case eeq.not_finite:r="Number must be finite";break;default:r=t.defaultError,tP.assertNever(e)}return{message:r}};(eY=tL||(tL={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},eY.toString=e=>"string"==typeof e?e:e?.message;let eeY=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],s={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(s,{data:t,defaultError:o}).message;return{...i,path:a,message:o}};function eeX(e,t){let r=eeY({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,eeJ,void 0].filter(e=>!!e)});e.common.issues.push(r)}class eeZ{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return ee$;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return eeZ.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:i}=n;if("aborted"===t.status||"aborted"===i.status)return ee$;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||n.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let ee$=Object.freeze({status:"aborted"}),ee0=e=>({status:"dirty",value:e}),ee1=e=>({status:"valid",value:e}),ee2=e=>"u">typeof Promise&&e instanceof Promise;class ee3{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let ee9=(e,t)=>{if("valid"===t.status)return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new eeK(e.common.issues);return this._error=t,this._error}}};function ee4(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??i.defaultError}:void 0===i.data?{message:a??n??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:a??r??i.defaultError}},description:i}}class ee5{get description(){return this._def.description}_getType(e){return eeW(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:eeW(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new eeZ,ctx:{common:e.parent.common,data:e.data,parsedType:eeW(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ee2(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeW(e)},n=this._parseSync({data:e,path:r.path,parent:r});return ee9(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeW(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return"valid"===r.status?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>"valid"===e.status?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeW(e)},n=this._parse({data:e,path:r.path,parent:r});return ee9(r,await (ee2(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((r,n)=>{let i=e(r),a=()=>n.addIssue({code:eeq.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new etG({schema:this,typeName:tN.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return etH.create(this,this._def)}nullable(){return etV.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return etM.create(this)}promise(){return etj.create(this,this._def)}or(e){return etB.create([this,e],this._def)}and(e){return etR.create(this,e,this._def)}transform(e){return new etG({...ee4(this._def),schema:this,typeName:tN.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new etW({...ee4(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:tN.ZodDefault})}brand(){return new etJ({typeName:tN.ZodBranded,type:this,...ee4(this._def)})}catch(e){return new etq({...ee4(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:tN.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return etY.create(this,e)}readonly(){return etX.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let ee8=/^c[^\s-]{8,}$/i,ee6=/^[0-9a-z]+$/,ee7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ete=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ett=/^[a-z0-9_-]{21}$/i,etr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,etn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,eti=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eta=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ets=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,eto=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,etl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,etc=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,etu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,etd="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",eth=RegExp(`^${etd}$`);function etp(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}class etf extends ee5{_parse(e){var t,r,n,i;let a;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==eeV.string){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.string,received:t.parsedType}),ee$}let s=new eeZ;for(let o of this._def.checks)if("min"===o.kind)e.data.length<o.value&&(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if("max"===o.kind)e.data.length>o.value&&(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if("length"===o.kind){let t=e.data.length>o.value,r=e.data.length<o.value;(t||r)&&(a=this._getOrReturnCtx(e,a),t?eeX(a,{code:eeq.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):r&&eeX(a,{code:eeq.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if("email"===o.kind)eti.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"email",code:eeq.invalid_string,message:o.message}),s.dirty());else if("emoji"===o.kind)I||(I=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),I.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:eeq.invalid_string,message:o.message}),s.dirty());else if("uuid"===o.kind)ete.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:eeq.invalid_string,message:o.message}),s.dirty());else if("nanoid"===o.kind)ett.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:eeq.invalid_string,message:o.message}),s.dirty());else if("cuid"===o.kind)ee8.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:eeq.invalid_string,message:o.message}),s.dirty());else if("cuid2"===o.kind)ee6.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:eeq.invalid_string,message:o.message}),s.dirty());else if("ulid"===o.kind)ee7.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:eeq.invalid_string,message:o.message}),s.dirty());else if("url"===o.kind)try{new URL(e.data)}catch{eeX(a=this._getOrReturnCtx(e,a),{validation:"url",code:eeq.invalid_string,message:o.message}),s.dirty()}else"regex"===o.kind?(o.regex.lastIndex=0,o.regex.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"regex",code:eeq.invalid_string,message:o.message}),s.dirty())):"trim"===o.kind?e.data=e.data.trim():"includes"===o.kind?e.data.includes(o.value,o.position)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.dirty()):"toLowerCase"===o.kind?e.data=e.data.toLowerCase():"toUpperCase"===o.kind?e.data=e.data.toUpperCase():"startsWith"===o.kind?e.data.startsWith(o.value)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):"endsWith"===o.kind?e.data.endsWith(o.value)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):"datetime"===o.kind?(function(e){let t=`${etd}T${etp(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)})(o).test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:"datetime",message:o.message}),s.dirty()):"date"===o.kind?eth.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:"date",message:o.message}),s.dirty()):"time"===o.kind?RegExp(`^${etp(o)}$`).test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{code:eeq.invalid_string,validation:"time",message:o.message}),s.dirty()):"duration"===o.kind?etn.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"duration",code:eeq.invalid_string,message:o.message}),s.dirty()):"ip"===o.kind?(t=e.data,!(("v4"===(r=o.version)||!r)&&eta.test(t)||("v6"===r||!r)&&eto.test(t))&&1&&(eeX(a=this._getOrReturnCtx(e,a),{validation:"ip",code:eeq.invalid_string,message:o.message}),s.dirty())):"jwt"===o.kind?!function(e,t){if(!etr.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,o.alg)&&(eeX(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:eeq.invalid_string,message:o.message}),s.dirty()):"cidr"===o.kind?(n=e.data,!(("v4"===(i=o.version)||!i)&&ets.test(n)||("v6"===i||!i)&&etl.test(n))&&1&&(eeX(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:eeq.invalid_string,message:o.message}),s.dirty())):"base64"===o.kind?etc.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"base64",code:eeq.invalid_string,message:o.message}),s.dirty()):"base64url"===o.kind?etu.test(e.data)||(eeX(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:eeq.invalid_string,message:o.message}),s.dirty()):tP.assertNever(o);return{status:s.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:eeq.invalid_string,...tL.errToObj(r)})}_addCheck(e){return new etf({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tL.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tL.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tL.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tL.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tL.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tL.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tL.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tL.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tL.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tL.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tL.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tL.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tL.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tL.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tL.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tL.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tL.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tL.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tL.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tL.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tL.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tL.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tL.errToObj(t)})}nonempty(e){return this.min(1,tL.errToObj(e))}trim(){return new etf({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new etf({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new etf({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}etf.create=e=>new etf({checks:[],typeName:tN.ZodString,coerce:e?.coerce??!1,...ee4(e)});class etA extends ee5{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==eeV.number){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.number,received:t.parsedType}),ee$}let r=new eeZ;for(let n of this._def.checks)"int"===n.kind?tP.isInteger(e.data)||(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,n.value)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.not_finite,message:n.message}),r.dirty()):tP.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tL.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tL.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tL.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tL.toString(t))}setLimit(e,t,r,n){return new etA({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tL.toString(n)}]})}_addCheck(e){return new etA({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tL.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tL.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tL.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tL.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tL.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tL.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tL.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tL.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tL.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tP.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}etA.create=e=>new etA({checks:[],typeName:tN.ZodNumber,coerce:e?.coerce||!1,...ee4(e)});class etg extends ee5{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==eeV.bigint)return this._getInvalidInput(e);let r=new eeZ;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):tP.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.bigint,received:t.parsedType}),ee$}gte(e,t){return this.setLimit("min",e,!0,tL.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tL.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tL.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tL.toString(t))}setLimit(e,t,r,n){return new etg({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tL.toString(n)}]})}_addCheck(e){return new etg({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tL.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tL.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tL.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tL.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tL.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}etg.create=e=>new etg({checks:[],typeName:tN.ZodBigInt,coerce:e?.coerce??!1,...ee4(e)});class etm extends ee5{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==eeV.boolean){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.boolean,received:t.parsedType}),ee$}return ee1(e.data)}}etm.create=e=>new etm({typeName:tN.ZodBoolean,coerce:e?.coerce||!1,...ee4(e)});class etv extends ee5{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==eeV.date){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.date,received:t.parsedType}),ee$}if(Number.isNaN(e.data.getTime()))return eeX(this._getOrReturnCtx(e),{code:eeq.invalid_date}),ee$;let r=new eeZ;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(eeX(t=this._getOrReturnCtx(e,t),{code:eeq.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):tP.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new etv({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tL.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tL.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}etv.create=e=>new etv({checks:[],coerce:e?.coerce||!1,typeName:tN.ZodDate,...ee4(e)});class etb extends ee5{_parse(e){if(this._getType(e)!==eeV.symbol){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.symbol,received:t.parsedType}),ee$}return ee1(e.data)}}etb.create=e=>new etb({typeName:tN.ZodSymbol,...ee4(e)});class ety extends ee5{_parse(e){if(this._getType(e)!==eeV.undefined){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.undefined,received:t.parsedType}),ee$}return ee1(e.data)}}ety.create=e=>new ety({typeName:tN.ZodUndefined,...ee4(e)});class etw extends ee5{_parse(e){if(this._getType(e)!==eeV.null){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.null,received:t.parsedType}),ee$}return ee1(e.data)}}etw.create=e=>new etw({typeName:tN.ZodNull,...ee4(e)});class etx extends ee5{constructor(){super(...arguments),this._any=!0}_parse(e){return ee1(e.data)}}etx.create=e=>new etx({typeName:tN.ZodAny,...ee4(e)});class etC extends ee5{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee1(e.data)}}etC.create=e=>new etC({typeName:tN.ZodUnknown,...ee4(e)});class etE extends ee5{_parse(e){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.never,received:t.parsedType}),ee$}}etE.create=e=>new etE({typeName:tN.ZodNever,...ee4(e)});class etS extends ee5{_parse(e){if(this._getType(e)!==eeV.undefined){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.void,received:t.parsedType}),ee$}return ee1(e.data)}}etS.create=e=>new etS({typeName:tN.ZodVoid,...ee4(e)});class etM extends ee5{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==eeV.array)return eeX(t,{code:eeq.invalid_type,expected:eeV.array,received:t.parsedType}),ee$;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(e||i)&&(eeX(t,{code:e?eeq.too_big:eeq.too_small,minimum:i?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(eeX(t,{code:eeq.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(eeX(t,{code:eeq.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new ee3(t,e,t.path,r)))).then(e=>eeZ.mergeArray(r,e));let i=[...t.data].map((e,r)=>n.type._parseSync(new ee3(t,e,t.path,r)));return eeZ.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new etM({...this._def,minLength:{value:e,message:tL.toString(t)}})}max(e,t){return new etM({...this._def,maxLength:{value:e,message:tL.toString(t)}})}length(e,t){return new etM({...this._def,exactLength:{value:e,message:tL.toString(t)}})}nonempty(e){return this.min(1,e)}}etM.create=(e,t)=>new etM({type:e,minLength:null,maxLength:null,exactLength:null,typeName:tN.ZodArray,...ee4(t)});class etI extends ee5{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tP.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==eeV.object){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.object,received:t.parsedType}),ee$}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof etE&&"strip"===this._def.unknownKeys))for(let e in r.data)i.includes(e)||a.push(e);let s=[];for(let e of i){let t=n[e],i=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ee3(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof etE){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(eeX(r,{code:eeq.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ee3(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of s){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>eeZ.mergeObjectSync(t,e)):eeZ.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return tL.errToObj,new etI({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tL.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new etI({...this._def,unknownKeys:"strip"})}passthrough(){return new etI({...this._def,unknownKeys:"passthrough"})}extend(e){return new etI({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new etI({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:tN.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new etI({...this._def,catchall:e})}pick(e){let t={};for(let r of tP.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new etI({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tP.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new etI({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof etI){let r={};for(let n in t.shape){let i=t.shape[n];r[n]=etH.create(e(i))}return new etI({...t._def,shape:()=>r})}if(t instanceof etM)return new etM({...t._def,type:e(t.element)});if(t instanceof etH)return etH.create(e(t.unwrap()));if(t instanceof etV)return etV.create(e(t.unwrap()));if(t instanceof etD)return etD.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tP.objectKeys(this.shape)){let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new etI({...this._def,shape:()=>t})}required(e){let t={};for(let r of tP.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof etH;)e=e._def.innerType;t[r]=e}return new etI({...this._def,shape:()=>t})}keyof(){return etQ(tP.objectKeys(this.shape))}}etI.create=(e,t)=>new etI({shape:()=>e,unknownKeys:"strip",catchall:etE.create(),typeName:tN.ZodObject,...ee4(t)}),etI.strictCreate=(e,t)=>new etI({shape:()=>e,unknownKeys:"strict",catchall:etE.create(),typeName:tN.ZodObject,...ee4(t)}),etI.lazycreate=(e,t)=>new etI({shape:e,unknownKeys:"strip",catchall:etE.create(),typeName:tN.ZodObject,...ee4(t)});class etB extends ee5{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new eeK(e.ctx.common.issues));return eeX(t,{code:eeq.invalid_union,unionErrors:r}),ee$});{let e,n=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=n.map(e=>new eeK(e));return eeX(t,{code:eeq.invalid_union,unionErrors:i}),ee$}}get options(){return this._def.options}}etB.create=(e,t)=>new etB({options:e,typeName:tN.ZodUnion,...ee4(t)});let etk=e=>{if(e instanceof etF)return etk(e.schema);if(e instanceof etG)return etk(e.innerType());if(e instanceof etO)return[e.value];if(e instanceof etU)return e.options;if(e instanceof etz)return tP.objectValues(e.enum);else if(e instanceof etW)return etk(e._def.innerType);else if(e instanceof ety)return[void 0];else if(e instanceof etw)return[null];else if(e instanceof etH)return[void 0,...etk(e.unwrap())];else if(e instanceof etV)return[null,...etk(e.unwrap())];else if(e instanceof etJ)return etk(e.unwrap());else if(e instanceof etX)return etk(e.unwrap());else if(e instanceof etq)return etk(e._def.innerType);else return[]};class etT extends ee5{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==eeV.object)return eeX(t,{code:eeq.invalid_type,expected:eeV.object,received:t.parsedType}),ee$;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(eeX(t,{code:eeq.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ee$)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let r of t){let t=etk(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,r)}}return new etT({typeName:tN.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...ee4(r)})}}class etR extends ee5{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if("aborted"===e.status||"aborted"===n.status)return ee$;let i=function e(t,r){let n=eeW(t),i=eeW(r);if(t===r)return{valid:!0,data:t};if(n===eeV.object&&i===eeV.object){let n=tP.objectKeys(r),i=tP.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...r};for(let n of i){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===eeV.array&&i===eeV.array){if(t.length!==r.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let a=e(t[i],r[i]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}if(n===eeV.date&&i===eeV.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return i.valid?(("dirty"===e.status||"dirty"===n.status)&&t.dirty(),{status:t.value,value:i.data}):(eeX(r,{code:eeq.invalid_intersection_types}),ee$)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}etR.create=(e,t,r)=>new etR({left:e,right:t,typeName:tN.ZodIntersection,...ee4(r)});class etD extends ee5{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeV.array)return eeX(r,{code:eeq.invalid_type,expected:eeV.array,received:r.parsedType}),ee$;if(r.data.length<this._def.items.length)return eeX(r,{code:eeq.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee$;!this._def.rest&&r.data.length>this._def.items.length&&(eeX(r,{code:eeq.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new ee3(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>eeZ.mergeArray(t,e)):eeZ.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new etD({...this._def,rest:e})}}etD.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new etD({items:e,typeName:tN.ZodTuple,rest:null,...ee4(t)})};class etP extends ee5{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeV.object)return eeX(r,{code:eeq.invalid_type,expected:eeV.object,received:r.parsedType}),ee$;let n=[],i=this._def.keyType,a=this._def.valueType;for(let e in r.data)n.push({key:i._parse(new ee3(r,e,r.path,e)),value:a._parse(new ee3(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?eeZ.mergeObjectAsync(t,n):eeZ.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new etP(t instanceof ee5?{keyType:e,valueType:t,typeName:tN.ZodRecord,...ee4(r)}:{keyType:etf.create(),valueType:e,typeName:tN.ZodRecord,...ee4(t)})}}class et_ extends ee5{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeV.map)return eeX(r,{code:eeq.invalid_type,expected:eeV.map,received:r.parsedType}),ee$;let n=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new ee3(r,e,r.path,[a,"key"])),value:i._parse(new ee3(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return ee$;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return ee$;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}et_.create=(e,t,r)=>new et_({valueType:t,keyType:e,typeName:tN.ZodMap,...ee4(r)});class etL extends ee5{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeV.set)return eeX(r,{code:eeq.invalid_type,expected:eeV.set,received:r.parsedType}),ee$;let n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(eeX(r,{code:eeq.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(eeX(r,{code:eeq.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let r=new Set;for(let n of e){if("aborted"===n.status)return ee$;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let s=[...r.data.values()].map((e,t)=>i._parse(new ee3(r,e,r.path,t)));return r.common.async?Promise.all(s).then(e=>a(e)):a(s)}min(e,t){return new etL({...this._def,minSize:{value:e,message:tL.toString(t)}})}max(e,t){return new etL({...this._def,maxSize:{value:e,message:tL.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}etL.create=(e,t)=>new etL({valueType:e,minSize:null,maxSize:null,typeName:tN.ZodSet,...ee4(t)});class etN extends ee5{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==eeV.function)return eeX(t,{code:eeq.invalid_type,expected:eeV.function,received:t.parsedType}),ee$;function r(e,r){return eeY({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,eeJ,eeJ].filter(e=>!!e),issueData:{code:eeq.invalid_arguments,argumentsError:r}})}function n(e,r){return eeY({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,eeJ,eeJ].filter(e=>!!e),issueData:{code:eeq.invalid_return_type,returnTypeError:r}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof etj){let e=this;return ee1(async function(...t){let s=new eeK([]),o=await e._def.args.parseAsync(t,i).catch(e=>{throw s.addIssue(r(t,e)),s}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,i).catch(e=>{throw s.addIssue(n(l,e)),s})})}{let e=this;return ee1(function(...t){let s=e._def.args.safeParse(t,i);if(!s.success)throw new eeK([r(t,s.error)]);let o=Reflect.apply(a,this,s.data),l=e._def.returns.safeParse(o,i);if(!l.success)throw new eeK([n(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new etN({...this._def,args:etD.create(e).rest(etC.create())})}returns(e){return new etN({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new etN({args:e||etD.create([]).rest(etC.create()),returns:t||etC.create(),typeName:tN.ZodFunction,...ee4(r)})}}class etF extends ee5{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}etF.create=(e,t)=>new etF({getter:e,typeName:tN.ZodLazy,...ee4(t)});class etO extends ee5{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return eeX(t,{received:t.data,code:eeq.invalid_literal,expected:this._def.value}),ee$}return{status:"valid",value:e.data}}get value(){return this._def.value}}function etQ(e,t){return new etU({values:e,typeName:tN.ZodEnum,...ee4(t)})}etO.create=(e,t)=>new etO({value:e,typeName:tN.ZodLiteral,...ee4(t)});class etU extends ee5{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return eeX(t,{expected:tP.joinValues(r),received:t.parsedType,code:eeq.invalid_type}),ee$}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return eeX(t,{received:t.data,code:eeq.invalid_enum_value,options:r}),ee$}return ee1(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return etU.create(e,{...this._def,...t})}exclude(e,t=this._def){return etU.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}etU.create=etQ;class etz extends ee5{_parse(e){let t=tP.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==eeV.string&&r.parsedType!==eeV.number){let e=tP.objectValues(t);return eeX(r,{expected:tP.joinValues(e),received:r.parsedType,code:eeq.invalid_type}),ee$}if(this._cache||(this._cache=new Set(tP.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tP.objectValues(t);return eeX(r,{received:r.data,code:eeq.invalid_enum_value,options:e}),ee$}return ee1(e.data)}get enum(){return this._def.values}}etz.create=(e,t)=>new etz({values:e,typeName:tN.ZodNativeEnum,...ee4(t)});class etj extends ee5{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==eeV.promise&&!1===t.common.async?(eeX(t,{code:eeq.invalid_type,expected:eeV.promise,received:t.parsedType}),ee$):ee1((t.parsedType===eeV.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}etj.create=(e,t)=>new etj({type:e,typeName:tN.ZodPromise,...ee4(t)});class etG extends ee5{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===tN.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{eeX(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){let e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return ee$;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?ee$:"dirty"===n.status||"dirty"===t.value?ee0(n.value):n});{if("aborted"===t.value)return ee$;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?ee$:"dirty"===n.status||"dirty"===t.value?ee0(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?ee$:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?ee$:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>"valid"!==e.status?ee$:Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})));else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if("valid"!==e.status)return ee$;let a=n.transform(e.value,i);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}tP.assertNever(n)}}etG.create=(e,t,r)=>new etG({schema:e,typeName:tN.ZodEffects,effect:t,...ee4(r)}),etG.createWithPreprocess=(e,t,r)=>new etG({schema:t,effect:{type:"preprocess",transform:e},typeName:tN.ZodEffects,...ee4(r)});class etH extends ee5{_parse(e){return this._getType(e)===eeV.undefined?ee1(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}etH.create=(e,t)=>new etH({innerType:e,typeName:tN.ZodOptional,...ee4(t)});class etV extends ee5{_parse(e){return this._getType(e)===eeV.null?ee1(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}etV.create=(e,t)=>new etV({innerType:e,typeName:tN.ZodNullable,...ee4(t)});class etW extends ee5{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===eeV.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}etW.create=(e,t)=>new etW({innerType:e,typeName:tN.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ee4(t)});class etq extends ee5{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ee2(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new eeK(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new eeK(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}etq.create=(e,t)=>new etq({innerType:e,typeName:tN.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ee4(t)});class etK extends ee5{_parse(e){if(this._getType(e)!==eeV.nan){let t=this._getOrReturnCtx(e);return eeX(t,{code:eeq.invalid_type,expected:eeV.nan,received:t.parsedType}),ee$}return{status:"valid",value:e.data}}}etK.create=e=>new etK({typeName:tN.ZodNaN,...ee4(e)}),Symbol("zod_brand");class etJ extends ee5{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class etY extends ee5{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?ee$:"dirty"===e.status?(t.dirty(),ee0(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?ee$:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new etY({in:e,out:t,typeName:tN.ZodPipeline})}}class etX extends ee5{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return ee2(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}etX.create=(e,t)=>new etX({innerType:e,typeName:tN.ZodReadonly,...ee4(t)}),etI.lazycreate,(eX=tN||(tN={})).ZodString="ZodString",eX.ZodNumber="ZodNumber",eX.ZodNaN="ZodNaN",eX.ZodBigInt="ZodBigInt",eX.ZodBoolean="ZodBoolean",eX.ZodDate="ZodDate",eX.ZodSymbol="ZodSymbol",eX.ZodUndefined="ZodUndefined",eX.ZodNull="ZodNull",eX.ZodAny="ZodAny",eX.ZodUnknown="ZodUnknown",eX.ZodNever="ZodNever",eX.ZodVoid="ZodVoid",eX.ZodArray="ZodArray",eX.ZodObject="ZodObject",eX.ZodUnion="ZodUnion",eX.ZodDiscriminatedUnion="ZodDiscriminatedUnion",eX.ZodIntersection="ZodIntersection",eX.ZodTuple="ZodTuple",eX.ZodRecord="ZodRecord",eX.ZodMap="ZodMap",eX.ZodSet="ZodSet",eX.ZodFunction="ZodFunction",eX.ZodLazy="ZodLazy",eX.ZodLiteral="ZodLiteral",eX.ZodEnum="ZodEnum",eX.ZodEffects="ZodEffects",eX.ZodNativeEnum="ZodNativeEnum",eX.ZodOptional="ZodOptional",eX.ZodNullable="ZodNullable",eX.ZodDefault="ZodDefault",eX.ZodCatch="ZodCatch",eX.ZodPromise="ZodPromise",eX.ZodBranded="ZodBranded",eX.ZodPipeline="ZodPipeline",eX.ZodReadonly="ZodReadonly";let etZ=etf.create,et$=etA.create;etK.create,etg.create;let et0=etm.create;etv.create,etb.create,ety.create,etw.create,etx.create;let et1=etC.create;etE.create,etS.create,etM.create;let et2=etI.create;etI.strictCreate,etB.create,etT.create,etR.create,etD.create,etP.create,et_.create,etL.create,etN.create,etF.create,etO.create;let et3=etU.create;etz.create,etj.create,etG.create,etH.create,etV.create;let et9=etG.createWithPreprocess;etY.create;let et4=et3(["cm","inch"]),et5=et3(["different_fields","one_field"]),et8=et3(["left_bottom","center","right_bottom","left_center","right_center"]),et6=et2({buttonLabel:etZ(),backgroundColor:etZ(),borderColor:etZ(),textColor:etZ(),borderRadius:et$(),borderWidth:et$()}),et7=et2({units:et4,productWidthAndHeight:et5,metafieldForWidth:etZ().nullable(),metafieldForHeight:etZ().nullable(),metafieldForWidthAndHeight:etZ().nullable(),widgetPosition:et8,_widgetSettings:et6.optional(),isWidgetActive:et0()}),ere=function(e){let t=e?.trim().replace(/\/+$/,"")??"";if(!t||t.includes("/v1/http")||t.endsWith("/v1"))return t;let r=t.indexOf("/http");return r>=0?`${t.slice(0,r)}/v1${t.slice(r)}`:`${t}/v1`}("/apps/vizbl-wall-art/http"),ert=et2({token:etZ().trim().min(1),sid:etZ().trim().min(1),expiresIn:et$().finite()}),err=et2({metafields:etZ().trim().min(1),posterPic:etZ().trim().min(1),title:etZ().trim().optional(),widgetSession:et1().optional()}),ern=et9(e=>"string"==typeof e?JSON.parse(e):e,et2({metafield:et1(),tinuuid:etZ().trim().optional()}));async function eri(e,t){let r=await eeH({productType:"wallart-shopify",variant_id:e,metafield_key:"poster_settings"},{baseURL:ere,signal:t});return function(e){let t,r,n=err.safeParse("string"!=typeof e?e:JSON.parse(e));if(!n.success)return null;let i=ern.safeParse(n.data.metafields);if(!i.success)return null;let a=(t=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return}}(i.data.metafield),(r=et7.safeParse(t)).success?r.data:null);if(!a)return null;let s=ert.safeParse(n.data.widgetSession);return{settings:a,posterPic:n.data.posterPic,title:n.data.title??null,tinuuid:i.data.tinuuid??null,widgetSession:s.success?s.data:null}}(r.body??r)}let era="44px",ers="60px",ero={left_center:{left:ers,top:"50%",transform:"translateY(-50%)"},left_bottom:{left:ers,bottom:era},center:{left:`calc(50% + ${ers})`,bottom:era,transform:"translateX(-50%)"},right_bottom:{right:ers,bottom:era},right_center:{right:ers,top:"50%",transform:"translateY(-50%)"}},erl=et9(e=>"number"==typeof e&&Number.isFinite(e)?String(e):e,etZ().trim().regex(/^\d+$/));function erc(e){let t=erl.safeParse(e);return t.success?t.data:null}function eru(e){return e?e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.value:e.getAttribute("value"):null}let erd=["product-form","[data-main-product]",'[id*="MainProduct"]',".product",".product__info-wrapper",".product__info-container","#MainContent"],erh=[".product-recommendations",".related-products","[data-product-recommendations]"];var erp=r("./src/shopify.css?inline");function erf(){let e=function({documentRef:e=document,locationRef:t=window.location,analytics:r=window.ShopifyAnalytics}={}){var n;let i=e.body;if(i?.classList.contains("template-collection"))return!1;if(n=t.pathname,/(?:^|\/)products\/[^/]+/i.test(n)||r?.meta?.page?.pageType?.toLowerCase()==="product")return!0;let a=e.querySelector('meta[property="og:type"]')?.getAttribute("content");return!!(a?.trim().toLowerCase()==="product"||i?.classList.contains("template-product"))}();return{isProductPage:e,variantId:e?function({documentRef:e=document,locationRef:t=window.location}={}){return function(e=window.location){return erc(new URLSearchParams(e.search).get("variant"))}(t)??function(e=document){for(let{field:t}of Array.from(e.querySelectorAll('form[action*="/cart/add"]')).flatMap((t,r)=>{let n;return[...Array.from(t.querySelectorAll('input[name="id"], select[name="id"]')),...!(n=t.getAttribute("id"))?[]:Array.from(e.querySelectorAll('input[name="id"][form], select[name="id"][form]')).filter(e=>e.getAttribute("form")===n)].map((e,n)=>({field:e,formIndex:r,fieldIndex:n,score:function(e){let t=0,r=(e.getAttribute("id")??"").toLowerCase(),n=(e.getAttribute("class")??"").toLowerCase();for(let i of(r.includes("product-form")&&(t+=100),n.includes("product-form")&&(t+=80),erd))e.closest(i)&&(t+=25);for(let r of erh)e.closest(r)&&(t-=100);return t}(t)}))}).sort((e,t)=>t.score-e.score||e.formIndex-t.formIndex||e.fieldIndex-t.fieldIndex)){let e=erc(eru(t));if(e)return e}return null}(e)??function(e=document){for(let t of Array.from(e.querySelectorAll('[name="id"][form^="product-form"]'))){let e=erc(eru(t));if(e)return e}return null}(e)??function(e=document){let t=e.querySelector("[data-selected-variant-id]");return erc(t?.getAttribute("data-selected-variant-id")??null)}(e)}():null}}function erA(){let e=function(){let[e,t]=(0,rx.useState)(erf);return(0,rx.useEffect)(()=>{let e=null,r=window.history.pushState,n=window.history.replaceState,i=()=>{null===e&&(e=window.requestAnimationFrame(()=>{e=null,t(e=>{let t=erf();return e.isProductPage===t.isProductPage&&e.variantId===t.variantId?e:t})}))};window.history.pushState=function(...e){let t=r.apply(this,e);return i(),t},window.history.replaceState=function(...e){let t=n.apply(this,e);return i(),t};let a=ag('body.template-product, body.template-collection, meta[property="og:type"], form[action*="/cart/add"], form[action*="/cart/add"] [name="id"], [name="id"][form], [data-selected-variant-id]',{initialize(e){let t;return{add(){t=(e=>{var t;let r=(t=e).matches("body")?["class"]:t.matches('meta[property="og:type"]')?["content"]:t.matches('form[action*="/cart/add"]')?["action","class","id"]:t.matches('form[action*="/cart/add"] [name="id"], [name="id"][form]')?["form","value"]:t.matches("[data-selected-variant-id]")?["data-selected-variant-id"]:[];if(0===r.length)return;let n=new MutationObserver(i);return n.observe(e,{attributes:!0,attributeFilter:r}),()=>{n.disconnect()}})(e),i()},remove(){t?.(),t=void 0,i()}}}});return document.addEventListener("change",i,!0),document.addEventListener("input",i,!0),document.addEventListener("click",i,!0),window.addEventListener("popstate",i),i(),()=>{null!==e&&window.cancelAnimationFrame(e),window.history.pushState=r,window.history.replaceState=n,a.abort(),document.removeEventListener("change",i,!0),document.removeEventListener("input",i,!0),document.removeEventListener("click",i,!0),window.removeEventListener("popstate",i)}},[]),e}(),[t,r]=(0,rx.useState)(!1),{data:n}=od({queryKey:["vizbl-shopify-room-viewer","activation",e.variantId],queryFn:({signal:t})=>eri(e.variantId??"",t),enabled:e.isProductPage&&null!==e.variantId,staleTime:3e5,gcTime:3e5,refetchOnWindowFocus:!1},s2,void 0),i=(0,rx.useCallback)(()=>{r(!0)},[]),a=(0,rx.useCallback)(e=>{r(e)},[]);if(!e.isProductPage||!e.variantId||!n?.settings.isWidgetActive)return null;let{settings:s,posterPic:o,title:l}=n,c=s._widgetSettings,u=function(e){if("one_field"===e.productWidthAndHeight){let[t,r]=e.metafieldForWidthAndHeight.split("x");return{width:Number(t),height:Number(r)}}return{width:Number(e.metafieldForWidth),height:Number(e.metafieldForHeight)}}(s),d="inch"===s.units?"in":"cm";return(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("button",{type:"button",onClick:i,style:{position:"fixed",zIndex:0x7ffffffe,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"13.522px 21.635px",borderStyle:"solid",borderColor:c?.borderColor??"rgba(65, 90, 229, 0.3)",borderWidth:c?.borderWidth??1,borderRadius:c?.borderRadius??121.053,background:c?.backgroundColor??"#ffffff",boxShadow:"0px 0px 20px 0px rgba(23, 32, 51, 0.14), 0px 16px 32px 0px rgba(23, 32, 51, 0.17)",color:c?.textColor??"#111111",boxSizing:"border-box",cursor:"pointer",maxWidth:"calc(100vw - 16px)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontSize:18,fontWeight:600,letterSpacing:0,lineHeight:"18px",margin:0,appearance:"none",...ero[s.widgetPosition]},children:c?.buttonLabel??"View in place"}),(0,rE.jsx)(eeU,{open:t,onOpenChange:a,type:"wallart",source:"shopify",src:o,name:l??"",width:u.width,height:u.height,dimensionUnit:d,widgetSession:n.widgetSession}),t&&(0,am.createPortal)((0,rE.jsx)("style",{children:erp.A}),document.head)]})}let erg="vizbl-shopify-room-viewer",erm=new rw({defaultOptions:{queries:{refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(ix(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function erv(){let e,t=((e=document.getElementById(erg))||((e=document.createElement("div")).id=erg,document.body.appendChild(e)),e),r=ij.createRoot(t);r.render((0,rx.createElement)(rI,{client:erm},(0,rx.createElement)(erA)));let n=ag(`#${erg}`,{remove(){n.abort(),r.unmount(),erv()}})}iz({baseURL:ere}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",erv,{once:!0}):erv()})()})();
|
|
7636
|
+
Defaulting to \`null\`.`));let u=$2(a,c)?a:null,d=$0(u)?o(u,c):void 0;return(0,rE.jsx)($q,{scope:i,value:u,max:c,children:(0,rE.jsx)(Kh.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":$0(u)?u:void 0,"aria-valuetext":d,role:"progressbar","data-state":$$(u,c),"data-value":u??void 0,"data-max":c,...l,ref:t})})});$J.displayName=$H;var $Y="ProgressIndicator",$X=rx.forwardRef((e,t)=>{let{__scopeProgress:r,...n}=e,i=$K($Y,r);return(0,rE.jsx)(Kh.div,{"data-state":$$(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...n,ref:t})});function $Z(e,t){return`${Math.round(e/t*100)}%`}function $$(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function $0(e){return"number"==typeof e}function $1(e){return $0(e)&&!isNaN(e)&&e>0}function $2(e,t){return $0(e)&&!isNaN(e)&&e<=t&&e>=0}function $3({className:e,value:t,max:r=100,...n}){let i=r>0?r:100,a="number"==typeof t?Math.min(Math.max(t/i*100,0),100):0;return(0,rE.jsx)($J,{"data-slot":"progress",className:WC("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),value:t,max:i,...n,children:(0,rE.jsx)($X,{"data-slot":"progress-indicator",className:"h-full bg-primary transition-[width]",style:{width:`${a}%`}})})}$X.displayName=$Y;let $9=[{minimumProgress:0,translationKey:"floor.processing.stages.reading"},{minimumProgress:28,translationKey:"floor.processing.stages.mapping"},{minimumProgress:56,translationKey:"floor.processing.stages.lighting"},{minimumProgress:82,translationKey:"floor.processing.stages.finalizing"},{minimumProgress:100,translationKey:"floor.processing.stages.ready"}];function $4({isComplete:e,open:t,onCloseAnimationEnd:r,onOpenChange:n,portalContainer:i}){let{t:a}=sf(),s=(0,rx.useRef)(t),[o,l]=(0,rx.useState)(8),c=e?100:o,u=function(e){for(let t=$9.length-1;t>=0;t-=1){let r=$9[t];if(r&&e>=r.minimumProgress)return r}return $9[0]}(c);(0,rx.useEffect)(()=>{t&&!s.current&&l(8),s.current=t},[t]),(0,rx.useEffect)(()=>{if(!t||e)return;let r=window.setInterval(()=>{l(e=>Math.min(92,e+Math.max(2,Math.round((92-e)/8))))},650);return()=>window.clearInterval(r)},[e,t]);let d=(0,rE.jsxs)("div",{role:"status","aria-live":"polite",className:"grid content-start gap-4",children:[(0,rE.jsx)("h2",{className:"typo-base-18 font-medium text-text-dark",children:a("floor.processing.title")}),(0,rE.jsxs)("div",{"data-testid":"floor-processing-progress-panel",className:"grid min-h-[97px] min-w-0 content-center gap-2 overflow-hidden rounded-xl bg-background-base px-6 py-8",children:[(0,rE.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,rE.jsx)("span",{className:"typo-base-14 min-w-0 flex-1 truncate text-left font-medium text-text-light",children:a(u.translationKey)}),(0,rE.jsxs)("span",{className:"typo-base-14 shrink-0 font-medium text-text-dark",children:[c,"%"]})]}),(0,rE.jsx)($3,{value:c,"aria-label":a("floor.processing.progressLabel"),className:"h-1 bg-background-base-3 [&_[data-slot=progress-indicator]]:bg-button-dark [&_[data-slot=progress-indicator]]:duration-500 [&_[data-slot=progress-indicator]]:ease-out"})]})]});return(0,rE.jsx)(WM,{open:t,onOpenChange:n,children:(0,rE.jsxs)(WT,{portalContainer:i,showCloseButton:!1,"data-testid":"floor-processing-card",className:"top-auto bottom-2 w-[calc(100%-16px)] !max-w-none translate-y-0 gap-4 overflow-hidden rounded-2xl p-6 text-center sm:top-[50%] sm:bottom-auto sm:w-full sm:!max-w-[377px] sm:translate-y-[-50%] sm:p-6",onInteractOutside:e=>{e.preventDefault()},onAnimationEnd:e=>{e.currentTarget===e.target&&"closed"===e.currentTarget.getAttribute("data-state")&&r?.()},children:[(0,rE.jsx)(WP,{className:"sr-only",children:a("floor.processing.title")}),(0,rE.jsx)(W_,{className:"sr-only",children:a(u.translationKey)}),d]})})}let $5={desktop:[{slot:"product-card",container:"leading",appearance:"card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"leading",appearance:"card",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"card",actionVariant:"secondary",actionSize:"sm"}],tablet:[{slot:"product-card",container:"leading",appearance:"compact-card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"framed-row",actionLabelKey:"floor.interiorSelection.chooseInteriorShort",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"inline-compact",actionVariant:"secondary",actionSize:"default"}],phone:[{slot:"product-card",container:"leading",appearance:"flow-card",actionLabelResourceTypeKey:"replaceProductShort",actionVariant:"outline",actionSize:"sm",actionWidth:"fixed"},{slot:"room-card",container:"trailing",appearance:"plain-row",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"},{slot:"ar-card",container:"trailing",appearance:"inline-large",actionVariant:"secondary",actionSize:"lg"}]},$8={desktop:[{slot:"product-card",container:"leading",appearance:"card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"leading",appearance:"card",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"}],tablet:[{slot:"product-card",container:"leading",appearance:"compact-card",actionLabelResourceTypeKey:"replaceProduct",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"framed-row",actionLabelKey:"floor.interiorSelection.chooseInteriorShort",actionVariant:"outline",actionSize:"sm"}],phone:[{slot:"product-card",container:"leading",appearance:"flow-card",actionLabelResourceTypeKey:"replaceProductShort",actionVariant:"outline",actionSize:"sm",actionWidth:"auto"},{slot:"room-card",container:"trailing",appearance:"plain-row",actionLabelKey:"floor.interiorSelection.chooseInterior",actionVariant:"outline",actionSize:"sm"}]},$6={"inline-compact":"h-9 w-full rounded-xl","inline-large":"h-11 w-full rounded-xl"},$7={"inline-compact":"size-5","inline-large":"size-6"},eee={desktop:"floor-ar-card",tablet:void 0,phone:void 0},eet=/^[a-z][a-z\d+.-]*:/i,eer={card:"flex min-h-24 w-fit max-w-100 items-center gap-4 rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","compact-card":"flex min-h-[116px] w-fit max-w-[421px] items-center gap-4 rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","flow-card":"flex items-center justify-start gap-4 border-b border-border-light bg-background-containers p-4 text-left"},een={card:"size-6 text-icons-normal","compact-card":"size-6 text-icons-normal","flow-card":"size-5 text-icons-normal"},eei={desktop:"floor-desktop-product-card",tablet:"floor-tablet-product-card",phone:"floor-mobile-product-card"},eea={card:"flex h-24 w-[254px] items-center gap-4 overflow-hidden rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","framed-row":"flex h-[72px] items-center justify-between gap-3 overflow-hidden rounded-2xl bg-background-containers p-4 text-left text-text-dark shadow-[var(--shadow-login)]","plain-row":"flex w-full items-center justify-between gap-3 rounded-full bg-background-containers text-left"},ees={desktop:"floor-room-card",tablet:"floor-tablet-room-card",phone:void 0},eeo={desktop:"floor-desktop-room-name",tablet:"floor-tablet-room-name",phone:"floor-mobile-room-name"},eel={"product-card":function({actions:e,band:t,slot:r,presentation:n}){let i,{t:a}=sf(),{displayUnit:s,name:o,type:l}=W6(),{containerRef:c}=qr(),{material:u,selectedObject:d,tinuuid:h}=qt(),{variantItems:p,selectedTinuuid:f,selectVariant:A}=function(){let{tinuuid:e,selectedObject:t,selectResourceVariant:r,apiKey:n,baseURL:i,language:a,source:s,widgetSession:o}=qt(),{type:l}=W6(),{decodeVariant:c}=qO(l),u=t?.kit?.uuid,d=t?.owner?.uuid,{data:h,fetchNextPage:p,hasNextPage:f,isFetchingNextPage:A,isFetchNextPageError:g}=od({queryKey:WA(u,d,{apiKey:n,baseURL:i,language:a,source:s,resourceType:l}),enabled:!!c&&!!u&&!!d,queryFn:({pageParam:e,signal:t})=>{if(!u||!d)throw Error("Kit uuid and owner uuid are required.");return Wv(u,d,e,{apiKey:n,baseURL:i,language:a,signal:t,source:s,widgetSession:o,resourceType:l})},initialPageParam:0,getNextPageParam:(e,t,r)=>void 0!==e.pages_count?r+1<e.pages_count?r+1:void 0:e.objs?.length?r+1:void 0},ou,void 0);(0,rx.useEffect)(()=>{!f||A||g||p({cancelRefetch:!1})},[p,f,A,g]);let m=(0,rx.useMemo)(()=>h?.pages.flatMap(e=>e.objs??[])??[],[h]),v=(0,rx.useMemo)(()=>m.flatMap(e=>{let t=c?.(e.description);return e.tinuuid&&e.materials?.[0]&&t?[{tinuuid:e.tinuuid,...t}]:[]}),[m,c]);return{variantItems:v,selectedTinuuid:e,selectVariant:e=>!!v.some(t=>t.tinuuid===e)&&(r(e),!0)}}(),g=eei[t],m=a(`units.${s}`),v=e.isMaterialSelectionOpen,b=a(v?"floor.scene.hideCatalog":`resourceType.${l}.${n.actionLabelResourceTypeKey}`),y=qz(l,d,u,o),w=(i=u?.previews?.[0],i?.subRes?.small??i?.url??d?.preview?.subRes?.small??d?.preview?.url??d?.mainPreview),x=p.find(e=>e.tinuuid===f),C=function(e){let t=e?.trim();if(!t||eet.test(t)&&!/^https?:/i.test(t)||/^[./?#]/.test(t)&&!t.startsWith("//"))return;let r=t.startsWith("//")?`https:${t}`:/^https?:/i.test(t)?t:`https://${t}`;try{let e=new URL(r);if("http:"!==e.protocol&&"https:"!==e.protocol||!e.hostname)return;return e.href}catch{return}}(d?.tinuuid===h?d.destinationUrl:void 0),E=v?e.onMaterialSelectionActionPointerDown:void 0;return(0,rE.jsxs)("div",{className:eer[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-product":"","data-testid":g,children:[(0,rE.jsx)("div",{className:"grid size-16 shrink-0 place-items-center overflow-hidden bg-background-base",children:w?(0,rE.jsx)("img",{src:w,alt:"",className:"size-full object-cover"}):(0,rE.jsx)(WG,{className:een[n.appearance]})}),(0,rE.jsxs)("div",{className:"grid min-h-16 min-w-0 flex-1 grid-cols-1 content-center gap-2",children:[(0,rE.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[(0,rE.jsxs)("div",{className:"min-w-0",children:[(0,rE.jsx)("div",{className:"sr-only",children:a(`resourceType.${l}.productCardTitle`)}),(0,rE.jsx)("div",{className:"typo-button-normal truncate text-text-dark",children:y})]}),C&&(0,rE.jsx)("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"typo-base-12 shrink-0 text-button-primary underline-offset-2 hover:underline","data-testid":`${g}-description-link`,children:a("floor.scene.description")})]}),(0,rE.jsxs)("div",{className:"flex flex-nowrap items-center gap-2",children:[(0,rE.jsxs)(WS,{type:"button",variant:n.actionVariant,size:n.actionSize,[$Q]:!0,"aria-expanded":v,className:WC("w-fit shrink-0","fixed"===n.actionWidth&&"w-[137px]"),onPointerDown:E?e=>{e.preventDefault(),e.stopPropagation(),E()}:void 0,onClick:v?e.closeMaterialSelection:e.openMaterialSelection,children:[v?(0,rE.jsx)(WO,{className:"size-4"}):(0,rE.jsx)(WV,{className:"size-4"}),b]}),p.length>1&&!!x&&(0,rE.jsxs)(qu,{value:f??void 0,onValueChange:A,children:[(0,rE.jsx)(qh,{size:"sm",className:"w-fit min-w-0 shrink *:data-[slot=select-value]:block *:data-[slot=select-value]:truncate","data-testid":`${g}-variant-select`,children:(0,rE.jsx)(qd,{})}),(0,rE.jsx)(qp,{portalContainer:c,children:p.map(e=>{var t;let r;return(0,rE.jsx)(qf,{value:e.tinuuid,children:"color"in e?e.color:(t=e.size,r=t.split("\xd7").map(e=>"cm"===s?e:Math.round(qZ(Number(e)/100,s)).toString()).join("\xd7"),`${r} ${m}`)},e.tinuuid)})})]})]})]})]})},"room-card":function({actions:e,band:t,slot:r,presentation:n}){let{t:i}=sf(),{room:a}=qe(),s=i(`rooms.${a.id}`,{defaultValue:a.name}),o=(0,rE.jsx)(WS,{type:"button",variant:n.actionVariant,size:n.actionSize,className:"card"===n.appearance?"w-fit":"shrink-0",onClick:e.openInteriorSelection,children:i(n.actionLabelKey)});return"card"===n.appearance?(0,rE.jsxs)("div",{className:eea[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-room":"","data-testid":ees[t],children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(a),alt:"",className:"size-16 shrink-0 rounded-lg object-cover"}),(0,rE.jsxs)("span",{className:"grid min-w-0 flex-1 content-center gap-2",children:[(0,rE.jsx)("span",{className:"typo-button-normal block min-h-[1.35em] truncate !leading-[1.35] text-text-dark","data-testid":eeo[t],children:s}),o]})]}):(0,rE.jsxs)("div",{className:eea[n.appearance],"data-chrome-slot":r,"data-neurodyn-room-viewer-room":"","data-testid":ees[t],children:[(0,rE.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(a),alt:"",className:"size-10 shrink-0 rounded-full object-cover"}),(0,rE.jsxs)("span",{className:"grid min-w-0",children:[(0,rE.jsx)("span",{className:"typo-base-12 truncate text-text-light",children:i("floor.scene.interiorCardTitle")}),(0,rE.jsx)("span",{className:"typo-button-normal min-h-[1.35em] truncate !leading-[1.35] text-text-dark","data-testid":eeo[t],children:s})]})]}),o]})},"ar-card":function({band:e,slot:t,presentation:r}){let{t:n}=sf(),{room:i}=qe(),{type:a}=W6(),{tinuuid:s}=qt();return $T(Ww[a].handoff,s)?"card"===r.appearance?(0,rE.jsxs)("div",{className:"flex h-24 w-[280px] items-center gap-4 overflow-hidden rounded-2xl bg-background-containers p-4 text-text-dark shadow-[var(--shadow-login)]","data-chrome-slot":t,"data-neurodyn-room-viewer-try-at-home":"","data-testid":eee[e],children:[(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(i),alt:"",className:"size-16 shrink-0 rounded-lg object-cover"}),(0,rE.jsxs)("div",{className:"grid min-w-0 flex-1 content-center gap-2",children:[(0,rE.jsx)($R,{buttonLabel:n("floor.scene.tryAtHome"),buttonVariant:r.actionVariant,buttonSize:r.actionSize,buttonClassName:"w-fit"}),(0,rE.jsx)("div",{className:"typo-base-12 truncate font-medium text-text-light",children:n("floor.scene.tryAtHomeBody")})]})]}):(0,rE.jsx)($R,{className:"w-full","data-chrome-slot":t,"data-neurodyn-room-viewer-try-at-home":"",buttonLabel:n("floor.scene.tryAtHome"),buttonLeadingIcon:(0,rE.jsx)(WY,{className:$7[r.appearance]}),buttonVariant:r.actionVariant,buttonSize:r.actionSize,buttonClassName:$6[r.appearance]}):null}};function eec({actions:e,band:t,entry:r}){let n=eel[r.slot];return(0,rE.jsx)(n,{actions:e,band:t,slot:r.slot,presentation:r})}function eeu({actions:e,band:t,container:r}){let{type:n}=W6(),i="immersive-panels"===Ww[n].presentation?$8:$5;return(0,rE.jsx)(rE.Fragment,{children:i[t].filter(e=>e.container===r).map(r=>(0,rE.jsx)(eec,{actions:e,band:t,entry:r},r.slot))})}async function eed(e,t={}){let r=t.source??"default",n={image:e};if(VL({apiKey:t.apiKey,source:r})){let e=await t.widgetSession?.getTokenForRequest();return V6(n,{baseURL:t.baseURL,headers:{"x-api-key":t.apiKey,...e?{[Wo]:e}:{}},signal:t.signal,timeout:0,params:{productType:VN({apiKey:t.apiKey,source:r,resourceType:t.resourceType})}})}return t.signal?V0(n,{signal:t.signal,timeout:0}):V0(n,{timeout:0})}let eeh=[{id:0,label:"empty",rgb:[0,0,0]},{id:1,label:"floor",rgb:[32,208,96]},{id:2,label:"wall-1",rgb:[255,59,48]},{id:3,label:"wall-2",rgb:[10,132,255]},{id:4,label:"ceiling",rgb:[255,214,10]},{id:5,label:"plane-5",rgb:[191,90,242]},{id:6,label:"plane-6",rgb:[255,159,10]},{id:7,label:"plane-7",rgb:[100,210,255]},{id:8,label:"plane-8",rgb:[255,45,85]}];function eep(){try{return"1"===window.localStorage.getItem("neurodyn-room-viewer:debug-mask-export")}catch{return!1}}async function eef(e,t){var r,n,i;let a,s,o,l,c=await (r=e.planeIds.dataPng,new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error("Failed to load room plane id mask image.")),n.crossOrigin="anonymous",n.src=r})),u=e.planeIds.width||c.naturalWidth||c.width,d=e.planeIds.height||c.naturalHeight||c.height,h=document.createElement("canvas"),p=h.getContext("2d",{willReadFrequently:!0});if(!p)throw Error("Failed to prepare room plane mask canvas.");h.width=u,h.height=d,p.drawImage(c,0,0,u,d);let f=p.getImageData(0,0,u,d),A=document.createElement("canvas"),g=A.getContext("2d");if(!g)throw Error("Failed to prepare room debug mask canvas.");A.width=u,A.height=d;for(let e=0;e<u*d;e++){let t=4*e,r=function(e){return eeh.find(t=>t.id===e)??{id:e,label:`plane-${e}`,rgb:[73*e%255,151*e%255,211*e%255]}}(f.data[t]??0);f.data[t]=r.rgb[0],f.data[t+1]=r.rgb[1],f.data[t+2]=r.rgb[2],f.data[t+3]=255}g.putImageData(f,0,0),n=await new Promise((e,t)=>{A.toBlob(r=>{r?e(r):t(Error("Failed to export room plane mask image."))},"image/png")}),s=Array.from((a=t.lastIndexOf("."))>0?t.slice(0,a):t).map(e=>{let t=e.charCodeAt(0),r="."===e||"_"===e||"-"===e;return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||r?e:"-"}).join("").split("-").filter(Boolean).join("-"),i=`${s||"room"}.debug-mask.colors.png`,o=URL.createObjectURL(n),(l=document.createElement("a")).href=o,l.download=i,l.style.display="none",document.body.append(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),1e3)}let eeA="custom-interiors";function eeg(){return"u">typeof crypto&&"function"==typeof crypto.randomUUID?`custom-interior-${crypto.randomUUID()}`:`custom-interior-${Date.now()}-${Math.random().toString(36).slice(2)}`}function eem(){let e="u"<typeof indexedDB?null:indexedDB;return e?new Promise((t,r)=>{let n=e.open("neurodyn-floor-custom-interiors",1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(eeA)||e.createObjectStore(eeA,{keyPath:"id"})},n.onerror=()=>r(n.error??Error("Failed to open Custom Interior store.")),n.onsuccess=()=>t(n.result)}):Promise.resolve(null)}async function eev(e,t,r=new Date){let n=await eem();if(!n)return null;let i={id:eeg(),schemaVersion:1,name:e.name,fileName:e.name,createdAt:r.toISOString(),imageBlob:e,scene:t};try{let e=n.transaction(eeA,"readwrite");return e.objectStore(eeA).put(i),await new Promise((t,r)=>{e.oncomplete=()=>t(),e.onerror=()=>r(e.error??Error("Custom Interior transaction failed.")),e.onabort=()=>r(e.error??Error("Custom Interior transaction aborted."))}),i}finally{n.close()}}async function eeb(){let e=await eem();if(!e)return[];try{return await new Promise((t,r)=>{let n=e.transaction(eeA,"readonly").objectStore(eeA).getAll();n.onerror=()=>r(n.error??Error("Failed to read Custom Interiors.")),n.onsuccess=()=>{let e=n.result.filter(e=>1===e.schemaVersion).sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt));t(e)}})}finally{e.close()}}function eey(e){let t=[];return{rooms:e.map(e=>{let r=URL.createObjectURL(e.imageBlob);return t.push(r),{id:e.id,name:e.name,image_url:r,scene:e.scene}}),revokeObjectUrls:()=>{for(let e of t)URL.revokeObjectURL(e);t.length=0}}}let eew={placementReady:!1,prepareReady:!1,artifactsReady:!1,assetsReady:!1};function eex(e){let t="dialog"===e?"interior-selection":"scene";return{step:t,hasSceneSelection:"scene"===t,sceneResetKey:0}}function eeC(e,t){switch(t.type){case"clear-interior-selection":return{...e,step:"interior-selection",hasSceneSelection:!1,automaticRoomId:t.automaticRoomId};case"select-initial-room":return{step:"scene",hasSceneSelection:!0,sceneResetKey:e.sceneResetKey+1,automaticRoomId:t.roomId};case"open-interior-selection":case"return-to-interior-selection":return{...e,step:"interior-selection"};case"dismiss-interior-selection":case"recover-to-scene":return e.hasSceneSelection?{...e,step:"scene"}:e;case"start-custom-interior-processing":return{...e,step:"processing-custom-interior"};case"commit-interior-selection":return{step:"scene",hasSceneSelection:!0,sceneResetKey:e.sceneResetKey+1}}}function eeE(e,t){return!e.aborted&&t()}async function eeS({abortSignal:e,apiOptions:t,commitCustomInteriorSelection:r,downloadDebugMask:n,file:i,isActive:a,isDebugMaskExportEnabled:s,onDebugMaskError:o,onPersistenceError:l,onProcessingComplete:c,predictRoomScene:u,saveCustomInterior:d,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p}){let f=await u(i,{...t,signal:e});if(!eeE(e,a))return null;s()&&n(f,i.name).catch(o);let A=h(i,f);return eeE(e,a)&&A&&(d(i,f).catch(l),c(),await p(),eeE(e,a))?(r(A),A):null}function eeM(){return new Promise(e=>window.setTimeout(e,250))}function eeI(e){console.error("Failed to export room debug mask",e)}function eeB(e){console.error("Failed to persist Custom Interior",e)}function eek(e){console.error("Failed to prepare Custom Interior",e)}let eeT={"immersive-room":function({showDialogCloseButton:e=!1}){var t;let{t:r}=sf(),{name:n,type:i}=W6(),{accessError:a,glbUrl:s,apiKey:o,baseURL:l,hasRooms:c,source:u,widgetSession:d,isViewerAccessPending:h,loadError:p,selectedObject:f,tinuuid:A}=qt(),{clearActiveError:g,handleAccessError:m}=function(){let{setAccessError:e,setLoadError:t}=qt();return{clearActiveError:(0,rx.useCallback)(()=>{e(null),t(null)},[e,t]),handleAccessError:e}}(),{room:v,sourceRooms:b}=qe(),{resourceRef:y,containerRef:w,setContainerRef:x,sceneLoad:C,isRoomScenePending:E}=qr(),{dialogPortalContainer:S,viewerSurface:M,viewerDialogOpen:I,onViewerDialogOpenChange:B}=W7(),[k,T]=(0,rx.useState)(!1),[R,D]=(0,rx.useState)(!1),P=(0,rx.useRef)(null),_=(0,rx.useRef)(!1),L=a??p,N=!!L,F=(t=r("floor.scene.companyFallback"),f?.owner?.name??f?.brand??t),{canShare:O,download:Q,isDownloading:U,isSharing:z,share:j}=$P({captureRef:P,fallbackToClipboard:!0,shareMessage:r(`shareMessage.${i}`)}),G=(0,rx.useCallback)(()=>{T(!1),D(!1)},[]),H=(0,rx.useCallback)(()=>{if(_.current){_.current=!1;return}T(!0),D(!1)},[]),V=(0,rx.useCallback)(()=>{_.current=!0,G()},[G]),W=(0,rx.useCallback)(()=>{D(!0),T(!1)},[]),q=function({activeError:e,apiKey:t,baseURL:r,clearActiveError:n,closeMaterialSelection:i,glbUrl:a,handleAccessError:s,hasDialogPortalContainer:o,hasRooms:l,isRoomScenePending:c,isViewerAccessPending:u,onViewerDialogOpenChange:d,resourceType:h,sceneLoad:p,source:f,sourceRooms:A,viewerDialogOpen:g,viewerSurface:m,widgetSession:v}){let b=function(e){let{initialRoomId:t,room:r,sourceRooms:n}=qe(),{isViewerAccessPending:i,loadError:a,setLoadError:s}=qt(),{type:o}=W6(),{patchSceneLoad:l,setAngle:c,setRotation:u}=qr(),d=(0,rx.useMemo)(()=>({patchSceneLoad:l,setAngle:c,setRotation:u}),[l,c,u]),h=n.find(e=>e.id===t),p=!!h&&(!h?.scene||ZG(h.scene,Wx(o)).length>0),f=function(e,t,r){let[n,i]=(0,rx.useReducer)(eeC,e,eex),[a,s]=(0,rx.useState)();!r?.isPending&&a!==r?.roomId&&(s(r?.roomId),r&&i(r.isAvailable?{type:"select-initial-room",roomId:r.roomId}:{type:"clear-interior-selection"}));let o=(0,rx.useCallback)(e=>{e(),function({patchSceneLoad:e,setAngle:t,setRotation:r}){t(0),r(0),e(eew)}(t),i({type:"commit-interior-selection"})},[t]),l=(0,rx.useCallback)(()=>{i({type:"dismiss-interior-selection"})},[]),c=(0,rx.useCallback)(()=>{i({type:"open-interior-selection"})},[]),u=(0,rx.useCallback)(()=>{i({type:"recover-to-scene"})},[]),d=(0,rx.useCallback)(()=>{i({type:"return-to-interior-selection"})},[]),h=(0,rx.useCallback)(()=>{i({type:"clear-interior-selection",automaticRoomId:n.automaticRoomId})},[n.automaticRoomId]),p=(0,rx.useCallback)(()=>{i({type:"start-custom-interior-processing"})},[]);return(0,rx.useMemo)(()=>({...n,commitInteriorSelection:o,dismissInteriorSelection:l,openInteriorSelection:c,recoverToScene:u,returnToInteriorSelection:d,clearInteriorSelection:h,startCustomInteriorProcessing:p}),[o,l,c,u,d,h,p,n])}(e,d,t?{roomId:t,isAvailable:p,isPending:i}:void 0),{automaticRoomId:A,clearInteriorSelection:g}=f;return(0,rx.useEffect)(()=>{A&&r.id===A&&"room-load-failed"===a&&(g(),s(null))},[A,g,a,r.id,s]),f}(m),{appendRuntimeCustomInterior:y,customRooms:w}=function({listCustomInteriors:e}){let{appendRuntimeCustomInterior:t,customRooms:r,replaceRuntimeCustomInteriors:n}=function(){let[e,t]=(0,rx.useState)(()=>[]),r=(0,rx.useRef)(null),n=(0,rx.useCallback)(e=>{r.current?.revokeObjectUrls();let n=eey(e);return r.current=n,t(n.rooms),n.rooms},[]),i=(0,rx.useCallback)((e,n)=>{let i=eey([{id:eeg(),schemaVersion:1,name:e.name,fileName:e.name,createdAt:new Date().toISOString(),imageBlob:e,scene:n}]),a=i.rooms[0];if(!a)return i.revokeObjectUrls(),null;let s=r.current;return r.current={rooms:[],revokeObjectUrls:()=>{s?.revokeObjectUrls(),i.revokeObjectUrls()}},t(e=>[a,...e.filter(e=>e.id!==a.id)]),a},[]);return(0,rx.useEffect)(()=>()=>{r.current?.revokeObjectUrls()},[]),(0,rx.useMemo)(()=>({appendRuntimeCustomInterior:i,customRooms:e,replaceRuntimeCustomInteriors:n}),[i,e,n])}(),i=(0,rx.useRef)(!0);(0,rx.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=(0,rx.useCallback)(async()=>{let t=await e();i.current&&n(t)},[e,n]);return(0,rx.useEffect)(()=>{a()},[a]),(0,rx.useMemo)(()=>({appendRuntimeCustomInterior:t,customRooms:r,replaceRuntimeCustomInteriors:n,refreshCustomInteriors:a}),[t,r,a,n])}({listCustomInteriors:eeb}),x=(0,rx.useMemo)(()=>new Set(A.map(e=>e.id)),[A]),{commitCustomInteriorSelection:C,selectInterior:E}=function(e){let{room:t,setRoomId:r,setRooms:n}=qe(),{widgetSession:i}=qt();return function({floorFlow:e,customRooms:t,selectedRoomId:r,onInteriorSelected:n,restoreSourceRooms:i,setRoomId:a,setRooms:s}){let o=(0,rx.useCallback)(t=>{e.commitInteriorSelection(()=>{s(e=>[t,...i(e).filter(e=>e.id!==t.id)]),a(t.id)}),n?.()},[e,n,i,a,s]),l=(0,rx.useCallback)(t=>{let o=t===r;o&&e.hasSceneSelection||(e.commitInteriorSelection(()=>{s(i),a(t)}),o||n?.())},[e,n,i,r,a,s]),c=(0,rx.useCallback)(n=>{if(n===r&&e.hasSceneSelection)return;let i=t.find(e=>e.id===n);i&&o(i)},[e.hasSceneSelection,o,t,r]),u=(0,rx.useCallback)(e=>{t.some(t=>t.id===e)?c(e):l(e)},[t,c,l]);return(0,rx.useMemo)(()=>({commitCustomInteriorSelection:o,selectInterior:u}),[o,u])}({...e,selectedRoomId:t.id,onInteriorSelected:()=>Wd(i,"interior_selected"),setRoomId:r,setRooms:n})}({floorFlow:b,customRooms:w,restoreSourceRooms:(0,rx.useCallback)(e=>[...A,...e.filter(e=>!x.has(e.id))],[x,A])}),S=function(e){let{setIsRoomScenePending:t}=qr();return function({apiOptions:e,floorFlow:t,commitCustomInteriorSelection:r,downloadDebugMask:n,isDebugMaskExportEnabled:i,onAccessError:a,onDebugMaskError:s,onPersistenceError:o,onProcessingError:l,predictRoomScene:c,saveCustomInterior:u,setIsRoomScenePending:d,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p}){let[f,A]=(0,rx.useState)(!1),[g,m]=(0,rx.useState)(!1),[v,b]=(0,rx.useState)(null),[y,w]=(0,rx.useState)(null),[x,C]=(0,rx.useState)(!1),[E,S]=(0,rx.useState)(0),M=(0,rx.useRef)(null),I=(0,rx.useRef)(!1),B=(0,rx.useRef)(!0),k=(0,rx.useRef)(v);v&&(k.current=v),(0,rx.useEffect)(()=>(B.current=!0,()=>{B.current=!1,M.current?.abort()}),[]);let T=(0,rx.useCallback)(()=>{b(null),w(null),C(!1)},[]),R=(0,rx.useCallback)(e=>{T(),A(!1),e()},[T]),D=(0,rx.useCallback)(async f=>{if(T(),!f.type.startsWith("image/"))return void A(!0);A(!1),m(!1),t.startCustomInteriorProcessing(),I.current=!0;let g=new AbortController;M.current?.abort(),M.current=g,d(!0);try{await eeS({abortSignal:g.signal,apiOptions:e,commitCustomInteriorSelection:r,downloadDebugMask:n,file:f,isActive:()=>B.current,isDebugMaskExportEnabled:i,onDebugMaskError:s,onPersistenceError:o,onProcessingComplete:()=>{m(!0)},predictRoomScene:c,saveCustomInterior:u,trackRuntimeCustomInterior:h,waitForProcessingCompletion:p})}catch(t){if(g.signal.aborted)return;let e=VO(t);if(e){I.current&&C(!0),a(e);return}if(l(t),I.current){w("custom-interior-processing"),C(!0);return}b("custom-interior-processing")}finally{M.current===g&&(M.current=null,B.current&&d(!1))}},[e,t,r,n,i,a,s,o,l,c,T,u,d,h,p]),P=(0,rx.useCallback)(()=>{T(),A(!1),t.returnToInteriorSelection(),S(e=>e+1)},[t,T]),_=(0,rx.useCallback)(()=>{T(),t.returnToInteriorSelection()},[t,T]),L=(0,rx.useCallback)(({clearError:e,closeMaterialSelection:r})=>{e(),r(),t.hasSceneSelection&&t.recoverToScene()},[t]),N=(0,rx.useCallback)(()=>{I.current=!1,C(!1),y&&(b(y),w(null))},[y]),F=(0,rx.useCallback)(()=>B.current,[]);return(0,rx.useMemo)(()=>({displayedUploadError:v??k.current,isCustomInteriorProcessingComplete:g,isInvalidFile:f,isMounted:F,isProcessingDialogClosingForError:x,pendingUploadError:y,uploadError:v,uploadRetryRequestId:E,cancelUploadError:_,handleProcessingDialogCloseAnimationEnd:N,openInteriorSelection:R,processUploadFile:D,recoverFromActiveError:L,resetUploadErrorPresentation:T,tryUploadAgain:P}),[_,N,g,f,F,x,R,y,D,L,T,P,v,E])}({...e,setIsRoomScenePending:t})}({apiOptions:(0,rx.useMemo)(()=>({resourceType:h,apiKey:t,baseURL:r,source:f,widgetSession:v}),[t,r,h,f,v]),floorFlow:b,commitCustomInteriorSelection:C,downloadDebugMask:eef,isDebugMaskExportEnabled:eep,onAccessError:s,onDebugMaskError:eeI,onPersistenceError:eeB,onProcessingError:eek,predictRoomScene:eed,saveCustomInterior:eev,trackRuntimeCustomInterior:y,waitForProcessingCompletion:eeM}),{dismissInteriorSelection:M,hasSceneSelection:I,openInteriorSelection:B,sceneResetKey:k,step:T}=b,{cancelUploadError:R,displayedUploadError:D,handleProcessingDialogCloseAnimationEnd:P,isCustomInteriorProcessingComplete:_,isInvalidFile:L,isProcessingDialogClosingForError:N,openInteriorSelection:F,pendingUploadError:O,processUploadFile:Q,recoverFromActiveError:U,resetUploadErrorPresentation:z,tryUploadAgain:j,uploadError:G,uploadRetryRequestId:H}=S,V=l&&I,W=(0,rx.useRef)(e),q=!!(e&&V&&a);e&&(W.current=e);let K=(0,rx.useCallback)(()=>{V&&(z(),M())},[M,V,z]),J=(0,rx.useCallback)(()=>{i(),F(B)},[i,B,F]),Y=(0,rx.useCallback)(()=>{U({clearError:n,closeMaterialSelection:i})},[n,i,U]),X=(0,rx.useCallback)(e=>{if(!e){if(V)return void K();d?.(!1)}},[K,V,d]),Z=(0,rx.useCallback)(e=>{if(!e){if(q)return void Y();d?.(!1)}},[q,Y,d]),$=(0,rx.useCallback)(e=>{e||R()},[R]);!function({fallbackMs:e,handleProcessingDialogCloseAnimationEnd:t,isProcessingDialogClosingForError:r}){(0,rx.useEffect)(()=>{if(!r)return;let n=window.setTimeout(t,e);return()=>window.clearTimeout(n)},[e,t,r])}({fallbackMs:220,handleProcessingDialogCloseAnimationEnd:P,isProcessingDialogClosingForError:N});let ee=function({activeError:e,canRecoverFromActiveError:t,floorFlow:r,hasDialogPortalContainer:n,hasRooms:i,isProcessingDialogClosingForError:a,isRoomScenePending:s,isViewerAccessPending:o,pendingUploadError:l,sceneLoad:c,uploadError:u,viewerDialogOpen:d,viewerSurface:h}){let p="dialog"===h&&n,f=!p||d,A=i&&r.hasSceneSelection,g=i||"scene"!==r.step?r.step:"interior-selection",m=!o&&A&&(!e||t),v=A||p,b=!o&&!e&&v,y=!o&&!e&&!v&&"interior-selection"===g;return{activeErrorDialog:{open:!a&&!!e&&f,showCloseButton:!t},interiorSelection:{open:b&&"interior-selection"===g&&f,presentation:b?"dialog":y?"screen":null,shouldRender:b||y},processingDialog:{open:!e&&!u&&!l&&s&&"processing-custom-interior"===r.step&&f},scene:{isLoading:s||!Object.values(c).every(Boolean),resetKey:r.sceneResetKey,shouldRender:m,shouldRenderDialog:m},surface:{usesSiblingDialogFlow:p},uploadErrorDialog:{open:!a&&!e&&!!u&&f}}}({activeError:e,canRecoverFromActiveError:q,floorFlow:{hasSceneSelection:I,sceneResetKey:k,step:T},hasDialogPortalContainer:o,hasRooms:l,isProcessingDialogClosingForError:N,isRoomScenePending:c,isViewerAccessPending:u,pendingUploadError:O,sceneLoad:p,uploadError:G,viewerDialogOpen:g,viewerSurface:m});return{...ee,activeErrorDialog:{...ee.activeErrorDialog,onCancel:q?Y:void 0,onOpenChange:Z,onTryAgain:q?Y:void 0,variant:e??W.current},customRooms:w,interiorSelection:{...ee.interiorSelection,isInvalidFile:L,onOpenChange:X,onSelectRoom:E,onUploadFile:Q,openFromScene:J,uploadRetryRequestId:H},sourceRooms:A,processingDialog:{...ee.processingDialog,isComplete:_,onCloseAnimationEnd:P,onOpenChange:ee.surface.usesSiblingDialogFlow?d:void 0},step:T,uploadErrorDialog:{...ee.uploadErrorDialog,onCancel:R,onOpenChange:$,onTryAgain:j,variant:D}}}({activeError:L,apiKey:o,baseURL:l,clearActiveError:g,closeMaterialSelection:G,glbUrl:s,handleAccessError:m,hasDialogPortalContainer:null!==S,hasRooms:c,isRoomScenePending:E,isViewerAccessPending:h,onViewerDialogOpenChange:B,resourceType:i,sceneLoad:C,source:u,sourceRooms:b,viewerDialogOpen:I,viewerSurface:M,widgetSession:d}),K=(0,rx.useRef)(null),J=function(e,t){let[r,n]=(0,rx.useState)(!1);return e&&r&&n(!1),(0,rx.useEffect)(()=>{let r;if(e)return;let i=()=>{t.current&&(0===Number(getComputedStyle(t.current).opacity)?n(!0):r=requestAnimationFrame(i))};return r=requestAnimationFrame(i),()=>cancelAnimationFrame(r)},[e,t]),!e&&r}(q.scene.isLoading||!q.scene.shouldRender||!I,K),Y=ZB(),{pending:X,finish:Z}=function(e,t,r){let[n,i]=(0,rx.useState)({open:e,pending:e&&t,sceneKey:r});n.open!==e?i({open:e,pending:e&&t,sceneKey:r}):n.sceneKey!==r?i({...n,sceneKey:r,pending:n.pending&&null===n.sceneKey}):n.pending&&!t&&i({...n,pending:!1});let a=(0,rx.useCallback)(()=>i(e=>({...e,pending:!1})),[]);return{pending:e&&n.pending,finish:a}}(I,Kt("(max-width: 639px)")&&"focus-resource"===Ww[i].introduction,q.scene.shouldRender?`${q.scene.resetKey}:${A??""}`:null),$=Y?.select,ee=(0,rx.useCallback)(()=>{Z(),$?.("0,0")},[Z,$]),et=(0,rx.useMemo)(()=>X?{ready:J,target:y,onComplete:ee,onCancel:Z}:void 0,[X,ee,Z,J,y]),er=q.interiorSelection.openFromScene,en=(0,rx.useCallback)(()=>{G(),er()},[G,er]),ei=(0,rx.useMemo)(()=>({isMaterialSelectionOpen:k,openMaterialSelection:H,closeMaterialSelection:G,onMaterialSelectionActionPointerDown:V,openInteriorSelection:en}),[G,V,en,H,k]),ea=(0,rx.useMemo)(()=>({isMaterialSelectionOpen:R,openMaterialSelection:W,closeMaterialSelection:G,openInteriorSelection:en}),[G,en,W,R]);(0,rx.useEffect)(()=>{if(k)return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)};function e(e){var t;(t=e.target)instanceof Element&&t.closest(`[${$Q}], [${$U}]`)||T(!1)}function t(e){"Escape"===e.key&&T(!1)}},[k]);let es=q.surface.usesSiblingDialogFlow?S:w,eo=(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("div",{className:"absolute inset-0 bg-constant-black","data-testid":"floor-scene-background-base"}),(0,rE.jsx)("div",{"aria-hidden":!0,className:"absolute top-[-52px] right-[-1.36%] bottom-[-52px] left-[-1.36%] blur-[40px]","data-testid":"floor-blur-background",children:(0,rE.jsx)("img",{crossOrigin:"anonymous",src:q9(v),alt:"",className:"block size-full max-w-none object-cover object-center opacity-50"})}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute top-0 right-0 left-0 z-20 flex min-h-22 items-start justify-between gap-4 bg-linear-to-b from-black/75 via-black/35 to-transparent px-4 pt-4 pb-8 text-constant-white sm:px-6 lg:min-h-25 lg:pt-6",children:[(0,rE.jsx)("div",{className:"min-w-0 pt-1",children:(0,rE.jsx)("h1",{"data-testid":"floor-scene-header-company",className:"typo-base-16 truncate font-medium lg:typo-base-18",children:F})}),(0,rE.jsxs)("div",{className:"pointer-events-auto inline-flex shrink-0 items-center gap-2",children:[(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("floor.scene.share"),"data-neurodyn-room-viewer-share":"",disabled:!O||z,onClick:j,className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)(WJ,{className:"size-5"}),(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("floor.scene.share")})]}),(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("floor.scene.download"),"data-neurodyn-room-viewer-download":"",disabled:U,onClick:Q,className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)(WQ,{className:"size-5"}),(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("floor.scene.download")})]}),e&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsxs)(WS,{type:"button",variant:"secondary","aria-label":r("close"),className:"size-10 rounded-full px-0 lg:h-9 lg:w-auto lg:rounded-xl lg:px-3.5",children:[(0,rE.jsx)("span",{className:"hidden lg:inline",children:r("close")}),(0,rE.jsx)(WO,{className:"!size-5"})]})})]})]}),(0,rE.jsxs)("div",{className:"relative z-10 size-full min-h-0 min-w-0","data-testid":"floor-scene-viewport",children:[(0,rE.jsx)($g,{introduction:et,captureRef:P,className:"relative z-10 size-full min-h-0",canvasWrapperClassName:"p-0 sm:pt-0 sm:pb-0"},q.scene.resetKey),(0,rE.jsx)("div",{"aria-hidden":!q.scene.isLoading,className:WC("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",q.scene.isLoading?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),ref:K,"data-testid":"floor-scene-loader",style:{transitionDuration:q.scene.isLoading?"0ms":"250ms"},children:(0,rE.jsx)(WZ,{variant:"logo"})})]}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute right-6 bottom-6 left-6 z-20 hidden items-end justify-between gap-4 lg:flex","data-testid":"floor-desktop-cards",children:[(0,rE.jsx)("div",{className:"pointer-events-auto flex min-w-0 items-stretch gap-3",children:(0,rE.jsx)(eeu,{actions:ei,band:"desktop",container:"leading"})}),(0,rE.jsx)("div",{className:"pointer-events-auto",children:(0,rE.jsx)(eeu,{actions:ei,band:"desktop",container:"trailing"})})]}),(0,rE.jsxs)("div",{className:"pointer-events-none absolute right-6 bottom-6 left-6 z-20 hidden items-end justify-between gap-2 sm:flex lg:hidden","data-testid":"floor-tablet-cards",children:[(0,rE.jsx)("div",{className:"pointer-events-auto flex min-w-0 items-stretch gap-3",children:(0,rE.jsx)(eeu,{actions:ei,band:"tablet",container:"leading"})}),(0,rE.jsx)("div",{className:"pointer-events-auto grid w-[254px] gap-2",children:(0,rE.jsx)(eeu,{actions:ei,band:"tablet",container:"trailing"})})]}),(0,rE.jsxs)("div",{className:"relative z-20 grid bg-background-containers text-text-dark shadow-[var(--shadow-login)] sm:hidden","data-testid":"floor-mobile-cards",children:[(0,rE.jsx)("div",{className:"grid",children:(0,rE.jsx)(eeu,{actions:ea,band:"phone",container:"leading"})}),(0,rE.jsx)("div",{className:"grid gap-4 bg-background-containers px-6 pt-4 pb-6","data-testid":"floor-mobile-bottom-actions",children:(0,rE.jsx)(eeu,{actions:ea,band:"phone",container:"trailing"})})]}),k&&!N&&(0,rE.jsx)($j,{[$U]:!0,className:"absolute bottom-[152px] left-6 z-30 hidden max-h-[calc(100%-252px)] w-[348px] rounded-2xl bg-background-containers sm:flex lg:bottom-[132px] lg:max-h-[calc(100%-232px)]",gridClassName:"px-4 pb-4",titleClassName:"px-4 pt-4",onOpenChange:G}),(0,rE.jsx)($G,{open:R&&!N,portalContainer:es,onOpenChange:D})]}),el=q.interiorSelection.shouldRender?"dialog"===q.interiorSelection.presentation?(0,rE.jsx)($O,{open:q.interiorSelection.open,showCloseButton:e||q.scene.shouldRender,portalContainer:es,rooms:q.sourceRooms,customRooms:q.customRooms,selectedRoomId:v.id,isInvalidFile:q.interiorSelection.isInvalidFile,uploadRetryRequestId:q.interiorSelection.uploadRetryRequestId,onOpenChange:q.interiorSelection.onOpenChange,onSelectRoom:q.interiorSelection.onSelectRoom,onUploadFile:q.interiorSelection.onUploadFile}):"screen"===q.interiorSelection.presentation?(0,rE.jsx)($F,{rooms:q.sourceRooms,customRooms:q.customRooms,selectedRoomId:v.id,isInvalidFile:q.interiorSelection.isInvalidFile,uploadRetryRequestId:q.interiorSelection.uploadRetryRequestId,showCloseButton:e,onSelectRoom:q.interiorSelection.onSelectRoom,onUploadFile:q.interiorSelection.onUploadFile}):null:null,ec=(0,rE.jsx)($4,{isComplete:q.processingDialog.isComplete,open:q.processingDialog.open,portalContainer:es,onCloseAnimationEnd:q.processingDialog.onCloseAnimationEnd,onOpenChange:q.processingDialog.onOpenChange}),eu=(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)($L,{variant:q.activeErrorDialog.variant,open:q.activeErrorDialog.open,portalContainer:es,showDialogCloseButton:e&&q.activeErrorDialog.showCloseButton,onOpenChange:q.activeErrorDialog.onOpenChange,onTryAgain:q.activeErrorDialog.onTryAgain,onCancel:q.activeErrorDialog.onCancel}),(0,rE.jsx)($L,{variant:q.uploadErrorDialog.variant,open:q.uploadErrorDialog.open,portalContainer:es,onOpenChange:q.uploadErrorDialog.onOpenChange,onTryAgain:q.uploadErrorDialog.onTryAgain,onCancel:q.uploadErrorDialog.onCancel})]}),ed=(0,rE.jsxs)("div",{ref:x,className:"relative grid size-full grid-rows-[minmax(0,1fr)_auto] overflow-hidden text-foreground sm:block","data-neurodyn-room-viewer-container":"","data-testid":"floor-viewer-root",children:[h?(0,rE.jsx)("div",{className:"flex size-full items-center justify-center bg-radial from-background-containers to-background-base-2",children:(0,rE.jsx)(WZ,{variant:"logo"})}):q.scene.shouldRender?eo:null,!q.surface.usesSiblingDialogFlow&&el,!q.surface.usesSiblingDialogFlow&&ec]});return q.surface.usesSiblingDialogFlow?(0,rE.jsxs)(rE.Fragment,{children:[(q.scene.shouldRenderDialog||h)&&(0,rE.jsx)(WM,{open:I,onOpenChange:B,children:(0,rE.jsxs)(WT,{className:W$,contentInsideOverlay:!0,portalContainer:S,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsx)(WP,{className:"sr-only",children:n}),(0,rE.jsx)(W_,{className:"sr-only"}),ed]})}),el,ec,eu]}):(0,rE.jsxs)(rE.Fragment,{children:[ed,eu]})},"framed-scene":function({showDialogCloseButton:e=!1}){let{name:t}=W6(),{isViewerAccessPending:r,accessError:n,loadError:i,setLoadError:a,hasRooms:s}=qt(),{setContainerRef:o,sceneLoad:l,isRoomScenePending:c}=qr(),{dialogPortalContainer:u,viewerSurface:d,viewerDialogOpen:h,onViewerDialogOpenChange:p}=W7(),{t:f}=sf(),A=(0,rx.useRef)(null),g=r||c||s&&!Object.values(l).every(Boolean),m=n??i,v=m?(0,rE.jsx)("div",{ref:o,"data-neurodyn-room-viewer-container":"",className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,rE.jsx)(q7,{variant:m,showDialogCloseButton:e})}):(0,rE.jsxs)("div",{ref:o,"data-neurodyn-room-viewer-container":"",className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,rE.jsx)(WB,{asChild:!0,children:(0,rE.jsxs)(WS,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[f("close"),(0,rE.jsx)(uc,{})]})}),!r&&(s?(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)(q6,{className:"absolute top-0 right-0 left-0 z-15"}),(0,rE.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,rE.jsx)(Z_,{onError:()=>a("viewer-load-failed"),children:(0,rE.jsx)($g,{captureRef:A,className:"size-full min-h-0",controls:(0,rE.jsx)($_,{captureRef:A})})}),(0,rE.jsx)(q8,{className:"bg-background"})]})]}):(0,rE.jsx)(q5,{className:"absolute inset-x-0 bottom-0 bg-background"})),(0,rE.jsx)("div",{"aria-hidden":!g,className:WC("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",g?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,rE.jsx)(WZ,{variant:"logo"})})]});return"dialog"!==d?v:(0,rE.jsx)(WM,{open:h,onOpenChange:p,children:(0,rE.jsxs)(WT,{className:W$,contentInsideOverlay:!0,portalContainer:u,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,rE.jsxs)(WR,{className:"sr-only",children:[(0,rE.jsx)(WP,{children:t}),(0,rE.jsx)(W_,{})]}),v]})})}};function eeR({showDialogCloseButton:e=!1}){let{type:t}=W6(),r=eeT[Ww[t].chrome];return(0,rE.jsx)(r,{showDialogCloseButton:e})}let eeD=0;function eeP(e){return{layoutReady:!1,placementReady:!1,materialReady:"artwork-src"===e.materialSource,artifactsReady:!1,assetsReady:!1,prepareReady:!1}}let ee_=[];function eeL(e,t,r){if(t===r)return e;let n=new Set(t.map(e=>e.id)),i=new Set(r.map(e=>e.id)),a=e.filter(e=>!n.has(e.id)&&!i.has(e.id));return a.length>0?[...a,...r]:r}function eeN({children:e,src:t,tinuuid:r,roomId:n,type:i,viewerSurface:a,dialogPortalContainer:s=null,viewerDialogOpen:o=!0,onViewerDialogOpenChange:l,width:c,height:u,displayUnit:d,name:h,apiKey:p,baseURL:f,source:A,externalWidgetSession:g}){var m,v;let b=function(){let{t:e}=sf();return(0,rx.useMemo)(()=>[{value:.025,label:`2.5 ${e("units.cm")}`},{value:.05,label:`5 ${e("units.cm")}`}],[e])}(),y=q$(d),w=function(){let{i18n:e}=sf();return"ru"===(e.resolvedLanguage??e.language)?"ru":"en"}(),x=qU(i),C="immersive-room"===Ww[i].chrome&&n?.trim()||void 0,E="finish"===Ww[i].materialRole,{offersSizeVariants:S}=qO(i),M="floor-room-presets"===Ww[i].roomPresets?qR:qT,I=VL({apiKey:p,baseURL:f,source:A}),[B,k]=(0,rx.useState)(r),[T,R]=(0,rx.useState)(null),D=(0,rx.useCallback)(e=>{R(null),k(e)},[]),P=(0,rx.useCallback)(e=>{R(e),k(e)},[]),[_,L]=(0,rx.useState)(null),[N,F]=(0,rx.useState)(b[0].value),[O,Q]=(0,rx.useState)(y[0].value),[U,z]=(0,rx.useState)(0),[j,G]=(0,rx.useState)(0),[H,V]=(0,rx.useState)(!1),[W,q]=(0,rx.useState)(null),[K,J]=(0,rx.useState)(()=>eeP(x)),[Y,X]=(0,rx.useState)(!1),[Z,$]=(0,rx.useState)(null),[ee,et]=(0,rx.useState)(null),er=(0,rx.useRef)(null),en=(0,rx.useRef)(new Set),ei=(0,rx.useRef)(null),ea=(0,rx.useRef)(!0),es=(0,rx.useRef)(!1),eo="object-glb"===x.materialSource,el="default"===A&&void 0!==p,ec=VF("wall-panel"===(m={apiKey:p,baseURL:f,source:A,resourceType:i}).resourceType?m:{...m,resourceType:void 0}),eu=od({queryKey:["room-viewer","activate",{apiKey:p??null,source:A,resourceType:i}],enabled:el,queryFn:({signal:e})=>V2(ec.query,{...ec.config,baseURL:f,headers:{"x-api-key":p},signal:e})},s2,void 0),ed=VO(eu.error),eh=(0,rx.useMemo)(()=>{let e=eu.data;return Wu(e?.widgetSession,{apiConfig:{baseURL:f,headers:{"x-api-key":p}}})},[eu.data,p,f]),ep=(0,rx.useMemo)(()=>g instanceof Wc?g:Wu(g,{apiConfig:{baseURL:f,headers:{"x-api-key":p}}})??eh,[eh,p,f,g]),ef="shopify"===A?null!==ep:el&&eu.isSuccess,eA=od({queryKey:["room-viewer","rooms",{apiKey:(v={apiKey:p,baseURL:f,language:w,source:A,widgetSession:ep,resourceType:i}).apiKey??null,language:v.language??null,source:v.source,resourceType:v.resourceType??null,widgetSessionId:v.widgetSession?.sid??null}],enabled:I&&ef,queryFn:async({signal:e})=>{try{return await Wb({apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}catch(e){if(VO(e))throw e;return[]}}},s2,void 0),eg=I?eA.data??ee_:M,[em,ev]=(0,rx.useState)(()=>({rooms:eg,sourceRooms:eg})),eb=(0,rx.useMemo)(()=>eeL(em.rooms,em.sourceRooms,eg),[em.rooms,em.sourceRooms,eg]),ey=(0,rx.useCallback)(e=>{ev(t=>{let r=eeL(t.rooms,t.sourceRooms,eg);return{rooms:"function"==typeof e?e(r):e,sourceRooms:eg}})},[eg]),[ew,ex]=(0,rx.useState)(()=>C??M[0].id),[eC,eE]=(0,rx.useState)(C);eC!==C&&(eE(C),C&&(ex(C),z(0),G(0),J(eeP(x)),et(e=>"room-load-failed"===e?null:e)));let eS=eb.find(e=>e.id===ew),eM=eS??eb[0]??M[0],eI="rotate-on-floor"===Ww[i].manipulation;(0,rx.useEffect)(()=>{eI&&G(0)},[eI,eM.id]);let eB=eb.length>0;!eS&&eb[0]&&ew!==eb[0].id&&ex(eb[0].id);let ek=!el||eu.isSuccess||eu.isError&&null===ed,eT=od({queryKey:Wf(r??void 0,{apiKey:p,baseURL:f,language:w,source:A,resourceType:i}),enabled:ek&&eo&&null===_&&!!r,queryFn:async({signal:e})=>{if(!r)throw Error("Tinuuid is required.");return Wg(r,{apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}},s2,void 0),eR=od({queryKey:Wf(B??void 0,{apiKey:p,baseURL:f,language:w,source:A,resourceType:i}),enabled:ek&&eo&&!!B,placeholderData:t4,queryFn:async({signal:e})=>{if(!B)throw Error("Tinuuid is required.");return Wg(B,{apiKey:p,baseURL:f,language:w,signal:e,source:A,widgetSession:ep,resourceType:i})}},s2,void 0),eD=eT.data??null,eP=eR.data??null,e_=eD?.materials?.[0]??null,eL=_?.native?.glbUrl??null,eN=VO(eT.error),eF=VO(eA.error),eO=I&&("shopify"===A?null===ep||eA.isLoading:eu.isSuccess&&eA.isLoading),eQ=el&&eu.isLoading||eO,eU=eu.error&&null===ed?"viewer-load-failed":null,ez=eT.error&&null===eN?"viewer-load-failed":null,ej="artwork-src"===x.materialSource&&("string"!=typeof t||0===t.trim().length)?"artwork-load-failed":null,eG=eo&&!eQ&&(!r||eT.isSuccess&&null===e_||null!==_&&null===eL)?"viewer-load-failed":null,eH=null!==T&&T===B&&(eR.isError||eR.isSuccess&&eP?.tinuuid===B&&!eP.materials?.[0]?.native?.glbUrl)?"viewer-load-failed":null,eV=Z??ed??eF??eN,eW=ee??eH??eU??ez??eG??ej,eq=(0,rx.useCallback)(e=>{J(t=>Object.assign({},t,e))},[]);(0,rx.useEffect)(()=>{let e=new Set(eb.map(e=>e.image_url));for(let t of Array.from(en.current))e.has(t)||(URL.revokeObjectURL(t),en.current.delete(t))},[eb]),(0,rx.useEffect)(()=>{let e=en.current;return ea.current=!0,()=>{for(let t of(ea.current=!1,ei.current?.abort(),Array.from(e)))URL.revokeObjectURL(t);e.clear()}},[]);let eK=(0,rx.useCallback)(async e=>{let t=null,r=new AbortController;ei.current?.abort(),ei.current=r,X(!0);try{t=URL.createObjectURL(e);let n=await eed(e,{resourceType:i,apiKey:p,baseURL:f,source:A,signal:r.signal,widgetSession:ep});if(r.signal.aborted||!ea.current)return void URL.revokeObjectURL(t);eep()&&eef(n,e.name).catch(e=>{console.error("Failed to export room debug mask",e)});let a={id:(eeD+=1,`room-custom-${eeD}`),name:e.name,image_url:t,scene:n};en.current.add(t),eq({placementReady:!1,prepareReady:!1,artifactsReady:!1,assetsReady:!1}),ey(e=>[a,...e]),ex(a.id)}catch(n){if(t&&URL.revokeObjectURL(t),r.signal.aborted)return;let e=VO(n);if(e)return void $(e);console.error("Failed to prepare custom room scene",n)}finally{ei.current===r&&(ei.current=null,ea.current&&X(!1))}},[p,f,eq,ey,A,i,ep]);(0,rx.useEffect)(()=>{if("dialog"!==a||!o){es.current=!1;return}es.current||ep&&(Wd(ep,"widget_opened"),es.current=!0)},[o,a,ep]),(0,rx.useEffect)(()=>{eo&&(D(r),L(null),$(null),et(null))},[r,D,eo]),(0,rx.useEffect)(()=>{$(null),et(null)},[p,A]),(0,rx.useEffect)(()=>{eo&&eD&&null===_&&L(e_)},[_,e_,eD,eo]),(0,rx.useEffect)(()=>{if(!eo||!S&&!E&&T!==B||null===eP||eP.tinuuid!==B)return;let e=eP.materials?.[0];if(!e)return;let t=eP.materials?.some(e=>e===_||!!e.hid&&e.hid===_?.hid);if(T===B){R(null),L(e);return}(!t||E)&&_!==e&&L(e)},[E,_,S,eP,B,eo,T]);let eJ=(0,rx.useMemo)(()=>({type:i,name:h,width:c,height:u,displayUnit:d}),[i,h,c,u,d]),eY=(0,rx.useMemo)(()=>({viewerSurface:a,dialogPortalContainer:s,viewerDialogOpen:o,onViewerDialogOpenChange:l}),[a,s,o,l]),eX=(0,rx.useMemo)(()=>({rooms:eb,sourceRooms:eg,setRooms:ey,room:eM,initialRoomId:C,setRoomId:ex}),[eb,eM,C,ey,eg]),eZ=(0,rx.useMemo)(()=>({src:t,glbUrl:eL,tinuuid:B,embeddedObject:eD,selectedObject:eP,material:_,setTinuuid:D,selectResourceVariant:P,setMaterial:L,apiKey:p,baseURL:f,language:w,source:A,widgetSession:ep,hasRooms:eB,isViewerAccessPending:eQ,accessError:eV,setAccessError:$,loadError:eW,setLoadError:et}),[t,eL,B,eD,eP,_,D,P,p,f,w,A,ep,eB,eQ,eV,eW]),e$=(0,rx.useMemo)(()=>({containerRef:W,setContainerRef:q,resourceRef:er,angle:U,setAngle:z,rotation:j,setRotation:G,isDragging:H,setIsDragging:V,sceneLoad:K,patchSceneLoad:eq,isRoomScenePending:Y,setIsRoomScenePending:X}),[W,U,j,H,K,eq,Y]),e0=(0,rx.useMemo)(()=>({frameWidth:N,setFrameWidth:F,matting:O,setMatting:Q}),[N,O]),e1=(0,rx.useMemo)(()=>({isRoomScenePending:Y,selectCustomRoomFile:eK}),[Y,eK]);return(0,rE.jsx)(W0,{value:eJ,children:(0,rE.jsx)(W1,{value:eY,children:(0,rE.jsx)(W2,{value:eX,children:(0,rE.jsx)(W3,{value:eZ,children:(0,rE.jsx)(W9,{value:e$,children:(0,rE.jsx)(W4,{value:e0,children:(0,rE.jsx)(W5,{value:e1,children:(0,rE.jsx)(ZI,{children:e})})})})})})})})}let eeF={poster:"wallart",carpet:"rugs"};function eeO(e){return"poster"===e||"carpet"===e}let eeQ=new rw({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(ix(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function eeU({type:e,src:t,tinuuid:r,roomId:n,name:i,height:a,width:s,language:o,dimensionUnit:l="m",displayUnit:c="cm",apiKey:u,source:d="default",showDialogCloseButton:h=!1,viewerSurface:p="inline",dialogPortalContainer:f=null,viewerDialogOpen:A=!0,onViewerDialogOpenChange:g,widgetSession:m}){let{i18n:v}=sf(),b=u?.trim()||void 0,y=r?.trim()||void 0,w=eeO(e)?eeF[e]:e,x=qU(w).takesDimensionProps?function(e,t,r="m"){return{width:qX(e??0,r),height:qX(t??0,r)}}(s,a,l):null;return(0,rx.useEffect)(()=>{eeO(e)&&eeF[e]},[e]),(0,rx.useEffect)(()=>{"string"==typeof o&&v.changeLanguage(o)},[v,o]),(0,rE.jsx)(rI,{client:eeQ,children:(0,rE.jsx)(eeN,{src:t??null,tinuuid:y??null,roomId:n,type:w,viewerSurface:p,dialogPortalContainer:f,viewerDialogOpen:A,onViewerDialogOpenChange:g,name:i,width:x?.width??0,height:x?.height??0,displayUnit:c,apiKey:b,baseURL:"shopify"===d?V_:void 0,source:d,externalWidgetSession:m,children:(0,rE.jsx)(eeR,{showDialogCloseButton:h})})})}function eez({type:e,src:t,tinuuid:r,roomId:n,width:i,height:a,dimensionUnit:s,displayUnit:o,name:l,language:c,apiKey:u,source:d,widgetSession:h,disableClose:p=!1,open:f,defaultOpen:A,onOpenChange:g}){let[m,v]=(0,rx.useState)(null),b="immersive-room"===Ww[eeO(e)?eeF[e]:e].chrome&&p,[y,w]=(0,rx.useState)(A??!1),x=f??y,[C,E]=(0,rx.useState)(x),S=x||C;(0,rx.useEffect)(()=>{x&&E(!0)},[x]);let M=(0,rE.jsx)(eeU,{type:e,src:t,tinuuid:r,roomId:n,name:l,height:a,width:i,dimensionUnit:s,displayUnit:o,language:c,apiKey:u,source:d,widgetSession:h,showDialogCloseButton:!b,viewerSurface:"dialog",dialogPortalContainer:m,viewerDialogOpen:x,onViewerDialogOpenChange:function(e){(e||!b)&&(void 0===f&&w(e),g?.(e))}});return(0,rE.jsxs)(rE.Fragment,{children:[(0,am.createPortal)((0,rE.jsx)("style",{children:VI.A}),document.head),(0,am.createPortal)((0,rE.jsxs)(s_.div,{"data-neurodyn-room-viewer-root":"",style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,rE.jsx)("style",{children:":host{display:block!important;visibility:visible!important}"}),(0,rE.jsx)("style",{children:VD}),(0,rE.jsx)("div",{ref:v}),m&&(0,rE.jsx)(VM,{root:m,storageKey:"neurodyn-theme",defaultTheme:"light",children:(0,rE.jsx)(sA,{i18n:Vk,children:S&&M})})]}),document.body)]})}Wt({baseURL:"https://api.neurodyn.ai/v1/"}),VY({baseURL:"https://api.neurodyn.ai/"});let eej=iQ({clientName:"API node client",configureFunctionName:"configureNodeApiClient",defaultBaseURL:"https://api.vizbl.com"});eej.configureClientRuntime,eej.configureAccessTokenResolverRuntime,eej.configureHeadersResolverRuntime,eej.configureUnauthorizedHandlerRuntime,eej.isClientConfiguredRuntime,eej.assertClientConfiguredRuntime,eej.resetClientForTestsRuntime;let eeG=eej.requestRuntime;async function eeH(e){return eeG(e)}async function eeV(e,t={}){let{client:r=eeH,...n}=t;return(await r({method:"POST",url:"/public/widget/activate-wallart",params:e,...n})).data}eej.requestWithoutUnauthorizedRecovery,eej.addResponseInterceptorRuntime,(eJ=tP||(tP={})).assertEqual=e=>{},eJ.assertIs=function(e){},eJ.assertNever=function(e){throw Error()},eJ.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},eJ.getValidEnumValues=e=>{let t=eJ.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let n of t)r[n]=e[n];return eJ.objectValues(r)},eJ.objectValues=e=>eJ.objectKeys(e).map(function(t){return e[t]}),eJ.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},eJ.find=(e,t)=>{for(let r of e)if(t(r))return r},eJ.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,eJ.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},eJ.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(t_||(t_={})).mergeShapes=(e,t)=>({...e,...t});let eeW=tP.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),eeq=e=>{switch(typeof e){case"undefined":return eeW.undefined;case"string":return eeW.string;case"number":return Number.isNaN(e)?eeW.nan:eeW.number;case"boolean":return eeW.boolean;case"function":return eeW.function;case"bigint":return eeW.bigint;case"symbol":return eeW.symbol;case"object":if(Array.isArray(e))return eeW.array;if(null===e)return eeW.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return eeW.promise;if("u">typeof Map&&e instanceof Map)return eeW.map;if("u">typeof Set&&e instanceof Set)return eeW.set;if("u">typeof Date&&e instanceof Date)return eeW.date;return eeW.object;default:return eeW.unknown}},eeK=tP.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class eeJ extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;n<i.path.length;){let r=i.path[n];n===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof eeJ))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tP.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}eeJ.create=e=>new eeJ(e);let eeY=(e,t)=>{let r;switch(e.code){case eeK.invalid_type:r=e.received===eeW.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case eeK.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,tP.jsonStringifyReplacer)}`;break;case eeK.unrecognized_keys:r=`Unrecognized key(s) in object: ${tP.joinValues(e.keys,", ")}`;break;case eeK.invalid_union:r="Invalid input";break;case eeK.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${tP.joinValues(e.options)}`;break;case eeK.invalid_enum_value:r=`Invalid enum value. Expected ${tP.joinValues(e.options)}, received '${e.received}'`;break;case eeK.invalid_arguments:r="Invalid function arguments";break;case eeK.invalid_return_type:r="Invalid function return type";break;case eeK.invalid_date:r="Invalid date";break;case eeK.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:tP.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case eeK.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case eeK.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case eeK.custom:r="Invalid input";break;case eeK.invalid_intersection_types:r="Intersection results could not be merged";break;case eeK.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case eeK.not_finite:r="Number must be finite";break;default:r=t.defaultError,tP.assertNever(e)}return{message:r}};(eY=tL||(tL={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},eY.toString=e=>"string"==typeof e?e:e?.message;let eeX=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],s={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(s,{data:t,defaultError:o}).message;return{...i,path:a,message:o}};function eeZ(e,t){let r=eeX({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,eeY,void 0].filter(e=>!!e)});e.common.issues.push(r)}class ee${constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return ee0;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return ee$.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:i}=n;if("aborted"===t.status||"aborted"===i.status)return ee0;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||n.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let ee0=Object.freeze({status:"aborted"}),ee1=e=>({status:"dirty",value:e}),ee2=e=>({status:"valid",value:e}),ee3=e=>"u">typeof Promise&&e instanceof Promise;class ee9{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let ee4=(e,t)=>{if("valid"===t.status)return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new eeJ(e.common.issues);return this._error=t,this._error}}};function ee5(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??i.defaultError}:void 0===i.data?{message:a??n??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:a??r??i.defaultError}},description:i}}class ee8{get description(){return this._def.description}_getType(e){return eeq(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:eeq(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ee$,ctx:{common:e.parent.common,data:e.data,parsedType:eeq(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ee3(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeq(e)},n=this._parseSync({data:e,path:r.path,parent:r});return ee4(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeq(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return"valid"===r.status?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>"valid"===e.status?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eeq(e)},n=this._parse({data:e,path:r.path,parent:r});return ee4(r,await (ee3(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((r,n)=>{let i=e(r),a=()=>n.addIssue({code:eeK.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new etH({schema:this,typeName:tN.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return etV.create(this,this._def)}nullable(){return etW.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return etI.create(this)}promise(){return etG.create(this,this._def)}or(e){return etk.create([this,e],this._def)}and(e){return etD.create(this,e,this._def)}transform(e){return new etH({...ee5(this._def),schema:this,typeName:tN.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new etq({...ee5(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:tN.ZodDefault})}brand(){return new etY({typeName:tN.ZodBranded,type:this,...ee5(this._def)})}catch(e){return new etK({...ee5(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:tN.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return etX.create(this,e)}readonly(){return etZ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let ee6=/^c[^\s-]{8,}$/i,ee7=/^[0-9a-z]+$/,ete=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ett=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,etr=/^[a-z0-9_-]{21}$/i,etn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,eti=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,eta=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ets=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,eto=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,etl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,etc=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,etu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,etd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eth="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",etp=RegExp(`^${eth}$`);function etf(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}class etA extends ee8{_parse(e){var t,r,n,i;let a;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==eeW.string){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.string,received:t.parsedType}),ee0}let s=new ee$;for(let o of this._def.checks)if("min"===o.kind)e.data.length<o.value&&(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if("max"===o.kind)e.data.length>o.value&&(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if("length"===o.kind){let t=e.data.length>o.value,r=e.data.length<o.value;(t||r)&&(a=this._getOrReturnCtx(e,a),t?eeZ(a,{code:eeK.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):r&&eeZ(a,{code:eeK.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if("email"===o.kind)eta.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"email",code:eeK.invalid_string,message:o.message}),s.dirty());else if("emoji"===o.kind)I||(I=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),I.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:eeK.invalid_string,message:o.message}),s.dirty());else if("uuid"===o.kind)ett.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:eeK.invalid_string,message:o.message}),s.dirty());else if("nanoid"===o.kind)etr.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:eeK.invalid_string,message:o.message}),s.dirty());else if("cuid"===o.kind)ee6.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:eeK.invalid_string,message:o.message}),s.dirty());else if("cuid2"===o.kind)ee7.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:eeK.invalid_string,message:o.message}),s.dirty());else if("ulid"===o.kind)ete.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:eeK.invalid_string,message:o.message}),s.dirty());else if("url"===o.kind)try{new URL(e.data)}catch{eeZ(a=this._getOrReturnCtx(e,a),{validation:"url",code:eeK.invalid_string,message:o.message}),s.dirty()}else"regex"===o.kind?(o.regex.lastIndex=0,o.regex.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"regex",code:eeK.invalid_string,message:o.message}),s.dirty())):"trim"===o.kind?e.data=e.data.trim():"includes"===o.kind?e.data.includes(o.value,o.position)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.dirty()):"toLowerCase"===o.kind?e.data=e.data.toLowerCase():"toUpperCase"===o.kind?e.data=e.data.toUpperCase():"startsWith"===o.kind?e.data.startsWith(o.value)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):"endsWith"===o.kind?e.data.endsWith(o.value)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):"datetime"===o.kind?(function(e){let t=`${eth}T${etf(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)})(o).test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:"datetime",message:o.message}),s.dirty()):"date"===o.kind?etp.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:"date",message:o.message}),s.dirty()):"time"===o.kind?RegExp(`^${etf(o)}$`).test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{code:eeK.invalid_string,validation:"time",message:o.message}),s.dirty()):"duration"===o.kind?eti.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"duration",code:eeK.invalid_string,message:o.message}),s.dirty()):"ip"===o.kind?(t=e.data,!(("v4"===(r=o.version)||!r)&&ets.test(t)||("v6"===r||!r)&&etl.test(t))&&1&&(eeZ(a=this._getOrReturnCtx(e,a),{validation:"ip",code:eeK.invalid_string,message:o.message}),s.dirty())):"jwt"===o.kind?!function(e,t){if(!etn.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,o.alg)&&(eeZ(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:eeK.invalid_string,message:o.message}),s.dirty()):"cidr"===o.kind?(n=e.data,!(("v4"===(i=o.version)||!i)&&eto.test(n)||("v6"===i||!i)&&etc.test(n))&&1&&(eeZ(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:eeK.invalid_string,message:o.message}),s.dirty())):"base64"===o.kind?etu.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"base64",code:eeK.invalid_string,message:o.message}),s.dirty()):"base64url"===o.kind?etd.test(e.data)||(eeZ(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:eeK.invalid_string,message:o.message}),s.dirty()):tP.assertNever(o);return{status:s.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:eeK.invalid_string,...tL.errToObj(r)})}_addCheck(e){return new etA({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tL.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tL.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tL.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tL.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tL.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tL.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tL.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tL.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tL.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tL.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tL.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tL.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tL.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tL.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tL.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tL.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tL.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tL.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tL.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tL.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tL.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tL.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tL.errToObj(t)})}nonempty(e){return this.min(1,tL.errToObj(e))}trim(){return new etA({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new etA({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new etA({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}etA.create=e=>new etA({checks:[],typeName:tN.ZodString,coerce:e?.coerce??!1,...ee5(e)});class etg extends ee8{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==eeW.number){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.number,received:t.parsedType}),ee0}let r=new ee$;for(let n of this._def.checks)"int"===n.kind?tP.isInteger(e.data)||(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,n.value)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.not_finite,message:n.message}),r.dirty()):tP.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tL.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tL.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tL.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tL.toString(t))}setLimit(e,t,r,n){return new etg({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tL.toString(n)}]})}_addCheck(e){return new etg({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tL.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tL.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tL.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tL.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tL.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tL.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tL.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tL.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tL.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tP.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}etg.create=e=>new etg({checks:[],typeName:tN.ZodNumber,coerce:e?.coerce||!1,...ee5(e)});class etm extends ee8{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==eeW.bigint)return this._getInvalidInput(e);let r=new ee$;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):tP.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.bigint,received:t.parsedType}),ee0}gte(e,t){return this.setLimit("min",e,!0,tL.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tL.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tL.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tL.toString(t))}setLimit(e,t,r,n){return new etm({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tL.toString(n)}]})}_addCheck(e){return new etm({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tL.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tL.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tL.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tL.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tL.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}etm.create=e=>new etm({checks:[],typeName:tN.ZodBigInt,coerce:e?.coerce??!1,...ee5(e)});class etv extends ee8{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==eeW.boolean){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.boolean,received:t.parsedType}),ee0}return ee2(e.data)}}etv.create=e=>new etv({typeName:tN.ZodBoolean,coerce:e?.coerce||!1,...ee5(e)});class etb extends ee8{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==eeW.date){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.date,received:t.parsedType}),ee0}if(Number.isNaN(e.data.getTime()))return eeZ(this._getOrReturnCtx(e),{code:eeK.invalid_date}),ee0;let r=new ee$;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(eeZ(t=this._getOrReturnCtx(e,t),{code:eeK.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):tP.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new etb({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tL.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tL.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}etb.create=e=>new etb({checks:[],coerce:e?.coerce||!1,typeName:tN.ZodDate,...ee5(e)});class ety extends ee8{_parse(e){if(this._getType(e)!==eeW.symbol){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.symbol,received:t.parsedType}),ee0}return ee2(e.data)}}ety.create=e=>new ety({typeName:tN.ZodSymbol,...ee5(e)});class etw extends ee8{_parse(e){if(this._getType(e)!==eeW.undefined){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.undefined,received:t.parsedType}),ee0}return ee2(e.data)}}etw.create=e=>new etw({typeName:tN.ZodUndefined,...ee5(e)});class etx extends ee8{_parse(e){if(this._getType(e)!==eeW.null){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.null,received:t.parsedType}),ee0}return ee2(e.data)}}etx.create=e=>new etx({typeName:tN.ZodNull,...ee5(e)});class etC extends ee8{constructor(){super(...arguments),this._any=!0}_parse(e){return ee2(e.data)}}etC.create=e=>new etC({typeName:tN.ZodAny,...ee5(e)});class etE extends ee8{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee2(e.data)}}etE.create=e=>new etE({typeName:tN.ZodUnknown,...ee5(e)});class etS extends ee8{_parse(e){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.never,received:t.parsedType}),ee0}}etS.create=e=>new etS({typeName:tN.ZodNever,...ee5(e)});class etM extends ee8{_parse(e){if(this._getType(e)!==eeW.undefined){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.void,received:t.parsedType}),ee0}return ee2(e.data)}}etM.create=e=>new etM({typeName:tN.ZodVoid,...ee5(e)});class etI extends ee8{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==eeW.array)return eeZ(t,{code:eeK.invalid_type,expected:eeW.array,received:t.parsedType}),ee0;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(e||i)&&(eeZ(t,{code:e?eeK.too_big:eeK.too_small,minimum:i?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(eeZ(t,{code:eeK.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(eeZ(t,{code:eeK.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new ee9(t,e,t.path,r)))).then(e=>ee$.mergeArray(r,e));let i=[...t.data].map((e,r)=>n.type._parseSync(new ee9(t,e,t.path,r)));return ee$.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new etI({...this._def,minLength:{value:e,message:tL.toString(t)}})}max(e,t){return new etI({...this._def,maxLength:{value:e,message:tL.toString(t)}})}length(e,t){return new etI({...this._def,exactLength:{value:e,message:tL.toString(t)}})}nonempty(e){return this.min(1,e)}}etI.create=(e,t)=>new etI({type:e,minLength:null,maxLength:null,exactLength:null,typeName:tN.ZodArray,...ee5(t)});class etB extends ee8{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tP.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==eeW.object){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.object,received:t.parsedType}),ee0}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof etS&&"strip"===this._def.unknownKeys))for(let e in r.data)i.includes(e)||a.push(e);let s=[];for(let e of i){let t=n[e],i=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ee9(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof etS){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(eeZ(r,{code:eeK.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ee9(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of s){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>ee$.mergeObjectSync(t,e)):ee$.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return tL.errToObj,new etB({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tL.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new etB({...this._def,unknownKeys:"strip"})}passthrough(){return new etB({...this._def,unknownKeys:"passthrough"})}extend(e){return new etB({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new etB({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:tN.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new etB({...this._def,catchall:e})}pick(e){let t={};for(let r of tP.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new etB({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tP.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new etB({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof etB){let r={};for(let n in t.shape){let i=t.shape[n];r[n]=etV.create(e(i))}return new etB({...t._def,shape:()=>r})}if(t instanceof etI)return new etI({...t._def,type:e(t.element)});if(t instanceof etV)return etV.create(e(t.unwrap()));if(t instanceof etW)return etW.create(e(t.unwrap()));if(t instanceof etP)return etP.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tP.objectKeys(this.shape)){let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new etB({...this._def,shape:()=>t})}required(e){let t={};for(let r of tP.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof etV;)e=e._def.innerType;t[r]=e}return new etB({...this._def,shape:()=>t})}keyof(){return etU(tP.objectKeys(this.shape))}}etB.create=(e,t)=>new etB({shape:()=>e,unknownKeys:"strip",catchall:etS.create(),typeName:tN.ZodObject,...ee5(t)}),etB.strictCreate=(e,t)=>new etB({shape:()=>e,unknownKeys:"strict",catchall:etS.create(),typeName:tN.ZodObject,...ee5(t)}),etB.lazycreate=(e,t)=>new etB({shape:e,unknownKeys:"strip",catchall:etS.create(),typeName:tN.ZodObject,...ee5(t)});class etk extends ee8{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new eeJ(e.ctx.common.issues));return eeZ(t,{code:eeK.invalid_union,unionErrors:r}),ee0});{let e,n=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=n.map(e=>new eeJ(e));return eeZ(t,{code:eeK.invalid_union,unionErrors:i}),ee0}}get options(){return this._def.options}}etk.create=(e,t)=>new etk({options:e,typeName:tN.ZodUnion,...ee5(t)});let etT=e=>{if(e instanceof etO)return etT(e.schema);if(e instanceof etH)return etT(e.innerType());if(e instanceof etQ)return[e.value];if(e instanceof etz)return e.options;if(e instanceof etj)return tP.objectValues(e.enum);else if(e instanceof etq)return etT(e._def.innerType);else if(e instanceof etw)return[void 0];else if(e instanceof etx)return[null];else if(e instanceof etV)return[void 0,...etT(e.unwrap())];else if(e instanceof etW)return[null,...etT(e.unwrap())];else if(e instanceof etY)return etT(e.unwrap());else if(e instanceof etZ)return etT(e.unwrap());else if(e instanceof etK)return etT(e._def.innerType);else return[]};class etR extends ee8{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==eeW.object)return eeZ(t,{code:eeK.invalid_type,expected:eeW.object,received:t.parsedType}),ee0;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(eeZ(t,{code:eeK.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ee0)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let r of t){let t=etT(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,r)}}return new etR({typeName:tN.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...ee5(r)})}}class etD extends ee8{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if("aborted"===e.status||"aborted"===n.status)return ee0;let i=function e(t,r){let n=eeq(t),i=eeq(r);if(t===r)return{valid:!0,data:t};if(n===eeW.object&&i===eeW.object){let n=tP.objectKeys(r),i=tP.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...r};for(let n of i){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===eeW.array&&i===eeW.array){if(t.length!==r.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let a=e(t[i],r[i]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}if(n===eeW.date&&i===eeW.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return i.valid?(("dirty"===e.status||"dirty"===n.status)&&t.dirty(),{status:t.value,value:i.data}):(eeZ(r,{code:eeK.invalid_intersection_types}),ee0)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}etD.create=(e,t,r)=>new etD({left:e,right:t,typeName:tN.ZodIntersection,...ee5(r)});class etP extends ee8{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeW.array)return eeZ(r,{code:eeK.invalid_type,expected:eeW.array,received:r.parsedType}),ee0;if(r.data.length<this._def.items.length)return eeZ(r,{code:eeK.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee0;!this._def.rest&&r.data.length>this._def.items.length&&(eeZ(r,{code:eeK.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new ee9(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>ee$.mergeArray(t,e)):ee$.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new etP({...this._def,rest:e})}}etP.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new etP({items:e,typeName:tN.ZodTuple,rest:null,...ee5(t)})};class et_ extends ee8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeW.object)return eeZ(r,{code:eeK.invalid_type,expected:eeW.object,received:r.parsedType}),ee0;let n=[],i=this._def.keyType,a=this._def.valueType;for(let e in r.data)n.push({key:i._parse(new ee9(r,e,r.path,e)),value:a._parse(new ee9(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?ee$.mergeObjectAsync(t,n):ee$.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new et_(t instanceof ee8?{keyType:e,valueType:t,typeName:tN.ZodRecord,...ee5(r)}:{keyType:etA.create(),valueType:e,typeName:tN.ZodRecord,...ee5(t)})}}class etL extends ee8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeW.map)return eeZ(r,{code:eeK.invalid_type,expected:eeW.map,received:r.parsedType}),ee0;let n=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new ee9(r,e,r.path,[a,"key"])),value:i._parse(new ee9(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return ee0;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return ee0;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}etL.create=(e,t,r)=>new etL({valueType:t,keyType:e,typeName:tN.ZodMap,...ee5(r)});class etN extends ee8{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==eeW.set)return eeZ(r,{code:eeK.invalid_type,expected:eeW.set,received:r.parsedType}),ee0;let n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(eeZ(r,{code:eeK.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(eeZ(r,{code:eeK.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let r=new Set;for(let n of e){if("aborted"===n.status)return ee0;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let s=[...r.data.values()].map((e,t)=>i._parse(new ee9(r,e,r.path,t)));return r.common.async?Promise.all(s).then(e=>a(e)):a(s)}min(e,t){return new etN({...this._def,minSize:{value:e,message:tL.toString(t)}})}max(e,t){return new etN({...this._def,maxSize:{value:e,message:tL.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}etN.create=(e,t)=>new etN({valueType:e,minSize:null,maxSize:null,typeName:tN.ZodSet,...ee5(t)});class etF extends ee8{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==eeW.function)return eeZ(t,{code:eeK.invalid_type,expected:eeW.function,received:t.parsedType}),ee0;function r(e,r){return eeX({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,eeY,eeY].filter(e=>!!e),issueData:{code:eeK.invalid_arguments,argumentsError:r}})}function n(e,r){return eeX({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,eeY,eeY].filter(e=>!!e),issueData:{code:eeK.invalid_return_type,returnTypeError:r}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof etG){let e=this;return ee2(async function(...t){let s=new eeJ([]),o=await e._def.args.parseAsync(t,i).catch(e=>{throw s.addIssue(r(t,e)),s}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,i).catch(e=>{throw s.addIssue(n(l,e)),s})})}{let e=this;return ee2(function(...t){let s=e._def.args.safeParse(t,i);if(!s.success)throw new eeJ([r(t,s.error)]);let o=Reflect.apply(a,this,s.data),l=e._def.returns.safeParse(o,i);if(!l.success)throw new eeJ([n(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new etF({...this._def,args:etP.create(e).rest(etE.create())})}returns(e){return new etF({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new etF({args:e||etP.create([]).rest(etE.create()),returns:t||etE.create(),typeName:tN.ZodFunction,...ee5(r)})}}class etO extends ee8{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}etO.create=(e,t)=>new etO({getter:e,typeName:tN.ZodLazy,...ee5(t)});class etQ extends ee8{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return eeZ(t,{received:t.data,code:eeK.invalid_literal,expected:this._def.value}),ee0}return{status:"valid",value:e.data}}get value(){return this._def.value}}function etU(e,t){return new etz({values:e,typeName:tN.ZodEnum,...ee5(t)})}etQ.create=(e,t)=>new etQ({value:e,typeName:tN.ZodLiteral,...ee5(t)});class etz extends ee8{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return eeZ(t,{expected:tP.joinValues(r),received:t.parsedType,code:eeK.invalid_type}),ee0}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return eeZ(t,{received:t.data,code:eeK.invalid_enum_value,options:r}),ee0}return ee2(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return etz.create(e,{...this._def,...t})}exclude(e,t=this._def){return etz.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}etz.create=etU;class etj extends ee8{_parse(e){let t=tP.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==eeW.string&&r.parsedType!==eeW.number){let e=tP.objectValues(t);return eeZ(r,{expected:tP.joinValues(e),received:r.parsedType,code:eeK.invalid_type}),ee0}if(this._cache||(this._cache=new Set(tP.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tP.objectValues(t);return eeZ(r,{received:r.data,code:eeK.invalid_enum_value,options:e}),ee0}return ee2(e.data)}get enum(){return this._def.values}}etj.create=(e,t)=>new etj({values:e,typeName:tN.ZodNativeEnum,...ee5(t)});class etG extends ee8{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==eeW.promise&&!1===t.common.async?(eeZ(t,{code:eeK.invalid_type,expected:eeW.promise,received:t.parsedType}),ee0):ee2((t.parsedType===eeW.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}etG.create=(e,t)=>new etG({type:e,typeName:tN.ZodPromise,...ee5(t)});class etH extends ee8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===tN.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{eeZ(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){let e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return ee0;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?ee0:"dirty"===n.status||"dirty"===t.value?ee1(n.value):n});{if("aborted"===t.value)return ee0;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?ee0:"dirty"===n.status||"dirty"===t.value?ee1(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?ee0:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?ee0:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>"valid"!==e.status?ee0:Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})));else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if("valid"!==e.status)return ee0;let a=n.transform(e.value,i);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}tP.assertNever(n)}}etH.create=(e,t,r)=>new etH({schema:e,typeName:tN.ZodEffects,effect:t,...ee5(r)}),etH.createWithPreprocess=(e,t,r)=>new etH({schema:t,effect:{type:"preprocess",transform:e},typeName:tN.ZodEffects,...ee5(r)});class etV extends ee8{_parse(e){return this._getType(e)===eeW.undefined?ee2(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}etV.create=(e,t)=>new etV({innerType:e,typeName:tN.ZodOptional,...ee5(t)});class etW extends ee8{_parse(e){return this._getType(e)===eeW.null?ee2(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}etW.create=(e,t)=>new etW({innerType:e,typeName:tN.ZodNullable,...ee5(t)});class etq extends ee8{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===eeW.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}etq.create=(e,t)=>new etq({innerType:e,typeName:tN.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ee5(t)});class etK extends ee8{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ee3(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new eeJ(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new eeJ(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}etK.create=(e,t)=>new etK({innerType:e,typeName:tN.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ee5(t)});class etJ extends ee8{_parse(e){if(this._getType(e)!==eeW.nan){let t=this._getOrReturnCtx(e);return eeZ(t,{code:eeK.invalid_type,expected:eeW.nan,received:t.parsedType}),ee0}return{status:"valid",value:e.data}}}etJ.create=e=>new etJ({typeName:tN.ZodNaN,...ee5(e)}),Symbol("zod_brand");class etY extends ee8{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class etX extends ee8{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?ee0:"dirty"===e.status?(t.dirty(),ee1(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?ee0:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new etX({in:e,out:t,typeName:tN.ZodPipeline})}}class etZ extends ee8{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return ee3(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}etZ.create=(e,t)=>new etZ({innerType:e,typeName:tN.ZodReadonly,...ee5(t)}),etB.lazycreate,(eX=tN||(tN={})).ZodString="ZodString",eX.ZodNumber="ZodNumber",eX.ZodNaN="ZodNaN",eX.ZodBigInt="ZodBigInt",eX.ZodBoolean="ZodBoolean",eX.ZodDate="ZodDate",eX.ZodSymbol="ZodSymbol",eX.ZodUndefined="ZodUndefined",eX.ZodNull="ZodNull",eX.ZodAny="ZodAny",eX.ZodUnknown="ZodUnknown",eX.ZodNever="ZodNever",eX.ZodVoid="ZodVoid",eX.ZodArray="ZodArray",eX.ZodObject="ZodObject",eX.ZodUnion="ZodUnion",eX.ZodDiscriminatedUnion="ZodDiscriminatedUnion",eX.ZodIntersection="ZodIntersection",eX.ZodTuple="ZodTuple",eX.ZodRecord="ZodRecord",eX.ZodMap="ZodMap",eX.ZodSet="ZodSet",eX.ZodFunction="ZodFunction",eX.ZodLazy="ZodLazy",eX.ZodLiteral="ZodLiteral",eX.ZodEnum="ZodEnum",eX.ZodEffects="ZodEffects",eX.ZodNativeEnum="ZodNativeEnum",eX.ZodOptional="ZodOptional",eX.ZodNullable="ZodNullable",eX.ZodDefault="ZodDefault",eX.ZodCatch="ZodCatch",eX.ZodPromise="ZodPromise",eX.ZodBranded="ZodBranded",eX.ZodPipeline="ZodPipeline",eX.ZodReadonly="ZodReadonly";let et$=etA.create,et0=etg.create;etJ.create,etm.create;let et1=etv.create;etb.create,ety.create,etw.create,etx.create,etC.create;let et2=etE.create;etS.create,etM.create,etI.create;let et3=etB.create;etB.strictCreate,etk.create,etR.create,etD.create,etP.create,et_.create,etL.create,etN.create,etF.create,etO.create,etQ.create;let et9=etz.create;etj.create,etG.create,etH.create,etV.create,etW.create;let et4=etH.createWithPreprocess;etX.create;let et5=et9(["cm","inch"]),et8=et9(["different_fields","one_field"]),et6=et9(["left_bottom","center","right_bottom","left_center","right_center"]),et7=et3({buttonLabel:et$(),backgroundColor:et$(),borderColor:et$(),textColor:et$(),borderRadius:et0(),borderWidth:et0()}),ere=et3({units:et5,productWidthAndHeight:et8,metafieldForWidth:et$().nullable(),metafieldForHeight:et$().nullable(),metafieldForWidthAndHeight:et$().nullable(),widgetPosition:et6,_widgetSettings:et7.optional(),isWidgetActive:et1()}),ert=function(e){let t=e?.trim().replace(/\/+$/,"")??"";if(!t||t.includes("/v1/http")||t.endsWith("/v1"))return t;let r=t.indexOf("/http");return r>=0?`${t.slice(0,r)}/v1${t.slice(r)}`:`${t}/v1`}("/apps/vizbl-wall-art/http"),err=et3({token:et$().trim().min(1),sid:et$().trim().min(1),expiresIn:et0().finite()}),ern=et3({metafields:et$().trim().min(1),posterPic:et$().trim().min(1),title:et$().trim().optional(),widgetSession:et2().optional()}),eri=et4(e=>"string"==typeof e?JSON.parse(e):e,et3({metafield:et2(),tinuuid:et$().trim().optional()}));async function era(e,t){let r=await eeV({productType:"wallart-shopify",variant_id:e,metafield_key:"poster_settings"},{baseURL:ert,signal:t});return function(e){let t,r,n=ern.safeParse("string"!=typeof e?e:JSON.parse(e));if(!n.success)return null;let i=eri.safeParse(n.data.metafields);if(!i.success)return null;let a=(t=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return}}(i.data.metafield),(r=ere.safeParse(t)).success?r.data:null);if(!a)return null;let s=err.safeParse(n.data.widgetSession);return{settings:a,posterPic:n.data.posterPic,title:n.data.title??null,tinuuid:i.data.tinuuid??null,widgetSession:s.success?s.data:null}}(r.body??r)}let ers="44px",ero="60px",erl={left_center:{left:ero,top:"50%",transform:"translateY(-50%)"},left_bottom:{left:ero,bottom:ers},center:{left:`calc(50% + ${ero})`,bottom:ers,transform:"translateX(-50%)"},right_bottom:{right:ero,bottom:ers},right_center:{right:ero,top:"50%",transform:"translateY(-50%)"}},erc=et4(e=>"number"==typeof e&&Number.isFinite(e)?String(e):e,et$().trim().regex(/^\d+$/));function eru(e){let t=erc.safeParse(e);return t.success?t.data:null}function erd(e){return e?e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.value:e.getAttribute("value"):null}let erh=["product-form","[data-main-product]",'[id*="MainProduct"]',".product",".product__info-wrapper",".product__info-container","#MainContent"],erp=[".product-recommendations",".related-products","[data-product-recommendations]"];var erf=r("./src/shopify.css?inline");function erA(){let e=function({documentRef:e=document,locationRef:t=window.location,analytics:r=window.ShopifyAnalytics}={}){var n;let i=e.body;if(i?.classList.contains("template-collection"))return!1;if(n=t.pathname,/(?:^|\/)products\/[^/]+/i.test(n)||r?.meta?.page?.pageType?.toLowerCase()==="product")return!0;let a=e.querySelector('meta[property="og:type"]')?.getAttribute("content");return!!(a?.trim().toLowerCase()==="product"||i?.classList.contains("template-product"))}();return{isProductPage:e,variantId:e?function({documentRef:e=document,locationRef:t=window.location}={}){return function(e=window.location){return eru(new URLSearchParams(e.search).get("variant"))}(t)??function(e=document){for(let{field:t}of Array.from(e.querySelectorAll('form[action*="/cart/add"]')).flatMap((t,r)=>{let n;return[...Array.from(t.querySelectorAll('input[name="id"], select[name="id"]')),...!(n=t.getAttribute("id"))?[]:Array.from(e.querySelectorAll('input[name="id"][form], select[name="id"][form]')).filter(e=>e.getAttribute("form")===n)].map((e,n)=>({field:e,formIndex:r,fieldIndex:n,score:function(e){let t=0,r=(e.getAttribute("id")??"").toLowerCase(),n=(e.getAttribute("class")??"").toLowerCase();for(let i of(r.includes("product-form")&&(t+=100),n.includes("product-form")&&(t+=80),erh))e.closest(i)&&(t+=25);for(let r of erp)e.closest(r)&&(t-=100);return t}(t)}))}).sort((e,t)=>t.score-e.score||e.formIndex-t.formIndex||e.fieldIndex-t.fieldIndex)){let e=eru(erd(t));if(e)return e}return null}(e)??function(e=document){for(let t of Array.from(e.querySelectorAll('[name="id"][form^="product-form"]'))){let e=eru(erd(t));if(e)return e}return null}(e)??function(e=document){let t=e.querySelector("[data-selected-variant-id]");return eru(t?.getAttribute("data-selected-variant-id")??null)}(e)}():null}}function erg(){let e=function(){let[e,t]=(0,rx.useState)(erA);return(0,rx.useEffect)(()=>{let e=null,r=window.history.pushState,n=window.history.replaceState,i=()=>{null===e&&(e=window.requestAnimationFrame(()=>{e=null,t(e=>{let t=erA();return e.isProductPage===t.isProductPage&&e.variantId===t.variantId?e:t})}))};window.history.pushState=function(...e){let t=r.apply(this,e);return i(),t},window.history.replaceState=function(...e){let t=n.apply(this,e);return i(),t};let a=ag('body.template-product, body.template-collection, meta[property="og:type"], form[action*="/cart/add"], form[action*="/cart/add"] [name="id"], [name="id"][form], [data-selected-variant-id]',{initialize(e){let t;return{add(){t=(e=>{var t;let r=(t=e).matches("body")?["class"]:t.matches('meta[property="og:type"]')?["content"]:t.matches('form[action*="/cart/add"]')?["action","class","id"]:t.matches('form[action*="/cart/add"] [name="id"], [name="id"][form]')?["form","value"]:t.matches("[data-selected-variant-id]")?["data-selected-variant-id"]:[];if(0===r.length)return;let n=new MutationObserver(i);return n.observe(e,{attributes:!0,attributeFilter:r}),()=>{n.disconnect()}})(e),i()},remove(){t?.(),t=void 0,i()}}}});return document.addEventListener("change",i,!0),document.addEventListener("input",i,!0),document.addEventListener("click",i,!0),window.addEventListener("popstate",i),i(),()=>{null!==e&&window.cancelAnimationFrame(e),window.history.pushState=r,window.history.replaceState=n,a.abort(),document.removeEventListener("change",i,!0),document.removeEventListener("input",i,!0),document.removeEventListener("click",i,!0),window.removeEventListener("popstate",i)}},[]),e}(),[t,r]=(0,rx.useState)(!1),{data:n}=od({queryKey:["vizbl-shopify-room-viewer","activation",e.variantId],queryFn:({signal:t})=>era(e.variantId??"",t),enabled:e.isProductPage&&null!==e.variantId,staleTime:3e5,gcTime:3e5,refetchOnWindowFocus:!1},s2,void 0),i=(0,rx.useCallback)(()=>{r(!0)},[]),a=(0,rx.useCallback)(e=>{r(e)},[]);if(!e.isProductPage||!e.variantId||!n?.settings.isWidgetActive)return null;let{settings:s,posterPic:o,title:l}=n,c=s._widgetSettings,u=function(e){if("one_field"===e.productWidthAndHeight){let[t,r]=e.metafieldForWidthAndHeight.split("x");return{width:Number(t),height:Number(r)}}return{width:Number(e.metafieldForWidth),height:Number(e.metafieldForHeight)}}(s),d="inch"===s.units?"in":"cm";return(0,rE.jsxs)(rE.Fragment,{children:[(0,rE.jsx)("button",{type:"button",onClick:i,style:{position:"fixed",zIndex:0x7ffffffe,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"13.522px 21.635px",borderStyle:"solid",borderColor:c?.borderColor??"rgba(65, 90, 229, 0.3)",borderWidth:c?.borderWidth??1,borderRadius:c?.borderRadius??121.053,background:c?.backgroundColor??"#ffffff",boxShadow:"0px 0px 20px 0px rgba(23, 32, 51, 0.14), 0px 16px 32px 0px rgba(23, 32, 51, 0.17)",color:c?.textColor??"#111111",boxSizing:"border-box",cursor:"pointer",maxWidth:"calc(100vw - 16px)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontSize:18,fontWeight:600,letterSpacing:0,lineHeight:"18px",margin:0,appearance:"none",...erl[s.widgetPosition]},children:c?.buttonLabel??"View in place"}),(0,rE.jsx)(eez,{open:t,onOpenChange:a,type:"wallart",source:"shopify",src:o,name:l??"",width:u.width,height:u.height,dimensionUnit:d,widgetSession:n.widgetSession}),t&&(0,am.createPortal)((0,rE.jsx)("style",{children:erf.A}),document.head)]})}let erm="vizbl-shopify-room-viewer",erv=new rw({defaultOptions:{queries:{refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(ix(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function erb(){let e,t=((e=document.getElementById(erm))||((e=document.createElement("div")).id=erm,document.body.appendChild(e)),e),r=ij.createRoot(t);r.render((0,rx.createElement)(rI,{client:erv},(0,rx.createElement)(erg)));let n=ag(`#${erm}`,{remove(){n.abort(),r.unmount(),erb()}})}iz({baseURL:ert}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",erb,{once:!0}):erb()})()})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizbl/shopify-room-viewer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.30",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"react-dom": "^19.2.0",
|
|
16
16
|
"selector-observer": "^2.1.6",
|
|
17
17
|
"zod": "^3.25.76",
|
|
18
|
-
"@neurodyn/react-room-viewer": "0.0.
|
|
18
|
+
"@neurodyn/react-room-viewer": "0.0.30"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@rsbuild/core": "1.7.1",
|