'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),NoDataState=require("../../common/components/NoDataState.js");const ProductNotFound=({collectionHandle:t,productSrc:e,builderAttrs:o,children:r})=>{let n="STATIC"===core.usePageType(),c=core.useShopStore(t=>t.storefrontToken),a=core.useShopStore(t=>t.storefrontUrl),i="Collection"===e,[u,d]=React.useState(""),[s,l]=React.useState("get product"),[p,y]=React.useState("");React.useEffect(()=>{if(i){if(!t){d("We cannot find any collections from your Shopify store. Please try manually syncing the data from Shopify or add a new collection."),l("get collection"),y("collection");return}d("We cannot find any product of this collection from your Shopify store? Please try manually syncing the data from Shopify or add a new product to your collection."),l("get product of collection"),y("product");return}if(n&&!c){y("product"),d("We can not get your products from Shopify");return}y("product"),l("get product"),d("We cannot find any products from your Shopify store. Please try manually syncing the data from Shopify or add a new product.")},[t,i,n,c]);let f=React.useMemo(()=>{if(!a)return;let t=new URL(a);return i?`${t.protocol}//${t.host}/admin/collections`:`${t.protocol}//${t.host}/admin/products`},[i,a]),m=t=>{let e=new CustomEvent("editor:sync-product",{bubbles:!0,detail:{uid:t}});window.dispatchEvent(e)};return jsxRuntime.jsx(NoDataState.default,{elementType:"primary",children:r,builderAttrs:o,title:`Can not ${s} from Shopify`,description:u,primaryBtnTitle:`Add ${p}`,secondaryBtnTitle:"Sync from Shopify",primaryBtnCb:()=>{f&&window.open(f,"_blank")},secondaryBtnCb:()=>m(o?.["data-uid"]??o?.uid)})};exports.default=ProductNotFound;
