@census-ai/census-sdk 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var Ke="https://api.census.ai",fe=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||Ke,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let r=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!r.includes(e.type))throw new Error(`Census: type must be one of: ${r.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let r=new URLSearchParams;e?.category&&r.set("category",e.category),e?.search&&r.set("search",e.search),e?.limit&&r.set("limit",String(e.limit)),e?.offset&&r.set("offset",String(e.offset));let s=r.toString(),a=`/api/sdk/articles${s?`?${s}`:""}`,d=await this.request(a,"GET");return this.log("Fetched articles:",d.articles.length),d}async getArticle(e){try{let r=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),r.article}catch(r){if(r.status===404)return null;throw r}}async getFeatureGroups(){let e=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",e.feature_groups.length),e}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let r=new URLSearchParams;r.set("userId",this.currentUserId),e?.status&&r.set("status",e.status),e?.type&&r.set("type",e.type),e?.limit&&r.set("limit",String(e.limit)),e?.offset&&r.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${r.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async vote(e){if(!this.currentUserId)throw new Error("Census: User must be identified before voting. Call identify() first.");if(!e)throw new Error("Census: feedbackId is required for vote()");let r=await this.request("/api/sdk/requests/vote","POST",{feedbackId:e,userId:this.currentUserId});return this.log("Vote result:",r.action,"for feedback:",e),r}async track(e,r){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:r}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let r=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:r}),this.log("Batch events tracked:",e.events.length);}async getGuides(){let e=new URLSearchParams;this.currentUserId&&e.set("userId",this.currentUserId);let r=e.toString(),s=`/api/sdk/guides${r?`?${r}`:""}`,a=await this.request(s,"GET");return this.log("Fetched guides:",a.guides.length),a}async getGuide(e){try{let r=new URLSearchParams;this.currentUserId&&r.set("userId",this.currentUserId);let s=r.toString(),a=`/api/sdk/guides/${encodeURIComponent(e)}${s?`?${s}`:""}`,d=await this.request(a,"GET");return this.log("Fetched guide:",e),d.guide}catch(r){if(r.status===404)return null;throw r}}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,r,s){let a=`${this.baseUrl}${e}`,d={"X-Census-Key":this.apiKey};s&&(d["Content-Type"]="application/json"),this.log(`${r} ${e}`,s);let c=await fetch(a,{method:r,headers:d,body:s?JSON.stringify(s):void 0});if(!c.ok){let p=`Request failed with status ${c.status}`;try{p=(await c.json()).error||p;}catch{}throw {error:p,status:c.status}}return c.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function Ie(t){return new fe(t)}var ge=react.createContext(null);function Je({apiKey:t,baseUrl:e,debug:r,user:s,theme:a={},children:d}){let[c,p]=react.useState(false),[l,f]=react.useState(false),u=react.useMemo(()=>Ie({apiKey:t,baseUrl:e,debug:r}),[t,e,r]);react.useEffect(()=>{s?u.identify(s).then(()=>{f(true),p(true);}).catch(C=>{console.error("[Census] Failed to identify user:",C),p(true);}):p(true);},[u,s]);let m=react.useMemo(()=>({client:u,theme:a,isReady:c,isIdentified:l}),[u,a,c,l]);return jsxRuntime.jsx(ge.Provider,{value:m,children:d})}function Xe(){let t=react.useContext(ge);if(!t)throw new Error("useCensus must be used within a CensusProvider");return t.client}function R(){let t=react.useContext(ge);if(!t)throw new Error("useCensusContext must be used within a CensusProvider");return t}function Ze(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(null),d=react.useCallback(async p=>{r(true),a(null);try{await t.identify(p);}catch(l){throw a(l instanceof Error?l:new Error("Failed to identify user")),l}finally{r(false);}},[t]),c=react.useCallback(()=>{t.reset();},[t]);return {identify:d,reset:c,isIdentifying:e,isIdentified:t.isIdentified(),error:s}}function X(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(false),[d,c]=react.useState(null),[p,l]=react.useState(null),f=react.useCallback(async m=>{r(true),a(false),c(null),l(null);try{let C=await t.submitFeedback(m);return l(C.feedbackId),a(!0),C}catch(C){let _=C instanceof Error?C:new Error("Failed to submit feedback");throw c(_),_}finally{r(false);}},[t]),u=react.useCallback(()=>{a(false),c(null),l(null);},[]);return {submitFeedback:f,reset:u,isSubmitting:e,isSuccess:s,error:d,feedbackId:p}}function te(t){let{client:e,isReady:r}=R(),[s,a]=react.useState(null),[d,c]=react.useState(true),[p,l]=react.useState(null),f=react.useCallback(async()=>{c(true),l(null);try{let u=await e.getArticles(t);a(u);}catch(u){l(u instanceof Error?u:new Error("Failed to fetch articles"));}finally{c(false);}},[e,t?.category,t?.search,t?.limit,t?.offset]);return react.useEffect(()=>{r&&f();},[r,f]),{articles:s?.articles||[],pagination:s?.pagination,isLoading:d,error:p,refetch:f}}function re(t){let{client:e,isReady:r}=R(),[s,a]=react.useState(null),[d,c]=react.useState(true),[p,l]=react.useState(null),f=react.useCallback(async()=>{if(!t){a(null),c(false);return}c(true),l(null);try{let u=await e.getArticle(t);a(u);}catch(u){l(u instanceof Error?u:new Error("Failed to fetch article"));}finally{c(false);}},[e,t]);return react.useEffect(()=>{r&&f();},[r,f]),{article:s,isLoading:d,error:p,refetch:f}}var tt={feedbackVisibility:"own",allowVoting:false,allowRequestCreation:true};function oe(t){let{client:e,isReady:r,isIdentified:s}=R(),[a,d]=react.useState(null),[c,p]=react.useState(true),[l,f]=react.useState(null),u=react.useCallback(async()=>{if(!s){d(null),p(false);return}p(true),f(null);try{let m=await e.getRequests(t);d(m);}catch(m){f(m instanceof Error?m:new Error("Failed to fetch requests"));}finally{p(false);}},[e,s,t?.status,t?.type,t?.limit,t?.offset]);return react.useEffect(()=>{r&&(s?u():p(false));},[r,s,u]),{requests:a?.requests||[],pagination:a?.pagination,settings:a?.settings||tt,isLoading:c,error:l,refetch:u}}function me(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(null);return {vote:react.useCallback(async c=>{r(true),a(null);try{return await t.vote(c)}catch(p){let l=p instanceof Error?p:new Error("Failed to vote");throw a(l),l}finally{r(false);}},[t]),isVoting:e,error:s}}function rt(){let{client:t}=R(),e=react.useCallback(async(s,a)=>{await t.track(s,a);},[t]),r=react.useCallback(async s=>{await t.trackBatch({events:s});},[t]);return {track:e,trackBatch:r}}function be(){let{client:t,isReady:e}=R(),[r,s]=react.useState([]),[a,d]=react.useState(true),[c,p]=react.useState(null),l=react.useCallback(async()=>{d(true),p(null);try{let f=await t.getFeatureGroups();s(f.feature_groups);}catch(f){p(f instanceof Error?f:new Error("Failed to fetch feature groups"));}finally{d(false);}},[t]);return react.useEffect(()=>{e&&l();},[e,l]),{featureGroups:r,isLoading:a,error:c,refetch:l}}var Y={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:"transform 0.2s, box-shadow 0.2s",zIndex:9999},modal:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4},modalContent:{backgroundColor:"white",borderRadius:"12px",padding:"24px",width:"100%",maxWidth:"400px",margin:"16px",boxShadow:"0 20px 50px rgba(0, 0, 0, 0.2)",fontFamily:"system-ui, -apple-system, sans-serif"},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #e0e0e0",borderRadius:"6px",fontSize:"14px",marginBottom:"16px",minHeight:"100px",resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},submitButton:{width:"100%",padding:"12px",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500",transition:"opacity 0.2s"},typeButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"6px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"}},ot={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},nt={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},st={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function it(t){return {primaryColor:t.primaryColor||"#000000",textColor:t.textColor||"#333333",backgroundColor:t.backgroundColor||"#ffffff",borderRadius:t.borderRadius||"8px",fontFamily:t.fontFamily||"system-ui, -apple-system, sans-serif"}}function at({position:t="bottom-right",text:e="Feedback",allowedTypes:r=["feedback","bug_report","feature_request"],theme:s,onSubmit:a,onError:d,children:c}){let{theme:p}=R(),{submitFeedback:l,isSubmitting:f,isSuccess:u,reset:m}=X(),[C,_]=react.useState(false),[h,E]=react.useState(r[0]),[A,z]=react.useState(""),T={...p,...s},W=it(T),P=react.useCallback(()=>{_(true),m();},[m]),q=react.useCallback(()=>{_(false),z(""),E(r[0]);},[r]),U=react.useCallback(async D=>{D.preventDefault();let b={type:h,message:A};try{await l(b),a?.(b),setTimeout(q,1500);}catch(I){d?.(I instanceof Error?I:new Error("Failed to submit feedback"));}},[h,A,l,a,d,q]);return c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:P,style:{cursor:"pointer"},children:c}),C&&jsxRuntime.jsx(Be,{isOpen:C,onClose:q,selectedType:h,onTypeChange:E,allowedTypes:r,message:A,onMessageChange:z,onSubmit:U,isSubmitting:f,isSuccess:u,themeStyles:W})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:P,style:{...Y.button,...ot[t],backgroundColor:W.primaryColor,color:"white",borderRadius:W.borderRadius,fontFamily:W.fontFamily},"aria-label":"Open feedback form",children:e}),C&&jsxRuntime.jsx(Be,{isOpen:C,onClose:q,selectedType:h,onTypeChange:E,allowedTypes:r,message:A,onMessageChange:z,onSubmit:U,isSubmitting:f,isSuccess:u,themeStyles:W})]})}function Be({isOpen:t,onClose:e,selectedType:r,onTypeChange:s,allowedTypes:a,message:d,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:f,themeStyles:u}){return t?f?jsxRuntime.jsx("div",{style:Y.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Y.modalContent,textAlign:"center",fontFamily:u.fontFamily},onClick:m=>m.stopPropagation(),children:[jsxRuntime.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",color:u.textColor},children:"Thanks for your feedback!"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#666"},children:"We appreciate you taking the time to share."})]})}):jsxRuntime.jsx("div",{style:Y.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Y.modalContent,fontFamily:u.fontFamily},onClick:m=>m.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsxRuntime.jsx("h3",{style:{margin:0,color:u.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:e,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsxs("form",{onSubmit:p,children:[jsxRuntime.jsxs("div",{style:{marginBottom:"16px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"What kind of feedback?"}),jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap"},children:a.map(m=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(m),style:{...Y.typeButton,backgroundColor:r===m?u.primaryColor:"white",color:r===m?"white":u.textColor,borderColor:r===m?u.primaryColor:"#e0e0e0"},children:[st[m]," ",nt[m]]},m))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"Your message"}),jsxRuntime.jsx("textarea",{value:d,onChange:m=>c(m.target.value),placeholder:r==="bug_report"?"Describe the bug and steps to reproduce...":r==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:Y.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:l||!d.trim(),style:{...Y.submitButton,backgroundColor:u.primaryColor,color:"white",opacity:l||!d.trim()?.6:1,cursor:l||!d.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var k={container:{fontFamily:"system-ui, -apple-system, sans-serif",maxWidth:"800px"},searchInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"15px",marginBottom:"24px",boxSizing:"border-box"},categoryButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"20px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"},articleCard:{padding:"20px",border:"1px solid #e0e0e0",borderRadius:"8px",marginBottom:"12px",cursor:"pointer",transition:"box-shadow 0.2s, border-color 0.2s",backgroundColor:"white"},articleTitle:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:"600"},articleDescription:{margin:0,fontSize:"14px",color:"#666",lineHeight:1.5},articleMeta:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"12px",color:"#999"},backButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#666",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},loading:{textAlign:"center",padding:"40px",color:"#666"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"8px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"40px",color:"#666"}};function ct(t){return {primaryColor:t.primaryColor||"#000000",textColor:t.textColor||"#333333",backgroundColor:t.backgroundColor||"#ffffff",borderRadius:t.borderRadius||"8px",fontFamily:t.fontFamily||"system-ui, -apple-system, sans-serif"}}function dt({showSearch:t=true,showCategories:e=true,defaultCategory:r,theme:s,className:a,onArticleView:d}){let{theme:c}=R(),[p,l]=react.useState(""),[f,u]=react.useState(r),[m,C]=react.useState(null),_={...c,...s},h=ct(_),{articles:E,isLoading:A,error:z}=te({category:f,search:p||void 0}),{article:T,isLoading:W,error:P}=re(m||""),q=react.useMemo(()=>{let b=new Set;return E.forEach(I=>{I.category&&b.add(I.category);}),Array.from(b).sort()},[E]),U=b=>{C(b.slug),d?.(b);},D=()=>{C(null);};return m?W?jsxRuntime.jsx("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:jsxRuntime.jsx("div",{style:k.loading,children:"Loading article..."})}):P?jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:k.error,children:"Failed to load article. Please try again."})]}):T?jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 16px 0",color:h.textColor},children:T.title}),T.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[T.read_time_minutes," min read"]}),T.content_html?jsxRuntime.jsx("div",{style:{...k.articleContent,color:h.textColor},dangerouslySetInnerHTML:{__html:T.content_html}}):jsxRuntime.jsx("div",{style:{...k.articleContent,color:h.textColor},children:typeof T.content=="string"?T.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:k.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[t&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:b=>l(b.target.value),style:k.searchInput}),e&&q.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>u(void 0),style:{...k.categoryButton,backgroundColor:f?"white":h.primaryColor,color:f?h.textColor:"white",borderColor:f?"#e0e0e0":h.primaryColor},children:"All"}),q.map(b=>jsxRuntime.jsx("button",{onClick:()=>u(b),style:{...k.categoryButton,backgroundColor:f===b?h.primaryColor:"white",color:f===b?"white":h.textColor,borderColor:f===b?h.primaryColor:"#e0e0e0"},children:b},b))]}),A&&jsxRuntime.jsx("div",{style:k.loading,children:"Loading articles..."}),z&&jsxRuntime.jsx("div",{style:k.error,children:"Failed to load articles. Please try again."}),!A&&!z&&E.length===0&&jsxRuntime.jsx("div",{style:k.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!A&&!z&&E.length>0&&jsxRuntime.jsx("div",{children:E.map(b=>jsxRuntime.jsxs("div",{onClick:()=>U(b),style:k.articleCard,role:"button",tabIndex:0,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&U(b);},children:[jsxRuntime.jsx("h3",{style:{...k.articleTitle,color:h.textColor},children:b.title}),b.seo_description&&jsxRuntime.jsx("p",{style:k.articleDescription,children:b.seo_description}),jsxRuntime.jsxs("div",{style:k.articleMeta,children:[b.category&&jsxRuntime.jsx("span",{children:b.category}),b.read_time_minutes&&jsxRuntime.jsxs("span",{children:[b.read_time_minutes," min read"]})]})]},b.id))})]})}var y={container:{fontFamily:"system-ui, -apple-system, sans-serif"},list:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"12px"},card:{border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px",backgroundColor:"#ffffff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},cardHover:{borderColor:"#d1d5db",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"8px"},badges:{display:"flex",alignItems:"center",gap:"6px"},badge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},message:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},meta:{display:"flex",gap:"12px",marginTop:"8px",fontSize:"12px",color:"#6b7280"},empty:{textAlign:"center",padding:"32px 16px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 12px",color:"#d1d5db"},loading:{textAlign:"center",padding:"24px",color:"#6b7280"},error:{textAlign:"center",padding:"24px",color:"#dc2626"},voteButton:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"8px",borderRadius:"6px",border:"1px solid #e5e7eb",backgroundColor:"#ffffff",cursor:"pointer",minWidth:"48px",transition:"all 0.15s"},voteButtonActive:{backgroundColor:"#dbeafe",borderColor:"#2563eb",color:"#2563eb"},voteCount:{fontSize:"14px",fontWeight:600,color:"#111827"},cardWithVote:{display:"flex",gap:"12px"},cardContent:{flex:1},form:{marginBottom:"16px",padding:"16px",backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:"#111827",margin:0},typeSelector:{display:"flex",gap:"8px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #e5e7eb",backgroundColor:"#ffffff",fontSize:"13px",cursor:"pointer",transition:"all 0.15s"},typeButtonActive:{backgroundColor:"#111827",borderColor:"#111827",color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #e5e7eb",fontSize:"14px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px"},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:"#111827",color:"#ffffff",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"opacity 0.15s"},successMessage:{padding:"12px",backgroundColor:"#d1fae5",borderRadius:"6px",color:"#059669",fontSize:"14px",marginBottom:"16px"},ownBadge:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"9999px",fontSize:"11px",fontWeight:500,backgroundColor:"#f3f4f6",color:"#6b7280",marginLeft:"6px"}},Le={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},_e={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function ut(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var pt=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}];function ft({status:t,type:e,limit:r=50,className:s,showEmptyState:a=true,onRequestClick:d}){let{isIdentified:c}=R(),[p,l]=react.useState(null),[f,u]=react.useState(false),[m,C]=react.useState("feedback"),[_,h]=react.useState(""),[E,A]=react.useState({}),{requests:z,isLoading:T,error:W,refetch:P,settings:q}=oe({status:t,type:e,limit:r}),{vote:U,isVoting:D}=me(),{submitFeedback:b,isSubmitting:I,isSuccess:Z,reset:n}=X(),se=react.useCallback(g=>{d?.(g);},[d]),ue=react.useCallback(async(g,H,O)=>{if(!D){A($=>({...$,[g]:{count:O?H-1:H+1,hasVoted:!O}}));try{let $=await U(g);A(L=>({...L,[g]:{count:$.vote_count,hasVoted:$.user_has_voted}}));}catch{A($=>({...$,[g]:{count:H,hasVoted:O}}));}}},[U,D]),pe=react.useCallback(async g=>{if(g.preventDefault(),!(!_.trim()||I))try{await b({type:m,message:_}),h(""),u(!1),setTimeout(()=>{P(),n();},500);}catch{}},[m,_,I,b,P,n]),ie=g=>{let H=E[g.id];return {count:H?.count??g.vote_count,hasVoted:H?.hasVoted??g.user_has_voted}};if(!c)return a?jsxRuntime.jsx("div",{style:y.empty,children:jsxRuntime.jsx("p",{children:"Please sign in to view your requests."})}):null;if(T)return jsxRuntime.jsx("div",{style:y.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})});if(W)return jsxRuntime.jsx("div",{style:y.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests. ",jsxRuntime.jsx("button",{onClick:P,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})});let ae=()=>q.allowRequestCreation?Z?jsxRuntime.jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):f?jsxRuntime.jsxs("form",{onSubmit:pe,style:y.form,children:[jsxRuntime.jsxs("div",{style:y.formHeader,children:[jsxRuntime.jsx("p",{style:y.formTitle,children:"Submit a request"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280"},children:"\u2715"})]}),jsxRuntime.jsx("div",{style:y.typeSelector,children:pt.map(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>C(g.value),style:{...y.typeButton,...m===g.value?y.typeButtonActive:{}},children:g.label},g.value))}),jsxRuntime.jsx("textarea",{value:_,onChange:g=>h(g.target.value),placeholder:"Describe your request...",style:y.textarea,required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...y.submitButton,opacity:I?.6:1},disabled:I,children:I?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>u(true),style:{...y.submitButton,marginBottom:"16px",display:"flex",alignItems:"center",gap:"6px"},children:[jsxRuntime.jsx("svg",{width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"New Request"]}):null;if(z.length===0&&a)return jsxRuntime.jsxs("div",{style:y.container,className:s,children:[ae(),jsxRuntime.jsxs("div",{style:y.empty,children:[jsxRuntime.jsx("svg",{style:y.emptyIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),jsxRuntime.jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:"No requests yet"}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:q.allowRequestCreation?"Submit your first request above.":"When you submit feedback, bug reports, or feature requests, they'll appear here."})]})]});let G=q.allowVoting&&q.feedbackVisibility!=="own";return jsxRuntime.jsxs("div",{style:y.container,className:s,children:[ae(),jsxRuntime.jsx("ul",{style:y.list,children:z.map(g=>{let H=Le[g.feedback_type]||Le.feedback,O=_e[g.status]||_e.new,$=p===g.id,L=ie(g);return jsxRuntime.jsx("li",{style:{...y.card,...$?y.cardHover:{}},onMouseEnter:()=>l(g.id),onMouseLeave:()=>l(null),children:jsxRuntime.jsxs("div",{style:G?y.cardWithVote:void 0,children:[G&&jsxRuntime.jsxs("button",{onClick:J=>{J.stopPropagation(),ue(g.id,L.count,L.hasVoted);},disabled:D,style:{...y.voteButton,...L.hasVoted?y.voteButtonActive:{}},title:L.hasVoted?"Remove vote":"Upvote this request",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:L.hasVoted?"currentColor":"none",stroke:"currentColor",strokeWidth:2,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})}),jsxRuntime.jsx("span",{style:{...y.voteCount,...L.hasVoted?{color:"#2563eb"}:{}},children:L.count})]}),jsxRuntime.jsxs("div",{style:G?y.cardContent:void 0,onClick:()=>se(g),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&se(g);},children:[jsxRuntime.jsx("div",{style:y.header,children:jsxRuntime.jsxs("div",{style:y.badges,children:[jsxRuntime.jsx("span",{style:{...y.badge,color:H.color,backgroundColor:H.bg},children:H.label}),jsxRuntime.jsx("span",{style:{...y.badge,color:O.color,backgroundColor:O.bg},children:O.label}),g.is_own&&jsxRuntime.jsx("span",{style:y.ownBadge,children:"You"})]})}),jsxRuntime.jsx("p",{style:y.message,children:g.message||"No message provided"}),jsxRuntime.jsxs("div",{style:y.meta,children:[jsxRuntime.jsx("span",{children:ut(g.created_at)}),!G&&L.count>0&&jsxRuntime.jsxs("span",{children:[L.count," vote",L.count!==1?"s":""]}),g.page_url&&jsxRuntime.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",g.page_url]})]})]})]})},g.id)})})]})}var bt={articles:"Documentation",requests:"My Requests"},Ae={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},ze={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function yt(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var ht=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],xt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Me=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),Pe=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),vt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),kt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),Ct=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),wt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),St=()=>jsxRuntime.jsx("svg",{width:"48",height:"48",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),It=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),de=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{animation:"spin 1s linear infinite"},children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),He={light:{primary:"#c45a2c",primaryHover:"#a84a24",primaryLight:"rgba(196, 90, 44, 0.08)",primaryLightHover:"rgba(196, 90, 44, 0.15)",background:"transparent",surface:"#ffffff",surfaceHover:"#fafafa",border:"rgba(0, 0, 0, 0.08)",borderHover:"rgba(196, 90, 44, 0.25)",text:"#1a1a1a",textSecondary:"#525252",textMuted:"#737373",textLight:"#a3a3a3"},dark:{primary:"#e07347",primaryHover:"#f08a5d",primaryLight:"rgba(224, 115, 71, 0.12)",primaryLightHover:"rgba(224, 115, 71, 0.2)",background:"transparent",surface:"rgba(255, 255, 255, 0.03)",surfaceHover:"rgba(255, 255, 255, 0.06)",border:"rgba(255, 255, 255, 0.08)",borderHover:"rgba(224, 115, 71, 0.35)",text:"#fafafa",textSecondary:"#d4d4d4",textMuted:"#a3a3a3",textLight:"#737373"}},Rt=t=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:t.text},grid:{display:"grid",gridTemplateColumns:"220px 1fr",gap:"40px"},sidebar:{position:"sticky",top:"24px",height:"fit-content"},main:{minWidth:0},tabs:{display:"flex",borderBottom:`1px solid ${t.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottom:"2px solid transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:t.textMuted,marginBottom:"-1px"},tabActive:{color:t.primary,borderBottomColor:t.primary},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:t.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${t.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:t.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:t.textLight,marginBottom:"8px",marginTop:"20px"},navList:{listStyle:"none",padding:0,margin:0},navItem:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",fontSize:"13px",color:t.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:t.surfaceHover,color:t.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${t.border}`},articleGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},articleCard:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px",border:`1px solid ${t.border}`,borderRadius:"8px",backgroundColor:t.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:t.primaryLight,borderRadius:"8px",color:t.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:t.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:t.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:t.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:t.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:t.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:t.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:t.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:t.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:t.textMuted},emptyIcon:{color:t.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:t.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:t.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:t.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${t.border}`,borderRadius:"8px",padding:"16px",backgroundColor:t.surface,marginBottom:"10px",transition:"border-color 0.2s"},requestHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},badge:{display:"inline-flex",alignItems:"center",padding:"3px 8px",borderRadius:"9999px",fontSize:"11px",fontWeight:500},requestMessage:{fontSize:"14px",color:t.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:t.textMuted},form:{padding:"16px",backgroundColor:t.surface,borderRadius:"8px",border:`1px solid ${t.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:t.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${t.border}`,backgroundColor:"transparent",color:t.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:t.primary,borderColor:t.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${t.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:t.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:t.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"all 0.15s"},newRequestButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:t.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",marginBottom:"20px",transition:"background-color 0.15s"},successMessage:{padding:"12px 14px",backgroundColor:"rgba(5, 150, 105, 0.1)",borderRadius:"6px",color:"#059669",fontSize:"13px",marginBottom:"12px",fontWeight:500}}),Ft=(t,e)=>`
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var Ke="https://api.census.ai",ge=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(s=>e.apiKey.startsWith(s))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||Ke,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let r=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!r.includes(e.type))throw new Error(`Census: type must be one of: ${r.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let s=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",s.feedbackId),{feedbackId:s.feedbackId}}async getArticles(e){let r=new URLSearchParams;e?.category&&r.set("category",e.category),e?.search&&r.set("search",e.search),e?.limit&&r.set("limit",String(e.limit)),e?.offset&&r.set("offset",String(e.offset));let s=r.toString(),a=`/api/sdk/articles${s?`?${s}`:""}`,d=await this.request(a,"GET");return this.log("Fetched articles:",d.articles.length),d}async getArticle(e){try{let r=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),r.article}catch(r){if(r.status===404)return null;throw r}}async getFeatureGroups(){let e=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",e.feature_groups.length),e}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let r=new URLSearchParams;r.set("userId",this.currentUserId),e?.status&&r.set("status",e.status),e?.type&&r.set("type",e.type),e?.limit&&r.set("limit",String(e.limit)),e?.offset&&r.set("offset",String(e.offset));let s=await this.request(`/api/sdk/requests?${r.toString()}`,"GET");return this.log("Fetched requests:",s.requests.length),s}async vote(e){if(!this.currentUserId)throw new Error("Census: User must be identified before voting. Call identify() first.");if(!e)throw new Error("Census: feedbackId is required for vote()");let r=await this.request("/api/sdk/requests/vote","POST",{feedbackId:e,userId:this.currentUserId});return this.log("Vote result:",r.action,"for feedback:",e),r}async track(e,r){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:r}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let r=e.events.map(s=>({eventType:s.eventType,userId:this.currentUserId,articleId:s.articleId,featureId:s.featureId,properties:s.properties}));await this.request("/api/sdk/events","POST",{events:r}),this.log("Batch events tracked:",e.events.length);}async getGuides(){let e=new URLSearchParams;this.currentUserId&&e.set("userId",this.currentUserId);let r=e.toString(),s=`/api/sdk/guides${r?`?${r}`:""}`,a=await this.request(s,"GET");return this.log("Fetched guides:",a.guides.length),a}async getGuide(e){try{let r=new URLSearchParams;this.currentUserId&&r.set("userId",this.currentUserId);let s=r.toString(),a=`/api/sdk/guides/${encodeURIComponent(e)}${s?`?${s}`:""}`,d=await this.request(a,"GET");return this.log("Fetched guide:",e),d.guide}catch(r){if(r.status===404)return null;throw r}}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,r,s){let a=`${this.baseUrl}${e}`,d={"X-Census-Key":this.apiKey};s&&(d["Content-Type"]="application/json"),this.log(`${r} ${e}`,s);let c=await fetch(a,{method:r,headers:d,body:s?JSON.stringify(s):void 0});if(!c.ok){let p=`Request failed with status ${c.status}`;try{p=(await c.json()).error||p;}catch{}throw {error:p,status:c.status}}return c.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function Ie(t){return new ge(t)}var fe=react.createContext(null);function Je({apiKey:t,baseUrl:e,debug:r,user:s,theme:a={},children:d}){let[c,p]=react.useState(false),[l,g]=react.useState(false),u=react.useMemo(()=>Ie({apiKey:t,baseUrl:e,debug:r}),[t,e,r]);react.useEffect(()=>{s?u.identify(s).then(()=>{g(true),p(true);}).catch(C=>{let T=C?.error||C?.message||JSON.stringify(C);console.error("[Census] Failed to identify user:",T),p(true);}):p(true);},[u,s]);let m=react.useMemo(()=>({client:u,theme:a,isReady:c,isIdentified:l}),[u,a,c,l]);return jsxRuntime.jsx(fe.Provider,{value:m,children:d})}function Xe(){let t=react.useContext(fe);if(!t)throw new Error("useCensus must be used within a CensusProvider");return t.client}function R(){let t=react.useContext(fe);if(!t)throw new Error("useCensusContext must be used within a CensusProvider");return t}function Ze(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(null),d=react.useCallback(async p=>{r(true),a(null);try{await t.identify(p);}catch(l){throw a(l instanceof Error?l:new Error("Failed to identify user")),l}finally{r(false);}},[t]),c=react.useCallback(()=>{t.reset();},[t]);return {identify:d,reset:c,isIdentifying:e,isIdentified:t.isIdentified(),error:s}}function X(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(false),[d,c]=react.useState(null),[p,l]=react.useState(null),g=react.useCallback(async m=>{r(true),a(false),c(null),l(null);try{let C=await t.submitFeedback(m);return l(C.feedbackId),a(!0),C}catch(C){let T=C instanceof Error?C:new Error("Failed to submit feedback");throw c(T),T}finally{r(false);}},[t]),u=react.useCallback(()=>{a(false),c(null),l(null);},[]);return {submitFeedback:g,reset:u,isSubmitting:e,isSuccess:s,error:d,feedbackId:p}}function te(t){let{client:e,isReady:r}=R(),[s,a]=react.useState(null),[d,c]=react.useState(true),[p,l]=react.useState(null),g=react.useCallback(async()=>{c(true),l(null);try{let u=await e.getArticles(t);a(u);}catch(u){l(u instanceof Error?u:new Error("Failed to fetch articles"));}finally{c(false);}},[e,t?.category,t?.search,t?.limit,t?.offset]);return react.useEffect(()=>{r&&g();},[r,g]),{articles:s?.articles||[],pagination:s?.pagination,isLoading:d,error:p,refetch:g}}function re(t){let{client:e,isReady:r}=R(),[s,a]=react.useState(null),[d,c]=react.useState(true),[p,l]=react.useState(null),g=react.useCallback(async()=>{if(!t){a(null),c(false);return}c(true),l(null);try{let u=await e.getArticle(t);a(u);}catch(u){l(u instanceof Error?u:new Error("Failed to fetch article"));}finally{c(false);}},[e,t]);return react.useEffect(()=>{r&&g();},[r,g]),{article:s,isLoading:d,error:p,refetch:g}}var tt={feedbackVisibility:"own",allowVoting:false,allowRequestCreation:true};function oe(t){let{client:e,isReady:r,isIdentified:s}=R(),[a,d]=react.useState(null),[c,p]=react.useState(true),[l,g]=react.useState(null),u=react.useCallback(async()=>{if(!s){d(null),p(false);return}p(true),g(null);try{let m=await e.getRequests(t);d(m);}catch(m){g(m instanceof Error?m:new Error("Failed to fetch requests"));}finally{p(false);}},[e,s,t?.status,t?.type,t?.limit,t?.offset]);return react.useEffect(()=>{r&&(s?u():p(false));},[r,s,u]),{requests:a?.requests||[],pagination:a?.pagination,settings:a?.settings||tt,isLoading:c,error:l,refetch:u}}function me(){let{client:t}=R(),[e,r]=react.useState(false),[s,a]=react.useState(null);return {vote:react.useCallback(async c=>{r(true),a(null);try{return await t.vote(c)}catch(p){let l=p instanceof Error?p:new Error("Failed to vote");throw a(l),l}finally{r(false);}},[t]),isVoting:e,error:s}}function rt(){let{client:t}=R(),e=react.useCallback(async(s,a)=>{await t.track(s,a);},[t]),r=react.useCallback(async s=>{await t.trackBatch({events:s});},[t]);return {track:e,trackBatch:r}}function be(){let{client:t,isReady:e}=R(),[r,s]=react.useState([]),[a,d]=react.useState(true),[c,p]=react.useState(null),l=react.useCallback(async()=>{d(true),p(null);try{let g=await t.getFeatureGroups();s(g.feature_groups);}catch(g){p(g instanceof Error?g:new Error("Failed to fetch feature groups"));}finally{d(false);}},[t]);return react.useEffect(()=>{e&&l();},[e,l]),{featureGroups:r,isLoading:a,error:c,refetch:l}}var Y={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:"transform 0.2s, box-shadow 0.2s",zIndex:9999},modal:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4},modalContent:{backgroundColor:"white",borderRadius:"12px",padding:"24px",width:"100%",maxWidth:"400px",margin:"16px",boxShadow:"0 20px 50px rgba(0, 0, 0, 0.2)",fontFamily:"system-ui, -apple-system, sans-serif"},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #e0e0e0",borderRadius:"6px",fontSize:"14px",marginBottom:"16px",minHeight:"100px",resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},submitButton:{width:"100%",padding:"12px",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500",transition:"opacity 0.2s"},typeButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"6px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"}},ot={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},nt={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},st={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function it(t){return {primaryColor:t.primaryColor||"#000000",textColor:t.textColor||"#333333",backgroundColor:t.backgroundColor||"#ffffff",borderRadius:t.borderRadius||"8px",fontFamily:t.fontFamily||"system-ui, -apple-system, sans-serif"}}function at({position:t="bottom-right",text:e="Feedback",allowedTypes:r=["feedback","bug_report","feature_request"],theme:s,onSubmit:a,onError:d,children:c}){let{theme:p}=R(),{submitFeedback:l,isSubmitting:g,isSuccess:u,reset:m}=X(),[C,T]=react.useState(false),[h,E]=react.useState(r[0]),[A,z]=react.useState(""),B={...p,...s},W=it(B),P=react.useCallback(()=>{T(true),m();},[m]),L=react.useCallback(()=>{T(false),z(""),E(r[0]);},[r]),U=react.useCallback(async D=>{D.preventDefault();let b={type:h,message:A};try{await l(b),a?.(b),setTimeout(L,1500);}catch(I){d?.(I instanceof Error?I:new Error("Failed to submit feedback"));}},[h,A,l,a,d,L]);return c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:P,style:{cursor:"pointer"},children:c}),C&&jsxRuntime.jsx(Be,{isOpen:C,onClose:L,selectedType:h,onTypeChange:E,allowedTypes:r,message:A,onMessageChange:z,onSubmit:U,isSubmitting:g,isSuccess:u,themeStyles:W})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:P,style:{...Y.button,...ot[t],backgroundColor:W.primaryColor,color:"white",borderRadius:W.borderRadius,fontFamily:W.fontFamily},"aria-label":"Open feedback form",children:e}),C&&jsxRuntime.jsx(Be,{isOpen:C,onClose:L,selectedType:h,onTypeChange:E,allowedTypes:r,message:A,onMessageChange:z,onSubmit:U,isSubmitting:g,isSuccess:u,themeStyles:W})]})}function Be({isOpen:t,onClose:e,selectedType:r,onTypeChange:s,allowedTypes:a,message:d,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:g,themeStyles:u}){return t?g?jsxRuntime.jsx("div",{style:Y.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Y.modalContent,textAlign:"center",fontFamily:u.fontFamily},onClick:m=>m.stopPropagation(),children:[jsxRuntime.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",color:u.textColor},children:"Thanks for your feedback!"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#666"},children:"We appreciate you taking the time to share."})]})}):jsxRuntime.jsx("div",{style:Y.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Y.modalContent,fontFamily:u.fontFamily},onClick:m=>m.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsxRuntime.jsx("h3",{style:{margin:0,color:u.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:e,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsxs("form",{onSubmit:p,children:[jsxRuntime.jsxs("div",{style:{marginBottom:"16px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"What kind of feedback?"}),jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap"},children:a.map(m=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(m),style:{...Y.typeButton,backgroundColor:r===m?u.primaryColor:"white",color:r===m?"white":u.textColor,borderColor:r===m?u.primaryColor:"#e0e0e0"},children:[st[m]," ",nt[m]]},m))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"Your message"}),jsxRuntime.jsx("textarea",{value:d,onChange:m=>c(m.target.value),placeholder:r==="bug_report"?"Describe the bug and steps to reproduce...":r==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:Y.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:l||!d.trim(),style:{...Y.submitButton,backgroundColor:u.primaryColor,color:"white",opacity:l||!d.trim()?.6:1,cursor:l||!d.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var k={container:{fontFamily:"system-ui, -apple-system, sans-serif",maxWidth:"800px"},searchInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"15px",marginBottom:"24px",boxSizing:"border-box"},categoryButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"20px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"},articleCard:{padding:"20px",border:"1px solid #e0e0e0",borderRadius:"8px",marginBottom:"12px",cursor:"pointer",transition:"box-shadow 0.2s, border-color 0.2s",backgroundColor:"white"},articleTitle:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:"600"},articleDescription:{margin:0,fontSize:"14px",color:"#666",lineHeight:1.5},articleMeta:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"12px",color:"#999"},backButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#666",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},loading:{textAlign:"center",padding:"40px",color:"#666"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"8px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"40px",color:"#666"}};function ct(t){return {primaryColor:t.primaryColor||"#000000",textColor:t.textColor||"#333333",backgroundColor:t.backgroundColor||"#ffffff",borderRadius:t.borderRadius||"8px",fontFamily:t.fontFamily||"system-ui, -apple-system, sans-serif"}}function dt({showSearch:t=true,showCategories:e=true,defaultCategory:r,theme:s,className:a,onArticleView:d}){let{theme:c}=R(),[p,l]=react.useState(""),[g,u]=react.useState(r),[m,C]=react.useState(null),T={...c,...s},h=ct(T),{articles:E,isLoading:A,error:z}=te({category:g,search:p||void 0}),{article:B,isLoading:W,error:P}=re(m||""),L=react.useMemo(()=>{let b=new Set;return E.forEach(I=>{I.category&&b.add(I.category);}),Array.from(b).sort()},[E]),U=b=>{C(b.slug),d?.(b);},D=()=>{C(null);};return m?W?jsxRuntime.jsx("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:jsxRuntime.jsx("div",{style:k.loading,children:"Loading article..."})}):P?jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:k.error,children:"Failed to load article. Please try again."})]}):B?jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 16px 0",color:h.textColor},children:B.title}),B.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[B.read_time_minutes," min read"]}),B.content_html?jsxRuntime.jsx("div",{style:{...k.articleContent,color:h.textColor},dangerouslySetInnerHTML:{__html:B.content_html}}):jsxRuntime.jsx("div",{style:{...k.articleContent,color:h.textColor},children:typeof B.content=="string"?B.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[jsxRuntime.jsx("button",{onClick:D,style:k.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:k.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...k.container,fontFamily:h.fontFamily},className:a,children:[t&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:b=>l(b.target.value),style:k.searchInput}),e&&L.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>u(void 0),style:{...k.categoryButton,backgroundColor:g?"white":h.primaryColor,color:g?h.textColor:"white",borderColor:g?"#e0e0e0":h.primaryColor},children:"All"}),L.map(b=>jsxRuntime.jsx("button",{onClick:()=>u(b),style:{...k.categoryButton,backgroundColor:g===b?h.primaryColor:"white",color:g===b?"white":h.textColor,borderColor:g===b?h.primaryColor:"#e0e0e0"},children:b},b))]}),A&&jsxRuntime.jsx("div",{style:k.loading,children:"Loading articles..."}),z&&jsxRuntime.jsx("div",{style:k.error,children:"Failed to load articles. Please try again."}),!A&&!z&&E.length===0&&jsxRuntime.jsx("div",{style:k.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!A&&!z&&E.length>0&&jsxRuntime.jsx("div",{children:E.map(b=>jsxRuntime.jsxs("div",{onClick:()=>U(b),style:k.articleCard,role:"button",tabIndex:0,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&U(b);},children:[jsxRuntime.jsx("h3",{style:{...k.articleTitle,color:h.textColor},children:b.title}),b.seo_description&&jsxRuntime.jsx("p",{style:k.articleDescription,children:b.seo_description}),jsxRuntime.jsxs("div",{style:k.articleMeta,children:[b.category&&jsxRuntime.jsx("span",{children:b.category}),b.read_time_minutes&&jsxRuntime.jsxs("span",{children:[b.read_time_minutes," min read"]})]})]},b.id))})]})}var y={container:{fontFamily:"system-ui, -apple-system, sans-serif"},list:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"12px"},card:{border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px",backgroundColor:"#ffffff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},cardHover:{borderColor:"#d1d5db",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"8px"},badges:{display:"flex",alignItems:"center",gap:"6px"},badge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},message:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},meta:{display:"flex",gap:"12px",marginTop:"8px",fontSize:"12px",color:"#6b7280"},empty:{textAlign:"center",padding:"32px 16px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 12px",color:"#d1d5db"},loading:{textAlign:"center",padding:"24px",color:"#6b7280"},error:{textAlign:"center",padding:"24px",color:"#dc2626"},voteButton:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"8px",borderRadius:"6px",border:"1px solid #e5e7eb",backgroundColor:"#ffffff",cursor:"pointer",minWidth:"48px",transition:"all 0.15s"},voteButtonActive:{backgroundColor:"#dbeafe",borderColor:"#2563eb",color:"#2563eb"},voteCount:{fontSize:"14px",fontWeight:600,color:"#111827"},cardWithVote:{display:"flex",gap:"12px"},cardContent:{flex:1},form:{marginBottom:"16px",padding:"16px",backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:"#111827",margin:0},typeSelector:{display:"flex",gap:"8px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #e5e7eb",backgroundColor:"#ffffff",fontSize:"13px",cursor:"pointer",transition:"all 0.15s"},typeButtonActive:{backgroundColor:"#111827",borderColor:"#111827",color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #e5e7eb",fontSize:"14px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px"},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:"#111827",color:"#ffffff",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"opacity 0.15s"},successMessage:{padding:"12px",backgroundColor:"#d1fae5",borderRadius:"6px",color:"#059669",fontSize:"14px",marginBottom:"16px"},ownBadge:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"9999px",fontSize:"11px",fontWeight:500,backgroundColor:"#f3f4f6",color:"#6b7280",marginLeft:"6px"}},Le={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},_e={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function ut(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var pt=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}];function gt({status:t,type:e,limit:r=50,className:s,showEmptyState:a=true,onRequestClick:d}){let{isIdentified:c}=R(),[p,l]=react.useState(null),[g,u]=react.useState(false),[m,C]=react.useState("feedback"),[T,h]=react.useState(""),[E,A]=react.useState({}),{requests:z,isLoading:B,error:W,refetch:P,settings:L}=oe({status:t,type:e,limit:r}),{vote:U,isVoting:D}=me(),{submitFeedback:b,isSubmitting:I,isSuccess:Z,reset:n}=X(),se=react.useCallback(f=>{d?.(f);},[d]),ue=react.useCallback(async(f,H,O)=>{if(!D){A($=>({...$,[f]:{count:O?H-1:H+1,hasVoted:!O}}));try{let $=await U(f);A(_=>({..._,[f]:{count:$.vote_count,hasVoted:$.user_has_voted}}));}catch{A($=>({...$,[f]:{count:H,hasVoted:O}}));}}},[U,D]),pe=react.useCallback(async f=>{if(f.preventDefault(),!(!T.trim()||I))try{await b({type:m,message:T}),h(""),u(!1),setTimeout(()=>{P(),n();},500);}catch{}},[m,T,I,b,P,n]),ie=f=>{let H=E[f.id];return {count:H?.count??f.vote_count,hasVoted:H?.hasVoted??f.user_has_voted}};if(!c)return a?jsxRuntime.jsx("div",{style:y.empty,children:jsxRuntime.jsx("p",{children:"Please sign in to view your requests."})}):null;if(B)return jsxRuntime.jsx("div",{style:y.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})});if(W)return jsxRuntime.jsx("div",{style:y.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests. ",jsxRuntime.jsx("button",{onClick:P,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})});let ae=()=>L.allowRequestCreation?Z?jsxRuntime.jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):g?jsxRuntime.jsxs("form",{onSubmit:pe,style:y.form,children:[jsxRuntime.jsxs("div",{style:y.formHeader,children:[jsxRuntime.jsx("p",{style:y.formTitle,children:"Submit a request"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280"},children:"\u2715"})]}),jsxRuntime.jsx("div",{style:y.typeSelector,children:pt.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>C(f.value),style:{...y.typeButton,...m===f.value?y.typeButtonActive:{}},children:f.label},f.value))}),jsxRuntime.jsx("textarea",{value:T,onChange:f=>h(f.target.value),placeholder:"Describe your request...",style:y.textarea,required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...y.submitButton,opacity:I?.6:1},disabled:I,children:I?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>u(true),style:{...y.submitButton,marginBottom:"16px",display:"flex",alignItems:"center",gap:"6px"},children:[jsxRuntime.jsx("svg",{width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"New Request"]}):null;if(z.length===0&&a)return jsxRuntime.jsxs("div",{style:y.container,className:s,children:[ae(),jsxRuntime.jsxs("div",{style:y.empty,children:[jsxRuntime.jsx("svg",{style:y.emptyIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),jsxRuntime.jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:"No requests yet"}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:L.allowRequestCreation?"Submit your first request above.":"When you submit feedback, bug reports, or feature requests, they'll appear here."})]})]});let G=L.allowVoting&&L.feedbackVisibility!=="own";return jsxRuntime.jsxs("div",{style:y.container,className:s,children:[ae(),jsxRuntime.jsx("ul",{style:y.list,children:z.map(f=>{let H=Le[f.feedback_type]||Le.feedback,O=_e[f.status]||_e.new,$=p===f.id,_=ie(f);return jsxRuntime.jsx("li",{style:{...y.card,...$?y.cardHover:{}},onMouseEnter:()=>l(f.id),onMouseLeave:()=>l(null),children:jsxRuntime.jsxs("div",{style:G?y.cardWithVote:void 0,children:[G&&jsxRuntime.jsxs("button",{onClick:J=>{J.stopPropagation(),ue(f.id,_.count,_.hasVoted);},disabled:D,style:{...y.voteButton,..._.hasVoted?y.voteButtonActive:{}},title:_.hasVoted?"Remove vote":"Upvote this request",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:_.hasVoted?"currentColor":"none",stroke:"currentColor",strokeWidth:2,children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})}),jsxRuntime.jsx("span",{style:{...y.voteCount,..._.hasVoted?{color:"#2563eb"}:{}},children:_.count})]}),jsxRuntime.jsxs("div",{style:G?y.cardContent:void 0,onClick:()=>se(f),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&se(f);},children:[jsxRuntime.jsx("div",{style:y.header,children:jsxRuntime.jsxs("div",{style:y.badges,children:[jsxRuntime.jsx("span",{style:{...y.badge,color:H.color,backgroundColor:H.bg},children:H.label}),jsxRuntime.jsx("span",{style:{...y.badge,color:O.color,backgroundColor:O.bg},children:O.label}),f.is_own&&jsxRuntime.jsx("span",{style:y.ownBadge,children:"You"})]})}),jsxRuntime.jsx("p",{style:y.message,children:f.message||"No message provided"}),jsxRuntime.jsxs("div",{style:y.meta,children:[jsxRuntime.jsx("span",{children:ut(f.created_at)}),!G&&_.count>0&&jsxRuntime.jsxs("span",{children:[_.count," vote",_.count!==1?"s":""]}),f.page_url&&jsxRuntime.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",f.page_url]})]})]})]})},f.id)})})]})}var bt={articles:"Documentation",requests:"My Requests"},Ae={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},ze={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function yt(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var ht=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],xt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Me=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),Pe=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),vt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),kt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),Ct=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),wt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),St=()=>jsxRuntime.jsx("svg",{width:"48",height:"48",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),It=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),de=()=>jsxRuntime.jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{animation:"spin 1s linear infinite"},children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),He={light:{primary:"#c45a2c",primaryHover:"#a84a24",primaryLight:"rgba(196, 90, 44, 0.08)",primaryLightHover:"rgba(196, 90, 44, 0.15)",background:"transparent",surface:"#ffffff",surfaceHover:"#fafafa",border:"rgba(0, 0, 0, 0.08)",borderHover:"rgba(196, 90, 44, 0.25)",text:"#1a1a1a",textSecondary:"#525252",textMuted:"#737373",textLight:"#a3a3a3"},dark:{primary:"#e07347",primaryHover:"#f08a5d",primaryLight:"rgba(224, 115, 71, 0.12)",primaryLightHover:"rgba(224, 115, 71, 0.2)",background:"transparent",surface:"rgba(255, 255, 255, 0.03)",surfaceHover:"rgba(255, 255, 255, 0.06)",border:"rgba(255, 255, 255, 0.08)",borderHover:"rgba(224, 115, 71, 0.35)",text:"#fafafa",textSecondary:"#d4d4d4",textMuted:"#a3a3a3",textLight:"#737373"}},Rt=t=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:t.text},grid:{display:"grid",gridTemplateColumns:"220px 1fr",gap:"40px"},sidebar:{position:"sticky",top:"24px",height:"fit-content"},main:{minWidth:0},tabs:{display:"flex",borderBottom:`1px solid ${t.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottom:"2px solid transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:t.textMuted,marginBottom:"-1px"},tabActive:{color:t.primary,borderBottom:`2px solid ${t.primary}`},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:t.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${t.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:t.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:t.textLight,marginBottom:"8px",marginTop:"20px"},navList:{listStyle:"none",padding:0,margin:0},navItem:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",fontSize:"13px",color:t.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:t.surfaceHover,color:t.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${t.border}`},articleGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},articleCard:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px",border:`1px solid ${t.border}`,borderRadius:"8px",backgroundColor:t.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:t.primaryLight,borderRadius:"8px",color:t.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:t.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:t.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:t.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:t.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:t.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:t.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:t.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:t.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:t.textMuted},emptyIcon:{color:t.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:t.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:t.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:t.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${t.border}`,borderRadius:"8px",padding:"16px",backgroundColor:t.surface,marginBottom:"10px",transition:"border-color 0.2s"},requestHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},badge:{display:"inline-flex",alignItems:"center",padding:"3px 8px",borderRadius:"9999px",fontSize:"11px",fontWeight:500},requestMessage:{fontSize:"14px",color:t.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:t.textMuted},form:{padding:"16px",backgroundColor:t.surface,borderRadius:"8px",border:`1px solid ${t.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:t.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${t.border}`,backgroundColor:"transparent",color:t.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:t.primary,borderColor:t.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${t.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:t.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:t.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"all 0.15s"},newRequestButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:t.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",marginBottom:"20px",transition:"background-color 0.15s"},successMessage:{padding:"12px 14px",backgroundColor:"rgba(5, 150, 105, 0.1)",borderRadius:"6px",color:"#059669",fontSize:"13px",marginBottom:"12px",fontWeight:500}}),Ft=(t,e)=>`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
@@ -51,5 +51,5 @@
51
51
  .census-hc .census-textarea::placeholder {
52
52
  color: ${t.textLight};
53
53
  }
54
- `;function Tt({tabs:t=["articles","requests"],defaultTab:e="articles",tabLabels:r={},showSearch:s=true,className:a,theme:d="auto"}){let[c,p]=react.useState(e),[l,f]=react.useState(""),[u,m]=react.useState(null),[C,_]=react.useState(new Set),[h,E]=react.useState(null),[A,z]=react.useState(false),[T,W]=react.useState("feedback"),[P,q]=react.useState(""),U=react.useRef(null),[D,b]=react.useState(false);react.useEffect(()=>{if(d==="auto"){let i=window.matchMedia("(prefers-color-scheme: dark)");b(i.matches);let w=V=>b(V.matches);return i.addEventListener("change",w),()=>i.removeEventListener("change",w)}},[d]);let I=d==="dark"||d==="auto"&&D,Z=I?He.dark:He.light,n=react.useMemo(()=>Rt(Z),[Z]),se=react.useMemo(()=>Ft(Z,I),[Z,I]),{isIdentified:ue,isReady:pe}=R(),{articles:ie,isLoading:ae}=te({search:l||void 0}),{article:G,isLoading:g}=re(u?.slug||""),{requests:H,isLoading:O,refetch:$,settings:L}=oe({limit:50}),{featureGroups:J,isLoading:We}=be(),{submitFeedback:Ce,isSubmitting:ee,isSuccess:Ue,reset:we}=X(),De={...bt,...r};react.useEffect(()=>{let i=w=>{(w.metaKey||w.ctrlKey)&&w.key==="k"&&(w.preventDefault(),U.current?.focus());};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]);let Ge=i=>{_(w=>{let V=new Set(w);return V.has(i)?V.delete(i):V.add(i),V});},Se=react.useMemo(()=>ie.filter(i=>!h||i.feature_id===h),[ie,h]),$e=react.useCallback(async i=>{if(i.preventDefault(),!(!P.trim()||ee))try{await Ce({type:T,message:P}),q(""),z(!1),setTimeout(()=>{$(),we();},500);}catch{}},[T,P,ee,Ce,$,we]),Ve=()=>g||!G?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:n.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>m(null),style:n.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(kt,{}),"Back to articles"]}),jsxRuntime.jsx("h1",{style:n.articleDetailTitle,children:G.title}),G.read_time_minutes&&jsxRuntime.jsxs("div",{style:n.articleDetailMeta,children:[jsxRuntime.jsx(Ct,{}),G.read_time_minutes," min read"]}),G.content_html?jsxRuntime.jsx("div",{style:n.articleDetailContent,dangerouslySetInnerHTML:{__html:G.content_html}}):jsxRuntime.jsx("p",{style:{...n.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),Ne=()=>u?Ve():ae||We?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):Se.length===0?jsxRuntime.jsxs("div",{style:n.emptyState,children:[jsxRuntime.jsx("div",{style:n.emptyIcon,children:jsxRuntime.jsx(Me,{})}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:"No articles found"}),jsxRuntime.jsx("p",{style:n.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsxRuntime.jsx("div",{style:n.articleGrid,children:Se.map(i=>jsxRuntime.jsxs("button",{onClick:()=>m(i),style:n.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:n.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(Me,{})}),jsxRuntime.jsxs("div",{style:n.articleContent,children:[jsxRuntime.jsx("h3",{style:n.articleTitle,children:i.title}),i.seo_description&&jsxRuntime.jsx("p",{style:n.articleDesc,children:i.seo_description}),i.read_time_minutes&&jsxRuntime.jsxs("p",{style:n.articleMeta,children:[i.read_time_minutes," min read"]})]}),jsxRuntime.jsx("span",{style:n.articleChevron,className:"census-article-chevron",children:jsxRuntime.jsx(Pe,{})})]},i.id))}),Oe=()=>L.allowRequestCreation?Ue?jsxRuntime.jsx("div",{style:n.successMessage,children:"Thanks for your feedback! It has been submitted."}):A?jsxRuntime.jsxs("form",{onSubmit:$e,style:n.form,children:[jsxRuntime.jsxs("div",{style:n.formHeader,children:[jsxRuntime.jsx("p",{style:n.formTitle,children:"Submit a request"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>z(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:n.typeSelector,children:ht.map(i=>jsxRuntime.jsx("button",{type:"button",onClick:()=>W(i.value),style:{...n.typeButton,...T===i.value?n.typeButtonActive:{}},children:i.label},i.value))}),jsxRuntime.jsx("textarea",{value:P,onChange:i=>q(i.target.value),placeholder:"Describe your request...",style:n.textarea,className:"census-textarea",required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...n.submitButton,opacity:ee?.6:1},disabled:ee,className:"census-submit-btn",children:ee?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>z(true),style:n.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(It,{}),"New Request"]}):null,je=()=>pe?ue?O?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[Oe(),H.length===0?jsxRuntime.jsxs("div",{style:n.emptyState,children:[jsxRuntime.jsx("div",{style:n.emptyIcon,children:jsxRuntime.jsx(St,{})}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:"No requests yet"}),jsxRuntime.jsx("p",{style:n.emptyText,children:L.allowRequestCreation?"Submit your first request above.":"When you submit feedback, they'll appear here."})]}):jsxRuntime.jsx("div",{children:H.map(i=>{let w=Ae[i.feedback_type]||Ae.feedback,V=ze[i.status]||ze.new;return jsxRuntime.jsxs("div",{style:n.requestCard,children:[jsxRuntime.jsxs("div",{style:n.requestHeader,children:[jsxRuntime.jsx("span",{style:{...n.badge,color:w.color,backgroundColor:w.bg},children:w.label}),jsxRuntime.jsx("span",{style:{...n.badge,color:V.color,backgroundColor:V.bg},children:V.label})]}),jsxRuntime.jsx("p",{style:n.requestMessage,children:i.message||"No message provided"}),jsxRuntime.jsx("div",{style:n.requestMeta,children:jsxRuntime.jsx("span",{children:yt(i.created_at)})})]},i.id)})})]}):jsxRuntime.jsx("div",{style:n.emptyState,children:jsxRuntime.jsx("p",{style:n.emptyText,children:"Please sign in to view your requests."})}):jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading..."})]});return jsxRuntime.jsxs("div",{style:n.container,className:`census-hc ${a||""}`,children:[jsxRuntime.jsx("style",{children:se}),t.length>1&&jsxRuntime.jsx("div",{style:n.tabs,children:t.map(i=>jsxRuntime.jsx("button",{onClick:()=>p(i),style:{...n.tab,...c===i?n.tabActive:{}},className:c!==i?"census-tab":void 0,children:De[i]},i))}),jsxRuntime.jsxs("div",{style:n.grid,children:[jsxRuntime.jsxs("aside",{style:n.sidebar,children:[s&&c==="articles"&&jsxRuntime.jsxs("div",{style:n.searchContainer,children:[jsxRuntime.jsx("div",{style:n.searchIcon,children:jsxRuntime.jsx(xt,{})}),jsxRuntime.jsx("input",{ref:U,type:"text",placeholder:"Search...",value:l,onChange:i=>f(i.target.value),style:n.searchInput,className:"census-search-input"})]}),c==="articles"&&J.length>0&&jsxRuntime.jsxs("nav",{children:[jsxRuntime.jsx("h3",{style:n.sectionTitle,children:"Features"}),jsxRuntime.jsxs("ul",{style:n.navList,children:[jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>E(null),style:{...n.navItem,...h?{}:n.navItemActive},className:h?"census-nav-item":void 0,children:"All Articles"})}),J.map(i=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Ge(i.id),style:n.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(wt,{}),i.name]}),C.has(i.id)?jsxRuntime.jsx(vt,{}):jsxRuntime.jsx(Pe,{})]}),C.has(i.id)&&i.features.length>0&&jsxRuntime.jsx("ul",{style:n.subNav,children:i.features.map(w=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>E(w.id),style:{...n.navItem,padding:"6px 12px",fontSize:"13px",...h===w.id?n.navItemActive:{}},className:h!==w.id?"census-nav-item":void 0,children:w.name})},w.id))})]},i.id))]})]})]}),jsxRuntime.jsxs("main",{style:n.main,children:[c==="articles"&&Ne(),c==="requests"&&je()]})]})]})}exports.CensusProvider=Je;exports.FeedbackButton=at;exports.HelpCenter=Tt;exports.KnowledgeBase=dt;exports.Requests=ft;exports.useArticle=re;exports.useArticles=te;exports.useCensus=Xe;exports.useCensusContext=R;exports.useFeatureGroups=be;exports.useFeedback=X;exports.useIdentify=Ze;exports.useRequests=oe;exports.useTrack=rt;exports.useVote=me;//# sourceMappingURL=index.cjs.map
54
+ `;function Tt({tabs:t=["articles","requests"],defaultTab:e="articles",tabLabels:r={},showSearch:s=true,className:a,theme:d="auto"}){let[c,p]=react.useState(e),[l,g]=react.useState(""),[u,m]=react.useState(null),[C,T]=react.useState(new Set),[h,E]=react.useState(null),[A,z]=react.useState(false),[B,W]=react.useState("feedback"),[P,L]=react.useState(""),U=react.useRef(null),[D,b]=react.useState(false);react.useEffect(()=>{if(d==="auto"){let i=window.matchMedia("(prefers-color-scheme: dark)");b(i.matches);let w=V=>b(V.matches);return i.addEventListener("change",w),()=>i.removeEventListener("change",w)}},[d]);let I=d==="dark"||d==="auto"&&D,Z=I?He.dark:He.light,n=react.useMemo(()=>Rt(Z),[Z]),se=react.useMemo(()=>Ft(Z,I),[Z,I]),{isIdentified:ue,isReady:pe}=R(),{articles:ie,isLoading:ae}=te({search:l||void 0}),{article:G,isLoading:f}=re(u?.slug||""),{requests:H,isLoading:O,refetch:$,settings:_}=oe({limit:50}),{featureGroups:J,isLoading:We}=be(),{submitFeedback:Ce,isSubmitting:ee,isSuccess:Ue,reset:we}=X(),De={...bt,...r};react.useEffect(()=>{let i=w=>{(w.metaKey||w.ctrlKey)&&w.key==="k"&&(w.preventDefault(),U.current?.focus());};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]);let Ge=i=>{T(w=>{let V=new Set(w);return V.has(i)?V.delete(i):V.add(i),V});},Se=react.useMemo(()=>ie.filter(i=>!h||i.feature_id===h),[ie,h]),$e=react.useCallback(async i=>{if(i.preventDefault(),!(!P.trim()||ee))try{await Ce({type:B,message:P}),L(""),z(!1),setTimeout(()=>{$(),we();},500);}catch{}},[B,P,ee,Ce,$,we]),Ve=()=>f||!G?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:n.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>m(null),style:n.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(kt,{}),"Back to articles"]}),jsxRuntime.jsx("h1",{style:n.articleDetailTitle,children:G.title}),G.read_time_minutes&&jsxRuntime.jsxs("div",{style:n.articleDetailMeta,children:[jsxRuntime.jsx(Ct,{}),G.read_time_minutes," min read"]}),G.content_html?jsxRuntime.jsx("div",{style:n.articleDetailContent,dangerouslySetInnerHTML:{__html:G.content_html}}):jsxRuntime.jsx("p",{style:{...n.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),Ne=()=>u?Ve():ae||We?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):Se.length===0?jsxRuntime.jsxs("div",{style:n.emptyState,children:[jsxRuntime.jsx("div",{style:n.emptyIcon,children:jsxRuntime.jsx(Me,{})}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:"No articles found"}),jsxRuntime.jsx("p",{style:n.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsxRuntime.jsx("div",{style:n.articleGrid,children:Se.map(i=>jsxRuntime.jsxs("button",{onClick:()=>m(i),style:n.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:n.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(Me,{})}),jsxRuntime.jsxs("div",{style:n.articleContent,children:[jsxRuntime.jsx("h3",{style:n.articleTitle,children:i.title}),i.seo_description&&jsxRuntime.jsx("p",{style:n.articleDesc,children:i.seo_description}),i.read_time_minutes&&jsxRuntime.jsxs("p",{style:n.articleMeta,children:[i.read_time_minutes," min read"]})]}),jsxRuntime.jsx("span",{style:n.articleChevron,className:"census-article-chevron",children:jsxRuntime.jsx(Pe,{})})]},i.id))}),Oe=()=>_.allowRequestCreation?Ue?jsxRuntime.jsx("div",{style:n.successMessage,children:"Thanks for your feedback! It has been submitted."}):A?jsxRuntime.jsxs("form",{onSubmit:$e,style:n.form,children:[jsxRuntime.jsxs("div",{style:n.formHeader,children:[jsxRuntime.jsx("p",{style:n.formTitle,children:"Submit a request"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>z(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:n.typeSelector,children:ht.map(i=>jsxRuntime.jsx("button",{type:"button",onClick:()=>W(i.value),style:{...n.typeButton,...B===i.value?n.typeButtonActive:{}},children:i.label},i.value))}),jsxRuntime.jsx("textarea",{value:P,onChange:i=>L(i.target.value),placeholder:"Describe your request...",style:n.textarea,className:"census-textarea",required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...n.submitButton,opacity:ee?.6:1},disabled:ee,className:"census-submit-btn",children:ee?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>z(true),style:n.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(It,{}),"New Request"]}):null,je=()=>pe?ue?O?jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[Oe(),H.length===0?jsxRuntime.jsxs("div",{style:n.emptyState,children:[jsxRuntime.jsx("div",{style:n.emptyIcon,children:jsxRuntime.jsx(St,{})}),jsxRuntime.jsx("h3",{style:n.emptyTitle,children:"No requests yet"}),jsxRuntime.jsx("p",{style:n.emptyText,children:_.allowRequestCreation?"Submit your first request above.":"When you submit feedback, they'll appear here."})]}):jsxRuntime.jsx("div",{children:H.map(i=>{let w=Ae[i.feedback_type]||Ae.feedback,V=ze[i.status]||ze.new;return jsxRuntime.jsxs("div",{style:n.requestCard,children:[jsxRuntime.jsxs("div",{style:n.requestHeader,children:[jsxRuntime.jsx("span",{style:{...n.badge,color:w.color,backgroundColor:w.bg},children:w.label}),jsxRuntime.jsx("span",{style:{...n.badge,color:V.color,backgroundColor:V.bg},children:V.label})]}),jsxRuntime.jsx("p",{style:n.requestMessage,children:i.message||"No message provided"}),jsxRuntime.jsx("div",{style:n.requestMeta,children:jsxRuntime.jsx("span",{children:yt(i.created_at)})})]},i.id)})})]}):jsxRuntime.jsx("div",{style:n.emptyState,children:jsxRuntime.jsx("p",{style:n.emptyText,children:"Please sign in to view your requests."})}):jsxRuntime.jsxs("div",{style:n.loading,children:[jsxRuntime.jsx(de,{}),jsxRuntime.jsx("span",{children:"Loading..."})]});return jsxRuntime.jsxs("div",{style:n.container,className:`census-hc ${a||""}`,children:[jsxRuntime.jsx("style",{children:se}),t.length>1&&jsxRuntime.jsx("div",{style:n.tabs,children:t.map(i=>jsxRuntime.jsx("button",{onClick:()=>p(i),style:{...n.tab,...c===i?n.tabActive:{}},className:c!==i?"census-tab":void 0,children:De[i]},i))}),jsxRuntime.jsxs("div",{style:n.grid,children:[jsxRuntime.jsxs("aside",{style:n.sidebar,children:[s&&c==="articles"&&jsxRuntime.jsxs("div",{style:n.searchContainer,children:[jsxRuntime.jsx("div",{style:n.searchIcon,children:jsxRuntime.jsx(xt,{})}),jsxRuntime.jsx("input",{ref:U,type:"text",placeholder:"Search...",value:l,onChange:i=>g(i.target.value),style:n.searchInput,className:"census-search-input"})]}),c==="articles"&&J.length>0&&jsxRuntime.jsxs("nav",{children:[jsxRuntime.jsx("h3",{style:n.sectionTitle,children:"Features"}),jsxRuntime.jsxs("ul",{style:n.navList,children:[jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>E(null),style:{...n.navItem,...h?{}:n.navItemActive},className:h?"census-nav-item":void 0,children:"All Articles"})}),J.map(i=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Ge(i.id),style:n.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(wt,{}),i.name]}),C.has(i.id)?jsxRuntime.jsx(vt,{}):jsxRuntime.jsx(Pe,{})]}),C.has(i.id)&&i.features.length>0&&jsxRuntime.jsx("ul",{style:n.subNav,children:i.features.map(w=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>E(w.id),style:{...n.navItem,padding:"6px 12px",fontSize:"13px",...h===w.id?n.navItemActive:{}},className:h!==w.id?"census-nav-item":void 0,children:w.name})},w.id))})]},i.id))]})]})]}),jsxRuntime.jsxs("main",{style:n.main,children:[c==="articles"&&Ne(),c==="requests"&&je()]})]})]})}exports.CensusProvider=Je;exports.FeedbackButton=at;exports.HelpCenter=Tt;exports.KnowledgeBase=dt;exports.Requests=gt;exports.useArticle=re;exports.useArticles=te;exports.useCensus=Xe;exports.useCensusContext=R;exports.useFeatureGroups=be;exports.useFeedback=X;exports.useIdentify=Ze;exports.useRequests=oe;exports.useTrack=rt;exports.useVote=me;//# sourceMappingURL=index.cjs.map
55
55
  //# sourceMappingURL=index.cjs.map