@census-ai/census-sdk 0.5.5 → 0.5.6
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.
- package/dist/react/index.cjs +7 -7
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +24 -2
- package/dist/react/index.d.ts +24 -2
- package/dist/react/index.js +7 -7
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var ro="https://census-api-production-97c0.up.railway.app",De=class{constructor(t){this.currentUserId=null;if(!t.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(r=>t.apiKey.startsWith(r))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||ro,this.projectId=t.projectId||null,this.debug=t.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(t){if(!t.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=t.userId,await this.request("/api/sdk/identify","POST",{userId:t.userId,email:t.email,name:t.name,avatarUrl:t.avatarUrl,metadata:t.metadata,organizationId:t.organizationId,organizationName:t.organizationName,organizationDomain:t.organizationDomain,organizationPlan:t.organizationPlan}),this.log("User identified:",t.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(t){let o=["feedback","bug_report","feature_request","article_rating"];if(!t.type||!o.includes(t.type))throw new Error(`Census: type must be one of: ${o.join(", ")}`);if(t.type==="article_rating"){if(t.rating===void 0&&t.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!t.message)throw new Error("Census: message is required for this feedback type");let r=await this.request("/api/sdk/feedback","POST",{type:t.type,message:t.message,rating:t.rating,helpful:t.helpful,userId:this.currentUserId,articleId:t.articleId,projectId:this.projectId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:t.metadata});return this.log("Feedback submitted:",r.feedbackId),{feedbackId:r.feedbackId}}async getArticles(t){let o=new URLSearchParams;this.projectId&&o.set("project_id",this.projectId),t?.category&&o.set("category",t.category),t?.search&&o.set("search",t.search),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=o.toString(),i=`/api/sdk/articles${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched articles:",n.articles.length),n}async getArticle(t){try{let o=await this.request(`/api/sdk/articles/${encodeURIComponent(t)}`,"GET");return this.log("Fetched article:",t),o.article}catch(o){if(o.status===404)return null;throw o}}async getFeatureGroups(){let t=new URLSearchParams;this.projectId&&t.set("project_id",this.projectId);let o=t.toString(),r=await this.request(`/api/sdk/feature-groups${o?`?${o}`:""}`,"GET");return this.log("Fetched feature groups:",r.feature_groups.length),r}async getRequests(t){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let o=new URLSearchParams;o.set("userId",this.currentUserId),this.projectId&&o.set("project_id",this.projectId),t?.status&&o.set("status",t.status),t?.type&&o.set("type",t.type),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=await this.request(`/api/sdk/requests?${o.toString()}`,"GET");return this.log("Fetched requests:",r.requests.length),r}async track(t,o){if(!t)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:t,userId:this.currentUserId,properties:o}),this.log("Event tracked:",t);}async trackBatch(t){if(!t.events||t.events.length===0)throw new Error("Census: at least one event is required");if(t.events.length>100)throw new Error("Census: maximum 100 events per batch");let o=t.events.map(r=>({eventType:r.eventType,userId:this.currentUserId,articleId:r.articleId,featureId:r.featureId,properties:r.properties}));await this.request("/api/sdk/events","POST",{events:o}),this.log("Batch events tracked:",t.events.length);}async getGuides(t){let o=new URLSearchParams,r=t?.projectId||this.projectId;r&&o.set("project_id",r),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let i=o.toString(),n=`/api/sdk/guides${i?`?${i}`:""}`,c=await this.request(n,"GET");return this.log("Fetched guides:",c.guides.length),c}async getGuide(t){try{let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"GET");return this.log("Fetched guide:",t),o.guide}catch(o){if(o.status===404)return null;throw o}}async createGuide(t){if(!t.name||!t.slug)throw new Error("Census: name and slug are required for createGuide()");let o=await this.request("/api/sdk/guides","POST",{name:t.name,slug:t.slug,description:t.description,project_id:t.projectId||this.projectId,trigger_type:t.triggerType||"manual",trigger_config:t.triggerConfig||{},theme:t.theme||{},allow_skip:t.allowSkip??true,show_progress:t.showProgress??true});return this.log("Guide created:",o.guide.id),o.guide}async updateGuide(t,o){if(!t)throw new Error("Census: guideId is required for updateGuide()");let r={};o.name!==void 0&&(r.name=o.name),o.slug!==void 0&&(r.slug=o.slug),o.description!==void 0&&(r.description=o.description),o.triggerType!==void 0&&(r.trigger_type=o.triggerType),o.triggerConfig!==void 0&&(r.trigger_config=o.triggerConfig),o.theme!==void 0&&(r.theme=o.theme),o.allowSkip!==void 0&&(r.allow_skip=o.allowSkip),o.showProgress!==void 0&&(r.show_progress=o.showProgress),o.status!==void 0&&(r.status=o.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"PUT",r);return this.log("Guide updated:",t),i.guide}async deleteGuide(t){if(!t)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"DELETE"),this.log("Guide deleted:",t);}async getGuideSteps(t){let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"GET");return this.log("Fetched steps for guide:",t),o.steps}async addGuideStep(t,o){if(!t)throw new Error("Census: guideId is required for addGuideStep()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"POST",{step_type:o.stepType||"tooltip",sort_order:o.sortOrder,selector_strategy:o.selectorStrategy||{},title:o.title,content:o.content,tooltip_position:o.tooltipPosition||"auto",rich_content:o.richContent||{},display_config:o.displayConfig||{},advance_config:o.advanceConfig||{trigger:"button"},style_config:o.styleConfig||{}});return this.log("Step added to guide:",t),r.step}async updateGuideStep(t,o,r){if(!t||!o)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let i={};r.stepType!==void 0&&(i.step_type=r.stepType),r.sortOrder!==void 0&&(i.sort_order=r.sortOrder),r.selectorStrategy!==void 0&&(i.selector_strategy=r.selectorStrategy),r.title!==void 0&&(i.title=r.title),r.content!==void 0&&(i.content=r.content),r.tooltipPosition!==void 0&&(i.tooltip_position=r.tooltipPosition),r.richContent!==void 0&&(i.rich_content=r.richContent),r.displayConfig!==void 0&&(i.display_config=r.displayConfig),r.advanceConfig!==void 0&&(i.advance_config=r.advanceConfig),r.styleConfig!==void 0&&(i.style_config=r.styleConfig);let n=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"PUT",i);return this.log("Step updated:",o),n.step}async deleteGuideStep(t,o){if(!t||!o)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"DELETE"),this.log("Step deleted:",o);}async reorderGuideSteps(t,o){if(!t)throw new Error("Census: guideId is required for reorderGuideSteps()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"PUT",{steps:o});return this.log("Steps reordered for guide:",t),r.steps}async trackGuideEvent(t){if(!t.guideId||!t.eventType||!t.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:t.guideId,eventType:t.eventType,stepId:t.stepId,stepIndex:t.stepIndex,pageUrl:t.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:t.sessionId,userId:t.userId||this.currentUserId,metadata:t.metadata}),this.log("Guide event tracked:",t.eventType,t.guideId);}async markGuideCompleted(t){if(!t)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:t,userId:this.currentUserId}),this.log("Guide marked completed:",t);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(t,o,r){let i=`${this.baseUrl}${t}`,n=1;for(let c=0;c<=n;c++){let p=new AbortController,l=setTimeout(()=>p.abort(),3e4);try{let s={"X-Census-Key":this.apiKey};r&&(s["Content-Type"]="application/json"),this.log(`${o} ${t}`,r);let a=await fetch(i,{method:o,headers:s,body:r?JSON.stringify(r):void 0,signal:p.signal});if(!a.ok){if(a.status>=500&&c<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(c+1)));continue}let d=`Request failed with status ${a.status}`;try{d=(await a.json()).error||d;}catch{}throw {error:d,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(c<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(d=>setTimeout(d,1e3*(c+1)));continue}throw {error:p.signal.aborted?`Request timed out after 30s: ${o} ${t}`:`Network error: ${o} ${t}`}}finally{clearTimeout(l);}}throw {error:"Unexpected error",status:500}}log(...t){this.debug&&console.log("[Census]",...t);}};function ut(e){return new De(e)}var Ne=react.createContext(null);function so({apiKey:e,baseUrl:t,projectId:o,debug:r,user:i,theme:n={},children:c}){let[p,l]=react.useState(false),[s,a]=react.useState(false),d=react.useMemo(()=>ut({apiKey:e,baseUrl:t,projectId:o,debug:r}),[e,t,o,r]);react.useEffect(()=>{i?d.identify(i).then(()=>{a(true),l(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),l(true);}):l(true);},[d,i]);let g=react.useMemo(()=>({client:d,theme:n,isReady:p,isIdentified:s}),[d,n,p,s]);return jsxRuntime.jsx(Ne.Provider,{value:g,children:c})}function ao(){let e=react.useContext(Ne);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function O(){let e=react.useContext(Ne);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function lo(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(null);return {identify:async p=>{o(true),i(null);try{await e.identify(p);}catch(l){throw i(l instanceof Error?l:new Error("Failed to identify user")),l}finally{o(false);}},reset:()=>{e.reset();},isIdentifying:t,isIdentified:e.isIdentified(),error:r}}function ye(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(false),[n,c]=react.useState(null),[p,l]=react.useState(null),s=react.useCallback(async d=>{o(true),i(false),c(null),l(null);try{let g=await e.submitFeedback(d);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw c(f),f}finally{o(false);}},[e]),a=react.useCallback(()=>{i(false),c(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:p}}function he(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{c(true),l(null);try{let a=await t.getArticles(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch articles"));}finally{c(false);}},[t,JSON.stringify(e)]);return react.useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:p,refetch:s}}function xe(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{if(!e){i(null),c(false);return}c(true),l(null);try{let a=await t.getArticle(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch article"));}finally{c(false);}},[t,e]);return react.useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:p,refetch:s}}function Oe(){let{client:e,isReady:t}=O(),[o,r]=react.useState([]),[i,n]=react.useState(true),[c,p]=react.useState(null),l=react.useCallback(async()=>{n(true),p(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){p(s instanceof Error?s:new Error("Failed to fetch feature groups"));}finally{n(false);}},[e]);return react.useEffect(()=>{t&&l();},[t,l]),{featureGroups:o,isLoading:i,error:c,refetch:l}}function ve(e){let{client:t,isReady:o,isIdentified:r}=O(),[i,n]=react.useState(null),[c,p]=react.useState(true),[l,s]=react.useState(null),a=react.useCallback(async()=>{if(!r){n(null),p(false);return}p(true),s(null);try{let d=await t.getRequests(e);n(d);}catch(d){s(d instanceof Error?d:new Error("Failed to fetch requests"));}finally{p(false);}},[t,r,e?.status,e?.type,e?.limit,e?.offset]);return react.useEffect(()=>{o&&r&&a();},[o,r,a]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:c,error:l,refetch:a}}function uo(){let{client:e}=O(),t=react.useCallback(async(r,i)=>{await e.track(r,i);},[e]),o=react.useCallback(async r=>{await e.trackBatch({events:r});},[e]);return {track:t,trackBatch:o}}function fo(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{c(true),l(null);try{let a=await t.getGuides(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch guides"));}finally{c(false);}},[t,e?.projectId,e?.url,e?.userId]);return react.useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:p,refetch:s}}function $e(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState([]),[c,p]=react.useState(false),[l,s]=react.useState(false),[a,d]=react.useState(null),[g,f]=react.useState(null),u=react.useRef(false),C=react.useCallback(async R=>{p(true),d(null);try{let h=await e.getGuide(R);return h&&(r(h),n(h.guide_steps||[]),f(h.guide_steps?.[0]?.id||null)),h}catch(h){return d(h instanceof Error?h:new Error("Failed to load guide")),null}finally{p(false);}},[e]),G=react.useCallback(async R=>{s(true),d(null);try{let h=await e.createGuide(R);return r(h),n([]),f(null),h}catch(h){throw d(h instanceof Error?h:new Error("Failed to create guide")),h}finally{s(false);}},[e]),x=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.updateGuide(o.id,R);return r(h),u.current=!1,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to update guide")),h}finally{s(false);}},[e,o]),E=react.useCallback(async()=>x({status:"published"}),[x]),v=react.useCallback(async()=>x({status:"draft"}),[x]),w=react.useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw d(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),T=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.addGuideStep(o.id,R);return n(U=>[...U,h]),f(h.id),u.current=!0,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to add step")),h}finally{s(false);}},[e,o]),S=react.useCallback(async(R,h)=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let U=await e.updateGuideStep(o.id,R,h);return n(q=>q.map(Q=>Q.id===R?U:Q)),u.current=!0,U}catch(U){throw d(U instanceof Error?U:new Error("Failed to update step")),U}finally{s(false);}},[e,o]),I=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuideStep(o.id,R),n(h=>h.filter(U=>U.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(h){throw d(h instanceof Error?h:new Error("Failed to delete step")),h}finally{s(false);}},[e,o,g,i]),m=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.reorderGuideSteps(o.id,R);return n(h),u.current=!0,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to reorder steps")),h}finally{s(false);}},[e,o]),A=react.useCallback(async R=>{let h=i.findIndex(q=>q.id===R);if(h<=0)return;let U=i.map((q,Q)=>Q===h?{id:q.id,sort_order:h-1}:Q===h-1?{id:q.id,sort_order:h}:{id:q.id,sort_order:Q});return m(U)},[i,m]),D=react.useCallback(async R=>{let h=i.findIndex(q=>q.id===R);if(h<0||h>=i.length-1)return;let U=i.map((q,Q)=>Q===h?{id:q.id,sort_order:h+1}:Q===h+1?{id:q.id,sort_order:h}:{id:q.id,sort_order:Q});return m(U)},[i,m]),y=g&&i.find(R=>R.id===g)||null,P=react.useCallback(()=>{r(null),n([]),f(null),d(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:y,selectedStepId:g,isLoading:c,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:C,createGuide:G,updateGuide:x,publishGuide:E,unpublishGuide:v,deleteGuide:w,addStep:T,updateStep:S,deleteStep:I,reorderSteps:m,moveStepUp:A,moveStepDown:D,setSelectedStepId:f,reset:P}}function go(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState(0),[c,p]=react.useState(false),[l,s]=react.useState([]),[a,d]=react.useState([]),g=react.useCallback((P,R=0)=>{r(P),n(R),p(true);},[]),f=react.useCallback(()=>{if(!o)return;let P=o.guide_steps||[];i<P.length-1?n(R=>R+1):(s(R=>[...R,o.id]),p(false),r(null));},[o,i]),u=react.useCallback(()=>{i>0&&n(P=>P-1);},[i]),C=react.useCallback(P=>{if(!o)return;let R=o.guide_steps||[];P>=0&&P<R.length&&n(P);},[o]),G=react.useCallback(()=>{o&&d(P=>[...P,o.id]),p(false),r(null),n(0);},[o]),x=react.useCallback(()=>{p(false);},[]),E=react.useCallback(()=>{o&&p(true);},[o]),v=react.useCallback(async(P,R)=>{let h=P.guide_steps?.[R];if(h)try{await e.track("guide_step_viewed",{guide_id:P.id,guide_name:P.name,step_id:h.id,step_index:R,step_type:h.step_type});}catch{}},[e]),w=react.useCallback(async P=>{try{await e.track("guide_completed",{guide_id:P.id,guide_name:P.name,total_steps:P.guide_steps?.length||0});}catch{}},[e]),T=react.useCallback(async(P,R)=>{try{await e.track("guide_dismissed",{guide_id:P.id,guide_name:P.name,dismissed_at_step:R,total_steps:P.guide_steps?.length||0});}catch{}},[e]),S=o?.guide_steps?.[i]||null,I=o?.guide_steps?.length||0,m=i===I-1,A=i===0,D=react.useCallback(P=>l.includes(P),[l]),y=react.useCallback(P=>a.includes(P),[a]);return {activeGuide:o,currentStep:S,currentStepIndex:i,totalSteps:I,isPlaying:c,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:C,dismiss:G,pause:x,resume:E,trackStepView:v,trackGuideComplete:w,trackGuideDismiss:T,completedGuideIds:l,dismissedGuideIds:a,isGuideCompleted:D,isGuideDismissed:y}}var ie={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",transition:"transform 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"}},mo={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},bo={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},yo={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function ho(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function xo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:c}){let{theme:p}=O(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:d}=ye(),[g,f]=react.useState(false),[u,C]=react.useState(o[0]),[G,x]=react.useState(""),E={...p,...r},v=ho(E),w=react.useCallback(()=>{f(true),d();},[d]),T=react.useCallback(()=>{f(false),x(""),C(o[0]);},[o]),S=react.useCallback(async I=>{I.preventDefault();let m={type:u,message:G};try{await l(m),i?.(m),setTimeout(T,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,G,l,i,n,T]);return c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:w,style:{cursor:"pointer"},children:c}),g&&jsxRuntime.jsx(mt,{isOpen:g,onClose:T,selectedType:u,onTypeChange:C,allowedTypes:o,message:G,onMessageChange:x,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:w,style:{...ie.button,...mo[e],backgroundColor:v.primaryColor,color:"white",borderRadius:v.borderRadius,fontFamily:v.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsxRuntime.jsx(mt,{isOpen:g,onClose:T,selectedType:u,onTypeChange:C,allowedTypes:o,message:G,onMessageChange:x,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]})}function mt({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:s,themeStyles:a}){return e?s?jsxRuntime.jsx("div",{style:ie.modal,onClick:t,children:jsxRuntime.jsxs("div",{style:{...ie.modalContent,textAlign:"center",fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxRuntime.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",color:a.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:ie.modal,onClick:t,children:jsxRuntime.jsxs("div",{style:{...ie.modalContent,fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsxRuntime.jsx("h3",{style:{margin:0,color:a.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:t,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:i.map(d=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(d),style:{...ie.typeButton,backgroundColor:o===d?a.primaryColor:"white",color:o===d?"white":a.textColor,borderColor:o===d?a.primaryColor:"#e0e0e0"},children:[yo[d]," ",bo[d]]},d))})]}),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:n,onChange:d=>c(d.target.value),placeholder:o==="bug_report"?"Describe the bug and steps to reproduce...":o==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:ie.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:l||!n.trim(),style:{...ie.submitButton,backgroundColor:a.primaryColor,color:"white",opacity:l||!n.trim()?.6:1,cursor:l||!n.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var M={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:"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 Co(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function So({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:c}=O(),[p,l]=react.useState(""),[s,a]=react.useState(o),[d,g]=react.useState(null),f={...c,...r},u=Co(f),{articles:C,isLoading:G,error:x}=he({category:s,search:p||void 0}),{article:E,isLoading:v,error:w}=xe(d||""),T=react.useMemo(()=>{let m=new Set;return C.forEach(A=>{A.category&&m.add(A.category);}),Array.from(m).sort()},[C]),S=m=>{g(m.slug),n?.(m);},I=()=>{g(null);};return d?v?jsxRuntime.jsx("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:jsxRuntime.jsx("div",{style:M.loading,children:"Loading article..."})}):w?jsxRuntime.jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:M.error,children:"Failed to load article. Please try again."})]}):E?jsxRuntime.jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 16px 0",color:u.textColor},children:E.title}),E.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[E.read_time_minutes," min read"]}),E.content_html?jsxRuntime.jsx("div",{style:{...M.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:E.content_html}}):jsxRuntime.jsx("div",{style:{...M.articleContent,color:u.textColor},children:typeof E.content=="string"?E.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:M.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[e&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:m=>l(m.target.value),style:M.searchInput}),t&&T.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>a(void 0),style:{...M.categoryButton,backgroundColor:s?"white":u.primaryColor,color:s?u.textColor:"white",borderColor:s?"#e0e0e0":u.primaryColor},children:"All"}),T.map(m=>jsxRuntime.jsx("button",{onClick:()=>a(m),style:{...M.categoryButton,backgroundColor:s===m?u.primaryColor:"white",color:s===m?"white":u.textColor,borderColor:s===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),G&&jsxRuntime.jsx("div",{style:M.loading,children:"Loading articles..."}),x&&jsxRuntime.jsx("div",{style:M.error,children:"Failed to load articles. Please try again."}),!G&&!x&&C.length===0&&jsxRuntime.jsx("div",{style:M.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!G&&!x&&C.length>0&&jsxRuntime.jsx("div",{children:C.map(m=>jsxRuntime.jsxs("div",{onClick:()=>S(m),style:M.articleCard,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&S(m);},children:[jsxRuntime.jsx("h3",{style:{...M.articleTitle,color:u.textColor},children:m.title}),m.seo_description&&jsxRuntime.jsx("p",{style:M.articleDescription,children:m.seo_description}),jsxRuntime.jsxs("div",{style:M.articleMeta,children:[m.category&&jsxRuntime.jsx("span",{children:m.category}),m.read_time_minutes&&jsxRuntime.jsxs("span",{children:[m.read_time_minutes," min read"]})]})]},m.id))})]})}var K={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"},cardHover:{borderColor:"#d1d5db"},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"}},yt={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"}},ht={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 Ro(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Eo({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:c}=O(),[p,l]=react.useState(null),{requests:s,isLoading:a,error:d,refetch:g}=ve({status:e,type:t,limit:o}),f=react.useCallback(u=>{n?.(u);},[n]);return c?a?jsxRuntime.jsx("div",{style:K.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})}):d?jsxRuntime.jsx("div",{style:K.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests. ",jsxRuntime.jsx("button",{onClick:g,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):s.length===0&&i?jsxRuntime.jsxs("div",{style:K.empty,children:[jsxRuntime.jsx("svg",{style:K.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:"When you submit feedback, bug reports, or feature requests, they'll appear here."})]}):jsxRuntime.jsx("div",{style:K.container,className:r,children:jsxRuntime.jsx("ul",{style:K.list,children:s.map(u=>{let C=yt[u.feedback_type]||yt.feedback,G=ht[u.status]||ht.new,x=p===u.id;return jsxRuntime.jsxs("li",{style:{...K.card,...x?K.cardHover:{}},onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(null),onClick:()=>f(u),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&f(u);},children:[jsxRuntime.jsx("div",{style:K.header,children:jsxRuntime.jsxs("div",{style:K.badges,children:[jsxRuntime.jsx("span",{style:{...K.badge,color:C.color,backgroundColor:C.bg},children:C.label}),jsxRuntime.jsx("span",{style:{...K.badge,color:G.color,backgroundColor:G.bg},children:G.label})]})}),jsxRuntime.jsx("p",{style:K.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:K.meta,children:[jsxRuntime.jsx("span",{children:Ro(u.created_at)}),u.page_url&&jsxRuntime.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",u.page_url]})]})]},u.id)})})}):i?jsxRuntime.jsx("div",{style:K.empty,children:jsxRuntime.jsx("p",{children:"Please sign in to view your requests."})}):null}var Io={articles:"Documentation",requests:"My Requests"},vt={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"}},Ct={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},planned:{label:"Planned",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 Po(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var _o=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],Bo=()=>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"})}),St=()=>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"})}),wt=()=>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"})}),Lo=()=>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"})}),Fo=()=>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"})}),zo=()=>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"})}),Ao=()=>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"})}),qo=()=>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"})}),Mo=()=>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"})}),Ve=()=>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"})}),kt={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"}},Do=e=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:e.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 ${e.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:e.textMuted,marginBottom:"-1px"},tabActive:{color:e.primary,borderBottomColor:e.primary},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:e.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${e.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:e.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:e.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:e.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:e.surfaceHover,color:e.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${e.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 ${e.border}`,borderRadius:"8px",backgroundColor:e.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.primaryLight,borderRadius:"8px",color:e.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:e.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:e.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:e.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:e.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:e.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:e.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:e.textMuted},emptyIcon:{color:e.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:e.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:e.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:e.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${e.border}`,borderRadius:"8px",padding:"16px",backgroundColor:e.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:e.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:e.textMuted},form:{padding:"16px",backgroundColor:e.surface,borderRadius:"8px",border:`1px solid ${e.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,backgroundColor:"transparent",color:e.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:e.primary,borderColor:e.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:e.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.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:e.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}}),No=(e,t)=>`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var so="https://census-api-production-97c0.up.railway.app",De=class{constructor(t){this.currentUserId=null;if(!t.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(r=>t.apiKey.startsWith(r))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||so,this.projectId=t.projectId||null,this.debug=t.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(t){if(!t.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=t.userId,await this.request("/api/sdk/identify","POST",{userId:t.userId,email:t.email,name:t.name,avatarUrl:t.avatarUrl,metadata:t.metadata,organizationId:t.organizationId,organizationName:t.organizationName,organizationDomain:t.organizationDomain,organizationPlan:t.organizationPlan}),this.log("User identified:",t.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(t){let o=["feedback","bug_report","feature_request","article_rating"];if(!t.type||!o.includes(t.type))throw new Error(`Census: type must be one of: ${o.join(", ")}`);if(t.type==="article_rating"){if(t.rating===void 0&&t.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!t.message)throw new Error("Census: message is required for this feedback type");let r=await this.request("/api/sdk/feedback","POST",{type:t.type,message:t.message,rating:t.rating,helpful:t.helpful,userId:this.currentUserId,articleId:t.articleId,projectId:this.projectId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:t.metadata});return this.log("Feedback submitted:",r.feedbackId),{feedbackId:r.feedbackId}}async getArticles(t){let o=new URLSearchParams;this.projectId&&o.set("project_id",this.projectId),t?.category&&o.set("category",t.category),t?.search&&o.set("search",t.search),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=o.toString(),i=`/api/sdk/articles${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched articles:",n.articles.length),n}async getArticle(t){try{let o=await this.request(`/api/sdk/articles/${encodeURIComponent(t)}`,"GET");return this.log("Fetched article:",t),o.article}catch(o){if(o.status===404)return null;throw o}}async getFeatureGroups(){let t=new URLSearchParams;this.projectId&&t.set("project_id",this.projectId);let o=t.toString(),r=await this.request(`/api/sdk/feature-groups${o?`?${o}`:""}`,"GET");return this.log("Fetched feature groups:",r.feature_groups.length),r}async getRequests(t){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let o=new URLSearchParams;o.set("userId",this.currentUserId),this.projectId&&o.set("project_id",this.projectId),t?.status&&o.set("status",t.status),t?.type&&o.set("type",t.type),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=await this.request(`/api/sdk/requests?${o.toString()}`,"GET");return this.log("Fetched requests:",r.requests.length),r}async track(t,o){if(!t)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:t,userId:this.currentUserId,properties:o}),this.log("Event tracked:",t);}async trackBatch(t){if(!t.events||t.events.length===0)throw new Error("Census: at least one event is required");if(t.events.length>100)throw new Error("Census: maximum 100 events per batch");let o=t.events.map(r=>({eventType:r.eventType,userId:this.currentUserId,articleId:r.articleId,featureId:r.featureId,properties:r.properties}));await this.request("/api/sdk/events","POST",{events:o}),this.log("Batch events tracked:",t.events.length);}async getGuides(t){let o=new URLSearchParams,r=t?.projectId||this.projectId;r&&o.set("project_id",r),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let i=o.toString(),n=`/api/sdk/guides${i?`?${i}`:""}`,c=await this.request(n,"GET");return this.log("Fetched guides:",c.guides.length),c}async getGuide(t){try{let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"GET");return this.log("Fetched guide:",t),o.guide}catch(o){if(o.status===404)return null;throw o}}async createGuide(t){if(!t.name||!t.slug)throw new Error("Census: name and slug are required for createGuide()");let o=await this.request("/api/sdk/guides","POST",{name:t.name,slug:t.slug,description:t.description,project_id:t.projectId||this.projectId,trigger_type:t.triggerType||"manual",trigger_config:t.triggerConfig||{},theme:t.theme||{},allow_skip:t.allowSkip??true,show_progress:t.showProgress??true});return this.log("Guide created:",o.guide.id),o.guide}async updateGuide(t,o){if(!t)throw new Error("Census: guideId is required for updateGuide()");let r={};o.name!==void 0&&(r.name=o.name),o.slug!==void 0&&(r.slug=o.slug),o.description!==void 0&&(r.description=o.description),o.triggerType!==void 0&&(r.trigger_type=o.triggerType),o.triggerConfig!==void 0&&(r.trigger_config=o.triggerConfig),o.theme!==void 0&&(r.theme=o.theme),o.allowSkip!==void 0&&(r.allow_skip=o.allowSkip),o.showProgress!==void 0&&(r.show_progress=o.showProgress),o.status!==void 0&&(r.status=o.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"PUT",r);return this.log("Guide updated:",t),i.guide}async deleteGuide(t){if(!t)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"DELETE"),this.log("Guide deleted:",t);}async getGuideSteps(t){let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"GET");return this.log("Fetched steps for guide:",t),o.steps}async addGuideStep(t,o){if(!t)throw new Error("Census: guideId is required for addGuideStep()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"POST",{step_type:o.stepType||"tooltip",sort_order:o.sortOrder,selector_strategy:o.selectorStrategy||{},title:o.title,content:o.content,tooltip_position:o.tooltipPosition||"auto",rich_content:o.richContent||{},display_config:o.displayConfig||{},advance_config:o.advanceConfig||{trigger:"button"},style_config:o.styleConfig||{}});return this.log("Step added to guide:",t),r.step}async updateGuideStep(t,o,r){if(!t||!o)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let i={};r.stepType!==void 0&&(i.step_type=r.stepType),r.sortOrder!==void 0&&(i.sort_order=r.sortOrder),r.selectorStrategy!==void 0&&(i.selector_strategy=r.selectorStrategy),r.title!==void 0&&(i.title=r.title),r.content!==void 0&&(i.content=r.content),r.tooltipPosition!==void 0&&(i.tooltip_position=r.tooltipPosition),r.richContent!==void 0&&(i.rich_content=r.richContent),r.displayConfig!==void 0&&(i.display_config=r.displayConfig),r.advanceConfig!==void 0&&(i.advance_config=r.advanceConfig),r.styleConfig!==void 0&&(i.style_config=r.styleConfig);let n=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"PUT",i);return this.log("Step updated:",o),n.step}async deleteGuideStep(t,o){if(!t||!o)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"DELETE"),this.log("Step deleted:",o);}async reorderGuideSteps(t,o){if(!t)throw new Error("Census: guideId is required for reorderGuideSteps()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"PUT",{steps:o});return this.log("Steps reordered for guide:",t),r.steps}async trackGuideEvent(t){if(!t.guideId||!t.eventType||!t.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:t.guideId,eventType:t.eventType,stepId:t.stepId,stepIndex:t.stepIndex,pageUrl:t.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:t.sessionId,userId:t.userId||this.currentUserId,metadata:t.metadata}),this.log("Guide event tracked:",t.eventType,t.guideId);}async markGuideCompleted(t){if(!t)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:t,userId:this.currentUserId}),this.log("Guide marked completed:",t);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(t,o,r){let i=`${this.baseUrl}${t}`,n=1;for(let c=0;c<=n;c++){let p=new AbortController,l=setTimeout(()=>p.abort(),3e4);try{let s={"X-Census-Key":this.apiKey};r&&(s["Content-Type"]="application/json"),this.log(`${o} ${t}`,r);let a=await fetch(i,{method:o,headers:s,body:r?JSON.stringify(r):void 0,signal:p.signal});if(!a.ok){if(a.status>=500&&c<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(c+1)));continue}let d=`Request failed with status ${a.status}`;try{d=(await a.json()).error||d;}catch{}throw {error:d,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(c<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(d=>setTimeout(d,1e3*(c+1)));continue}throw {error:p.signal.aborted?`Request timed out after 30s: ${o} ${t}`:`Network error: ${o} ${t}`}}finally{clearTimeout(l);}}throw {error:"Unexpected error",status:500}}log(...t){this.debug&&console.log("[Census]",...t);}};function bt(e){return new De(e)}function ye(){let{client:e}=U(),[t,o]=react.useState(false),[r,i]=react.useState(false),[n,c]=react.useState(null),[p,l]=react.useState(null),s=react.useCallback(async d=>{o(true),i(false),c(null),l(null);try{let g=await e.submitFeedback(d);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw c(f),f}finally{o(false);}},[e]),a=react.useCallback(()=>{i(false),c(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:p}}function xe(e){let{client:t,isReady:o}=U(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{c(true),l(null);try{let a=await t.getArticles(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch articles"));}finally{c(false);}},[t,JSON.stringify(e)]);return react.useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:p,refetch:s}}function he(e){let{client:t,isReady:o}=U(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{if(!e){i(null),c(false);return}c(true),l(null);try{let a=await t.getArticle(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch article"));}finally{c(false);}},[t,e]);return react.useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:p,refetch:s}}function Oe(){let{client:e,isReady:t}=U(),[o,r]=react.useState([]),[i,n]=react.useState(true),[c,p]=react.useState(null),l=react.useCallback(async()=>{n(true),p(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){p(s instanceof Error?s:new Error("Failed to fetch feature groups"));}finally{n(false);}},[e]);return react.useEffect(()=>{t&&l();},[t,l]),{featureGroups:o,isLoading:i,error:c,refetch:l}}function ve(e){let{client:t,isReady:o,isIdentified:r}=U(),[i,n]=react.useState(null),[c,p]=react.useState(true),[l,s]=react.useState(null),a=react.useCallback(async()=>{if(!r){n(null),p(false);return}p(true),s(null);try{let d=await t.getRequests(e);n(d);}catch(d){s(d instanceof Error?d:new Error("Failed to fetch requests"));}finally{p(false);}},[t,r,e?.status,e?.type,e?.limit,e?.offset]);return react.useEffect(()=>{o&&r&&a();},[o,r,a]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:c,error:l,refetch:a}}function lo(){let{client:e}=U(),t=react.useCallback(async(r,i)=>{await e.track(r,i);},[e]),o=react.useCallback(async r=>{await e.trackBatch({events:r});},[e]);return {track:t,trackBatch:o}}function co(e){let{client:t,isReady:o}=U(),[r,i]=react.useState(null),[n,c]=react.useState(true),[p,l]=react.useState(null),s=react.useCallback(async()=>{c(true),l(null);try{let a=await t.getGuides(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch guides"));}finally{c(false);}},[t,e?.projectId,e?.url,e?.userId]);return react.useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:p,refetch:s}}function Ne(){let{client:e,isReady:t}=U(),[o,r]=react.useState(null),[i,n]=react.useState([]),[c,p]=react.useState(false),[l,s]=react.useState(false),[a,d]=react.useState(null),[g,f]=react.useState(null),u=react.useRef(false),w=react.useCallback(async R=>{p(true),d(null);try{let x=await e.getGuide(R);return x&&(r(x),n(x.guide_steps||[]),f(x.guide_steps?.[0]?.id||null)),x}catch(x){return d(x instanceof Error?x:new Error("Failed to load guide")),null}finally{p(false);}},[e]),I=react.useCallback(async R=>{s(true),d(null);try{let x=await e.createGuide(R);return r(x),n([]),f(null),x}catch(x){throw d(x instanceof Error?x:new Error("Failed to create guide")),x}finally{s(false);}},[e]),h=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.updateGuide(o.id,R);return r(x),u.current=!1,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to update guide")),x}finally{s(false);}},[e,o]),E=react.useCallback(async()=>h({status:"published"}),[h]),C=react.useCallback(async()=>h({status:"draft"}),[h]),S=react.useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw d(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),_=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.addGuideStep(o.id,R);return n(H=>[...H,x]),f(x.id),u.current=!0,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to add step")),x}finally{s(false);}},[e,o]),v=react.useCallback(async(R,x)=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let H=await e.updateGuideStep(o.id,R,x);return n(q=>q.map(V=>V.id===R?H:V)),u.current=!0,H}catch(H){throw d(H instanceof Error?H:new Error("Failed to update step")),H}finally{s(false);}},[e,o]),G=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuideStep(o.id,R),n(x=>x.filter(H=>H.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(x){throw d(x instanceof Error?x:new Error("Failed to delete step")),x}finally{s(false);}},[e,o,g,i]),m=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.reorderGuideSteps(o.id,R);return n(x),u.current=!0,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to reorder steps")),x}finally{s(false);}},[e,o]),A=react.useCallback(async R=>{let x=i.findIndex(q=>q.id===R);if(x<=0)return;let H=i.map((q,V)=>V===x?{id:q.id,sort_order:x-1}:V===x-1?{id:q.id,sort_order:x}:{id:q.id,sort_order:V});return m(H)},[i,m]),B=react.useCallback(async R=>{let x=i.findIndex(q=>q.id===R);if(x<0||x>=i.length-1)return;let H=i.map((q,V)=>V===x?{id:q.id,sort_order:x+1}:V===x+1?{id:q.id,sort_order:x}:{id:q.id,sort_order:V});return m(H)},[i,m]),b=g&&i.find(R=>R.id===g)||null,P=react.useCallback(()=>{r(null),n([]),f(null),d(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:b,selectedStepId:g,isLoading:c,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:w,createGuide:I,updateGuide:h,publishGuide:E,unpublishGuide:C,deleteGuide:S,addStep:_,updateStep:v,deleteStep:G,reorderSteps:m,moveStepUp:A,moveStepDown:B,setSelectedStepId:f,reset:P}}function po(){let{client:e,isReady:t}=U(),[o,r]=react.useState(null),[i,n]=react.useState(0),[c,p]=react.useState(false),[l,s]=react.useState([]),[a,d]=react.useState([]),g=react.useCallback((P,R=0)=>{r(P),n(R),p(true);},[]),f=react.useCallback(()=>{if(!o)return;let P=o.guide_steps||[];i<P.length-1?n(R=>R+1):(s(R=>[...R,o.id]),p(false),r(null));},[o,i]),u=react.useCallback(()=>{i>0&&n(P=>P-1);},[i]),w=react.useCallback(P=>{if(!o)return;let R=o.guide_steps||[];P>=0&&P<R.length&&n(P);},[o]),I=react.useCallback(()=>{o&&d(P=>[...P,o.id]),p(false),r(null),n(0);},[o]),h=react.useCallback(()=>{p(false);},[]),E=react.useCallback(()=>{o&&p(true);},[o]),C=react.useCallback(async(P,R)=>{let x=P.guide_steps?.[R];if(x)try{await e.track("guide_step_viewed",{guide_id:P.id,guide_name:P.name,step_id:x.id,step_index:R,step_type:x.step_type});}catch{}},[e]),S=react.useCallback(async P=>{try{await e.track("guide_completed",{guide_id:P.id,guide_name:P.name,total_steps:P.guide_steps?.length||0});}catch{}},[e]),_=react.useCallback(async(P,R)=>{try{await e.track("guide_dismissed",{guide_id:P.id,guide_name:P.name,dismissed_at_step:R,total_steps:P.guide_steps?.length||0});}catch{}},[e]),v=o?.guide_steps?.[i]||null,G=o?.guide_steps?.length||0,m=i===G-1,A=i===0,B=react.useCallback(P=>l.includes(P),[l]),b=react.useCallback(P=>a.includes(P),[a]);return {activeGuide:o,currentStep:v,currentStepIndex:i,totalSteps:G,isPlaying:c,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:w,dismiss:I,pause:h,resume:E,trackStepView:C,trackGuideComplete:S,trackGuideDismiss:_,completedGuideIds:l,dismissedGuideIds:a,isGuideCompleted:B,isGuideDismissed:b}}var yt={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},fo={tooltip:"Points to a specific element with an arrow",modal:"Centered overlay that grabs attention",slideout:"Slides in from the side of the screen",hotspot:"Pulsing beacon that expands on click",banner:"Top or bottom bar announcement",embedded:"Inline content injected into the page"},go=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],mo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Ue({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=react.useState(false),[c,p]=react.useState(e.step_type),[l,s]=react.useState(e.rich_content?.title||e.title||""),[a,d]=react.useState(e.rich_content?.body||e.content||""),[g,f]=react.useState(e.tooltip_position||e.display_config?.position||"auto"),[u,w]=react.useState(e.selector_strategy?.css||""),[I,h]=react.useState(e.display_config?.backdrop!==false),[E,C]=react.useState(e.advance_config?.trigger||"button"),[S,_]=react.useState(e.advance_config?.delay||3e3),v=react.useCallback(async()=>{n(true);try{let m=u?{css:u}:void 0,A={title:l||void 0,body:a||void 0},B={position:g!=="auto"?g:void 0,backdrop:I},b={trigger:E,delay:E==="delay"?S:void 0};await t(e.id,{stepType:c,selectorStrategy:m,richContent:A,displayConfig:B,advanceConfig:b,tooltipPosition:g});}finally{n(false);}},[e.id,c,l,a,g,u,I,E,S,t]),G=c==="tooltip"||c==="hotspot";return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[jsxRuntime.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:"Edit Step"}),jsxRuntime.jsx("button",{onClick:v,disabled:i,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:i?"wait":"pointer",opacity:i?.7:1},children:i?"Saving...":"Save Changes"})]}),jsxRuntime.jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Step Type"}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px"},children:Object.keys(yt).map(m=>jsxRuntime.jsxs("button",{onClick:()=>p(m),style:{padding:"10px",border:`2px solid ${c===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:c===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:yt[m]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:fo[m]})]},m))})]}),G&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Target Element"}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsxRuntime.jsx("input",{type:"text",value:u,onChange:m=>w(m.target.value),placeholder:"CSS selector (e.g., #my-button)",style:{flex:1,padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",fontFamily:"monospace"}}),jsxRuntime.jsx("button",{onClick:o,disabled:r,style:{padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:r?"#f3f4f6":"white",cursor:r?"wait":"pointer"},children:r?"Selecting...":"Select"})]}),jsxRuntime.jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px"},children:'Click "Select" to pick an element on the page, or enter a CSS selector manually'})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Title"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:m=>s(m.target.value),placeholder:"Enter step title",style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Content"}),jsxRuntime.jsx("textarea",{value:a,onChange:m=>d(m.target.value),placeholder:"Enter step content (HTML supported)",rows:4,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",resize:"vertical",fontFamily:"inherit"}})]}),(c==="tooltip"||c==="hotspot")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Position"}),jsxRuntime.jsx("select",{value:g,onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:go.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),c==="banner"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Banner Position"}),jsxRuntime.jsxs("select",{value:g==="bottom"?"bottom":"top",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"top",children:"Top"}),jsxRuntime.jsx("option",{value:"bottom",children:"Bottom"})]})]}),c==="slideout"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Slideout Side"}),jsxRuntime.jsxs("select",{value:g==="left"?"left":"right",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"right",children:"Right"}),jsxRuntime.jsx("option",{value:"left",children:"Left"})]})]}),(c==="tooltip"||c==="modal")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:I,onChange:m=>h(m.target.checked),style:{width:"16px",height:"16px"}}),jsxRuntime.jsx("span",{style:{fontSize:"13px",fontWeight:500},children:"Show backdrop overlay"})]}),jsxRuntime.jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px",marginLeft:"24px"},children:"Dims the background to focus attention on the step"})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Advance When"}),jsxRuntime.jsx("select",{value:E,onChange:m=>C(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:mo.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),E==="delay"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Delay (seconds)"}),jsxRuntime.jsx("input",{type:"number",value:S/1e3,onChange:m=>_(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function yo(e){let t={},o=e.getAttribute("data-testid");if(o)return t.testId=o,t.css=`[data-testid="${o}"]`,t;if(e.id)return t.css=`#${CSS.escape(e.id)}`,t;let r=[],i=e,n=0,c=5;for(;i&&i!==document.body&&n<c;){let l=i.tagName.toLowerCase(),s=Array.from(i.classList).filter(g=>!g.startsWith("hover")&&!g.startsWith("focus")&&!g.startsWith("active")).slice(0,2);s.length>0&&(l+="."+s.map(g=>CSS.escape(g)).join("."));let a=i.parentElement;if(a){let g=Array.from(a.children).filter(f=>f.tagName===i.tagName);if(g.length>1){let f=g.indexOf(i)+1;l+=`:nth-of-type(${f})`;}}r.unshift(l);let d=r.join(" > ");try{if(document.querySelectorAll(d).length===1){t.css=d;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let p=e.textContent?.trim();return p&&p.length<100&&p.length>2&&(t.text=p.slice(0,50)),t}function xo(e){let t=0;if(e.css)try{t=document.querySelectorAll(e.css).length;}catch{}return e.testId&&(t=document.querySelectorAll(`[data-testid="${e.testId}"]`).length),{isUnique:t===1,count:t}}function ht({isActive:e,onSelect:t,onCancel:o,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,c]=react.useState(null),[p,l]=react.useState(null),[s,a]=react.useState(null),d=react.useRef(null),g=react.useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);react.useEffect(()=>{if(!e)return;let w=h=>{let C=document.elementsFromPoint(h.clientX,h.clientY).find(S=>!(d.current?.contains(S)||r&&S.closest(r)||S===document.body||S===document.documentElement));C!==n&&(c(C||null),a(C?yo(C):null));},I=()=>{g();};return document.addEventListener("mousemove",w,true),window.addEventListener("scroll",I,true),window.addEventListener("resize",I),()=>{document.removeEventListener("mousemove",w,true),window.removeEventListener("scroll",I,true),window.removeEventListener("resize",I);}},[e,n,r,g]),react.useEffect(()=>{g();},[n,g]);let f=react.useCallback(w=>{w.preventDefault(),w.stopPropagation(),n&&s&&t(s,n);},[n,s,t]);if(react.useEffect(()=>{if(!e)return;let w=I=>{I.key==="Escape"&&o();};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e,o]),!e)return null;let u=s?xo(s):null;return jsxRuntime.jsxs("div",{ref:d,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[p&&jsxRuntime.jsx("div",{style:{position:"fixed",top:p.top,left:p.left,width:p.width,height:p.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),p&&s&&jsxRuntime.jsxs("div",{style:{position:"fixed",top:Math.max(8,p.top-40),left:p.left,padding:"6px 10px",backgroundColor:"#1f2937",color:"white",fontSize:"12px",fontFamily:"monospace",borderRadius:"4px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af"},children:s.testId?"data-testid: ":""}),s.testId||s.css,u&&jsxRuntime.jsxs("span",{style:{marginLeft:"8px",color:u.isUnique?"#4ade80":"#fbbf24"},children:["(",u.count," match",u.count!==1?"es":"",")"]})]}),jsxRuntime.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,padding:"12px 20px",backgroundColor:"#1f2937",color:"white",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px"},children:[jsxRuntime.jsxs("span",{children:["Click on any element to select it, or press ",jsxRuntime.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:"#374151",borderRadius:"4px",marginLeft:"4px",marginRight:"4px"},children:"Esc"})," to cancel"]}),jsxRuntime.jsx("button",{onClick:w=>{w.stopPropagation(),o();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function je({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:c,mode:p="fullscreen"}){let[l,s]=react.useState(false),a=e??l,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,loadGuide:E,updateGuide:C,publishGuide:S,addStep:_,updateStep:v,deleteStep:G,moveStepUp:m,moveStepDown:A,setSelectedStepId:B,reset:b}=Ne(),P=react.useCallback(async()=>{s(true),o&&await E(o);},[o,E]),R=react.useCallback(()=>{s(false),b(),t?.();},[b,t]),x=react.useCallback(async()=>{if(d)try{await C({}),r?.(d);}catch{}},[d,C,r]),H=react.useCallback(async()=>{if(d)try{let V=await S();i?.(V);}catch{}},[d,S,i]),q=react.useCallback(async(V="tooltip")=>{try{await _({stepType:V,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[_]);return n&&e===void 0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{onClick:P,children:n}),a&&jsxRuntime.jsx(vt,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,onClose:R,onSave:x,onPublish:H,onAddStep:q,onSelectStep:B,onUpdateStep:v,onDeleteStep:G,onMoveStepUp:m,onMoveStepDown:A,className:c,mode:p})]}):a?jsxRuntime.jsx(vt,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,onClose:R,onSave:x,onPublish:H,onAddStep:q,onSelectStep:B,onUpdateStep:v,onDeleteStep:G,onMoveStepUp:m,onMoveStepDown:A,className:c,mode:p}):null}function vt({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:c,onClose:p,onSave:l,onPublish:s,onAddStep:a,onSelectStep:d,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:w,className:I,mode:h="fullscreen"}){let[E,C]=react.useState(false),[S,_]=react.useState(false),v=h==="docked",G={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},m=react.useCallback((B,b)=>{o&&g(o.id,{selectorStrategy:B}),C(false);},[o,g]),A=i?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:"Loading..."}):t.length===0?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):t.map((B,b)=>jsxRuntime.jsxs("div",{onClick:()=>d(B.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===B.id?"#eff6ff":"white",border:`1px solid ${r===B.id?"#3b82f6":"#e5e7eb"}`,cursor:"pointer"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:[b+1,". ",G[B.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),u(B.id);},disabled:b===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:b===0?"not-allowed":"pointer",opacity:b===0?.3:1},children:"Up"}),jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),w(B.id);},disabled:b===t.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:b===t.length-1?"not-allowed":"pointer",opacity:b===t.length-1?.3:1},children:"Down"}),jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),confirm("Delete this step?")&&f(B.id);},style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #fecaca",borderRadius:"3px",backgroundColor:"#fef2f2",color:"#dc2626",cursor:"pointer"},children:"Delete"})]})]}),jsxRuntime.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"#6b7280"},children:B.rich_content?.title||B.title||"Untitled"})]},B.id));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ht,{isActive:E,onSelect:m,onCancel:()=>C(false),ignoreSelector:"[data-census-builder]"}),v&&jsxRuntime.jsx("button",{"data-census-builder":true,onClick:()=>_(!S),style:{position:"fixed",top:"50%",right:S?0:"420px",transform:"translateY(-50%)",zIndex:1e4,width:"24px",height:"48px",border:"1px solid #e5e7eb",borderRight:S?"1px solid #e5e7eb":"none",borderRadius:"6px 0 0 6px",backgroundColor:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"-2px 0 8px rgba(0,0,0,0.08)",transition:"right 0.2s ease",fontSize:"12px",color:"#6b7280",padding:0},children:S?"\u25C0":"\u25B6"}),jsxRuntime.jsxs("div",{className:I,"data-census-builder":true,style:v?{position:"fixed",top:0,right:S?"-420px":0,bottom:0,width:"420px",zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"-4px 0 20px rgba(0,0,0,0.1)",transition:"right 0.2s ease"}:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:v?"10px 16px":"12px 20px",backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:v?"8px":"12px",minWidth:0},children:[jsxRuntime.jsx("button",{onClick:p,style:{padding:v?"6px 10px":"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer",fontSize:v?"13px":"14px",flexShrink:0},children:"Close"}),jsxRuntime.jsx("h1",{style:{margin:0,fontSize:v?"15px":"18px",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e?e.name:"Guide Builder"}),e?.status&&jsxRuntime.jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:e.status==="published"?"#dcfce7":"#fef3c7",color:e.status==="published"?"#166534":"#92400e",flexShrink:0},children:e.status})]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px",flexShrink:0},children:[c&&!v&&jsxRuntime.jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:c.message}),jsxRuntime.jsx("button",{onClick:l,disabled:n||!e,style:{padding:v?"6px 12px":"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:n?"wait":"pointer",opacity:n?.5:1,fontSize:v?"13px":"14px"},children:n?"Saving...":"Save"}),jsxRuntime.jsx("button",{onClick:s,disabled:n||!e||e.status==="published",style:{padding:v?"6px 12px":"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:n?"wait":"pointer",opacity:n||e?.status==="published"?.5:1,fontSize:v?"13px":"14px"},children:"Publish"})]})]}),v&&c&&jsxRuntime.jsx("div",{style:{padding:"8px 16px",backgroundColor:"#fef2f2",borderBottom:"1px solid #fecaca",color:"#dc2626",fontSize:"13px"},children:c.message}),v?jsxRuntime.jsxs("div",{style:{flex:1,overflow:"auto"},children:[jsxRuntime.jsxs("div",{style:{backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxRuntime.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:["Steps (",t.length,")"]}),jsxRuntime.jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"5px 10px",fontSize:"12px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsxRuntime.jsx("div",{style:{padding:"8px"},children:A})]}),jsxRuntime.jsx("div",{style:{backgroundColor:"white"},children:o?jsxRuntime.jsx(Ue,{step:o,onUpdate:g,onSelectElement:()=>C(true),isSelectingElement:E}):jsxRuntime.jsx("div",{style:{padding:"16px",textAlign:"center",color:"#6b7280"},children:jsxRuntime.jsx("p",{children:"Select a step to edit"})})})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[jsxRuntime.jsxs("aside",{style:{width:"280px",backgroundColor:"white",borderRight:"1px solid #e5e7eb",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("span",{style:{fontWeight:500},children:["Steps (",t.length,")"]}),jsxRuntime.jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsxRuntime.jsx("div",{style:{flex:1,overflow:"auto",padding:"8px"},children:A})]}),jsxRuntime.jsxs("main",{style:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"#f3f4f6"},children:[jsxRuntime.jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"white"},children:jsxRuntime.jsx("span",{style:{fontWeight:500},children:"Preview"})}),jsxRuntime.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"},children:o?jsxRuntime.jsxs("div",{style:{padding:"24px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)",maxWidth:"400px",width:"100%"},children:[jsxRuntime.jsx("div",{style:{marginBottom:"12px"},children:jsxRuntime.jsx("span",{style:{padding:"4px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",textTransform:"uppercase"},children:G[o.step_type]})}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:o.rich_content?.title||o.title||"Step Preview"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#4b5563"},children:o.rich_content?.body||o.content||"No content"}),o.rich_content?.media&&jsxRuntime.jsx("div",{style:{marginTop:"12px"},children:o.rich_content.media.type==="image"&&jsxRuntime.jsx("img",{src:o.rich_content.media.url,alt:o.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),o.rich_content?.buttons&&o.rich_content.buttons.length>0&&jsxRuntime.jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:o.rich_content.buttons.map((B,b)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:B.style==="primary"?"#2563eb":"#f3f4f6",color:B.style==="primary"?"white":"#374151"},children:B.label},b))}),o.selector_strategy?.css&&jsxRuntime.jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",o.selector_strategy.css]})]}):jsxRuntime.jsx("p",{children:"Select a step to preview"})})]}),jsxRuntime.jsx("aside",{style:{width:"360px",backgroundColor:"white",borderLeft:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"},children:o?jsxRuntime.jsx(Ue,{step:o,onUpdate:g,onSelectElement:()=>C(true),isSelectingElement:E}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Ve(){let[e,t]=react.useState(false),[o,r]=react.useState(void 0);react.useEffect(()=>{if(typeof window>"u")return;let n=new URLSearchParams(window.location.search),c=n.get("census-builder"),p=n.get("census-guide-id");c==="true"&&(t(true),p&&r(p));},[]);let i=react.useCallback(()=>{if(t(false),r(void 0),typeof window<"u"){let n=new URL(window.location.href);n.searchParams.delete("census-builder"),n.searchParams.delete("census-guide-id"),window.history.replaceState({},"",n.toString());}},[]);return e?jsxRuntime.jsx(je,{isOpen:true,guideId:o,mode:"docked",onClose:i}):null}var Ke=react.createContext(null);function ko({apiKey:e,baseUrl:t,projectId:o,debug:r,user:i,theme:n={},children:c}){let[p,l]=react.useState(false),[s,a]=react.useState(false),d=react.useMemo(()=>bt({apiKey:e,baseUrl:t,projectId:o,debug:r}),[e,t,o,r]);react.useEffect(()=>{i?d.identify(i).then(()=>{a(true),l(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),l(true);}):l(true);},[d,i]);let g=react.useMemo(()=>({client:d,theme:n,isReady:p,isIdentified:s}),[d,n,p,s]);return jsxRuntime.jsxs(Ke.Provider,{value:g,children:[c,jsxRuntime.jsx(Ve,{})]})}function Ro(){let e=react.useContext(Ke);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function U(){let e=react.useContext(Ke);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function Eo(){let{client:e}=U(),[t,o]=react.useState(false),[r,i]=react.useState(null);return {identify:async p=>{o(true),i(null);try{await e.identify(p);}catch(l){throw i(l instanceof Error?l:new Error("Failed to identify user")),l}finally{o(false);}},reset:()=>{e.reset();},isIdentifying:t,isIdentified:e.isIdentified(),error:r}}var ie={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",transition:"transform 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"}},To={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},Po={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},_o={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function Bo(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function Lo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:c}){let{theme:p}=U(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:d}=ye(),[g,f]=react.useState(false),[u,w]=react.useState(o[0]),[I,h]=react.useState(""),E={...p,...r},C=Bo(E),S=react.useCallback(()=>{f(true),d();},[d]),_=react.useCallback(()=>{f(false),h(""),w(o[0]);},[o]),v=react.useCallback(async G=>{G.preventDefault();let m={type:u,message:I};try{await l(m),i?.(m),setTimeout(_,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,I,l,i,n,_]);return c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:S,style:{cursor:"pointer"},children:c}),g&&jsxRuntime.jsx(Rt,{isOpen:g,onClose:_,selectedType:u,onTypeChange:w,allowedTypes:o,message:I,onMessageChange:h,onSubmit:v,isSubmitting:s,isSuccess:a,themeStyles:C})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:S,style:{...ie.button,...To[e],backgroundColor:C.primaryColor,color:"white",borderRadius:C.borderRadius,fontFamily:C.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsxRuntime.jsx(Rt,{isOpen:g,onClose:_,selectedType:u,onTypeChange:w,allowedTypes:o,message:I,onMessageChange:h,onSubmit:v,isSubmitting:s,isSuccess:a,themeStyles:C})]})}function Rt({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:s,themeStyles:a}){return e?s?jsxRuntime.jsx("div",{style:ie.modal,onClick:t,children:jsxRuntime.jsxs("div",{style:{...ie.modalContent,textAlign:"center",fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxRuntime.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",color:a.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:ie.modal,onClick:t,children:jsxRuntime.jsxs("div",{style:{...ie.modalContent,fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsxRuntime.jsx("h3",{style:{margin:0,color:a.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:t,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:i.map(d=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(d),style:{...ie.typeButton,backgroundColor:o===d?a.primaryColor:"white",color:o===d?"white":a.textColor,borderColor:o===d?a.primaryColor:"#e0e0e0"},children:[_o[d]," ",Po[d]]},d))})]}),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:n,onChange:d=>c(d.target.value),placeholder:o==="bug_report"?"Describe the bug and steps to reproduce...":o==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:ie.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:l||!n.trim(),style:{...ie.submitButton,backgroundColor:a.primaryColor,color:"white",opacity:l||!n.trim()?.6:1,cursor:l||!n.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var D={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:"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 Fo(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function Ao({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:c}=U(),[p,l]=react.useState(""),[s,a]=react.useState(o),[d,g]=react.useState(null),f={...c,...r},u=Fo(f),{articles:w,isLoading:I,error:h}=xe({category:s,search:p||void 0}),{article:E,isLoading:C,error:S}=he(d||""),_=react.useMemo(()=>{let m=new Set;return w.forEach(A=>{A.category&&m.add(A.category);}),Array.from(m).sort()},[w]),v=m=>{g(m.slug),n?.(m);},G=()=>{g(null);};return d?C?jsxRuntime.jsx("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:jsxRuntime.jsx("div",{style:D.loading,children:"Loading article..."})}):S?jsxRuntime.jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:D.error,children:"Failed to load article. Please try again."})]}):E?jsxRuntime.jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 16px 0",color:u.textColor},children:E.title}),E.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[E.read_time_minutes," min read"]}),E.content_html?jsxRuntime.jsx("div",{style:{...D.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:E.content_html}}):jsxRuntime.jsx("div",{style:{...D.articleContent,color:u.textColor},children:typeof E.content=="string"?E.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:D.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[e&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:m=>l(m.target.value),style:D.searchInput}),t&&_.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>a(void 0),style:{...D.categoryButton,backgroundColor:s?"white":u.primaryColor,color:s?u.textColor:"white",borderColor:s?"#e0e0e0":u.primaryColor},children:"All"}),_.map(m=>jsxRuntime.jsx("button",{onClick:()=>a(m),style:{...D.categoryButton,backgroundColor:s===m?u.primaryColor:"white",color:s===m?"white":u.textColor,borderColor:s===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),I&&jsxRuntime.jsx("div",{style:D.loading,children:"Loading articles..."}),h&&jsxRuntime.jsx("div",{style:D.error,children:"Failed to load articles. Please try again."}),!I&&!h&&w.length===0&&jsxRuntime.jsx("div",{style:D.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!I&&!h&&w.length>0&&jsxRuntime.jsx("div",{children:w.map(m=>jsxRuntime.jsxs("div",{onClick:()=>v(m),style:D.articleCard,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&v(m);},children:[jsxRuntime.jsx("h3",{style:{...D.articleTitle,color:u.textColor},children:m.title}),m.seo_description&&jsxRuntime.jsx("p",{style:D.articleDescription,children:m.seo_description}),jsxRuntime.jsxs("div",{style:D.articleMeta,children:[m.category&&jsxRuntime.jsx("span",{children:m.category}),m.read_time_minutes&&jsxRuntime.jsxs("span",{children:[m.read_time_minutes," min read"]})]})]},m.id))})]})}var X={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"},cardHover:{borderColor:"#d1d5db"},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"}},It={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"}},Gt={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 Do(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Oo({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:c}=U(),[p,l]=react.useState(null),{requests:s,isLoading:a,error:d,refetch:g}=ve({status:e,type:t,limit:o}),f=react.useCallback(u=>{n?.(u);},[n]);return c?a?jsxRuntime.jsx("div",{style:X.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})}):d?jsxRuntime.jsx("div",{style:X.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests. ",jsxRuntime.jsx("button",{onClick:g,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):s.length===0&&i?jsxRuntime.jsxs("div",{style:X.empty,children:[jsxRuntime.jsx("svg",{style:X.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:"When you submit feedback, bug reports, or feature requests, they'll appear here."})]}):jsxRuntime.jsx("div",{style:X.container,className:r,children:jsxRuntime.jsx("ul",{style:X.list,children:s.map(u=>{let w=It[u.feedback_type]||It.feedback,I=Gt[u.status]||Gt.new,h=p===u.id;return jsxRuntime.jsxs("li",{style:{...X.card,...h?X.cardHover:{}},onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(null),onClick:()=>f(u),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&f(u);},children:[jsxRuntime.jsx("div",{style:X.header,children:jsxRuntime.jsxs("div",{style:X.badges,children:[jsxRuntime.jsx("span",{style:{...X.badge,color:w.color,backgroundColor:w.bg},children:w.label}),jsxRuntime.jsx("span",{style:{...X.badge,color:I.color,backgroundColor:I.bg},children:I.label})]})}),jsxRuntime.jsx("p",{style:X.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:X.meta,children:[jsxRuntime.jsx("span",{children:Do(u.created_at)}),u.page_url&&jsxRuntime.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",u.page_url]})]})]},u.id)})})}):i?jsxRuntime.jsx("div",{style:X.empty,children:jsxRuntime.jsx("p",{children:"Please sign in to view your requests."})}):null}var $o={articles:"Documentation",requests:"My Requests"},Pt={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"}},_t={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},planned:{label:"Planned",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 Ho(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var Wo=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],jo=()=>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"})}),Bt=()=>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"})}),Lt=()=>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"})}),Vo=()=>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"})}),Ko=()=>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"})}),Xo=()=>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"})}),Yo=()=>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"})}),Qo=()=>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"})}),Jo=()=>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"})}),Ze=()=>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"})}),zt={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"}},Zo=e=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:e.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 ${e.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:e.textMuted,marginBottom:"-1px"},tabActive:{color:e.primary,borderBottomColor:e.primary},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:e.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${e.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:e.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:e.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:e.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:e.surfaceHover,color:e.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${e.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 ${e.border}`,borderRadius:"8px",backgroundColor:e.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.primaryLight,borderRadius:"8px",color:e.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:e.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:e.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:e.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:e.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:e.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:e.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:e.textMuted},emptyIcon:{color:e.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:e.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:e.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:e.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${e.border}`,borderRadius:"8px",padding:"16px",backgroundColor:e.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:e.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:e.textMuted},form:{padding:"16px",backgroundColor:e.surface,borderRadius:"8px",border:`1px solid ${e.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,backgroundColor:"transparent",color:e.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:e.primary,borderColor:e.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:e.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.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:e.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}}),er=(e,t)=>`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
.census-hc .census-textarea::placeholder {
|
|
51
51
|
color: ${e.textLight};
|
|
52
52
|
}
|
|
53
|
-
`;function Oo({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[c,p]=react.useState(t),[l,s]=react.useState(""),[a,d]=react.useState(null),[g,f]=react.useState(new Set),[u,C]=react.useState(null),[G,x]=react.useState(false),[E,v]=react.useState("feedback"),[w,T]=react.useState(""),S=react.useRef(null),[I,m]=react.useState(false);react.useEffect(()=>{if(n!=="auto")return;let k=()=>{let me=document.documentElement,pt=me.getAttribute("data-theme");if(pt==="dark")return true;if(pt==="light")return false;let oo=me.classList.contains("dark")||me.style.colorScheme!==""||me.getAttribute("data-color-mode")!==null;return me.classList.contains("dark")?true:oo?false:window.matchMedia("(prefers-color-scheme: dark)").matches};m(k());let N=window.matchMedia("(prefers-color-scheme: dark)"),J=()=>m(k());N.addEventListener("change",J);let ct=new MutationObserver(()=>m(k()));return ct.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme"]}),()=>{N.removeEventListener("change",J),ct.disconnect();}},[n]);let A=n==="dark"||n==="auto"&&I,D=A?kt.dark:kt.light,y=react.useMemo(()=>Do(D),[D]),P=react.useMemo(()=>No(D),[D,A]),{isIdentified:R}=O(),{articles:h,isLoading:U}=he({search:l||void 0}),{article:q,isLoading:Q}=xe(a?.slug||""),{requests:nt,isLoading:jt,refetch:it}=ve({limit:50}),{featureGroups:st,isLoading:Vt}=Oe(),{submitFeedback:at,isSubmitting:ge,isSuccess:Kt,reset:lt}=ye(),Xt={...Io,...o};react.useEffect(()=>{let k=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),S.current?.focus());};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);let Yt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},dt=react.useMemo(()=>h.filter(k=>!u||k.feature_id===u),[h,u]),Qt=react.useCallback(async k=>{if(k.preventDefault(),!(!w.trim()||ge))try{await at({type:E,message:w}),T(""),x(!1),setTimeout(()=>{it(),lt();},500);}catch{}},[E,w,ge,at,it,lt]),Jt=()=>Q||!q?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(Ve,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:y.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>d(null),style:y.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(Fo,{}),"Back to articles"]}),jsxRuntime.jsx("h1",{style:y.articleDetailTitle,children:q.title}),q.read_time_minutes&&jsxRuntime.jsxs("div",{style:y.articleDetailMeta,children:[jsxRuntime.jsx(zo,{}),q.read_time_minutes," min read"]}),q.content_html?jsxRuntime.jsx("div",{style:y.articleDetailContent,dangerouslySetInnerHTML:{__html:q.content_html}}):jsxRuntime.jsx("p",{style:{...y.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),Zt=()=>a?Jt():U||Vt?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(Ve,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):dt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(St,{})}),jsxRuntime.jsx("h3",{style:y.emptyTitle,children:"No articles found"}),jsxRuntime.jsx("p",{style:y.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsxRuntime.jsx("div",{style:y.articleGrid,children:dt.map(k=>jsxRuntime.jsxs("button",{onClick:()=>d(k),style:y.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:y.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(St,{})}),jsxRuntime.jsxs("div",{style:y.articleContent,children:[jsxRuntime.jsx("h3",{style:y.articleTitle,children:k.title}),k.seo_description&&jsxRuntime.jsx("p",{style:y.articleDesc,children:k.seo_description}),k.read_time_minutes&&jsxRuntime.jsxs("p",{style:y.articleMeta,children:[k.read_time_minutes," min read"]})]}),jsxRuntime.jsx("span",{style:y.articleChevron,className:"census-article-chevron",children:jsxRuntime.jsx(wt,{})})]},k.id))}),eo=()=>Kt?jsxRuntime.jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):G?jsxRuntime.jsxs("form",{onSubmit:Qt,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:()=>x(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:y.typeSelector,children:_o.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>v(k.value),style:{...y.typeButton,...E===k.value?y.typeButtonActive:{}},children:k.label},k.value))}),jsxRuntime.jsx("textarea",{value:w,onChange:k=>T(k.target.value),placeholder:"Describe your request...",style:y.textarea,className:"census-textarea",required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...y.submitButton,opacity:ge?.6:1},disabled:ge,className:"census-submit-btn",children:ge?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>x(true),style:y.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(Mo,{}),"New Request"]}),to=()=>R?jt?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(Ve,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[eo(),nt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(qo,{})}),jsxRuntime.jsx("h3",{style:y.emptyTitle,children:"No requests yet"}),jsxRuntime.jsx("p",{style:y.emptyText,children:"Submit your first request above."})]}):jsxRuntime.jsx("div",{children:nt.map(k=>{let N=vt[k.feedback_type]||vt.feedback,J=Ct[k.status]||Ct.new;return jsxRuntime.jsxs("div",{style:y.requestCard,children:[jsxRuntime.jsxs("div",{style:{...y.requestHeader,flexWrap:"wrap"},children:[jsxRuntime.jsx("span",{style:{...y.badge,color:N.color,backgroundColor:N.bg},children:N.label}),jsxRuntime.jsx("span",{style:{...y.badge,color:J.color,backgroundColor:J.bg},children:J.label}),k.feature_group&&jsxRuntime.jsx("span",{style:{...y.badge,color:k.feature_group.color||"#6b7280",backgroundColor:k.feature_group.color?`${k.feature_group.color}20`:"#f3f4f6",border:`1px solid ${k.feature_group.color||"#e5e7eb"}`},children:k.feature_group.name}),k.feature&&jsxRuntime.jsx("span",{style:{...y.badge,color:"#374151",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb"},children:k.feature.name})]}),jsxRuntime.jsx("p",{style:y.requestMessage,children:k.message||"No message provided"}),jsxRuntime.jsx("div",{style:y.requestMeta,children:jsxRuntime.jsx("span",{children:Po(k.created_at)})})]},k.id)})})]}):jsxRuntime.jsx("div",{style:y.emptyState,children:jsxRuntime.jsx("p",{style:y.emptyText,children:"Please sign in to view your requests."})});return jsxRuntime.jsxs("div",{style:y.container,className:`census-hc ${i||""}`,children:[jsxRuntime.jsx("style",{children:P}),e.length>1&&jsxRuntime.jsx("div",{style:y.tabs,children:e.map(k=>jsxRuntime.jsx("button",{onClick:()=>p(k),style:{...y.tab,...c===k?y.tabActive:{}},className:c!==k?"census-tab":void 0,children:Xt[k]},k))}),jsxRuntime.jsxs("div",{style:y.grid,children:[jsxRuntime.jsxs("aside",{style:y.sidebar,children:[r&&c==="articles"&&jsxRuntime.jsxs("div",{style:y.searchContainer,children:[jsxRuntime.jsx("div",{style:y.searchIcon,children:jsxRuntime.jsx(Bo,{})}),jsxRuntime.jsx("input",{ref:S,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:y.searchInput,className:"census-search-input"})]}),c==="articles"&&st.length>0&&jsxRuntime.jsxs("nav",{children:[jsxRuntime.jsx("h3",{style:y.sectionTitle,children:"Features"}),jsxRuntime.jsxs("ul",{style:y.navList,children:[jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>C(null),style:{...y.navItem,...u?{}:y.navItemActive},className:u?"census-nav-item":void 0,children:"All Articles"})}),st.map(k=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Yt(k.id),style:y.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(Ao,{}),k.name]}),g.has(k.id)?jsxRuntime.jsx(Lo,{}):jsxRuntime.jsx(wt,{})]}),g.has(k.id)&&k.features.length>0&&jsxRuntime.jsx("ul",{style:y.subNav,children:k.features.map(N=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>C(N.id),style:{...y.navItem,padding:"6px 12px",fontSize:"13px",...u===N.id?y.navItemActive:{}},className:u!==N.id?"census-nav-item":void 0,children:N.name})},N.id))})]},k.id))]})]})]}),jsxRuntime.jsxs("main",{style:y.main,children:[c==="articles"&&Zt(),c==="requests"&&to()]})]})]})}var Rt={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},Uo={tooltip:"Points to a specific element with an arrow",modal:"Centered overlay that grabs attention",slideout:"Slides in from the side of the screen",hotspot:"Pulsing beacon that expands on click",banner:"Top or bottom bar announcement",embedded:"Inline content injected into the page"},Ho=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],Wo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Et({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=react.useState(false),[c,p]=react.useState(e.step_type),[l,s]=react.useState(e.rich_content?.title||e.title||""),[a,d]=react.useState(e.rich_content?.body||e.content||""),[g,f]=react.useState(e.tooltip_position||e.display_config?.position||"auto"),[u,C]=react.useState(e.selector_strategy?.css||""),[G,x]=react.useState(e.display_config?.backdrop!==false),[E,v]=react.useState(e.advance_config?.trigger||"button"),[w,T]=react.useState(e.advance_config?.delay||3e3),S=react.useCallback(async()=>{n(true);try{let m=u?{css:u}:void 0,A={title:l||void 0,body:a||void 0},D={position:g!=="auto"?g:void 0,backdrop:G},y={trigger:E,delay:E==="delay"?w:void 0};await t(e.id,{stepType:c,selectorStrategy:m,richContent:A,displayConfig:D,advanceConfig:y,tooltipPosition:g});}finally{n(false);}},[e.id,c,l,a,g,u,G,E,w,t]),I=c==="tooltip"||c==="hotspot";return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[jsxRuntime.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:"Edit Step"}),jsxRuntime.jsx("button",{onClick:S,disabled:i,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:i?"wait":"pointer",opacity:i?.7:1},children:i?"Saving...":"Save Changes"})]}),jsxRuntime.jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Step Type"}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px"},children:Object.keys(Rt).map(m=>jsxRuntime.jsxs("button",{onClick:()=>p(m),style:{padding:"10px",border:`2px solid ${c===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:c===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:Rt[m]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:Uo[m]})]},m))})]}),I&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Target Element"}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsxRuntime.jsx("input",{type:"text",value:u,onChange:m=>C(m.target.value),placeholder:"CSS selector (e.g., #my-button)",style:{flex:1,padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",fontFamily:"monospace"}}),jsxRuntime.jsx("button",{onClick:o,disabled:r,style:{padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:r?"#f3f4f6":"white",cursor:r?"wait":"pointer"},children:r?"Selecting...":"Select"})]}),jsxRuntime.jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px"},children:'Click "Select" to pick an element on the page, or enter a CSS selector manually'})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Title"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:m=>s(m.target.value),placeholder:"Enter step title",style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Content"}),jsxRuntime.jsx("textarea",{value:a,onChange:m=>d(m.target.value),placeholder:"Enter step content (HTML supported)",rows:4,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",resize:"vertical",fontFamily:"inherit"}})]}),(c==="tooltip"||c==="hotspot")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Position"}),jsxRuntime.jsx("select",{value:g,onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Ho.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),c==="banner"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Banner Position"}),jsxRuntime.jsxs("select",{value:g==="bottom"?"bottom":"top",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"top",children:"Top"}),jsxRuntime.jsx("option",{value:"bottom",children:"Bottom"})]})]}),c==="slideout"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Slideout Side"}),jsxRuntime.jsxs("select",{value:g==="left"?"left":"right",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"right",children:"Right"}),jsxRuntime.jsx("option",{value:"left",children:"Left"})]})]}),(c==="tooltip"||c==="modal")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:G,onChange:m=>x(m.target.checked),style:{width:"16px",height:"16px"}}),jsxRuntime.jsx("span",{style:{fontSize:"13px",fontWeight:500},children:"Show backdrop overlay"})]}),jsxRuntime.jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px",marginLeft:"24px"},children:"Dims the background to focus attention on the step"})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Advance When"}),jsxRuntime.jsx("select",{value:E,onChange:m=>v(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Wo.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),E==="delay"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Delay (seconds)"}),jsxRuntime.jsx("input",{type:"number",value:w/1e3,onChange:m=>T(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function Vo(e){let t={},o=e.getAttribute("data-testid");if(o)return t.testId=o,t.css=`[data-testid="${o}"]`,t;if(e.id)return t.css=`#${CSS.escape(e.id)}`,t;let r=[],i=e,n=0,c=5;for(;i&&i!==document.body&&n<c;){let l=i.tagName.toLowerCase(),s=Array.from(i.classList).filter(g=>!g.startsWith("hover")&&!g.startsWith("focus")&&!g.startsWith("active")).slice(0,2);s.length>0&&(l+="."+s.map(g=>CSS.escape(g)).join("."));let a=i.parentElement;if(a){let g=Array.from(a.children).filter(f=>f.tagName===i.tagName);if(g.length>1){let f=g.indexOf(i)+1;l+=`:nth-of-type(${f})`;}}r.unshift(l);let d=r.join(" > ");try{if(document.querySelectorAll(d).length===1){t.css=d;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let p=e.textContent?.trim();return p&&p.length<100&&p.length>2&&(t.text=p.slice(0,50)),t}function Ko(e){let t=0;if(e.css)try{t=document.querySelectorAll(e.css).length;}catch{}return e.testId&&(t=document.querySelectorAll(`[data-testid="${e.testId}"]`).length),{isUnique:t===1,count:t}}function Gt({isActive:e,onSelect:t,onCancel:o,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,c]=react.useState(null),[p,l]=react.useState(null),[s,a]=react.useState(null),d=react.useRef(null),g=react.useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);react.useEffect(()=>{if(!e)return;let C=x=>{let v=document.elementsFromPoint(x.clientX,x.clientY).find(w=>!(d.current?.contains(w)||r&&w.closest(r)||w===document.body||w===document.documentElement));v!==n&&(c(v||null),a(v?Vo(v):null));},G=()=>{g();};return document.addEventListener("mousemove",C,true),window.addEventListener("scroll",G,true),window.addEventListener("resize",G),()=>{document.removeEventListener("mousemove",C,true),window.removeEventListener("scroll",G,true),window.removeEventListener("resize",G);}},[e,n,r,g]),react.useEffect(()=>{g();},[n,g]);let f=react.useCallback(C=>{C.preventDefault(),C.stopPropagation(),n&&s&&t(s,n);},[n,s,t]);if(react.useEffect(()=>{if(!e)return;let C=G=>{G.key==="Escape"&&o();};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,o]),!e)return null;let u=s?Ko(s):null;return jsxRuntime.jsxs("div",{ref:d,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[p&&jsxRuntime.jsx("div",{style:{position:"fixed",top:p.top,left:p.left,width:p.width,height:p.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),p&&s&&jsxRuntime.jsxs("div",{style:{position:"fixed",top:Math.max(8,p.top-40),left:p.left,padding:"6px 10px",backgroundColor:"#1f2937",color:"white",fontSize:"12px",fontFamily:"monospace",borderRadius:"4px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af"},children:s.testId?"data-testid: ":""}),s.testId||s.css,u&&jsxRuntime.jsxs("span",{style:{marginLeft:"8px",color:u.isUnique?"#4ade80":"#fbbf24"},children:["(",u.count," match",u.count!==1?"es":"",")"]})]}),jsxRuntime.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,padding:"12px 20px",backgroundColor:"#1f2937",color:"white",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px"},children:[jsxRuntime.jsxs("span",{children:["Click on any element to select it, or press ",jsxRuntime.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:"#374151",borderRadius:"4px",marginLeft:"4px",marginRight:"4px"},children:"Esc"})," to cancel"]}),jsxRuntime.jsx("button",{onClick:C=>{C.stopPropagation(),o();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function Xo({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:c}){let[p,l]=react.useState(false),s=e??p,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,loadGuide:x,updateGuide:E,publishGuide:v,addStep:w,updateStep:T,deleteStep:S,moveStepUp:I,moveStepDown:m,setSelectedStepId:A,reset:D}=$e(),y=react.useCallback(async()=>{l(true),o&&await x(o);},[o,x]),P=react.useCallback(()=>{l(false),D(),t?.();},[D,t]),R=react.useCallback(async()=>{if(a)try{await E({}),r?.(a);}catch{}},[a,E,r]),h=react.useCallback(async()=>{if(a)try{let q=await v();i?.(q);}catch{}},[a,v,i]),U=react.useCallback(async(q="tooltip")=>{try{await w({stepType:q,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[w]);return n&&e===void 0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{onClick:y,children:n}),s&&jsxRuntime.jsx(It,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,onClose:P,onSave:R,onPublish:h,onAddStep:U,onSelectStep:A,onUpdateStep:T,onDeleteStep:S,onMoveStepUp:I,onMoveStepDown:m,className:c})]}):s?jsxRuntime.jsx(It,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,onClose:P,onSave:R,onPublish:h,onAddStep:U,onSelectStep:A,onUpdateStep:T,onDeleteStep:S,onMoveStepUp:I,onMoveStepDown:m,className:c}):null}function It({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:c,onClose:p,onSave:l,onPublish:s,onAddStep:a,onSelectStep:d,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:C,className:G}){let[x,E]=react.useState(false),v={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},w=react.useCallback((T,S)=>{o&&g(o.id,{selectorStrategy:T}),E(false);},[o,g]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{isActive:x,onSelect:w,onCancel:()=>E(false),ignoreSelector:"[data-census-builder]"}),jsxRuntime.jsxs("div",{className:G,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[jsxRuntime.jsx("button",{onClick:p,style:{padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer"},children:"Close"}),jsxRuntime.jsx("h1",{style:{margin:0,fontSize:"18px",fontWeight:600},children:e?e.name:"Guide Builder"}),e?.status&&jsxRuntime.jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:e.status==="published"?"#dcfce7":"#fef3c7",color:e.status==="published"?"#166534":"#92400e"},children:e.status})]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px"},children:[c&&jsxRuntime.jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:c.message}),jsxRuntime.jsx("button",{onClick:l,disabled:n||!e,style:{padding:"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:n?"wait":"pointer",opacity:n?.5:1},children:n?"Saving...":"Save"}),jsxRuntime.jsx("button",{onClick:s,disabled:n||!e||e.status==="published",style:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:n?"wait":"pointer",opacity:n||e?.status==="published"?.5:1},children:"Publish"})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[jsxRuntime.jsxs("aside",{style:{width:"280px",backgroundColor:"white",borderRight:"1px solid #e5e7eb",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("span",{style:{fontWeight:500},children:["Steps (",t.length,")"]}),jsxRuntime.jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsxRuntime.jsx("div",{style:{flex:1,overflow:"auto",padding:"8px"},children:i?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:"Loading..."}):t.length===0?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):t.map((T,S)=>jsxRuntime.jsxs("div",{onClick:()=>d(T.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===T.id?"#eff6ff":"white",border:`1px solid ${r===T.id?"#3b82f6":"#e5e7eb"}`,cursor:"pointer"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:[S+1,". ",v[T.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:I=>{I.stopPropagation(),u(T.id);},disabled:S===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:S===0?"not-allowed":"pointer",opacity:S===0?.3:1},children:"Up"}),jsxRuntime.jsx("button",{onClick:I=>{I.stopPropagation(),C(T.id);},disabled:S===t.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:S===t.length-1?"not-allowed":"pointer",opacity:S===t.length-1?.3:1},children:"Down"}),jsxRuntime.jsx("button",{onClick:I=>{I.stopPropagation(),confirm("Delete this step?")&&f(T.id);},style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #fecaca",borderRadius:"3px",backgroundColor:"#fef2f2",color:"#dc2626",cursor:"pointer"},children:"Delete"})]})]}),jsxRuntime.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"#6b7280"},children:T.rich_content?.title||T.title||"Untitled"})]},T.id))})]}),jsxRuntime.jsxs("main",{style:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"#f3f4f6"},children:[jsxRuntime.jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"white"},children:jsxRuntime.jsx("span",{style:{fontWeight:500},children:"Preview"})}),jsxRuntime.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"},children:o?jsxRuntime.jsxs("div",{style:{padding:"24px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)",maxWidth:"400px",width:"100%"},children:[jsxRuntime.jsx("div",{style:{marginBottom:"12px"},children:jsxRuntime.jsx("span",{style:{padding:"4px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",textTransform:"uppercase"},children:v[o.step_type]})}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:o.rich_content?.title||o.title||"Step Preview"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#4b5563"},children:o.rich_content?.body||o.content||"No content"}),o.rich_content?.media&&jsxRuntime.jsx("div",{style:{marginTop:"12px"},children:o.rich_content.media.type==="image"&&jsxRuntime.jsx("img",{src:o.rich_content.media.url,alt:o.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),o.rich_content?.buttons&&o.rich_content.buttons.length>0&&jsxRuntime.jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:o.rich_content.buttons.map((T,S)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:T.style==="primary"?"#2563eb":"#f3f4f6",color:T.style==="primary"?"white":"#374151"},children:T.label},S))}),o.selector_strategy?.css&&jsxRuntime.jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",o.selector_strategy.css]})]}):jsxRuntime.jsx("p",{children:"Select a step to preview"})})]}),jsxRuntime.jsx("aside",{style:{width:"360px",backgroundColor:"white",borderLeft:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"},children:o?jsxRuntime.jsx(Et,{step:o,onUpdate:g,onSelectElement:()=>E(true),isSelectingElement:x}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Qe(e){let t=e.getBoundingClientRect();return {top:t.top+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX,bottom:t.bottom+window.scrollY,width:t.width,height:t.height}}function Je(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ye(e,t,o,r,i){let n=Je(),{scrollX:c,scrollY:p,width:l,height:s}=n;switch(r){case "top":return e.top-p-o-i>0&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "bottom":return e.bottom-p+o+i<s&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "left":return e.left-c-t-i>0&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;case "right":return e.right-c+t+i<l&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;default:return true}}function Yo(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(Ye(e,t,o,n,r))return n;return "bottom"}function Ie(e,t,o,r){let{preferredPosition:i,offset:n={x:0,y:0},containerPadding:c=10,arrowSize:p=8}=r,l=Qe(e),s=Je(),a=i;if(i==="auto")a=Yo(l,t,o,c);else if(!Ye(l,t,o,i,c)){let S={top:"bottom",bottom:"top",left:"right",right:"left"}[i];S&&Ye(l,t,o,S,c)&&(a=S);}let d=0,g=0,f={},u=p+4;switch(a){case "top":d=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:o,transform:"rotate(180deg)"};break;case "bottom":d=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:-p};break;case "left":d=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-p/2,left:t,transform:"rotate(-90deg)"};break;case "right":d=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-p/2,left:-p,transform:"rotate(90deg)"};break}let C=s.scrollX+c,G=s.scrollX+s.width-t-c,x=s.scrollY+c,E=s.scrollY+s.height-o-c,v=g;g=Math.max(C,Math.min(G,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(v-g));let w=d;return d=Math.max(x,Math.min(E,d)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(w-d)),{top:d,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=Je(),i=o.top<t,n=o.bottom>r.height-t,c=o.left<t,p=o.right>r.width-t;(i||n||c||p)&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function ce(e){if(!e)return null;if(e.css)try{let t=document.querySelector(e.css);if(t)return t}catch{}if(e.testId){let t=document.querySelector(`[data-testid="${e.testId}"]`);if(t)return t}if(e.xpath)try{let t=document.evaluate(e.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(t.singleNodeValue)return t.singleNodeValue}catch{}if(e.text){let t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),o;for(;o=t.nextNode();)if(o.textContent?.includes(e.text))return o.parentElement}return null}function Bt(e,t=8){let o=e.getBoundingClientRect(),r={top:o.top-t,left:o.left-t,right:o.right+t,bottom:o.bottom+t,width:o.width+t*2,height:o.height+t*2};return `polygon(
|
|
53
|
+
`;function tr({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[c,p]=react.useState(t),[l,s]=react.useState(""),[a,d]=react.useState(null),[g,f]=react.useState(new Set),[u,w]=react.useState(null),[I,h]=react.useState(false),[E,C]=react.useState("feedback"),[S,_]=react.useState(""),v=react.useRef(null),[G,m]=react.useState(false);react.useEffect(()=>{if(n!=="auto")return;let k=()=>{let me=document.documentElement,mt=me.getAttribute("data-theme");if(mt==="dark")return true;if(mt==="light")return false;let io=me.classList.contains("dark")||me.style.colorScheme!==""||me.getAttribute("data-color-mode")!==null;return me.classList.contains("dark")?true:io?false:window.matchMedia("(prefers-color-scheme: dark)").matches};m(k());let N=window.matchMedia("(prefers-color-scheme: dark)"),J=()=>m(k());N.addEventListener("change",J);let gt=new MutationObserver(()=>m(k()));return gt.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme"]}),()=>{N.removeEventListener("change",J),gt.disconnect();}},[n]);let A=n==="dark"||n==="auto"&&G,B=A?zt.dark:zt.light,b=react.useMemo(()=>Zo(B),[B]),P=react.useMemo(()=>er(B),[B,A]),{isIdentified:R}=U(),{articles:x,isLoading:H}=xe({search:l||void 0}),{article:q,isLoading:V}=he(a?.slug||""),{requests:lt,isLoading:Xt,refetch:dt}=ve({limit:50}),{featureGroups:ct,isLoading:Yt}=Oe(),{submitFeedback:pt,isSubmitting:ge,isSuccess:Qt,reset:ut}=ye(),Jt={...$o,...o};react.useEffect(()=>{let k=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),v.current?.focus());};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);let Zt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},ft=react.useMemo(()=>x.filter(k=>!u||k.feature_id===u),[x,u]),eo=react.useCallback(async k=>{if(k.preventDefault(),!(!S.trim()||ge))try{await pt({type:E,message:S}),_(""),h(!1),setTimeout(()=>{dt(),ut();},500);}catch{}},[E,S,ge,pt,dt,ut]),to=()=>V||!q?jsxRuntime.jsxs("div",{style:b.loading,children:[jsxRuntime.jsx(Ze,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:b.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>d(null),style:b.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(Ko,{}),"Back to articles"]}),jsxRuntime.jsx("h1",{style:b.articleDetailTitle,children:q.title}),q.read_time_minutes&&jsxRuntime.jsxs("div",{style:b.articleDetailMeta,children:[jsxRuntime.jsx(Xo,{}),q.read_time_minutes," min read"]}),q.content_html?jsxRuntime.jsx("div",{style:b.articleDetailContent,dangerouslySetInnerHTML:{__html:q.content_html}}):jsxRuntime.jsx("p",{style:{...b.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),oo=()=>a?to():H||Yt?jsxRuntime.jsxs("div",{style:b.loading,children:[jsxRuntime.jsx(Ze,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):ft.length===0?jsxRuntime.jsxs("div",{style:b.emptyState,children:[jsxRuntime.jsx("div",{style:b.emptyIcon,children:jsxRuntime.jsx(Bt,{})}),jsxRuntime.jsx("h3",{style:b.emptyTitle,children:"No articles found"}),jsxRuntime.jsx("p",{style:b.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsxRuntime.jsx("div",{style:b.articleGrid,children:ft.map(k=>jsxRuntime.jsxs("button",{onClick:()=>d(k),style:b.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:b.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(Bt,{})}),jsxRuntime.jsxs("div",{style:b.articleContent,children:[jsxRuntime.jsx("h3",{style:b.articleTitle,children:k.title}),k.seo_description&&jsxRuntime.jsx("p",{style:b.articleDesc,children:k.seo_description}),k.read_time_minutes&&jsxRuntime.jsxs("p",{style:b.articleMeta,children:[k.read_time_minutes," min read"]})]}),jsxRuntime.jsx("span",{style:b.articleChevron,className:"census-article-chevron",children:jsxRuntime.jsx(Lt,{})})]},k.id))}),ro=()=>Qt?jsxRuntime.jsx("div",{style:b.successMessage,children:"Thanks for your feedback! It has been submitted."}):I?jsxRuntime.jsxs("form",{onSubmit:eo,style:b.form,children:[jsxRuntime.jsxs("div",{style:b.formHeader,children:[jsxRuntime.jsx("p",{style:b.formTitle,children:"Submit a request"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>h(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:b.typeSelector,children:Wo.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>C(k.value),style:{...b.typeButton,...E===k.value?b.typeButtonActive:{}},children:k.label},k.value))}),jsxRuntime.jsx("textarea",{value:S,onChange:k=>_(k.target.value),placeholder:"Describe your request...",style:b.textarea,className:"census-textarea",required:true}),jsxRuntime.jsx("button",{type:"submit",style:{...b.submitButton,opacity:ge?.6:1},disabled:ge,className:"census-submit-btn",children:ge?"Submitting...":"Submit"})]}):jsxRuntime.jsxs("button",{onClick:()=>h(true),style:b.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(Jo,{}),"New Request"]}),no=()=>R?Xt?jsxRuntime.jsxs("div",{style:b.loading,children:[jsxRuntime.jsx(Ze,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[ro(),lt.length===0?jsxRuntime.jsxs("div",{style:b.emptyState,children:[jsxRuntime.jsx("div",{style:b.emptyIcon,children:jsxRuntime.jsx(Qo,{})}),jsxRuntime.jsx("h3",{style:b.emptyTitle,children:"No requests yet"}),jsxRuntime.jsx("p",{style:b.emptyText,children:"Submit your first request above."})]}):jsxRuntime.jsx("div",{children:lt.map(k=>{let N=Pt[k.feedback_type]||Pt.feedback,J=_t[k.status]||_t.new;return jsxRuntime.jsxs("div",{style:b.requestCard,children:[jsxRuntime.jsxs("div",{style:{...b.requestHeader,flexWrap:"wrap"},children:[jsxRuntime.jsx("span",{style:{...b.badge,color:N.color,backgroundColor:N.bg},children:N.label}),jsxRuntime.jsx("span",{style:{...b.badge,color:J.color,backgroundColor:J.bg},children:J.label}),k.feature_group&&jsxRuntime.jsx("span",{style:{...b.badge,color:k.feature_group.color||"#6b7280",backgroundColor:k.feature_group.color?`${k.feature_group.color}20`:"#f3f4f6",border:`1px solid ${k.feature_group.color||"#e5e7eb"}`},children:k.feature_group.name}),k.feature&&jsxRuntime.jsx("span",{style:{...b.badge,color:"#374151",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb"},children:k.feature.name})]}),jsxRuntime.jsx("p",{style:b.requestMessage,children:k.message||"No message provided"}),jsxRuntime.jsx("div",{style:b.requestMeta,children:jsxRuntime.jsx("span",{children:Ho(k.created_at)})})]},k.id)})})]}):jsxRuntime.jsx("div",{style:b.emptyState,children:jsxRuntime.jsx("p",{style:b.emptyText,children:"Please sign in to view your requests."})});return jsxRuntime.jsxs("div",{style:b.container,className:`census-hc ${i||""}`,children:[jsxRuntime.jsx("style",{children:P}),e.length>1&&jsxRuntime.jsx("div",{style:b.tabs,children:e.map(k=>jsxRuntime.jsx("button",{onClick:()=>p(k),style:{...b.tab,...c===k?b.tabActive:{}},className:c!==k?"census-tab":void 0,children:Jt[k]},k))}),jsxRuntime.jsxs("div",{style:b.grid,children:[jsxRuntime.jsxs("aside",{style:b.sidebar,children:[r&&c==="articles"&&jsxRuntime.jsxs("div",{style:b.searchContainer,children:[jsxRuntime.jsx("div",{style:b.searchIcon,children:jsxRuntime.jsx(jo,{})}),jsxRuntime.jsx("input",{ref:v,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:b.searchInput,className:"census-search-input"})]}),c==="articles"&&ct.length>0&&jsxRuntime.jsxs("nav",{children:[jsxRuntime.jsx("h3",{style:b.sectionTitle,children:"Features"}),jsxRuntime.jsxs("ul",{style:b.navList,children:[jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>w(null),style:{...b.navItem,...u?{}:b.navItemActive},className:u?"census-nav-item":void 0,children:"All Articles"})}),ct.map(k=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Zt(k.id),style:b.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(Yo,{}),k.name]}),g.has(k.id)?jsxRuntime.jsx(Vo,{}):jsxRuntime.jsx(Lt,{})]}),g.has(k.id)&&k.features.length>0&&jsxRuntime.jsx("ul",{style:b.subNav,children:k.features.map(N=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{onClick:()=>w(N.id),style:{...b.navItem,padding:"6px 12px",fontSize:"13px",...u===N.id?b.navItemActive:{}},className:u!==N.id?"census-nav-item":void 0,children:N.name})},N.id))})]},k.id))]})]})]}),jsxRuntime.jsxs("main",{style:b.main,children:[c==="articles"&&oo(),c==="requests"&&no()]})]})]})}function tt(e){let t=e.getBoundingClientRect();return {top:t.top+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX,bottom:t.bottom+window.scrollY,width:t.width,height:t.height}}function ot(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function et(e,t,o,r,i){let n=ot(),{scrollX:c,scrollY:p,width:l,height:s}=n;switch(r){case "top":return e.top-p-o-i>0&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "bottom":return e.bottom-p+o+i<s&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "left":return e.left-c-t-i>0&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;case "right":return e.right-c+t+i<l&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;default:return true}}function or(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(et(e,t,o,n,r))return n;return "bottom"}function Te(e,t,o,r){let{preferredPosition:i,offset:n={x:0,y:0},containerPadding:c=10,arrowSize:p=8}=r,l=tt(e),s=ot(),a=i;if(i==="auto")a=or(l,t,o,c);else if(!et(l,t,o,i,c)){let v={top:"bottom",bottom:"top",left:"right",right:"left"}[i];v&&et(l,t,o,v,c)&&(a=v);}let d=0,g=0,f={},u=p+4;switch(a){case "top":d=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:o,transform:"rotate(180deg)"};break;case "bottom":d=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:-p};break;case "left":d=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-p/2,left:t,transform:"rotate(-90deg)"};break;case "right":d=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-p/2,left:-p,transform:"rotate(90deg)"};break}let w=s.scrollX+c,I=s.scrollX+s.width-t-c,h=s.scrollY+c,E=s.scrollY+s.height-o-c,C=g;g=Math.max(w,Math.min(I,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(C-g));let S=d;return d=Math.max(h,Math.min(E,d)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(S-d)),{top:d,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=ot(),i=o.top<t,n=o.bottom>r.height-t,c=o.left<t,p=o.right>r.width-t;(i||n||c||p)&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function ce(e){if(!e)return null;if(e.css)try{let t=document.querySelector(e.css);if(t)return t}catch{}if(e.testId){let t=document.querySelector(`[data-testid="${e.testId}"]`);if(t)return t}if(e.xpath)try{let t=document.evaluate(e.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(t.singleNodeValue)return t.singleNodeValue}catch{}if(e.text){let t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),o;for(;o=t.nextNode();)if(o.textContent?.includes(e.text))return o.parentElement}return null}function Ft(e,t=8){let o=e.getBoundingClientRect(),r={top:o.top-t,left:o.left-t,right:o.right+t,bottom:o.bottom+t,width:o.width+t*2,height:o.height+t*2};return `polygon(
|
|
54
54
|
0 0,
|
|
55
55
|
100% 0,
|
|
56
56
|
100% 100%,
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
${r.right}px ${r.bottom}px,
|
|
62
62
|
${r.right}px ${r.top}px,
|
|
63
63
|
${r.left}px ${r.top}px
|
|
64
|
-
)`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:c=.5}){let[p,l]=react.useState(),s=react.useCallback(()=>{l(t?Bt(t,o):void 0);},[t,o]);return react.useEffect(()=>{if(e)return s(),window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}},[e,s]),e?jsxRuntime.jsx("div",{onClick:d=>{i&&r&&r(),d.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${c})`,clipPath:p,transition:"clip-path 0.2s ease-out",cursor:i?"pointer":"default",pointerEvents:"auto"},"aria-hidden":"true"}):null}function X({buttons:e,currentStep:t,isLastStep:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:p="#2563eb"}){if(!e||e.length===0)return jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsxRuntime.jsx("div",{children:t>0&&jsxRuntime.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"},children:"Back"})}),jsxRuntime.jsx("button",{onClick:o?n:r,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"},children:o?"Done":"Next"})]});let l=a=>{switch(a.action){case "next":r();break;case "prev":i();break;case "dismiss":n();break;case "url":a.url&&window.open(a.url,"_blank","noopener,noreferrer");break;case "custom":a.customAction&&c&&c(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:p,cursor:"pointer"};default:return {padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"}}};return jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:e.map((a,d)=>jsxRuntime.jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},d))})}function Y({step:e,textColor:t="#1f2937",showTitle:o=true}){let r=e.rich_content,i=r?.title||e.title,n=r?.body||e.content;return jsxRuntime.jsxs("div",{children:[o&&i&&jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:t,lineHeight:1.4},children:i}),n&&jsxRuntime.jsx("div",{style:{fontSize:"14px",color:t,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:n.includes("<")?{__html:or(n)}:void 0,children:n.includes("<")?null:n}),r?.media&&jsxRuntime.jsxs("div",{style:{marginTop:"12px"},children:[r.media.type==="image"&&jsxRuntime.jsx("img",{src:r.media.url,alt:r.media.alt||"",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}),r.media.type==="video"&&jsxRuntime.jsx("video",{src:r.media.url,controls:true,style:{maxWidth:"100%",height:"auto",borderRadius:"4px"},children:"Your browser does not support the video tag."})]})]})}function or(e){let t=["p","br","b","i","strong","em","u","s","h1","h2","h3","h4","h5","h6","ul","ol","li","a","code","pre","blockquote","span","div"];if(typeof document>"u")return e.replace(/<[^>]*>/g,"");let o=document.createElement("div");return o.innerHTML=e,o.querySelectorAll("script").forEach(n=>n.remove()),o.querySelectorAll("*").forEach(n=>{if(!t.includes(n.tagName.toLowerCase())){let p=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(p,n);return}Array.from(n.attributes).forEach(p=>{let l=p.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(p.name),l==="href"||l==="src"){let a=p.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(p.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(p.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function we({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[d,g]=react.useState(null),[f,u]=react.useState(null),[C,G]=react.useState(false),x={...l,...e.style_config},E=x.backgroundColor||"white",v=x.textColor||"#1f2937",w=x.accentColor||"#2563eb",T=x.borderRadius||8;react.useEffect(()=>{let I=ce(e.selector_strategy);g(I),I&&Pe(I,120);},[e.selector_strategy]);let S=react.useCallback(()=>{if(!d||!a.current)return;let I=a.current.getBoundingClientRect(),m=Ie(d,I.width,I.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),G(true);},[d,e.tooltip_position,e.display_config]);return react.useEffect(()=>{let I=setTimeout(S,10);return window.addEventListener("scroll",S,true),window.addEventListener("resize",S),()=>{clearTimeout(I),window.removeEventListener("scroll",S,true),window.removeEventListener("resize",S);}},[S]),d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:d,spotlightPadding:e.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxRuntime.jsxs("div",{ref:a,style:{position:"absolute",top:f?.top||0,left:f?.left||0,zIndex:s,padding:"16px 20px",backgroundColor:E,color:v,borderRadius:T,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:e.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:C?1:0,transition:"opacity 0.15s ease-out"},children:[f&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${E}`,top:f.arrowPosition.top,left:f.arrowPosition.left,transform:f.arrowPosition.transform}}),jsxRuntime.jsx(Y,{step:e,textColor:v}),p&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:true}),jsxRuntime.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:s,padding:"24px",backgroundColor:E,color:v,borderRadius:T,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",maxWidth:"400px",width:"90%",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsx(Y,{step:e,textColor:v}),p&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},d=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,C=e.display_config||{},G=C.width||480,x=C.position||"center",E=C.backdrop!==false;return react.useEffect(()=>{let w=T=>{T.key==="Escape"&&n();};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]),react.useEffect(()=>{let w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=w;}},[]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:true,onClick:E?n:void 0,dismissOnClick:E,opacity:.6}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(x){case "top":return {top:"10%",left:"50%",transform:"translateX(-50%)"};case "bottom":return {bottom:"10%",left:"50%",transform:"translateX(-50%)"};default:return {top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}})(),zIndex:s,width:"90%",maxWidth:G,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:d,color:g,borderRadius:u,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s"},onMouseEnter:w=>w.currentTarget.style.color="#6b7280",onMouseLeave:w=>w.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsxRuntime.jsx(Y,{step:e,textColor:g}),p&&o>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((w,T)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:T===t?f:"#e5e7eb",transition:"background-color 0.15s"}},T))}),jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:f})]})]})}function Le({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let[a,d]=react.useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",C=g.accentColor||"#2563eb",G=g.borderRadius||0,x=e.display_config||{},E=x.width||400,v=x.position==="left"?"left":"right",w=x.backdrop!==false;return react.useEffect(()=>{let S=setTimeout(()=>d(false),50);return ()=>clearTimeout(S)},[]),react.useEffect(()=>{let S=I=>{I.key==="Escape"&&n();};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[w&&jsxRuntime.jsx(re,{visible:true,onClick:n,dismissOnClick:true,opacity:.4}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let S={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:E,zIndex:s,backgroundColor:f,color:u,boxShadow:v==="right"?"-10px 0 30px -5px rgba(0, 0, 0, 0.1)":"10px 0 30px -5px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"auto",transition:"transform 0.3s ease-out"};return v==="right"?{...S,right:0,borderTopLeftRadius:G,borderBottomLeftRadius:G,transform:a?"translateX(100%)":"translateX(0)"}:{...S,left:0,borderTopRightRadius:G,borderBottomRightRadius:G,transform:a?"translateX(-100%)":"translateX(0)"}})(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #e5e7eb",position:"sticky",top:0,backgroundColor:f,zIndex:1},children:[jsxRuntime.jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:e.rich_content?.title||e.title||"Guide"}),jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close",style:{width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),jsxRuntime.jsxs("div",{style:{padding:"20px"},children:[jsxRuntime.jsx(Y,{step:e,textColor:u,showTitle:false}),p&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",t+1," of ",o]})]}),jsxRuntime.jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:f},children:jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:C})})]})]})}function ze({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[d,g]=react.useState(null),[f,u]=react.useState(false),[C,G]=react.useState({top:0,left:0}),[x,E]=react.useState(null),v={...l,...e.style_config},w=v.backgroundColor||"white",T=v.textColor||"#1f2937",S=v.accentColor||"#2563eb",I=v.borderRadius||8,m=e.display_config||{};react.useEffect(()=>{let R=ce(e.selector_strategy);g(R),R&&Pe(R,120);},[e.selector_strategy]);let D=react.useCallback(()=>{if(!d)return;let R=Qe(d);G({top:R.top-8,left:R.right-8});},[d]),y=react.useCallback(()=>{if(!d||!a.current||!f)return;let R=a.current.getBoundingClientRect(),h=Ie(d,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(h);},[d,f,e.tooltip_position,e.display_config?.offset]);if(react.useEffect(()=>(D(),f&&setTimeout(y,10),window.addEventListener("scroll",D,true),window.addEventListener("resize",D),()=>{window.removeEventListener("scroll",D,true),window.removeEventListener("resize",D);}),[D,y,f]),react.useEffect(()=>{if(!f)return;let R=h=>{a.current&&!a.current.contains(h.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!d)return null;let P=`
|
|
64
|
+
)`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:c=.5}){let[p,l]=react.useState(),s=react.useCallback(()=>{l(t?Ft(t,o):void 0);},[t,o]);return react.useEffect(()=>{if(e)return s(),window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}},[e,s]),e?jsxRuntime.jsx("div",{onClick:d=>{i&&r&&r(),d.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${c})`,clipPath:p,transition:"clip-path 0.2s ease-out",cursor:i?"pointer":"default",pointerEvents:"auto"},"aria-hidden":"true"}):null}function Y({buttons:e,currentStep:t,isLastStep:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:p="#2563eb"}){if(!e||e.length===0)return jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsxRuntime.jsx("div",{children:t>0&&jsxRuntime.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"},children:"Back"})}),jsxRuntime.jsx("button",{onClick:o?n:r,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"},children:o?"Done":"Next"})]});let l=a=>{switch(a.action){case "next":r();break;case "prev":i();break;case "dismiss":n();break;case "url":a.url&&window.open(a.url,"_blank","noopener,noreferrer");break;case "custom":a.customAction&&c&&c(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:p,cursor:"pointer"};default:return {padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"}}};return jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:e.map((a,d)=>jsxRuntime.jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},d))})}function Q({step:e,textColor:t="#1f2937",showTitle:o=true}){let r=e.rich_content,i=r?.title||e.title,n=r?.body||e.content;return jsxRuntime.jsxs("div",{children:[o&&i&&jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:t,lineHeight:1.4},children:i}),n&&jsxRuntime.jsx("div",{style:{fontSize:"14px",color:t,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:n.includes("<")?{__html:lr(n)}:void 0,children:n.includes("<")?null:n}),r?.media&&jsxRuntime.jsxs("div",{style:{marginTop:"12px"},children:[r.media.type==="image"&&jsxRuntime.jsx("img",{src:r.media.url,alt:r.media.alt||"",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}),r.media.type==="video"&&jsxRuntime.jsx("video",{src:r.media.url,controls:true,style:{maxWidth:"100%",height:"auto",borderRadius:"4px"},children:"Your browser does not support the video tag."})]})]})}function lr(e){let t=["p","br","b","i","strong","em","u","s","h1","h2","h3","h4","h5","h6","ul","ol","li","a","code","pre","blockquote","span","div"];if(typeof document>"u")return e.replace(/<[^>]*>/g,"");let o=document.createElement("div");return o.innerHTML=e,o.querySelectorAll("script").forEach(n=>n.remove()),o.querySelectorAll("*").forEach(n=>{if(!t.includes(n.tagName.toLowerCase())){let p=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(p,n);return}Array.from(n.attributes).forEach(p=>{let l=p.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(p.name),l==="href"||l==="src"){let a=p.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(p.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(p.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function we({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[d,g]=react.useState(null),[f,u]=react.useState(null),[w,I]=react.useState(false),h={...l,...e.style_config},E=h.backgroundColor||"white",C=h.textColor||"#1f2937",S=h.accentColor||"#2563eb",_=h.borderRadius||8;react.useEffect(()=>{let G=ce(e.selector_strategy);g(G),G&&Pe(G,120);},[e.selector_strategy]);let v=react.useCallback(()=>{if(!d||!a.current)return;let G=a.current.getBoundingClientRect(),m=Te(d,G.width,G.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),I(true);},[d,e.tooltip_position,e.display_config]);return react.useEffect(()=>{let G=setTimeout(v,10);return window.addEventListener("scroll",v,true),window.addEventListener("resize",v),()=>{clearTimeout(G),window.removeEventListener("scroll",v,true),window.removeEventListener("resize",v);}},[v]),d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:d,spotlightPadding:e.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxRuntime.jsxs("div",{ref:a,style:{position:"absolute",top:f?.top||0,left:f?.left||0,zIndex:s,padding:"16px 20px",backgroundColor:E,color:C,borderRadius:_,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:e.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:w?1:0,transition:"opacity 0.15s ease-out"},children:[f&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${E}`,top:f.arrowPosition.top,left:f.arrowPosition.left,transform:f.arrowPosition.transform}}),jsxRuntime.jsx(Q,{step:e,textColor:C}),p&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:true}),jsxRuntime.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:s,padding:"24px",backgroundColor:E,color:C,borderRadius:_,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",maxWidth:"400px",width:"90%",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsx(Q,{step:e,textColor:C}),p&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},d=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,w=e.display_config||{},I=w.width||480,h=w.position||"center",E=w.backdrop!==false;return react.useEffect(()=>{let S=_=>{_.key==="Escape"&&n();};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]),react.useEffect(()=>{let S=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=S;}},[]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:true,onClick:E?n:void 0,dismissOnClick:E,opacity:.6}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(h){case "top":return {top:"10%",left:"50%",transform:"translateX(-50%)"};case "bottom":return {bottom:"10%",left:"50%",transform:"translateX(-50%)"};default:return {top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}})(),zIndex:s,width:"90%",maxWidth:I,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:d,color:g,borderRadius:u,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s"},onMouseEnter:S=>S.currentTarget.style.color="#6b7280",onMouseLeave:S=>S.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsxRuntime.jsx(Q,{step:e,textColor:g}),p&&o>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((S,_)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:_===t?f:"#e5e7eb",transition:"background-color 0.15s"}},_))}),jsxRuntime.jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:f})]})]})}function Le({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let[a,d]=react.useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",w=g.accentColor||"#2563eb",I=g.borderRadius||0,h=e.display_config||{},E=h.width||400,C=h.position==="left"?"left":"right",S=h.backdrop!==false;return react.useEffect(()=>{let v=setTimeout(()=>d(false),50);return ()=>clearTimeout(v)},[]),react.useEffect(()=>{let v=G=>{G.key==="Escape"&&n();};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[S&&jsxRuntime.jsx(re,{visible:true,onClick:n,dismissOnClick:true,opacity:.4}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let v={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:E,zIndex:s,backgroundColor:f,color:u,boxShadow:C==="right"?"-10px 0 30px -5px rgba(0, 0, 0, 0.1)":"10px 0 30px -5px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"auto",transition:"transform 0.3s ease-out"};return C==="right"?{...v,right:0,borderTopLeftRadius:I,borderBottomLeftRadius:I,transform:a?"translateX(100%)":"translateX(0)"}:{...v,left:0,borderTopRightRadius:I,borderBottomRightRadius:I,transform:a?"translateX(-100%)":"translateX(0)"}})(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #e5e7eb",position:"sticky",top:0,backgroundColor:f,zIndex:1},children:[jsxRuntime.jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:e.rich_content?.title||e.title||"Guide"}),jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close",style:{width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),jsxRuntime.jsxs("div",{style:{padding:"20px"},children:[jsxRuntime.jsx(Q,{step:e,textColor:u,showTitle:false}),p&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",t+1," of ",o]})]}),jsxRuntime.jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:f},children:jsxRuntime.jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})})]})]})}function Fe({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[d,g]=react.useState(null),[f,u]=react.useState(false),[w,I]=react.useState({top:0,left:0}),[h,E]=react.useState(null),C={...l,...e.style_config},S=C.backgroundColor||"white",_=C.textColor||"#1f2937",v=C.accentColor||"#2563eb",G=C.borderRadius||8,m=e.display_config||{};react.useEffect(()=>{let R=ce(e.selector_strategy);g(R),R&&Pe(R,120);},[e.selector_strategy]);let B=react.useCallback(()=>{if(!d)return;let R=tt(d);I({top:R.top-8,left:R.right-8});},[d]),b=react.useCallback(()=>{if(!d||!a.current||!f)return;let R=a.current.getBoundingClientRect(),x=Te(d,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(x);},[d,f,e.tooltip_position,e.display_config?.offset]);if(react.useEffect(()=>(B(),f&&setTimeout(b,10),window.addEventListener("scroll",B,true),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,true),window.removeEventListener("resize",B);}),[B,b,f]),react.useEffect(()=>{if(!f)return;let R=x=>{a.current&&!a.current.contains(x.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!d)return null;let P=`
|
|
65
65
|
@keyframes census-hotspot-pulse {
|
|
66
66
|
0% {
|
|
67
67
|
transform: scale(1);
|
|
68
|
-
box-shadow: 0 0 0 0 ${
|
|
68
|
+
box-shadow: 0 0 0 0 ${v}66;
|
|
69
69
|
}
|
|
70
70
|
70% {
|
|
71
71
|
transform: scale(1.1);
|
|
72
|
-
box-shadow: 0 0 0 10px ${
|
|
72
|
+
box-shadow: 0 0 0 10px ${v}00;
|
|
73
73
|
}
|
|
74
74
|
100% {
|
|
75
75
|
transform: scale(1);
|
|
76
|
-
box-shadow: 0 0 0 0 ${
|
|
76
|
+
box-shadow: 0 0 0 0 ${v}00;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
`;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:P}}),jsxRuntime.jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:
|
|
79
|
+
`;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:P}}),jsxRuntime.jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:w.top,left:w.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:v,color:"white",cursor:"pointer",zIndex:s,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,animation:!f?"census-hotspot-pulse 2s infinite":"none",transition:"transform 0.15s"},children:"?"}),f&&jsxRuntime.jsxs("div",{ref:a,style:{position:"absolute",top:h?.top||w.top+30,left:h?.left||w.left-140,zIndex:s+1,padding:"16px 20px",backgroundColor:S,color:_,borderRadius:G,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:m.width||300,fontFamily:"system-ui, -apple-system, sans-serif"},children:[h&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${S}`,top:h.arrowPosition.top,left:h.arrowPosition.left,transform:h.arrowPosition.transform}}),jsxRuntime.jsx(Q,{step:e,textColor:_}),p&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:c,accentColor:v})]})]})}var Ae={info:{bg:"#eff6ff",text:"#1e40af",icon:"i"},warning:{bg:"#fef3c7",text:"#92400e",icon:"!"},success:{bg:"#dcfce7",text:"#166534",icon:"\u2713"},custom:{bg:"#2563eb",text:"white",icon:""}};function Me({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let [a,d]=react.useState(true),[g,f]=react.useState(true),u={...l,...e.style_config},I=(e.display_config||{}).bannerPosition||"top",h="custom",E=u.backgroundColor||Ae[h].bg,C=u.textColor||Ae[h].text;react.useEffect(()=>{let B=setTimeout(()=>d(false),50);return ()=>clearTimeout(B)},[]);let _=()=>{d(true),setTimeout(()=>{f(false),n();},200);};if(!g)return null;let v=e.rich_content,G=v?.title||e.title,m=v?.body||e.content,A=v?.buttons&&v.buttons.length>0;return jsxRuntime.jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[I]:0,zIndex:s,padding:"12px 20px",backgroundColor:E,color:C,boxShadow:I==="top"?"0 4px 6px -1px rgba(0, 0, 0, 0.1)":"0 -4px 6px -1px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",transform:a?I==="top"?"translateY(-100%)":"translateY(100%)":"translateY(0)",transition:"transform 0.2s ease-out"},children:jsxRuntime.jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",gap:"12px"},children:[Ae[h].icon,jsxRuntime.jsxs("div",{style:{flex:1},children:[G&&jsxRuntime.jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:G}),m&&jsxRuntime.jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),p&&o>1&&jsxRuntime.jsxs("span",{style:{fontSize:"12px",opacity:.7,flexShrink:0},children:[t+1,"/",o]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[A?jsxRuntime.jsx(Y,{buttons:v.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:_,onCustomAction:c,accentColor:"white"}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:t<o-1?jsxRuntime.jsx("button",{onClick:r,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:C,cursor:"pointer"},children:"Next"}):jsxRuntime.jsx("button",{onClick:_,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:C,cursor:"pointer"},children:"Got it"})}),jsxRuntime.jsx("button",{onClick:_,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:C,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}var hr=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","canvas"];function vr(e){return !hr.includes(e.tagName.toLowerCase())}function at({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l}){let[s,a]=react.useState(null),[d,g]=react.useState(false),f=react.useRef(null),u=react.useRef(null),w={...l,...e.style_config},h=(e.display_config||{}).embeddedPosition||"append",E=w.backgroundColor||"white",C=w.textColor||"#1f2937",S=w.accentColor||"#2563eb",_=w.borderRadius??8;if(react.useEffect(()=>{let G=ce(e.selector_strategy);G&&vr(G)?a(G):a(null);},[e.selector_strategy]),react.useEffect(()=>{if(!s)return;let G=document.createElement("div");return G.setAttribute("data-census-embedded","true"),f.current=G,h==="replace"?(u.current=s.innerHTML,s.innerHTML="",s.appendChild(G)):h==="prepend"?s.insertBefore(G,s.firstChild):s.appendChild(G),g(true),()=>{f.current&&f.current.remove(),h==="replace"&&u.current!==null&&s&&(s.innerHTML=u.current),f.current=null,u.current=null;}},[s,h]),!s||!d||!f.current)return null;let v=e.rich_content;return reactDom.createPortal(jsxRuntime.jsxs("div",{role:"region","aria-label":"Guide content",style:{position:"relative",padding:"16px",backgroundColor:E,color:C,borderRadius:`${_}px`,border:"1px solid #e5e7eb",fontFamily:"system-ui, -apple-system, sans-serif",boxSizing:"border-box"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Dismiss",style:{position:"absolute",top:"8px",right:"8px",width:"24px",height:"24px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:C,opacity:.5,fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"\xD7"}),p&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:C,opacity:.6,marginBottom:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Q,{step:e,textColor:C}),jsxRuntime.jsx(Y,{buttons:v?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]}),f.current)}function Sr({guide:e,onComplete:t,onDismiss:o,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:c=0,zIndex:p=9999}){let[l,s]=react.useState(c),[a,d]=react.useState(true),g=e.guide_steps||[],f=g.length,u=g[l];react.useEffect(()=>{r?.(l,f);},[l,f,r]);let w=react.useCallback(()=>{l<f-1?s(S=>S+1):(d(false),t?.(e));},[l,f,e,t]),I=react.useCallback(()=>{l>0&&s(S=>S-1);},[l]),h=react.useCallback(()=>{d(false),o?.(e,l);},[e,l,o]),E=react.useCallback(S=>{u&&i?.(S,u);},[u,i]);if(!a||!u||g.length===0)return null;let C={step:u,currentStep:l,totalSteps:f,onNext:w,onPrev:I,onDismiss:h,onCustomAction:E,showProgress:e.show_progress!==false,globalStyle:{...e.theme,...n},zIndex:p};switch(u.step_type){case "tooltip":return jsxRuntime.jsx(we,{...C});case "modal":return jsxRuntime.jsx(Be,{...C});case "slideout":return jsxRuntime.jsx(Le,{...C});case "hotspot":return jsxRuntime.jsx(Fe,{...C});case "banner":return jsxRuntime.jsx(Me,{...C});case "embedded":return jsxRuntime.jsx(at,{...C});default:return jsxRuntime.jsx(we,{...C})}}exports.Backdrop=re;exports.BannerStep=Me;exports.BuilderModeController=Ve;exports.CensusProvider=ko;exports.FeedbackButton=Lo;exports.GuideBuilder=je;exports.GuideRenderer=Sr;exports.HelpCenter=tr;exports.HotspotStep=Fe;exports.KnowledgeBase=Ao;exports.ModalStep=Be;exports.Requests=Oo;exports.SlideoutStep=Le;exports.StepButtons=Y;exports.StepContent=Q;exports.TooltipStep=we;exports.useArticle=he;exports.useArticles=xe;exports.useCensus=Ro;exports.useCensusContext=U;exports.useFeatureGroups=Oe;exports.useFeedback=ye;exports.useGuideBuilder=Ne;exports.useGuideRenderer=po;exports.useGuides=co;exports.useIdentify=Eo;exports.useRequests=ve;exports.useTrack=lo;//# sourceMappingURL=index.cjs.map
|
|
80
80
|
//# sourceMappingURL=index.cjs.map
|