(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[702],{8421:function(e,t,r){Promise.resolve().then(r.bind(r,1705)),Promise.resolve().then(r.t.bind(r,5411,23))},1705:function(e,t,r){"use strict";r.d(t,{SwitchWikiButton:function(){return u}});var n=r(5853),s=r(9916),a=r(4254);function u(e){let{path:t}=e,r=(0,s.useRouter)(),[u,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null);async function h(){o(!0),c(null);try{let n=await fetch("/api/wikis",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({type:"switch",path:t})});if(!n.ok){var e;let t=await n.json().catch(()=>({}));throw Error(null!==(e=t.error)&&void 0!==e?e:"HTTP ".concat(n.status))}r.refresh()}catch(e){c(e.message),o(!1)}}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",onClick:h,disabled:u,className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs hover:border-primary/40 hover:bg-accent disabled:opacity-50",children:u?"Switching…":"Switch →"}),i?(0,n.jsx)("span",{className:"text-xs text-destructive",role:"alert",children:i}):null]})}},9916:function(e,t,r){"use strict";var n=r(2535);r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})}},function(e){e.O(0,[411,285,749,744],function(){return e(e.s=8421)}),_N_E=e.O()}]);