import{j as f}from"./jsx-runtime.D_zvdyIk.js";import{_ as x}from"./preload-helper.BlTxHScW.js";import{r as o}from"./index.BIRwh3HZ.js";import{u as I}from"./useTranslation.Dg7DwAC5.js";import{a as _}from"./site-config.CgQ_bxrG.js";import{g as M}from"./utils.D6Ui05B2.js";import"./_commonjsHelpers.CqkleIqs.js";import"./index.RTTH55m1.js";import"./index.3whys8t3.js";import"./site.Deo0TYgJ.js";function v({id:t,host:e,repo:a,repoId:r,category:c,categoryId:m,mapping:u,term:p,strict:n,reactionsEnabled:d,emitMetadata:i,inputPosition:s,theme:h,lang:y,loading:E}){const[l,b]=o.useState(!1);return o.useEffect(()=>{l||x(()=>import("./giscus-Ci9LqPcC.cvwcBf5t.js"),[]).then(()=>b(!0))},[]),l?f.jsx("giscus-widget",{id:t,host:e,repo:a,repoid:r,category:c,categoryid:m,mapping:u,term:p,strict:n,reactionsenabled:d,emitmetadata:i,inputposition:s,theme:h,lang:y,loading:E}):null}function w(t){const e=document.querySelector("iframe.giscus-frame");e&&e.contentWindow?.postMessage({giscus:t},"https://giscus.app")}function g(){return document.documentElement.classList.contains("dark")?"dark":"light"}function q(){const t=_.giscus,{locale:e}=I(),[a,r]=o.useState("light"),[c,m]=o.useState(!1);if(o.useEffect(()=>{m(!0),r(g());const n=new MutationObserver(d=>{for(const i of d)if(i.type==="attributes"&&i.attributeName==="class"){const s=g();r(s),w({setConfig:{theme:s}})}});return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),!c||!t?.repo)return null;const[u,p]=t.repo.split("/");return!u||!p?(console.error('[Giscus] Invalid repo format. Expected "owner/repo"'),null):f.jsx(v,{host:t?.host,repo:t.repo,repoId:t.repoId,category:t?.category,categoryId:t?.categoryId,mapping:t?.mapping??"pathname",term:t?.term,strict:t?.strict,reactionsEnabled:t?.reactionsEnabled,emitMetadata:t?.emitMetadata,inputPosition:t?.inputPosition??"top",theme:t?.theme??a,lang:t?.lang??M(e),loading:t?.loading??"lazy"})}export{q as default};
