'use client';
import{jsx as e}from"react/jsx-runtime";import t from"next/link";import r from"../../text/components/Text.js";import{useArticleStore as i,useShopStore as o}from"@gem-sdk/core";import{useMemo as l}from"react";import{useArticleLink as c}from"../hooks/useArticleLink.js";import n from"../../common/components/NoDataState.js";let ArticleExcerpt=({setting:s,styles:a,builderProps:m})=>{let p=i(e=>e.article),d=o(e=>e.storefrontUrl),x=l(()=>p?.content?.excerptHtml,[p]),{shopifyArticleLink:f}=c(),u=()=>{if(!d)return;let e=new URL(d);window.open(`${e.protocol}//${e.host}/admin/content/articles`)};return e("div",{id:`shopify-text-element-${m?.uid}`,"data-article-id":p?.baseID?.replace("gid://shopify/OnlineStoreArticle/",""),children:p&&x?s?.linkArticle?e(t,{href:f,title:p?.title,children:e(r,{builderProps:m,styles:a,setting:{...s,text:x,excludeFlex:!0}})}):e(r,{builderProps:m,styles:a,setting:{...s,text:x,excludeFlex:!0}}):e(n,{elementType:"secondary",description:"Provide a brief summary or teaser of the article. ",descriptionActions:[{text:"Add article excerpt",callback:u},{text:"sync data",callback:"syncArticle"}]})})};export{ArticleExcerpt as default};
