{"version":3,"file":"SN_SchemaCollection.Lppod2fk.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/1TckCHeK693G2P2JXhRg/OFTkdOnkJp9EMpMdgyK8/SN_SchemaCollection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useState,useEffect}from\"react\";// SN_SchemaCollection — emits CollectionPage + BreadcrumbList + ItemList JSON-LD\n// on a category page.\n//\n// v2 (Chat #79): ZERO-CONFIG. The collection name no longer needs to be bound\n// to a CMS variable (which the binding UI doesn't allow) — it's fetched from the\n// Storefront collection by handle, together with the product ItemList. The\n// handle comes from the first URL segment. Props remain only as fallbacks.\n//\n// v3 (Chat #164): SERVER-SIDE COMPLETENESS. Zero-config had a cost that only\n// showed up in a SEMrush audit: every input came from `window` or a client\n// fetch, so the pre-rendered HTML carried a BreadcrumbList with empty `name`\n// AND empty `item` on both positions, plus a nameless CollectionPage — verified\n// by curl on 8/8 category pages. Google renders JS and reports the breadcrumb as\n// valid, so this was never a ranking emergency; but rendering is deferred and\n// budgeted, and an empty value in the first snapshot is a needless bet.\n//\n// The fix is a `path` control set per page (\"/armor-plates\"). From it the\n// component derives the handle, the canonical URL and — via prettify — a\n// truthful name, all without touching `window`. The client fetch still runs and\n// still wins, so the live title from the Storefront replaces the derived one.\n//\n// Naming is safe to derive; STOCK IS NOT. See the v3.2 note in\n// SN_SchemaProduct.tsx: baking a guessed availability into the pre-rendered HTML\n// stamped InStock on 140/140 pages and opened a \"Mismatched product\n// availability\" cluster in GMC. A category label cannot mismatch anything —\n// which is exactly why this component may do what that one must not.\nconst SHOP=\"ace-link-armor.myshopify.com\";const TOKEN=\"0a593db1c8af3044faa3d79170fe3985\";const API=\"2025-01\";const QUERY=`query($handle: String!, $n: Int!) {\n  collection(handle: $handle) {\n    title\n    description\n    products(first: $n) { edges { node { title handle } } }\n  }\n}`;/** Site origin — a constant so the breadcrumb has a real URL before hydration. */const ORIGIN=\"https://acelinkarmor.com\";function prettify(handle){return String(handle||\"\").split(\"-\").filter(Boolean).map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(\" \");}/** \"/body-armor/bulletproof-shirt\" → \"bulletproof-shirt\". */function lastSegment(path){return String(path||\"\").split(\"/\").filter(Boolean).pop()||\"\";}/** \"armor-plates\" or \"/armor-plates/\" → \"/armor-plates\". */function normalizePath(path){const p=String(path||\"\").trim();if(!p)return\"\";return(\"/\"+p.replace(/^\\/+/,\"\").replace(/\\/+$/,\"\")).replace(/\\/{2,}/g,\"/\");}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function SN_SchemaCollection(props){const{collectionHandle,path,name,description,homeName,homeUrl,maxItems}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[data,setData]=useState(null);// Everything below must resolve without `window`, or it is empty in the\n// pre-rendered HTML. `path` is the one thing the page has to tell us; the\n// window reads stay as a fallback for instances where it was never set.\nconst pagePath=normalizePath(path);const handle=collectionHandle||lastSegment(pagePath)||(typeof window!==\"undefined\"?window.location.pathname.split(\"/\").filter(Boolean)[0]||\"\":\"\");const origin=homeUrl||ORIGIN;const canonical=pagePath?`${origin}${pagePath}`:typeof window!==\"undefined\"?window.location.href.split(\"?\")[0]:\"\";useEffect(()=>{if(isCanvas||!handle||typeof window===\"undefined\")return;let cancel=false;(async()=>{try{const r=await fetch(`https://${SHOP}/api/${API}/graphql.json`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",\"X-Shopify-Storefront-Access-Token\":TOKEN},body:JSON.stringify({query:QUERY,variables:{handle,n:maxItems||24}})});const j=await r.json();const c=j?.data?.collection;if(!cancel&&c)setData({title:c.title||\"\",description:c.description||\"\",list:(c.products?.edges||[]).map(e=>({name:e.node.title,handle:e.node.handle}))});}catch{}})();return()=>{cancel=true;};},[isCanvas,handle,maxItems]);const collName=data&&data.title||name||prettify(handle);const collDesc=data&&data.description||description||\"\";const list=data&&data.list||[];const graph=[{\"@type\":\"CollectionPage\",...canonical?{\"@id\":canonical}:{},name:collName,...collDesc?{description:collDesc}:{}},{\"@type\":\"BreadcrumbList\",itemListElement:[{\"@type\":\"ListItem\",position:1,name:homeName||\"Home\",item:origin},// Omit rather than emit an empty `item`: an absent URL is a warning,\n// an empty string is an invalid one.\n{\"@type\":\"ListItem\",position:2,name:collName,...canonical?{item:canonical}:{}}]}];if(list.length>0){graph.push({\"@type\":\"ItemList\",itemListElement:list.map((p,i)=>({\"@type\":\"ListItem\",position:i+1,url:`${origin}/${handle}/${p.handle}`,name:p.name}))});}const schema={\"@context\":\"https://schema.org\",\"@graph\":graph};return /*#__PURE__*/_jsx(\"script\",{type:\"application/ld+json\",dangerouslySetInnerHTML:{__html:JSON.stringify(schema)}});}SN_SchemaCollection.defaultProps={collectionHandle:\"\",path:\"\",name:\"\",description:\"\",homeName:\"Home\",homeUrl:\"\",maxItems:24};addPropertyControls(SN_SchemaCollection,{path:{type:ControlType.String,title:\"Path\",description:\"SET THIS PER PAGE, e.g. /armor-plates. Without it the breadcrumb and canonical are empty in the pre-rendered HTML (they only fill in after JS).\"},collectionHandle:{type:ControlType.String,title:\"Collection Handle\",description:\"Empty = last segment of Path, then first URL segment. Set only when the Shopify handle differs from the URL.\"},maxItems:{type:ControlType.Number,title:\"Max Items\",defaultValue:24,min:1,max:100,step:1},name:{type:ControlType.String,title:\"Name (fallback)\",description:\"Auto-fetched from the Storefront collection. Type only to override.\"},description:{type:ControlType.String,title:\"Description (fallback)\",displayTextArea:true},homeName:{type:ControlType.String,title:\"Breadcrumb Home\",defaultValue:\"Home\"},homeUrl:{type:ControlType.String,title:\"Home URL\",description:\"Optional. Empty = site origin.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SN_SchemaCollection\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"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