{"version":3,"file":"ArticleTOC.D9SodRxB.mjs","names":["useRef","useState","startTransition","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","te","ce","init_jsx_runtime","p","_e","de","addPropertyControls","init_framer_BWFVvmND","RenderTarget","ControlType","ArticleTOC","props","isCanvas","rootRef","headingsRef","items","setItems","open","setOpen","openByDefault","hovered","setHovered","headHover","setHeadHover","root","findBodies","best","scope","i","found","bodyName","b","last","collect","hs","level","h","texts","sig","observers","mo","list","PREVIEW","minItems","go","top","scrollOffset","title","WHITE","FOCUS_CSS","TEXT_TITLE","BLACK","BLACK_60","CHEVRON","ITEMS_PADDING_RIGHT","on","TEXT_ITEM","text","init_ArticleTOC"],"sources":["https:/framerusercontent.com/modules/RcVrlil6UcSGXKMQOzAO/5G45TGRGsyz58umHkUpT/ArticleTOC.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef,useState,startTransition}from\"react\";// Colors are linked to the site's color styles (Black, Black 60, White).\nconst BLACK=\"var(--token-8d80ed24-4597-42dc-8cd5-f6474fc86f7f, rgb(22, 17, 15))\";const BLACK_60=\"var(--token-fad30637-b55a-4e98-8592-9ee54a658356, rgba(22, 17, 15, 0.6))\";const WHITE=\"var(--token-faa202c5-249e-48fc-b4b9-4fc0504fdb07, rgb(255, 255, 255))\";// Typography mirrors the FAQ block: question 18px / 130% Semibold,\n// answer text 18px / 170% Medium (\"Paragraph Content\").\nconst TEXT_TITLE={fontFamily:'\"PP Pangram Sans Semibold\", \"PP Pangram Sans\", sans-serif',fontWeight:600,fontSize:18,lineHeight:\"130%\"};const TEXT_ITEM={fontFamily:'\"PP Pangram Sans Medium\", \"PP Pangram Sans\", sans-serif',fontWeight:500,fontSize:18,lineHeight:\"170%\"};// Chevron icon copied from the site (used in buttons and \"все статьи\").\nconst CHEVRON=\"M 2.16 0.343 L 0.746 1.757 L 3.221 4.232 C 4.197 5.209 4.197 6.792 3.221 7.768 L 0.746 10.243 L 2.16 11.657 L 7.817 6 Z\";// Visible icon edge from the card's right side: 24px padding + 8px margin +\n// 10px (8×12 icon rotated to 12 wide, centered in its 8px box).\n// Item text stops 12px before the icon.\nconst ITEMS_PADDING_RIGHT=24+8+10+12;// Hide the focus ring after a mouse click, keep it for keyboard navigation.\nconst FOCUS_CSS=\".starter-toc-toggle:focus:not(:focus-visible){outline:none}\";const PREVIEW=[\"1. Первый раздел статьи\",\"2. Второй раздел статьи\",\"3. Третий раздел статьи\"];/**\n * Table of contents built from the headings of the article body next to it.\n * Styled after the site's FAQ block.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ArticleTOC(props){const{title=\"Содержание\",level=\"h2\",bodyName=\"ArticleBody\",minItems=3,openByDefault=true,scrollOffset=96}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const rootRef=useRef(null);const headingsRef=useRef([]);const[items,setItems]=useState([]);const[open,setOpen]=useState(openByDefault);const[hovered,setHovered]=useState(-1);const[headHover,setHeadHover]=useState(false);useEffect(()=>{if(isCanvas||typeof document===\"undefined\")return;const root=rootRef.current;if(!root)return;// Visible article bodies of the current breakpoint. Cases have several\n// bodies in sibling sections, so keep climbing and take the widest set.\nconst findBodies=()=>{let best=[];let scope=root.parentElement;for(let i=0;scope&&i<10;i++){const found=Array.from(scope.querySelectorAll(`[data-framer-name=\"${bodyName}\"]`)).filter(b=>b.getClientRects().length>0);if(found.length>best.length)best=found;scope=scope.parentElement;}return best;};let last=\"\";const collect=()=>{const hs=[];findBodies().forEach(b=>b.querySelectorAll(level).forEach(h=>{if(h.textContent&&h.textContent.trim())hs.push(h);}));const texts=hs.map(h=>h.textContent.trim());const sig=texts.join(\"|\");if(sig===last)return;last=sig;headingsRef.current=hs;startTransition(()=>setItems(texts));};collect();const observers=findBodies().map(b=>{const mo=new MutationObserver(collect);mo.observe(b,{childList:true,subtree:true,characterData:true});return mo;});return()=>observers.forEach(mo=>mo.disconnect());},[isCanvas,level,bodyName]);const list=isCanvas?PREVIEW:items;if(!isCanvas&&list.length<minItems){return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{display:\"none\"}});}const go=i=>{const h=headingsRef.current[i];if(!h||typeof window===\"undefined\")return;const top=h.getBoundingClientRect().top+window.scrollY-scrollOffset;window.scrollTo({top,behavior:\"smooth\"});};return /*#__PURE__*/_jsxs(\"nav\",{ref:rootRef,\"aria-label\":title,style:{...props.style,position:\"relative\",boxSizing:\"border-box\",width:\"100%\",background:WHITE,borderRadius:6,overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"style\",{children:FOCUS_CSS}),/*#__PURE__*/_jsxs(\"button\",{type:\"button\",className:\"starter-toc-toggle\",onClick:()=>startTransition(()=>setOpen(!open)),onMouseEnter:()=>setHeadHover(true),onMouseLeave:()=>setHeadHover(false),\"aria-expanded\":open,style:{...TEXT_TITLE,color:BLACK,width:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",gap:20,padding:24,margin:0,background:\"none\",border:\"none\",cursor:\"pointer\",textAlign:\"left\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{color:headHover?BLACK_60:BLACK},children:title}),/*#__PURE__*/_jsx(\"svg\",{width:\"8\",height:\"12\",viewBox:\"0 0 8 12\",\"aria-hidden\":\"true\",style:{flexShrink:0,margin:\"0 8px\",transform:open?\"rotate(-90deg)\":\"rotate(90deg)\",opacity:headHover?.6:1,// Only the rotation is animated; hover reacts instantly.\ntransition:\"transform 0.3s ease\"},children:/*#__PURE__*/_jsx(\"path\",{d:CHEVRON,fill:BLACK})})]}),/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":!open,style:{display:\"grid\",gridTemplateRows:open?\"1fr\":\"0fr\",transition:\"grid-template-rows 0.3s ease\"},children:/*#__PURE__*/_jsx(\"div\",{style:{overflow:\"hidden\",minHeight:0},children:/*#__PURE__*/_jsx(\"ol\",{style:{listStyle:\"none\",margin:0,padding:`0 ${ITEMS_PADDING_RIGHT}px 32px 24px`,display:\"flex\",flexDirection:\"column\",gap:8},children:list.map((text,i)=>{const on=hovered===i;return /*#__PURE__*/_jsx(\"li\",{style:{margin:0},children:/*#__PURE__*/_jsx(\"a\",{href:\"#\",tabIndex:open?0:-1,onClick:e=>{e.preventDefault();go(i);},onMouseEnter:()=>setHovered(i),onMouseLeave:()=>setHovered(-1),style:{...TEXT_ITEM,display:\"block\",color:on?BLACK:BLACK_60,textDecoration:\"none\"},children:text})},i);})})})})]});}addPropertyControls(ArticleTOC,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"Содержание\"},level:{type:ControlType.Enum,title:\"Headings\",options:[\"h2\",\"h3\"],optionTitles:[\"H2\",\"H3\"],defaultValue:\"h2\",displaySegmentedControl:true},bodyName:{type:ControlType.String,title:\"Body layer\",defaultValue:\"ArticleBody\"},minItems:{type:ControlType.Number,title:\"Min items\",defaultValue:3,min:1,max:10,step:1},openByDefault:{type:ControlType.Boolean,title:\"Open\",defaultValue:true},scrollOffset:{type:ControlType.Number,title:\"Scroll offset\",defaultValue:96,min:0,max:300,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ArticleTOC\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ArticleTOC.map"],"mappings":"A,uNAcG,SAAwBiB,EAAW,EAAM,CAAC,GAAK,CAAC,QAAM,aAAa,QAAM,KAAK,WAAS,cAAc,WAAS,EAAE,gBAAc,GAAK,eAAa,IAAIC,EAAYC,EAASJ,EAAa,QAAQ,IAAIA,EAAa,OAAaK,EAAQpB,EAAO,IAAI,EAAQqB,EAAYrB,EAAO,CAAC,CAAC,EAAO,CAACsB,EAAMC,GAAUtB,EAAS,CAAC,CAAC,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