https://www.totaltypescript.com/_next/static/chunks/pages/books/[book]/[chapter]-6f74503b1c3f4e81.js
1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2368],{97357:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/books/[book]/[chapter]",function(){return s(22107)}])},53308:function(e,t,s){"use strict";s.r(t),t.default={src:"/_next/static/media/[email protected]",height:776,width:1650,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAMAAACEE47CAAAABlBMVEWo9uyw++3nWCmSAAAAAnRSTlMBCRZURN0AAAAJcEhZcwAAEJwAABCcASbNOjQAAAAUSURBVHicY2BgYGRkZAADOAMNAAAAyQAHfJ5Z6gAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:4}},30751:function(e,t,s){"use strict";s.r(t),t.default={src:"/_next/static/media/[email protected]",height:214,width:236,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAHCAMAAAACh/xsAAAADFBMVEVfwaZUt7lXvrdn3s7pIZzgAAAABHRSTlMBDR02MyFrKQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAACdJREFUeJw9ycENADAMwkBj9t+5Sqr2PiCg1RhoiJ0CKLtcc6+X3wEHswApTDybkwAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:7}},10219:function(e,t,s){"use strict";s.r(t),t.default={src:"/_next/static/media/[email protected]",height:80,width:324,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAMAAABSSm3fAAAAFVBMVEXm7u7V1dfHx82Zqaxse4F8goSKyNDNrMZQAAAAB3RSTlMWIA03sV6eNLkYjQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAABpJREFUeJxjYGZjYGBgYmRiYGVhZmBkZGQCAAE9ACB73yfVAAAAAElFTkSuQmCC",blurWidth:8,blurHeight:2}},94806:function(e,t,s){"use strict";s.r(t),t.default={src:"/_next/static/media/[email protected]",height:80,width:324,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAMAAABSSm3fAAAAFVBMVEUrNUIZIC0kLDkxRU1BXGROWGFjkZwiDME1AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAGklEQVR4nGNgYWNgYGJkYmRgYWVgZmZiYAQAAWEAI92584QAAAAASUVORK5CYII=",blurWidth:8,blurHeight:2}},22107:function(e,t,s){"use strict";s.r(t),s.d(t,{__N_SSG:function(){return ei},default:function(){return ea}});var r=s(80900),l=s(5192);s(94684);var i=s(37264),a=s(59328),n=s(72713),o=s(52423),c=s(85933),d=s(50416),u=s(35383),h=s(35310),x=s(2449),m=s(90359),p=s(36281);let g=(0,p.Z)("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);var f=s(54631),b=s(95980),v=s.n(b),j=s(46995),w=s.n(j),y=s(6872),N=s(76449);let A=e=>{var t,s,i,a,o,d,p,b;let{filePath:j,book:A,title:C,resourceId:E}=e,{data:S,status:_}=(0,f.useSession)(),{data:z,status:B}=u.SX.userPrefs.getLocal.useQuery({resourceId:A._id},{enabled:!!A}),{data:R,status:I}=u.SX.exercises.getExerciseForBook.useQuery({resourceId:E},{enabled:!!E}),[L,Z]=l.useState(!1),F=!!z,M="https://www.totaltypescript.com"+"/api/video-thumb?videoResourceId=".concat(null==R?void 0:R.videoResourceId),V="/workshops/typescript-pro-essentials/".concat(null==R?void 0:null===(t=R.section)||void 0===t?void 0:t.slug,"/").concat(null==R?void 0:R.slug),O=(null==S?void 0:S.user)&&F&&(null==z?void 0:z.editorLaunchProtocol.includes("jetbrains"))?"jetbrains://web-storm/navigate/reference?project=".concat(null==A?void 0:null===(s=A.github)||void 0===s?void 0:s.repo,"&path=").concat(j):"".concat(null==z?void 0:z.editorLaunchProtocol).concat(null==z?void 0:z.localDirectoryPath).concat(j),{ability:G,abilityRulesStatus:U}=k(),T=G.can("view","Content");return E&&R?(0,r.jsx)(()=>{var e,t,s,l,i,a,o,d,u,p,g,f;return(0,r.jsxs)("div",{className:"not-prose relative mt-10 flex flex-col items-center rounded-lg bg-[#1B222F] px-2 pb-3 pt-2 shadow-xl sm:px-2",children:[(0,r.jsx)("div",{className:"flex w-full items-center justify-center","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute -top-2.5 h-5 w-5 rotate-45 bg-[#1B222F]"})}),"loading"===I||"loading"===U?(0,r.jsxs)("div",{className:"group relative flex aspect-video h-full w-full items-center justify-center overflow-hidden rounded",children:[(0,r.jsx)("div",{className:"absolute bottom-0 left-0 z-10 w-full border-t border-white/5 bg-background/50 px-4 py-3 text-sm font-medium backdrop-blur-md",children:(0,r.jsx)(x.Od,{className:"h-4 w-full bg-white/5"})}),(0,r.jsx)(x.Od,{className:"absolute h-full w-full bg-white/5"})]}):(0,r.jsx)(r.Fragment,{children:M&&(0,r.jsx)(r.Fragment,{children:T?(0,r.jsxs)(w(),{target:"_blank",href:V,className:"group relative flex aspect-video h-full w-full items-center justify-center overflow-hidden rounded",children:[(0,r.jsx)("div",{className:"absolute z-10 flex h-12 w-12 items-center justify-center rounded-full border border-white/10 bg-white/10 p-3 backdrop-blur-md transition duration-300 ease-in-out group-hover:scale-105",children:(0,r.jsx)("svg",{className:"-mr-1.5 h-5 w-5",viewBox:"0 0 14 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M0 0L14 9L0 18V0Z",fill:"currentColor"})})}),(0,r.jsxs)("div",{className:"absolute bottom-0 left-0 z-10 w-full border-t border-white/5 bg-background/50 px-4 py-3 text-sm font-medium backdrop-blur-md",children:[(null==R?void 0:null===(t=R.section)||void 0===t?void 0:null===(e=t.workshop)||void 0===e?void 0:e.title)||"TypeScript Pro Essentials",": ",(null==R?void 0:R.title)||C]}),(0,r.jsx)(v(),{src:M,fill:!0,alt:""})]}):(0,r.jsxs)("div",{className:"group relative flex aspect-video h-full w-full items-center justify-center overflow-hidden rounded",children:[(0,r.jsxs)("div",{className:"relative z-10 flex max-w-sm flex-col items-center justify-center px-5 text-center",children:[(0,r.jsxs)("p",{className:"text-balance text-base leading-normal sm:text-lg",children:["Solution to this exercise is included in"," ",(0,r.jsxs)("strong",{className:"font-semibold",children:[null==R?void 0:null===(l=R.section)||void 0===l?void 0:null===(s=l.workshop)||void 0===s?void 0:s.title,"."]})]}),(0,r.jsx)("div",{className:"mt-4 flex items-center gap-3",children:(0,r.jsx)(x.zx,{asChild:!0,className:"px-7 font-semibold shadow-xl",children:(0,r.jsx)(w(),{href:"/",onClick:()=>{(0,N.j)("clicked_go_pro",{location:"book_exercise_embed",resource:E})},children:"Get Access"})})})]}),(0,r.jsx)("div",{className:"absolute bottom-0 left-0 z-10 hidden w-full border-t border-white/5 bg-background/50 px-4 py-3 text-sm font-medium backdrop-blur-md md:flex",children:(0,r.jsxs)(w(),{href:V,className:"transition hover:text-primary",children:[(null==R?void 0:null===(a=R.section)||void 0===a?void 0:null===(i=a.workshop)||void 0===i?void 0:i.title)||"TypeScript Pro Essentials",": ",(null==R?void 0:R.title)||C]})}),(0,r.jsx)(v(),{src:M,fill:!0,alt:"",className:"opacity-50 blur-sm"})]})})}),(0,r.jsx)("div",{className:(0,n.cn)("flex w-full flex-wrap items-center justify-between gap-5 pr-1 pt-3",{"pl-3":!(null==S?void 0:S.user),"pl-1":null==S?void 0:S.user}),children:(0,r.jsx)("div",{className:"relative flex w-full items-center justify-between",children:"loading"===_||"loading"===B?(0,r.jsx)(x.Od,{className:"h-10 w-full rounded bg-white/5"}):(0,r.jsx)(r.Fragment,{children:(null==S?void 0:S.user)?(0,r.jsxs)(r.Fragment,{children:[F&&O?(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(x.zx,{asChild:!0,disabled:!F,className:"not-prose rounded-r-none font-semibold",children:(0,r.jsx)("a",{href:O,children:"Open in Editor"})}),(0,r.jsx)(c.Z,{resourceId:A._id,resourceTitle:A.title,githubRepositoryName:null===(o=A.github)||void 0===o?void 0:o.title,githubRepositoryUrl:"https://github.com/total-typescript/".concat(null===(d=A.github)||void 0===d?void 0:d.repo),isDialogOpen:L,children:(0,r.jsx)(x.hg,{asChild:!0,children:(0,r.jsxs)(x.zx,{"aria-label":"Configure local development settings",className:"gap-1 rounded-l-none bg-primary/80 px-2.5",children:[(0,r.jsx)(m.Z,{className:"h-4 w-4","aria-hidden":"true"}),(0,r.jsx)("span",{className:"sr-only",children:"Configure local development settings"})]})})})]}):(0,r.jsx)(c.Z,{resourceId:A._id,resourceTitle:A.title,githubRepositoryName:null===(u=A.github)||void 0===u?void 0:u.title,githubRepositoryUrl:"https://github.com/total-typescript/".concat(null===(p=A.github)||void 0===p?void 0:p.repo),isDialogOpen:L,children:(0,r.jsx)(x.hg,{asChild:!0,children:(0,r.jsxs)(x.zx,{variant:"secondary",className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:[(0,r.jsx)(m.Z,{className:"h-4 w-4","aria-hidden":"true"})," ","Configure Local Development"]})})}),(null==A?void 0:null===(g=A.github)||void 0===g?void 0:g.repo)&&(0,r.jsx)(x.zx,{variant:"secondary",asChild:!0,className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:(0,r.jsxs)("a",{href:"https://github.com/total-typescript/".concat(A.github.repo,"/blob/main").concat(j),target:"_blank",children:[(0,r.jsx)(h.J,{name:"Github"})," GitHub"]})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-sm sm:text-base",children:[(0,r.jsx)(w(),{href:"/login",className:"text-primary underline",children:"Log in"})," ","to open in your editor"]}),(null==A?void 0:null===(f=A.github)||void 0===f?void 0:f.repo)&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(x.zx,{variant:"secondary",asChild:!0,className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:(0,r.jsxs)("a",{href:"https://github.com/total-typescript/".concat(A.github.repo,"/blob/main").concat(j),target:"_blank",children:[(0,r.jsx)(h.J,{name:"Github"})," GitHub"]})})})]})})})})]})},{}):(0,r.jsxs)("div",{className:"not-prose relative mt-10 flex flex-col items-center gap-5 rounded-lg bg-[#1B222F] px-5 pb-8 pt-2 sm:px-6",children:[(0,r.jsx)("div",{className:"flex w-full items-center justify-center","aria-hidden":"true",children:(0,r.jsx)("div",{className:"absolute -top-2.5 h-5 w-5 rotate-45 bg-[#1B222F]"})}),C&&(0,r.jsxs)("p",{className:"inline-flex items-center gap-2 text-balance text-center text-base sm:text-lg",children:[(0,r.jsx)(g,{className:"w-5 text-white/70"})," ",(0,r.jsx)(y.D,{components:{p:e=>{let{children:t}=e;return t},code:e=>{let{children:t}=e;return(0,r.jsx)("code",{className:"!bg-white/5",children:t})}},children:C})]}),(0,r.jsx)("div",{className:"relative flex items-center",children:"loading"===_||"loading"===B?(0,r.jsx)(x.Od,{className:"h-10 w-full rounded bg-white/5"}):(0,r.jsx)(r.Fragment,{children:(null==S?void 0:S.user)?(0,r.jsxs)(r.Fragment,{children:[F&&O?(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(x.zx,{asChild:!0,disabled:!F,className:"not-prose rounded-r-none font-semibold",children:(0,r.jsx)("a",{href:O,children:"Open in Editor"})}),(0,r.jsx)(c.Z,{resourceId:A._id,resourceTitle:A.title,githubRepositoryName:null===(i=A.github)||void 0===i?void 0:i.title,githubRepositoryUrl:null===(a=A.github)||void 0===a?void 0:a.repo,isDialogOpen:L,children:(0,r.jsx)(x.hg,{asChild:!0,children:(0,r.jsxs)(x.zx,{"aria-label":"Configure local development settings",className:"gap-1 rounded-l-none bg-primary/80 px-2.5",children:[(0,r.jsx)(m.Z,{className:"h-4 w-4","aria-hidden":"true"}),(0,r.jsx)("span",{className:"sr-only",children:"Configure local development settings"})]})})})]}):(0,r.jsx)(c.Z,{resourceId:A._id,resourceTitle:A.title,githubRepositoryName:null===(o=A.github)||void 0===o?void 0:o.title,githubRepositoryUrl:null===(d=A.github)||void 0===d?void 0:d.repo,isDialogOpen:L,children:(0,r.jsx)(x.hg,{asChild:!0,children:(0,r.jsxs)(x.zx,{variant:"secondary",className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:[(0,r.jsx)(m.Z,{className:"h-4 w-4"})," Configure Local Development"]})})}),(null==A?void 0:null===(p=A.github)||void 0===p?void 0:p.repo)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mx-5 h-5 w-px bg-white/10"}),(0,r.jsx)(x.zx,{variant:"secondary",asChild:!0,className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:(0,r.jsxs)("a",{href:"https://github.com/total-typescript/".concat(A.github.repo,"/blob/main").concat(j),target:"_blank",children:[(0,r.jsx)(h.J,{name:"Github"})," GitHub"]})})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-base",children:[(0,r.jsx)(w(),{href:"/login",className:"text-primary underline",children:"Log in"})," ","to open in your editor"]}),(null==A?void 0:null===(b=A.github)||void 0===b?void 0:b.repo)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mx-5 h-5 w-px bg-white/10"}),(0,r.jsx)(x.zx,{variant:"secondary",asChild:!0,className:"gap-2 border border-white/5 bg-white/5 text-white hover:bg-white/10",children:(0,r.jsxs)("a",{href:"https://github.com/total-typescript/".concat(A.github.repo,"/blob/main").concat(j),target:"_blank",children:[(0,r.jsx)(h.J,{name:"Github"})," GitHub"]})})]})]})})})]})},k=()=>{let{data:e,status:t}=u.SX.modules.rules.useQuery({moduleSlug:"typescript-pro-essentials",moduleType:"workshop"});return{ability:(0,d.LX)(e||[]),abilityRulesStatus:t}},C=e=>{let{toc:t,visibleHeadingId:s,maxWidth:l,className:i}=e;return(0,r.jsx)("aside",{className:(0,n.cn)("fixed left-0 top-0 flex h-screen origin-left scale-90 flex-col items-center justify-center mix-blend-difference",i),children:(0,r.jsxs)("nav",{className:"group py-16 pr-5 scrollbar-none hover:overflow-y-auto",children:[(0,r.jsx)("strong",{className:"relative inline-flex translate-x-0 text-lg font-semibold text-white opacity-0 transition group-hover:translate-x-7 group-hover:opacity-100",children:"In this chapter"}),(0,r.jsx)("ol",{className:"mt-3 flex flex-col [&_*]:duration-300",children:t.map((e,t)=>(0,r.jsxs)("li",{children:[(0,r.jsxs)(w(),{className:"inline-flex min-h-3 items-center gap-2 leading-tight transition hover:text-foreground",href:"#".concat(e.slug),children:[(0,r.jsx)("div",{className:(0,n.cn)("relative h-px w-5 bg-gray-400 transition group-hover:-translate-x-5",{"bg-primary opacity-100":s===e.slug})}),(0,r.jsx)("span",{className:(0,n.cn)("relative -translate-x-10 truncate text-nowrap font-semibold text-white opacity-0 transition group-hover:translate-x-0 group-hover:opacity-100 hover:text-primary",{"text-primary group-hover:opacity-100":s===e.slug}),style:{maxWidth:l},children:e.text.replace(/`/g,"")})]}),"Exercises"!==e.text.trim()&&e.items.length>0&&(0,r.jsx)("ol",{children:e.items.filter(e=>{let{level:t}=e;return t<4}).map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)(w(),{className:"inline-flex min-h-3 items-center gap-2",href:"#".concat(e.slug),children:[(0,r.jsx)("div",{className:(0,n.cn)("relative h-px w-3 bg-gray-400 transition group-hover:-translate-x-5",{"bg-primary":s===e.slug})}),(0,r.jsx)("span",{className:(0,n.cn)("relative ml-6 -translate-x-10 truncate text-nowrap opacity-0 transition group-hover:translate-x-0 group-hover:opacity-100 hover:text-primary",{"text-[#ADF2F2] group-hover:opacity-100":s===e.slug}),style:{maxWidth:l},children:e.text.replace(/`/g,"")})]})},e.slug))})]},e.slug))})]})})},E=(e,t)=>{let[s,r]=l.useState("100%");return l.useEffect(()=>{if("left"===t){let t=()=>{var t;let s=null===(t=e.current)||void 0===t?void 0:t.getBoundingClientRect().left;r(s?"".concat(s-50,"px"):"100%")};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}}},[e,t]),s};var S=s(32572),_=s(13140),z=s(85809);let B=()=>{let{data:e,status:t}=u.SX.modules.rules.useQuery({moduleSlug:"typescript-pro-essentials",moduleType:"workshop"});return{ability:(0,d.LX)(e||[]),abilityRulesStatus:t}},R=e=>{let{toc:t,fontSizeIndex:s,visibleHeadingId:i}=e,{ability:a,abilityRulesStatus:o}=B(),c=a.can("view","Content"),d=l.useRef(null),[u,h]=l.useState(!1),[x,m]=l.useState(!1);l.useEffect(()=>{let e=()=>{let{scrollTop:e,scrollHeight:t,clientHeight:s}=d.current;m(t<=s||e+s>=t)},t=d.current;if(t){e(),t.addEventListener("scroll",e);let s=new ResizeObserver(e);return s.observe(t),()=>{t.removeEventListener("scroll",e),s.unobserve(t)}}},[d.current]);let p=(0,S.J)();l.useEffect(()=>{let e=()=>{(null==d?void 0:d.current)&&h(d.current.scrollTop>0)},t=d.current;return null==t||t.addEventListener("scroll",e),()=>{null==t||t.removeEventListener("scroll",e)}},[d.current]),l.useEffect(()=>{let e=null;return d.current&&i&&(e=setTimeout(()=>{var e;let t=null===(e=d.current)||void 0===e?void 0:e.querySelector('[data-active="true"]');if(t){let e=t.offsetTop-80;d.current.scrollTo({top:e,behavior:p?"instant":"smooth"})}},500)),()=>{e&&clearTimeout(e)}}
1,[d.current,i]);let g=l.useRef(null),[f,b]=l.useState(0);return l.useEffect(()=>{g.current&&b(g.current.clientHeight+20)},[g.current,b]),(0,r.jsx)("aside",{className:(0,n.cn)("relative w-full max-w-[300px] pl-5 pt-20",{"hidden xl:block":2===s,"hidden lg:block":2!==s}),children:(0,r.jsxs)("div",{className:"sticky top-16",children:[(0,r.jsx)(_.E.div,{initial:{opacity:1},animate:{opacity:x?0:1},"aria-hidden":"true",style:{bottom:f},className:"pointer-events-none absolute left-0 z-10 h-20 w-full bg-gradient-to-t from-background to-transparent"}),(0,r.jsx)(_.E.div,{initial:{opacity:0},animate:{opacity:u?1:0},"aria-hidden":"true",className:"pointer-events-none absolute left-0 top-0 z-10 h-20 w-full bg-gradient-to-b from-background to-transparent"}),(0,r.jsxs)("div",{className:"h-full overflow-y-auto scrollbar-none",style:{maxHeight:"calc(100vh - 7rem - ".concat(f,"px)")},ref:d,children:[(0,r.jsx)("strong",{children:"On this page"}),(0,r.jsx)("nav",{className:"group",children:(0,r.jsx)("ol",{className:"mt-3 flex flex-col",children:t.map((e,t)=>(0,r.jsxs)("li",{"data-active":i===e.slug,children:[(0,r.jsx)(w(),{className:"inline-flex min-h-3 items-center gap-2 py-2 leading-tight transition hover:text-foreground",href:"#".concat(e.slug),children:(0,r.jsx)("span",{className:(0,n.cn)("relative font-semibold text-white transition hover:text-primary",{"text-primary group-hover:opacity-100":i===e.slug}),children:e.text.replace(/`/g,"")})}),"Exercises"!==e.text.trim()&&e.items.length>0&&(0,r.jsx)("ol",{children:e.items.filter(e=>{let{level:t}=e;return t<4}).map(e=>(0,r.jsx)("li",{"data-active":i===e.slug,children:(0,r.jsxs)(w(),{className:"relative inline-flex min-h-3 items-center gap-2 py-1",href:"#".concat(e.slug),children:[(0,r.jsx)("div",{className:(0,n.cn)("absolute left-1 top-0 h-full w-[2px] bg-white/10",{"bg-primary":i===e.slug})}),(0,r.jsx)("span",{className:(0,n.cn)("relative pl-5 transition hover:text-primary",{"text-[#ADF2F2] group-hover:opacity-100":i===e.slug}),children:e.text.replace(/`/g,"")})]})},e.slug))})]},e.slug))})})]}),!c&&"success"===o&&(0,r.jsx)(z.u,{location:"chapter_sidebar_toc",ref:g})]})})};var I=s(36593);let L=l.forwardRef(function(e,t){return l.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:t},e),l.createElement("path",{d:"M5 4a2 2 0 012-2h6a2 2 0 012 2v14l-5-2.5L5 18V4z"}))});var Z=s(78215),F=s(29760),M=s(30752);let V=e=>{let{as:t="h2",appendValueForRepeatedIds:s,chapter:i,onChangeCapture:a,resourceId:o,...c}=e,d=c.id;d.startsWith("exercises-")&&s&&(d="".concat(d).concat(s));let{data:h}=(0,f.useSession)(),[m,p]=(0,I.Z)(),{data:g,status:b,isRefetching:v,isFetching:j}=u.SX.bookmarks.getBookmark.useQuery({id:o},{enabled:!!o,refetchOnWindowFocus:!1,refetchOnMount:!1,onSuccess:e=>{e&&N(!0)}}),[y,N]=l.useState(!1),A=u.SX.bookmarks.deleteBookmark.useMutation({onMutate:async e=>{N(!1)},onSuccess:()=>{M.ZP.success("Bookmark removed")},onError:e=>{N(!0),M.ZP.error("Error removing bookmark")}}),k="#".concat(d),C=()=>{if((0,F.j)()){let e=window.location.href,t=window.location.hash;p(e.replace(t,"")+k),M.ZP.success("Link copied")}},E=u.SX.bookmarks.addBookmark.useMutation({onMutate:async e=>{N(!0)},onSuccess:e=>{M.ZP.success("Bookmark added")},onError:e=>{var t;N(!1),(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.httpStatus)===401?M.ZP.error("Please log in to save bookmarks"):M.ZP.error("Error adding bookmark")}}),S=async e=>{let{resourceId:t,resourceTitle:s,resourceSlug:r}=e;return await E.mutateAsync({type:"book",resourceId:t,fields:{chapterSlug:null==i?void 0:i.slug,chapterTitle:null==i?void 0:i.title,resourceTitle:s,resourceSlug:r}})},_="loading"===b||v||j||E.isLoading||A.isLoading,z=!(null==h?void 0:h.user)||_;return(0,r.jsxs)("span",{className:"relative inline-flex w-full items-center",children:[(0,r.jsxs)("span",{className:"group relative inline-flex w-full items-center",children:[(0,r.jsx)("a",{href:k,className:"absolute left-[-2ch] translate-y-3 pr-3 !text-white/50 no-underline opacity-0 transition group-hover:opacity-100 hover:!text-cyan-300","aria-hidden":"true",children:"#"}),(0,r.jsx)(()=>l.createElement(t,{className:"group cursor-pointer relative pr-10",onClick:C,...c,id:d.replaceAll("--","-")},c.children),{})]}),o&&(0,r.jsxs)("button",{className:(0,n.cn)("absolute right-0 flex h-8 w-8 translate-y-2 items-center justify-center rounded-full bg-amber-300/10 p-2 transition duration-300 sm:translate-y-3",{"cursor-wait":_,"group-hover:bg-amber-300/20 hover:bg-amber-300/20":!z}),type:"button",disabled:z,onClick:async()=>{(null==h?void 0:h.user)&&(g?A.mutate({id:g.id}):await S({resourceId:o,resourceTitle:function e(t){return l.Children.toArray(t).reduce((t,s)=>"string"==typeof s?t+s:l.isValidElement(s)&&s.props.children?t+e(s.props.children):t,"")}(c.children),resourceSlug:c.id}))}
1,children:[(0,r.jsx)(x.pn,{delayDuration:0,children:(0,r.jsxs)(x.u,{children:[(0,r.jsx)(x.aJ,{asChild:!0,children:y?(0,r.jsx)(L,{className:"h-5 w-5 text-amber-200"}):(0,r.jsx)(Z.Z,{className:"h-5 w-5 text-amber-200"})}),(0,r.jsx)(x._v,{className:"bg-background text-foreground",children:(null==h?void 0:h.user)?g?"Remove bookmark":"Add bookmark":(0,r.jsxs)("span",{children:[(0,r.jsx)(w(),{href:"/login",children:"Log in"})," to bookmark"]})})]})}),(0,r.jsx)("span",{className:"sr-only",children:"Add Bookmark"})]})]})};var O=s(20650);let G=(0,p.Z)("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]),U=(0,p.Z)("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);var T=s(79690),D=s(13925),J=s(73693);let W=e=>{let{book:t,chapter:s,setIsMenuOpen:l,isMenuOpen:i}=e,a={hidden:{opacity:0,y:-20},show:{opacity:1,y:0}},{ability:o,abilityRulesStatus:c}=H(),d=o.can("view","Content");return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(x.Vq,{open:i,onOpenChange:e=>{l(e)},children:(0,r.jsx)(x.cZ,{withCloseButton:!1,className:"left-0 top-0 h-full w-full max-w-none translate-x-0 translate-y-0",children:(0,r.jsxs)(_.E.nav,{variants:{hidden:{opacity:0,transition:{duration:.5}},show:{opacity:1,transition:{staggerChildren:.05,type:"easeInOut"}}},initial:"hidden",animate:"show",className:"fixed left-0 top-0 flex h-screen w-full flex-col items-center justify-start overflow-y-auto bg-gradient-to-b from-background to-gray-800 py-5 text-foreground scrollbar-none sm:py-8",children:[(0,r.jsxs)(x.fK,{className:"mx-auto w-full max-w-4xl border-b border-gray-800 p-5 pb-8 sm:p-10 sm:pb-5",children:[(0,r.jsxs)(x.$N,{className:"flex w-full flex-col items-center justify-between sm:flex-row",children:[(0,r.jsx)(_.E.span,{className:"text-2xl font-semibold sm:text-3xl lg:text-4xl",children:(0,r.jsx)(w(),{href:"/books/".concat(t.slug.current),children:t.title})}),!d&&"success"===c&&(0,r.jsx)(_.E.li,{variants:a,className:"hidden flex-shrink-0 px-5 sm:flex",children:(0,r.jsx)(z.u,{location:"chapters_index_menu"})})]}),(0,r.jsx)("p",{className:"sm:text-lefttext-center font-sans text-lg font-normal opacity-75 sm:pt-5",children:"Chapters Index"})]}),(0,r.jsxs)(_.E.ol,{className:"mx-auto flex w-full max-w-4xl flex-col pb-24",children:[t.chapters.map((e,l)=>{let i=e._id===s._id;return(0,r.jsx)(_.E.li,{variants:a,children:(0,r.jsxs)(w(),{className:(0,n.cn)("flex items-center gap-5 rounded px-5 py-3 font-text text-xl font-semibold transition duration-150 hover:bg-white/5 sm:gap-10 sm:px-10 sm:py-5 sm:text-3xl sm:italic",{"bg-gray-800 text-primary hover:brightness-110":i}),href:"/books/".concat(t.slug.current,"/").concat(e.slug),children:[(0,r.jsx)("span",{className:"font-mono text-xs opacity-50",children:l+1}),(0,r.jsx)("span",{children:e.title}),i&&(0,r.jsx)("span",{className:"not-italic","aria-hidden":"true",children:"â"})]})},e._id)}),(0,r.jsx)(D.GG,{className:"fixed right-3 top-3 rounded-full bg-gray-800 p-3 transition ease-in-out hover:bg-gray-700 active:bg-gray-700 sm:right-5",children:(0,r.jsx)(J.Z,{className:"h-5 w-5"})}),!d&&"success"===c&&(0,r.jsx)(_.E.li,{variants:a,className:"flex px-5 sm:hidden",children:(0,r.jsx)(z.u,{})})]})]})})})})},H=()=>{let{data:e,status:t}=u.SX.modules.rules.useQuery({moduleSlug:"typescript-pro-essentials",moduleType:"workshop"});return{ability:(0,d.LX)(e||[]),abilityRulesStatus:t}},P=["sm","base","lg"],Q=["left","right"],X=e=>{let{book:t,chapter:i,isScrolledPastHero:a,fontSizeIndex:o,setFontSizeIndex:c,sidebarPlacement:d,setSidebarPlacement:u}=e,{status:h}=(0,f.useSession)(),[m,p]=l.useState(!1);return l.useEffect(()=>{i&&p(!1)},[i]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(W,{book:t,chapter:i,isMenuOpen:m,setIsMenuOpen:p}),(0,r.jsx)("header",{className:"fixed left-0 top-0 z-20 h-10 w-full border-b border-gray-800 bg-background px-3 sm:px-5 lg:border-none",children:(0,r.jsxs)("nav",{className:"flex h-10 items-center justify-between gap-5",children:[(0,r.jsxs)(w(),{href:"/books/".concat(t.slug.current),className:"flex flex-shrink-0 items-center justify-center font-heading text-base font-medium text-foreground transition ease-in-out hover:text-primary",children:[(0,r.jsxs)("span",{className:"hidden items-center lg:flex",children:[(0,r.jsx)(v(),{src:s(30751),width:118,priority:!0,qual
1ity:100,className:"pointer-events-none absolute left-0 top-0 z-50",alt:"","aria-hidden":"true"}),(0,r.jsx)(v(),{src:s(10219),width:158,priority:!0,quality:100,className:"absolute left-5",alt:t.title})]}),(0,r.jsx)(v(),{src:s(94806),width:158,priority:!0,quality:100,className:"absolute left-0 top-0 inline-block lg:hidden",alt:t.title})]}),(0,r.jsx)("div",{className:"pointer-events-none absolute left-0 top-2.5 flex w-full items-center justify-center",children:(0,r.jsx)(_.E.div,{className:"hidden truncate overflow-ellipsis text-center font-sans text-sm font-medium sm:block",initial:{opacity:0,y:-10},animate:{opacity:a?1:0,y:a?0:-10},children:(0,r.jsx)(w(),{href:"/books/".concat(t.slug.current,"/").concat(i.slug),className:"transition ease-in-out hover:text-primary",children:i.title})})}),(0,r.jsx)("div",{className:"flex items-center gap-3",children:"loading"===h?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-stretch",children:(0,r.jsx)(x.pn,{children:(0,r.jsx)(x.u,{delayDuration:0,children:(0,r.jsxs)(x.J2,{children:[(0,r.jsx)(x.aJ,{asChild:!0,children:(0,r.jsxs)(x.CM,{"aria-label":"Text & Layout Options",className:"group flex h-full items-stretch justify-center p-1 transition ease-in-out hover:text-primary",children:[(0,r.jsx)("svg",{className:"transition duration-500 ease-in-out group-hover:rotate-90",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:(0,r.jsxs)("g",{strokeWidth:"1",fill:"none",stroke:"currentColor",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor"}),(0,r.jsx)("path",{d:"M13.5,8 c0-0.465-0.064-0.913-0.172-1.344l1.917-1.107l-1.5-2.598L11.83,4.057c-0.644-0.626-1.441-1.093-2.33-1.344V0.5h-3v2.212 C5.612,2.964,4.815,3.431,4.17,4.057L2.255,2.951l-1.5,2.598l1.917,1.107C2.564,7.087,2.5,7.535,2.5,8 c0,0.464,0.064,0.913,0.172,1.344l-1.917,1.107l1.5,2.598l1.916-1.106c0.644,0.626,1.441,1.093,2.33,1.344V15.5h3v-2.212 c0.889-0.252,1.685-0.719,2.33-1.344l1.916,1.106l1.5-2.598l-1.917-1.107C13.436,8.913,13.5,8.464,13.5,8z"})," "]})}),(0,r.jsx)("span",{className:"sr-only",children:"Text & Layout Options"})]})}),(0,r.jsxs)(x._v,{className:"bg-background text-foreground",children:["Text"," ",(0,r.jsx)("span",{className:"hidden lg:inline-block",children:"& Layout"})," ","options"]}),(0,r.jsxs)(x.yk,{className:"flex w-auto flex-col items-start gap-2 bg-background text-foreground",children:[(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("label",{htmlFor:"font-size-slider",className:"mb-1 text-sm text-opacity-75",children:"Text size"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{"aria-label":"Decrease font size",disabled:0===o,type:"button",className:(0,n.cn)("opacity-70 transition ",{"hover:opacity-100":0!==o}),onClick:()=>{0!==o&&c(o-1)},children:(0,r.jsx)(G,{className:"w-4"})}),(0,r.jsx)(x.iR,{"aria-label":"Font size slider",id:"font-size-slider",className:"w-24 transition hover:brightness-125",value:[o],min:0,max:P.length-1,onValueChange:e=>{c(e[0])}}),(0,r.jsx)("button",{"aria-label":"Increase font size",disabled:o===P.length-1,type:"button",className:(0,n.cn)("opacity-70 transition ",{"hover:opacity-100":o<P.length-1}),onClick:()=>{o<P.length-1&&c(o+1)},children:(0,r.jsx)(U,{className:"w-4"})})]})]}),(0,r.jsxs)("div",{className:"hidden flex-col lg:flex",children:[(0,r.jsx)("label",{htmlFor:"sidebar-position",className:"mb-1 text-sm text-opacity-75",children:"Table of contents position"}),(0,r.jsx)("div",{className:"flex items-center",children:Q.map((e,t)=>(0,r.jsxs)("button",{id:"sidebar-position",type:"button","aria-label":"Table of contents position: ".concat(e),"aria-selected":d===e,onClick:()=>u(e),className:(0,n.cn)("border p-2 transition ease-in-out",{"border-primary bg-primary text-background":e===d,"border-gray-700 bg-white/10 text-foreground transition hover:bg-white/20":e!==d,"rounded-l":0===t,"rounded-r":t===Q.length-1}),children:[(0,r.jsx)("span",{className:"sr-only",children:e}),"left"===e?(0,r.jsx)("svg",{"aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"17",height:"14",fill:"none",viewBox:"0 0 17 14",children:(0,r.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M14.5.5h-12A1.5 1.5 0 0 0 1 2v10a1.5 1.5 0 0 0 1.5 1.5h12A1.5 1.5 0 0 0 16 12V2A1.5 1.5 0 0 0 14.5.5ZM5 .5v13M1 7h2M1 4h2m-2 6h2"})}):(0,r.jsx)("svg",{"aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"14",fill:"none",viewBox:"0 0 16 14",children:(0,r.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",d:"M14 .5H2A1.5 1.5 0 0 0 .5 2v10A1.5 1.5 0 0 0 2 13.5h12a1.5 1.5 0 0 0 1.5-1.5V2A1.5 1.5 0 0 0 14 .5ZM8.5.5v13M11 7h2m-2-3h2m-2 6h2"})})]},e))})]})]})]})})})}
1),(0,r.jsx)(x.pn,{children:(0,r.jsxs)(x.u,{delayDuration:0,children:[(0,r.jsx)(x.aJ,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","aria-expanded":m,"aria-label":"Chapters Index",className:"flex items-center gap-2 p-1 text-sm text-foreground transition hover:text-primary",onClick:()=>p(!m),children:[(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4",viewBox:"0 0 16 16","aria-hidden":"true",children:(0,r.jsxs)("g",{strokeWidth:"1",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:".5",y1:"2.5",x2:"15.5",y2:"2.5"}),(0,r.jsx)("line",{x1:".5",y1:"8",x2:"15.5",y2:"8",stroke:"currentColor"}),(0,r.jsx)("line",{stroke:"currentColor",x1:".5",y1:"13.5",x2:"8.5",y2:"13.5"})]})}),(0,r.jsx)("span",{className:"sr-only",children:"Chapters Index"})]})}),(0,r.jsx)(x._v,{className:"z-50 bg-background text-foreground",children:"Chapters Index"})]})}),"unauthenticated"===h?(0,r.jsx)(w(),{className:"text-sm",href:"/login",children:"Login"}):(0,r.jsx)("ul",{children:(0,r.jsx)(T.do,{className:"[&_button[data-radix-collection-item]]:h-6 [&_button[data-radix-collection-item]]:bg-transparent [&_button[data-radix-collection-item]]:px-1 [&_button[data-radix-collection-item]]:hover:bg-transparent [&_button[data-radix-collection-item]]:hover:radix-state-closed:bg-transparent [&_button[data-radix-collection-item]]:radix-state-open:bg-transparent [&_div[data-state='open']]:top-[30px] [&_img]:h-6 [&_img]:w-6 [&_ul]:text-sm"})})]})})]})})]})};var Y=s(69707);let q={some:0,all:1},K=(0,l.forwardRef)((e,t)=>{let{chapter:l,chapterIndex:i}=e;return(0,r.jsxs)("section",{ref:t,className:"relative z-10 flex min-h-[80vh] w-full flex-col items-center justify-center bg-background",children:[(0,r.jsxs)("div",{className:"absolute left-0 top-0 flex h-[calc(100%-2.5rem)] w-full flex-col items-center justify-center gap-20 overflow-hidden border-b border-gray-800 p-5 text-center sm:left-5 sm:top-10 sm:w-[calc(100%-2.5rem)] sm:border-x sm:p-16 lg:border",children:[(0,r.jsxs)("p",{className:"relative z-10 inline-flex items-center gap-3 font-text text-base font-medium text-primary sm:text-xl",children:["Chapter ",i+1," "]}),(0,r.jsx)("h1",{className:"relative z-10 text-balance bg-gradient-to-b from-white to-foreground bg-clip-text py-3 font-heading text-4xl font-bold italic text-transparent drop-shadow-xl sm:text-6xl lg:text-8xl",children:l.title}),(0,r.jsx)("p",{className:"relative z-10 max-w-md text-balance text-center font-text text-base sm:text-xl",children:l.description?l.description:null}),(0,r.jsx)("div",{className:"pointer-events-none absolute z-0 select-none bg-gradient-to-t from-transparent to-white/10 bg-clip-text font-heading text-[80vh] font-bold text-transparent opacity-65 ",children:i+1})]}),(0,r.jsx)(v(),{alt:"","aria-hidden":"true",src:s(53308),width:1100,className:"pointer-events-none absolute top-0 select-none",height:517,priority:!0})]})}),$=e=>{let{nextChapter:t,prevChapter:s,book:l,chapterIndex:i}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("section",{className:"bottom-0 left-0 flex w-full grid-cols-2 flex-col-reverse items-center justify-end gap-10 bg-gray-800 p-5 pb-24 pt-11 sm:pb-5 md:fixed md:z-0 md:grid md:h-screen",children:[s?(0,r.jsxs)(w(),{href:"/books/".concat(l.slug.current,"/").concat(s.slug),className:"group relative flex h-full w-full flex-col items-center justify-center px-5 py-8 text-center font-heading text-2xl font-bold transition duration-300 ease-in-out hover:bg-gray-700 sm:text-4xl md:justify-between lg:p-16 lg:pt-32 lg:text-5xl",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"absolute font-heading text-[30vw] font-bold text-background/50 md:static",children:i}),(0,r.jsxs)("div",{className:"relative z-10 flex flex-col text-balance transition ease-in-out group-hover:text-white",children:[(0,r.jsx)("span",{className:"mb-3 font-sans text-sm font-medium uppercase tracking-wide opacity-75",children:"Previous"}),s.title]})]}):(0,r.jsx)("div",{}),t?(0,r.jsxs)(w(),{href:"/books/".concat(l.slug.current,"/").concat(t.slug),className:"group relative flex h-full w-full flex-col items-center justify-center px-5 py-8 text-center font-heading text-2xl font-bold transition duration-300 ease-in-out hover:bg-gray-700 sm:text-4xl md:justify-between lg:p-16 lg:pt-32 lg:text-5xl",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"absolute font-heading text-[30vw] font-bold text-background/50 md:static",children:i+2}),(0,r.jsxs)("div",{className:"relative z-10 flex flex-col text-balance transition ease-in-out group-hover:text-white",children:[(0,r.jsx)("span",{className:"mb-3 font-sans text-sm font-medium uppercase tracking-wide opacity-75",children:"Next"}),t.title]})]}):(0,r.jsx)("div",{})]}),(0,r.jsx)("div",{"aria-hidden":"true",className:"md:h-screen"})]})};var ee=s(29149);let et=e=>{let{toc:t,visibleHeadingId:s,className:l,chapter:i,book:a}=e,o=a.chapters.findIndex(e=>e._id===i._id);return(0,r.jsxs)(x.Vq,{children:[(0,r.jsxs)(x.hg,{className:(0,n.cn)("fixed bottom-3 right-3 z-40 flex items-center justify-center gap-1 rounded bg-gray-800 px-3 py-2 text-sm font-medium text-foreground",l),children:[(0,r.jsx)(ee.Z,{className:"h-5 w-5 "})," On this page"]}),(0,r.jsxs)(x.cZ,{withCloseButton:!1,className:"left-0 top-0 z-50 flex h-full w-full max-w-none translate-x-0 translate-y-0 flex-col bg-background p-0 py-5 text-foreground",children:[(0,r.jsx)(x.fK,{className:"border-b border-gray-800 p-5",children:(0,r.jsx)(x.$N,{children:(0,r.jsxs)("span",{className:"relative flex flex-col items-center justify-center gap-2",children:[(0,r.jsxs)("p",{className:"relative z-10 inline-flex items-center gap-3 font-text text-sm font-medium",children:[(0,r.jsx)("span",{className:"h-px w-10 bg-gray-800","aria-hidden":"true"})," ","Chapter ",o+1," ",(0,r.jsx)("span",{className:"h-px w-10 bg-gray-800","aria-hidden":"true"})]}),(0,r.jsx)("strong",{className:"text-balance px-2 font-heading text-3xl font-semibold italic text-white",children:i.title})]})})}),(0,r.jsxs)("nav",{className:"overflow-y-auto p-5 py-0 text-lg",children:[(0,r.jsx)("strong",{className:"text-sm font-semibold uppercase opacity-65",children:"In this chapter"}),(0,r.jsx)("ol",{className:"mt-3 flex flex-col gap-2 pb-16",children:t.map((e,t)=>(0,r.jsxs)("li",{children:[(0,r.jsx)("div",{children:(0,r.jsx)(D.GG,{asChild:!0,children:(0,r.jsx)(w(),{href:"#".concat(e.slug),className:"font-semibold text-white",children:(0,r.jsx)("span",{className:(0,n.cn)("",{"":s===e.slug}),children:e.text.replace(/`/g,"")})})})}),e.items.length>0&&(0,r.jsx)("ol",{children:e.items.filter(e=>{let{level:t}=e;return t<4}).map(e=>(0,r.jsx)("li",{children:(0,r.jsx)("div",{className:"pl-5",children:(0,r.jsx)(D.GG,{asChild:!0,children:(0,r.jsx)(w(),{className:"leading-tight",href:"#".concat(e.slug),children:e.text.replace(/`/g,"")})})})},e.slug))})]},e.slug))})]}),(0,r.jsx)(D.GG,{className:"fixed bottom-3 right-3 flex h-12 w-12 items-center justify-center rounded-full bg-white text-[#001816]",children:(0,r.jsx)(J.Z,{className:"h-5 w-5"})})]})]})};var es=s(34655),er=s(31402),el=e=>{let{chapter:t,nextChapter:s,prevChapter:c,chapterBody:d,book:u,toc:h}=e,x=u.chapters.findIndex(e=>e._id===t._id),m=(0,o.c)(h),p=t.resources,g=(0,O.E)(m,{rootMargin:"0% 0% -80% 0%",threshold:.5}),f=l.useRef(null),b=l.useRef(null),v=function(e){let{ref:t}=e,[s,r]=l.useState(!1),i=function(e,{root:t,margin:s,amount:r,once:i=!1}={}){let[a,n]=(0,l.useState)(!1);return(0,l.useEffect)(()=>
1{if(!e.current||i&&a)return;let l={root:t&&t.current||void 0,margin:s,amount:r};return function(e,t,{root:s,margin:r,amount:l="some"}={}){let i=(0,Y.I)(e),a=new WeakMap,n=new IntersectionObserver(e=>{e.forEach(e=>{let s=a.get(e.target);if(!!s!==e.isIntersecting){if(e.isIntersecting){let s=t(e);"function"==typeof s?a.set(e.target,s):n.unobserve(e.target)}else s&&(s(e),a.delete(e.target))}})},{root:s,rootMargin:r,threshold:"number"==typeof l?l:q[l]});return i.forEach(e=>n.observe(e)),()=>n.disconnect()}(e.current,()=>(n(!0),i?void 0:()=>n(!1)),l)},[t,e,s,i,r]),a}(t,{amount:.2});return l.useEffect(()=>{i?r(!1):r(!0)},[i]),s}({ref:b}),[j,w]=l.useState(1),[y,N]=l.useState("right"),k=E(f,y);return(0,r.jsxs)(i.Z,{meta:{title:t.title,defaultTitle:u.title,ogImage:{url:"".concat("https://www.totaltypescript.com","/api/og/og-book?title=").concat(t.title)}},nav:null,footer:null,className:"relative",children:[(0,r.jsx)(X,{book:u,chapter:t,isScrolledPastHero:v,fontSizeIndex:j,setFontSizeIndex:w,sidebarPlacement:y,setSidebarPlacement:N}),(0,r.jsxs)("main",{className:"relative z-10",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-20 h-screen w-full p-5 pt-10",children:(0,r.jsx)("div",{className:"hidden h-full w-full border border-gray-800 lg:block"})}),(0,r.jsx)(K,{chapter:t,chapterIndex:x,ref:b}),h&&"left"===y&&(0,r.jsx)(C,{className:"z-30 hidden lg:flex",toc:h,visibleHeadingId:g,maxWidth:k}),(0,r.jsxs)("div",{className:"relative z-10 flex h-full w-full justify-center bg-background pb-16",children:[(0,r.jsxs)("article",{className:(0,n.cn)("w-full p-5 pt-5 sm:pt-16",{"max-w-3xl":1===j||0===j,"max-w-4xl":2===j}),children:[(0,r.jsx)("div",{ref:f,className:(0,n.cn)("prose max-w-none prose-headings:scroll-m-20 prose-headings:text-white prose-p:text-foreground prose-code:text-white prose-li:text-foreground [&>li>code]:bg-gray-800 [&>p>code]:bg-gray-800 [&_h2>code]:bg-gray-800 [&_h3>code]:bg-gray-800 [&_h4>code]:bg-gray-800",{"prose-sm sm:prose-base lg:prose-lg":0===j,"prose-base sm:prose-lg lg:prose-xl":1===j,"prose-lg sm:prose-xl lg:prose-2xl":2===j,"prose-p:text-justify prose-li:text-justify":!1}),children:(0,r.jsx)(a.Z,{contents:d,components:{...er.tl,Exercise:e=>{let{filePath:t,title:s,resourceId:l,...i}=e;return(0,r.jsx)(A,{filePath:t,title:s,book:u,resourceId:l,...i})},h2:e=>{var s;let l=null==p?void 0:null===(s=p.find(t=>t.slug===e.id))||void 0===s?void 0:s._id;return(0,r.jsx)(V,{chapter:t,appendValueForRepeatedIds:"-for-".concat((0,es.Z)(t.title)),as:"h2",resourceId:l,...e})},h3:e=>(0,r.jsx)(V,{appendValueForRepeatedIds:"-for-".concat((0,es.Z)(t.title)),as:"h3",...e}),h4:e=>(0,r.jsx)(V,{appendValueForRepeatedIds:"-for-".concat((0,es.Z)(t.title)),as:"h4",...e})}})}),(0,r.jsx)(z.D,{className:"flex lg:hidden"})]}),h&&"right"===y&&(0,r.jsx)(R,{toc:h,fontSizeIndex:j,visibleHeadingId:g})]})]}),(0,r.jsx)($,{nextChapter:s,prevChapter:c,book:u,chapterIndex:x}),h&&(0,r.jsx)(et,{toc:h,chapter:t,book:u,className:"flex lg:hidden",visibleHeadingId:g})]})},ei=!0,ea=e=>(0,r.jsx)(el,{...e})},78215:function(e,t,s){"use strict";var r=s(5192);let l=r.forwardRef(function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"}))});t.Z=l},69707:function(e,t,s){"use strict";s.d(t,{I:function(){return l}});var r=s(26024);function l(e,t,s){var l;if("string"==typeof e){let i=document;t&&((0,r.k)(!!t.current,"Scope provided, but no element detected."),i=t.current),s?(null!==(l=s[e])&&void 0!==l||(s[e]=i.querySelectorAll(e)),e=s[e]):e=i.querySelectorAll(e)}else e instanceof Element&&(e=[e]);return Array.from(e||[])}}},function(e){e.O(0,[1453,4084,2960,3827,3246,966,6872,1468,8811,1551,6411,661,2297,3031,2134,2888,9774,179],function(){return e(e.s=97357)}),_N_E=e.O()}]); 2//# sourceMappingURL=[chapter]-6f74503b1c3f4e81.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.