"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),ChildrenDroppable=require("../../../grid/components/ChildrenDroppable.js"),Loading=require("../../../common/components/Loading.js");require("react");var Row=require("../../../grid/components/row/Row.js"),system=require("@gem-sdk/system"),dynamic=require("next/dynamic"),useProductSetting=require("./hook/useProductSetting.js"),helpers=require("./common/helpers.js");const ProductNotFound=dynamic(()=>Promise.resolve().then(function(){return require("../ProductNotFound.js")}),{loading:Loading.default}),Product=e=>{let{builderProps:r,children:t,setting:s,style:i,builderAttrs:n}=e,{isAuto:u}=s??{},{isLoading:o,isProductPage:d,isProductNotFound:c,showProductNotFound:m,errorLoadProduct:l,product:j,isEditor:a,productProviderData:x,setShowProductNotFound:p}=useProductSetting.useProductSetting(e),{rowSetting:g,rowStyles:h}=helpers.getData(e),R=!c;if(d&&u)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:core.isEmptyChildren(t)?jsxRuntime.jsx(ChildrenDroppable.default,{}):t});let P=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:system.If(m,jsxRuntime.jsx(ProductNotFound,{builderAttrs:n,productSrc:"PickProduct",onClose:()=>p(!1),children:t}))}),y=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:o?jsxRuntime.jsx(Loading.default,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsxs("div",{children:["Error: ",l?.message]}):j?jsxRuntime.jsx(core.ProductProvider,{...x,children:jsxRuntime.jsx(Row.default,{builderProps:r,builderAttrs:n,style:i,styles:h,setting:g,customAttrs:a?{"data-product-id":j?.baseID?.replace("gid://shopify/Product/","")??""}:void 0,children:core.isEmptyChildren(t)?jsxRuntime.jsx(ChildrenDroppable.default,{}):t})}):null})});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:system.If(R,y(),P())})};exports.default=Product;
