'use client';
import{jsx as o}from"react/jsx-runtime";import{usePageType as t,useShopStore as r,useI18nStore as e}from"@gem-sdk/core";import{useState as n,useEffect as i,useMemo as c}from"react";import d from"../../common/components/NoDataState.js";let ProductNotFound=({collectionHandle:a,productSrc:l,builderAttrs:u,children:p})=>{let y="STATIC"===t(),f=r(o=>o.storefrontToken),m=r(o=>o.storefrontUrl),s="Collection"===l,[h,S]=n(""),[g,w]=n("get product"),[b,C]=n(""),{t:T}=e();i(()=>{if(s){if(!a){S(T("We cannot find any collections from your Shopify store. Please try manually syncing the data from Shopify or add a new collection.")),w(T("get collection")),C(T("collection"));return}S(T("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.")),w(T("get product of collection")),C(T("product"));return}if(y&&!f){C(T("product")),S(T("We can not get your products from Shopify"));return}C(T("product")),w(T("get product")),S(T("We cannot find any products from your Shopify store. Please try manually syncing the data from Shopify or add a new product."))},[a,s,y,f]);let P=c(()=>{if(!m)return;let o=new URL(m);return s?`${o.protocol}//${o.host}/admin/collections`:`${o.protocol}//${o.host}/admin/products`},[s,m]),k=o=>{let t=new CustomEvent("editor:sync-product",{bubbles:!0,detail:{uid:o}});window.dispatchEvent(t)};return o(d,{elementType:"primary",children:p,builderAttrs:u,title:T("Can not {textLink} from Shopify",{textLink:g}),description:h,primaryBtnTitle:T("Add {entity}",{entity:b}),secondaryBtnTitle:T("Sync from Shopify"),primaryBtnCb:()=>{P&&window.open(P,"_blank")},secondaryBtnCb:()=>k(u?.["data-uid"]??u?.uid)})};export{ProductNotFound as default};
