'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(""),{t:f}=core.useI18nStore();React.useEffect(()=>{if(i){if(!t){d(f("We cannot find any collections from your Shopify store. Please try manually syncing the data from Shopify or add a new collection.")),l(f("get collection")),y(f("collection"));return}d(f("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(f("get product of collection")),y(f("product"));return}if(n&&!c){y(f("product")),d(f("We can not get your products from Shopify"));return}y(f("product")),l(f("get product")),d(f("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 m=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]),S=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:f("Can not {textLink} from Shopify",{textLink:s}),description:u,primaryBtnTitle:f("Add {entity}",{entity:p}),secondaryBtnTitle:f("Sync from Shopify"),primaryBtnCb:()=>{m&&window.open(m,"_blank")},secondaryBtnCb:()=>S(o?.["data-uid"]??o?.uid)})};exports.default=ProductNotFound;
