@census-ai/census-sdk 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var Zt="https://census-api-production-97c0.up.railway.app",Me=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||Zt,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,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;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=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",t.feature_groups.length),t}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),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;t?.projectId&&o.set("project_id",t.projectId),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let r=o.toString(),i=`/api/sdk/guides${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched guides:",n.guides.length),n}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,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 p=0;p<=n;p++){let d=new AbortController,l=setTimeout(()=>d.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:d.signal});if(!a.ok){if(a.status>=500&&p<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(p+1)));continue}let c=`Request failed with status ${a.status}`;try{c=(await a.json()).error||c;}catch{}throw {error:c,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(p<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(c=>setTimeout(c,1e3*(p+1)));continue}throw {error:d.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 dt(e){return new Me(e)}var De=react.createContext(null);function oo({apiKey:e,baseUrl:t,debug:o,user:r,theme:i={},children:n}){let[p,d]=react.useState(false),[l,s]=react.useState(false),a=react.useMemo(()=>dt({apiKey:e,baseUrl:t,debug:o}),[e,t,o]);react.useEffect(()=>{r?a.identify(r).then(()=>{s(true),d(true);}).catch(g=>{console.error("[Census] Failed to identify user:",g),d(true);}):d(true);},[a,r]);let c=react.useMemo(()=>({client:a,theme:i,isReady:p,isIdentified:l}),[a,i,p,l]);return jsxRuntime.jsx(De.Provider,{value:c,children:n})}function ro(){let e=react.useContext(De);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function O(){let e=react.useContext(De);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function no(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(null);return {identify:async d=>{o(true),i(null);try{await e.identify(d);}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 be(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(false),[n,p]=react.useState(null),[d,l]=react.useState(null),s=react.useCallback(async c=>{o(true),i(false),p(null),l(null);try{let g=await e.submitFeedback(c);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw p(f),f}finally{o(false);}},[e]),a=react.useCallback(()=>{i(false),p(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:d}}function ye(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{p(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{p(false);}},[t,JSON.stringify(e)]);return react.useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:d,refetch:s}}function xe(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{if(!e){i(null),p(false);return}p(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{p(false);}},[t,e]);return react.useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:d,refetch:s}}function Ne(){let{client:e,isReady:t}=O(),[o,r]=react.useState([]),[i,n]=react.useState(true),[p,d]=react.useState(null),l=react.useCallback(async()=>{n(true),d(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){d(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:p,refetch:l}}function he(e){let{client:t,isReady:o,isIdentified:r}=O(),[i,n]=react.useState(null),[p,d]=react.useState(true),[l,s]=react.useState(null),a=react.useCallback(async()=>{if(!r){n(null),d(false);return}d(true),s(null);try{let c=await t.getRequests(e);n(c);}catch(c){s(c instanceof Error?c:new Error("Failed to fetch requests"));}finally{d(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:p,error:l,refetch:a}}function ao(){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 lo(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{p(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{p(false);}},[t,e?.projectId,e?.url,e?.userId]);return react.useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:d,refetch:s}}function Oe(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState([]),[p,d]=react.useState(false),[l,s]=react.useState(false),[a,c]=react.useState(null),[g,f]=react.useState(null),u=react.useRef(false),C=react.useCallback(async R=>{d(true),c(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 c(x instanceof Error?x:new Error("Failed to load guide")),null}finally{d(false);}},[e]),T=react.useCallback(async R=>{s(true),c(null);try{let x=await e.createGuide(R);return r(x),n([]),f(null),x}catch(x){throw c(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),c(null);try{let x=await e.updateGuide(o.id,R);return r(x),u.current=!1,x}catch(x){throw c(x instanceof Error?x:new Error("Failed to update guide")),x}finally{s(false);}},[e,o]),E=react.useCallback(async()=>h({status:"published"}),[h]),v=react.useCallback(async()=>h({status:"draft"}),[h]),w=react.useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw c(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),G=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{let x=await e.addGuideStep(o.id,R);return n(U=>[...U,x]),f(x.id),u.current=!0,x}catch(x){throw c(x instanceof Error?x:new Error("Failed to add step")),x}finally{s(false);}},[e,o]),S=react.useCallback(async(R,x)=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{let U=await e.updateGuideStep(o.id,R,x);return n(q=>q.map(Q=>Q.id===R?U:Q)),u.current=!0,U}catch(U){throw c(U instanceof Error?U:new Error("Failed to update step")),U}finally{s(false);}},[e,o]),P=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{await e.deleteGuideStep(o.id,R),n(x=>x.filter(U=>U.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(x){throw c(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),c(null);try{let x=await e.reorderGuideSteps(o.id,R);return n(x),u.current=!0,x}catch(x){throw c(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 U=i.map((q,Q)=>Q===x?{id:q.id,sort_order:x-1}:Q===x-1?{id:q.id,sort_order:x}:{id:q.id,sort_order:Q});return m(U)},[i,m]),D=react.useCallback(async R=>{let x=i.findIndex(q=>q.id===R);if(x<0||x>=i.length-1)return;let U=i.map((q,Q)=>Q===x?{id:q.id,sort_order:x+1}:Q===x+1?{id:q.id,sort_order:x}:{id:q.id,sort_order:Q});return m(U)},[i,m]),y=g&&i.find(R=>R.id===g)||null,I=react.useCallback(()=>{r(null),n([]),f(null),c(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:y,selectedStepId:g,isLoading:p,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:C,createGuide:T,updateGuide:h,publishGuide:E,unpublishGuide:v,deleteGuide:w,addStep:G,updateStep:S,deleteStep:P,reorderSteps:m,moveStepUp:A,moveStepDown:D,setSelectedStepId:f,reset:I}}function co(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState(0),[p,d]=react.useState(false),[l,s]=react.useState([]),[a,c]=react.useState([]),g=react.useCallback((I,R=0)=>{r(I),n(R),d(true);},[]),f=react.useCallback(()=>{if(!o)return;let I=o.guide_steps||[];i<I.length-1?n(R=>R+1):(s(R=>[...R,o.id]),d(false),r(null));},[o,i]),u=react.useCallback(()=>{i>0&&n(I=>I-1);},[i]),C=react.useCallback(I=>{if(!o)return;let R=o.guide_steps||[];I>=0&&I<R.length&&n(I);},[o]),T=react.useCallback(()=>{o&&c(I=>[...I,o.id]),d(false),r(null),n(0);},[o]),h=react.useCallback(()=>{d(false);},[]),E=react.useCallback(()=>{o&&d(true);},[o]),v=react.useCallback(async(I,R)=>{let x=I.guide_steps?.[R];if(x)try{await e.track("guide_step_viewed",{guide_id:I.id,guide_name:I.name,step_id:x.id,step_index:R,step_type:x.step_type});}catch{}},[e]),w=react.useCallback(async I=>{try{await e.track("guide_completed",{guide_id:I.id,guide_name:I.name,total_steps:I.guide_steps?.length||0});}catch{}},[e]),G=react.useCallback(async(I,R)=>{try{await e.track("guide_dismissed",{guide_id:I.id,guide_name:I.name,dismissed_at_step:R,total_steps:I.guide_steps?.length||0});}catch{}},[e]),S=o?.guide_steps?.[i]||null,P=o?.guide_steps?.length||0,m=i===P-1,A=i===0,D=react.useCallback(I=>l.includes(I),[l]),y=react.useCallback(I=>a.includes(I),[a]);return {activeGuide:o,currentStep:S,currentStepIndex:i,totalSteps:P,isPlaying:p,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:C,dismiss:T,pause:h,resume:E,trackStepView:v,trackGuideComplete:w,trackGuideDismiss:G,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",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:"transform 0.2s, box-shadow 0.2s",zIndex:9999},modal:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4},modalContent:{backgroundColor:"white",borderRadius:"12px",padding:"24px",width:"100%",maxWidth:"400px",margin:"16px",boxShadow:"0 20px 50px rgba(0, 0, 0, 0.2)",fontFamily:"system-ui, -apple-system, sans-serif"},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #e0e0e0",borderRadius:"6px",fontSize:"14px",marginBottom:"16px",minHeight:"100px",resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},submitButton:{width:"100%",padding:"12px",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500",transition:"opacity 0.2s"},typeButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"6px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"}},po={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},uo={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},fo={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function go(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 mo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:p}){let{theme:d}=O(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:c}=be(),[g,f]=react.useState(false),[u,C]=react.useState(o[0]),[T,h]=react.useState(""),E={...d,...r},v=go(E),w=react.useCallback(()=>{f(true),c();},[c]),G=react.useCallback(()=>{f(false),h(""),C(o[0]);},[o]),S=react.useCallback(async P=>{P.preventDefault();let m={type:u,message:T};try{await l(m),i?.(m),setTimeout(G,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,T,l,i,n,G]);return p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:w,style:{cursor:"pointer"},children:p}),g&&jsxRuntime.jsx(ut,{isOpen:g,onClose:G,selectedType:u,onTypeChange:C,allowedTypes:o,message:T,onMessageChange:h,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:w,style:{...ie.button,...po[e],backgroundColor:v.primaryColor,color:"white",borderRadius:v.borderRadius,fontFamily:v.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsxRuntime.jsx(ut,{isOpen:g,onClose:G,selectedType:u,onTypeChange:C,allowedTypes:o,message:T,onMessageChange:h,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]})}function ut({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:p,onSubmit:d,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:c=>c.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:c=>c.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:d,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(c=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(c),style:{...ie.typeButton,backgroundColor:o===c?a.primaryColor:"white",color:o===c?"white":a.textColor,borderColor:o===c?a.primaryColor:"#e0e0e0"},children:[fo[c]," ",uo[c]]},c))})]}),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:c=>p(c.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:"box-shadow 0.2s, border-color 0.2s",backgroundColor:"white"},articleTitle:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:"600"},articleDescription:{margin:0,fontSize:"14px",color:"#666",lineHeight:1.5},articleMeta:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"12px",color:"#999"},backButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#666",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},loading:{textAlign:"center",padding:"40px",color:"#666"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"8px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"40px",color:"#666"}};function yo(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({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:p}=O(),[d,l]=react.useState(""),[s,a]=react.useState(o),[c,g]=react.useState(null),f={...p,...r},u=yo(f),{articles:C,isLoading:T,error:h}=ye({category:s,search:d||void 0}),{article:E,isLoading:v,error:w}=xe(c||""),G=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);},P=()=>{g(null);};return c?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:P,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:P,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:P,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:d,onChange:m=>l(m.target.value),style:M.searchInput}),t&&G.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"}),G.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))]}),T&&jsxRuntime.jsx("div",{style:M.loading,children:"Loading articles..."}),h&&jsxRuntime.jsx("div",{style:M.error,children:"Failed to load articles. Please try again."}),!T&&!h&&C.length===0&&jsxRuntime.jsx("div",{style:M.empty,children:d?`No articles found for "${d}"`:"No articles available yet."}),!T&&!h&&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, box-shadow 0.15s"},cardHover:{borderColor:"#d1d5db",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"8px"},badges:{display:"flex",alignItems:"center",gap:"6px"},badge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},message:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},meta:{display:"flex",gap:"12px",marginTop:"8px",fontSize:"12px",color:"#6b7280"},empty:{textAlign:"center",padding:"32px 16px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 12px",color:"#d1d5db"},loading:{textAlign:"center",padding:"24px",color:"#6b7280"},error:{textAlign:"center",padding:"24px",color:"#dc2626"}},gt={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"}},mt={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 Co(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function So({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:p}=O(),[d,l]=react.useState(null),{requests:s,isLoading:a,error:c,refetch:g}=he({status:e,type:t,limit:o}),f=react.useCallback(u=>{n?.(u);},[n]);return p?a?jsxRuntime.jsx("div",{style:K.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})}):c?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=gt[u.feedback_type]||gt.feedback,T=mt[u.status]||mt.new,h=d===u.id;return jsxRuntime.jsxs("li",{style:{...K.card,...h?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:T.color,backgroundColor:T.bg},children:T.label})]})}),jsxRuntime.jsx("p",{style:K.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:K.meta,children:[jsxRuntime.jsx("span",{children:Co(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 Ro={articles:"Documentation",requests:"My Requests"},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"}},xt={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 Eo(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var Go=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],To=()=>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"})}),ht=()=>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"})}),vt=()=>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"})}),Po=()=>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"})}),Io=()=>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"})}),_o=()=>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"})}),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:"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"})}),Lo=()=>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"})}),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 4v16m8-8H4"})}),je=()=>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"})}),Ct={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"}},Fo=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}}),Ao=(e,t)=>`
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var to="https://census-api-production-97c0.up.railway.app",qe=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||to,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,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;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=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",t.feature_groups.length),t}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),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;t?.projectId&&o.set("project_id",t.projectId),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let r=o.toString(),i=`/api/sdk/guides${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched guides:",n.guides.length),n}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,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 p=0;p<=n;p++){let d=new AbortController,l=setTimeout(()=>d.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:d.signal});if(!a.ok){if(a.status>=500&&p<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(p+1)));continue}let c=`Request failed with status ${a.status}`;try{c=(await a.json()).error||c;}catch{}throw {error:c,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(p<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(c=>setTimeout(c,1e3*(p+1)));continue}throw {error:d.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 pt(e){return new qe(e)}var De=react.createContext(null);function no({apiKey:e,baseUrl:t,debug:o,user:r,theme:i={},children:n}){let[p,d]=react.useState(false),[l,s]=react.useState(false),a=react.useMemo(()=>pt({apiKey:e,baseUrl:t,debug:o}),[e,t,o]);react.useEffect(()=>{r?a.identify(r).then(()=>{s(true),d(true);}).catch(g=>{console.error("[Census] Failed to identify user:",g),d(true);}):d(true);},[a,r]);let c=react.useMemo(()=>({client:a,theme:i,isReady:p,isIdentified:l}),[a,i,p,l]);return jsxRuntime.jsx(De.Provider,{value:c,children:n})}function io(){let e=react.useContext(De);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function O(){let e=react.useContext(De);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function so(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(null);return {identify:async d=>{o(true),i(null);try{await e.identify(d);}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 be(){let{client:e}=O(),[t,o]=react.useState(false),[r,i]=react.useState(false),[n,p]=react.useState(null),[d,l]=react.useState(null),s=react.useCallback(async c=>{o(true),i(false),p(null),l(null);try{let g=await e.submitFeedback(c);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw p(f),f}finally{o(false);}},[e]),a=react.useCallback(()=>{i(false),p(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:d}}function ye(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{p(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{p(false);}},[t,JSON.stringify(e)]);return react.useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:d,refetch:s}}function xe(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{if(!e){i(null),p(false);return}p(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{p(false);}},[t,e]);return react.useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:d,refetch:s}}function Ne(){let{client:e,isReady:t}=O(),[o,r]=react.useState([]),[i,n]=react.useState(true),[p,d]=react.useState(null),l=react.useCallback(async()=>{n(true),d(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){d(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:p,refetch:l}}function he(e){let{client:t,isReady:o,isIdentified:r}=O(),[i,n]=react.useState(null),[p,d]=react.useState(true),[l,s]=react.useState(null),a=react.useCallback(async()=>{if(!r){n(null),d(false);return}d(true),s(null);try{let c=await t.getRequests(e);n(c);}catch(c){s(c instanceof Error?c:new Error("Failed to fetch requests"));}finally{d(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:p,error:l,refetch:a}}function co(){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 po(e){let{client:t,isReady:o}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,l]=react.useState(null),s=react.useCallback(async()=>{p(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{p(false);}},[t,e?.projectId,e?.url,e?.userId]);return react.useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:d,refetch:s}}function Oe(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState([]),[p,d]=react.useState(false),[l,s]=react.useState(false),[a,c]=react.useState(null),[g,f]=react.useState(null),u=react.useRef(false),C=react.useCallback(async R=>{d(true),c(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 c(x instanceof Error?x:new Error("Failed to load guide")),null}finally{d(false);}},[e]),T=react.useCallback(async R=>{s(true),c(null);try{let x=await e.createGuide(R);return r(x),n([]),f(null),x}catch(x){throw c(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),c(null);try{let x=await e.updateGuide(o.id,R);return r(x),u.current=!1,x}catch(x){throw c(x instanceof Error?x:new Error("Failed to update guide")),x}finally{s(false);}},[e,o]),E=react.useCallback(async()=>h({status:"published"}),[h]),v=react.useCallback(async()=>h({status:"draft"}),[h]),w=react.useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw c(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),G=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{let x=await e.addGuideStep(o.id,R);return n(U=>[...U,x]),f(x.id),u.current=!0,x}catch(x){throw c(x instanceof Error?x:new Error("Failed to add step")),x}finally{s(false);}},[e,o]),S=react.useCallback(async(R,x)=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{let U=await e.updateGuideStep(o.id,R,x);return n(M=>M.map(Q=>Q.id===R?U:Q)),u.current=!0,U}catch(U){throw c(U instanceof Error?U:new Error("Failed to update step")),U}finally{s(false);}},[e,o]),P=react.useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),c(null);try{await e.deleteGuideStep(o.id,R),n(x=>x.filter(U=>U.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(x){throw c(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),c(null);try{let x=await e.reorderGuideSteps(o.id,R);return n(x),u.current=!0,x}catch(x){throw c(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(M=>M.id===R);if(x<=0)return;let U=i.map((M,Q)=>Q===x?{id:M.id,sort_order:x-1}:Q===x-1?{id:M.id,sort_order:x}:{id:M.id,sort_order:Q});return m(U)},[i,m]),D=react.useCallback(async R=>{let x=i.findIndex(M=>M.id===R);if(x<0||x>=i.length-1)return;let U=i.map((M,Q)=>Q===x?{id:M.id,sort_order:x+1}:Q===x+1?{id:M.id,sort_order:x}:{id:M.id,sort_order:Q});return m(U)},[i,m]),y=g&&i.find(R=>R.id===g)||null,I=react.useCallback(()=>{r(null),n([]),f(null),c(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:y,selectedStepId:g,isLoading:p,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:C,createGuide:T,updateGuide:h,publishGuide:E,unpublishGuide:v,deleteGuide:w,addStep:G,updateStep:S,deleteStep:P,reorderSteps:m,moveStepUp:A,moveStepDown:D,setSelectedStepId:f,reset:I}}function uo(){let{client:e,isReady:t}=O(),[o,r]=react.useState(null),[i,n]=react.useState(0),[p,d]=react.useState(false),[l,s]=react.useState([]),[a,c]=react.useState([]),g=react.useCallback((I,R=0)=>{r(I),n(R),d(true);},[]),f=react.useCallback(()=>{if(!o)return;let I=o.guide_steps||[];i<I.length-1?n(R=>R+1):(s(R=>[...R,o.id]),d(false),r(null));},[o,i]),u=react.useCallback(()=>{i>0&&n(I=>I-1);},[i]),C=react.useCallback(I=>{if(!o)return;let R=o.guide_steps||[];I>=0&&I<R.length&&n(I);},[o]),T=react.useCallback(()=>{o&&c(I=>[...I,o.id]),d(false),r(null),n(0);},[o]),h=react.useCallback(()=>{d(false);},[]),E=react.useCallback(()=>{o&&d(true);},[o]),v=react.useCallback(async(I,R)=>{let x=I.guide_steps?.[R];if(x)try{await e.track("guide_step_viewed",{guide_id:I.id,guide_name:I.name,step_id:x.id,step_index:R,step_type:x.step_type});}catch{}},[e]),w=react.useCallback(async I=>{try{await e.track("guide_completed",{guide_id:I.id,guide_name:I.name,total_steps:I.guide_steps?.length||0});}catch{}},[e]),G=react.useCallback(async(I,R)=>{try{await e.track("guide_dismissed",{guide_id:I.id,guide_name:I.name,dismissed_at_step:R,total_steps:I.guide_steps?.length||0});}catch{}},[e]),S=o?.guide_steps?.[i]||null,P=o?.guide_steps?.length||0,m=i===P-1,A=i===0,D=react.useCallback(I=>l.includes(I),[l]),y=react.useCallback(I=>a.includes(I),[a]);return {activeGuide:o,currentStep:S,currentStepIndex:i,totalSteps:P,isPlaying:p,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:C,dismiss:T,pause:h,resume:E,trackStepView:v,trackGuideComplete:w,trackGuideDismiss:G,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"}},fo={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},go={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},mo={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 yo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:p}){let{theme:d}=O(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:c}=be(),[g,f]=react.useState(false),[u,C]=react.useState(o[0]),[T,h]=react.useState(""),E={...d,...r},v=bo(E),w=react.useCallback(()=>{f(true),c();},[c]),G=react.useCallback(()=>{f(false),h(""),C(o[0]);},[o]),S=react.useCallback(async P=>{P.preventDefault();let m={type:u,message:T};try{await l(m),i?.(m),setTimeout(G,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,T,l,i,n,G]);return p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:w,style:{cursor:"pointer"},children:p}),g&&jsxRuntime.jsx(gt,{isOpen:g,onClose:G,selectedType:u,onTypeChange:C,allowedTypes:o,message:T,onMessageChange:h,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:w,style:{...ie.button,...fo[e],backgroundColor:v.primaryColor,color:"white",borderRadius:v.borderRadius,fontFamily:v.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsxRuntime.jsx(gt,{isOpen:g,onClose:G,selectedType:u,onTypeChange:C,allowedTypes:o,message:T,onMessageChange:h,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]})}function gt({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:p,onSubmit:d,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:c=>c.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:c=>c.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:d,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(c=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(c),style:{...ie.typeButton,backgroundColor:o===c?a.primaryColor:"white",color:o===c?"white":a.textColor,borderColor:o===c?a.primaryColor:"#e0e0e0"},children:[mo[c]," ",go[c]]},c))})]}),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:c=>p(c.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 q={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 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 vo({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:p}=O(),[d,l]=react.useState(""),[s,a]=react.useState(o),[c,g]=react.useState(null),f={...p,...r},u=ho(f),{articles:C,isLoading:T,error:h}=ye({category:s,search:d||void 0}),{article:E,isLoading:v,error:w}=xe(c||""),G=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);},P=()=>{g(null);};return c?v?jsxRuntime.jsx("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:jsxRuntime.jsx("div",{style:q.loading,children:"Loading article..."})}):w?jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:q.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:q.error,children:"Failed to load article. Please try again."})]}):E?jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:q.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:{...q.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:E.content_html}}):jsxRuntime.jsx("div",{style:{...q.articleContent,color:u.textColor},children:typeof E.content=="string"?E.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:q.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:q.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[e&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:d,onChange:m=>l(m.target.value),style:q.searchInput}),t&&G.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>a(void 0),style:{...q.categoryButton,backgroundColor:s?"white":u.primaryColor,color:s?u.textColor:"white",borderColor:s?"#e0e0e0":u.primaryColor},children:"All"}),G.map(m=>jsxRuntime.jsx("button",{onClick:()=>a(m),style:{...q.categoryButton,backgroundColor:s===m?u.primaryColor:"white",color:s===m?"white":u.textColor,borderColor:s===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),T&&jsxRuntime.jsx("div",{style:q.loading,children:"Loading articles..."}),h&&jsxRuntime.jsx("div",{style:q.error,children:"Failed to load articles. Please try again."}),!T&&!h&&C.length===0&&jsxRuntime.jsx("div",{style:q.empty,children:d?`No articles found for "${d}"`:"No articles available yet."}),!T&&!h&&C.length>0&&jsxRuntime.jsx("div",{children:C.map(m=>jsxRuntime.jsxs("div",{onClick:()=>S(m),style:q.articleCard,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&S(m);},children:[jsxRuntime.jsx("h3",{style:{...q.articleTitle,color:u.textColor},children:m.title}),m.seo_description&&jsxRuntime.jsx("p",{style:q.articleDescription,children:m.seo_description}),jsxRuntime.jsxs("div",{style:q.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"}},bt={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"}},yt={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 wo(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function ko({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:p}=O(),[d,l]=react.useState(null),{requests:s,isLoading:a,error:c,refetch:g}=he({status:e,type:t,limit:o}),f=react.useCallback(u=>{n?.(u);},[n]);return p?a?jsxRuntime.jsx("div",{style:K.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})}):c?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=bt[u.feedback_type]||bt.feedback,T=yt[u.status]||yt.new,h=d===u.id;return jsxRuntime.jsxs("li",{style:{...K.card,...h?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:T.color,backgroundColor:T.bg},children:T.label})]})}),jsxRuntime.jsx("p",{style:K.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:K.meta,children:[jsxRuntime.jsx("span",{children:wo(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 Go={articles:"Documentation",requests:"My Requests"},ht={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"}},vt={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 To(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var Po=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],Io=()=>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"})}),Ct=()=>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"})}),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:2,d:"M9 5l7 7-7 7"})}),_o=()=>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"})}),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:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),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:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),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:"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"})}),zo=()=>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"})}),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:"M12 4v16m8-8H4"})}),je=()=>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"})}),wt={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"}},Mo=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}}),qo=(e,t)=>`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
@@ -6,7 +6,6 @@
6
6
 
7
7
  .census-hc .census-article-card:hover {
8
8
  border-color: ${e.borderHover} !important;
9
- box-shadow: ${t?"0 4px 12px rgba(0, 0, 0, 0.3)":"0 4px 12px rgba(0, 0, 0, 0.06)"};
10
9
  }
11
10
 
12
11
  .census-hc .census-article-card:hover .census-article-icon {
@@ -51,7 +50,7 @@
51
50
  .census-hc .census-textarea::placeholder {
52
51
  color: ${e.textLight};
53
52
  }
54
- `;function qo({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[p,d]=react.useState(t),[l,s]=react.useState(""),[a,c]=react.useState(null),[g,f]=react.useState(new Set),[u,C]=react.useState(null),[T,h]=react.useState(false),[E,v]=react.useState("feedback"),[w,G]=react.useState(""),S=react.useRef(null),[P,m]=react.useState(false);react.useEffect(()=>{if(n==="auto"){let k=window.matchMedia("(prefers-color-scheme: dark)");m(k.matches);let N=J=>m(J.matches);return k.addEventListener("change",N),()=>k.removeEventListener("change",N)}},[n]);let A=n==="dark"||n==="auto"&&P,D=A?Ct.dark:Ct.light,y=react.useMemo(()=>Fo(D),[D]),I=react.useMemo(()=>Ao(D,A),[D,A]),{isIdentified:R}=O(),{articles:x,isLoading:U}=ye({search:l||void 0}),{article:q,isLoading:Q}=xe(a?.slug||""),{requests:rt,isLoading:Ut,refetch:nt}=he({limit:50}),{featureGroups:it,isLoading:Ht}=Ne(),{submitFeedback:st,isSubmitting:ge,isSuccess:Wt,reset:at}=be(),jt={...Ro,...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 Vt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},lt=react.useMemo(()=>x.filter(k=>!u||k.feature_id===u),[x,u]),Kt=react.useCallback(async k=>{if(k.preventDefault(),!(!w.trim()||ge))try{await st({type:E,message:w}),G(""),h(!1),setTimeout(()=>{nt(),at();},500);}catch{}},[E,w,ge,st,nt,at]),Xt=()=>Q||!q?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:y.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>c(null),style:y.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(Io,{}),"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(_o,{}),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."})]}),Yt=()=>a?Xt():U||Ht?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):lt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(ht,{})}),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:lt.map(k=>jsxRuntime.jsxs("button",{onClick:()=>c(k),style:y.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:y.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(ht,{})}),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(vt,{})})]},k.id))}),Qt=()=>Wt?jsxRuntime.jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):T?jsxRuntime.jsxs("form",{onSubmit:Kt,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:()=>h(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:y.typeSelector,children:Go.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=>G(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:()=>h(true),style:y.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(zo,{}),"New Request"]}),Jt=()=>R?Ut?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[Qt(),rt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(Lo,{})}),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:rt.map(k=>{let N=yt[k.feedback_type]||yt.feedback,J=xt[k.status]||xt.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:Eo(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:I}),e.length>1&&jsxRuntime.jsx("div",{style:y.tabs,children:e.map(k=>jsxRuntime.jsx("button",{onClick:()=>d(k),style:{...y.tab,...p===k?y.tabActive:{}},className:p!==k?"census-tab":void 0,children:jt[k]},k))}),jsxRuntime.jsxs("div",{style:y.grid,children:[jsxRuntime.jsxs("aside",{style:y.sidebar,children:[r&&p==="articles"&&jsxRuntime.jsxs("div",{style:y.searchContainer,children:[jsxRuntime.jsx("div",{style:y.searchIcon,children:jsxRuntime.jsx(To,{})}),jsxRuntime.jsx("input",{ref:S,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:y.searchInput,className:"census-search-input"})]}),p==="articles"&&it.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"})}),it.map(k=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Vt(k.id),style:y.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(Bo,{}),k.name]}),g.has(k.id)?jsxRuntime.jsx(Po,{}):jsxRuntime.jsx(vt,{})]}),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:[p==="articles"&&Yt(),p==="requests"&&Jt()]})]})]})}var St={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},Do={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"},No=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],Oo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function wt({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=react.useState(false),[p,d]=react.useState(e.step_type),[l,s]=react.useState(e.rich_content?.title||e.title||""),[a,c]=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||""),[T,h]=react.useState(e.display_config?.backdrop!==false),[E,v]=react.useState(e.advance_config?.trigger||"button"),[w,G]=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:T},y={trigger:E,delay:E==="delay"?w:void 0};await t(e.id,{stepType:p,selectorStrategy:m,richContent:A,displayConfig:D,advanceConfig:y,tooltipPosition:g});}finally{n(false);}},[e.id,p,l,a,g,u,T,E,w,t]),P=p==="tooltip"||p==="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(St).map(m=>jsxRuntime.jsxs("button",{onClick:()=>d(m),style:{padding:"10px",border:`2px solid ${p===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:p===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:St[m]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:Do[m]})]},m))})]}),P&&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=>c(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"}})]}),(p==="tooltip"||p==="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:No.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),p==="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"})]})]}),p==="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"})]})]}),(p==="tooltip"||p==="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:T,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=>v(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Oo.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=>G(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function Uo(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,p=5;for(;i&&i!==document.body&&n<p;){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 c=r.join(" > ");try{if(document.querySelectorAll(c).length===1){t.css=c;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let d=e.textContent?.trim();return d&&d.length<100&&d.length>2&&(t.text=d.slice(0,50)),t}function Ho(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 Rt({isActive:e,onSelect:t,onCancel:o,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,p]=react.useState(null),[d,l]=react.useState(null),[s,a]=react.useState(null),c=react.useRef(null),g=react.useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);react.useEffect(()=>{if(!e)return;let C=h=>{let v=document.elementsFromPoint(h.clientX,h.clientY).find(w=>!(c.current?.contains(w)||r&&w.closest(r)||w===document.body||w===document.documentElement));v!==n&&(p(v||null),a(v?Uo(v):null));},T=()=>{g();};return document.addEventListener("mousemove",C,true),window.addEventListener("scroll",T,true),window.addEventListener("resize",T),()=>{document.removeEventListener("mousemove",C,true),window.removeEventListener("scroll",T,true),window.removeEventListener("resize",T);}},[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=T=>{T.key==="Escape"&&o();};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,o]),!e)return null;let u=s?Ho(s):null;return jsxRuntime.jsxs("div",{ref:c,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[d&&jsxRuntime.jsx("div",{style:{position:"fixed",top:d.top,left:d.left,width:d.width,height:d.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),d&&s&&jsxRuntime.jsxs("div",{style:{position:"fixed",top:Math.max(8,d.top-40),left:d.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 Wo({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:p}){let[d,l]=react.useState(false),s=e??d,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,loadGuide:h,updateGuide:E,publishGuide:v,addStep:w,updateStep:G,deleteStep:S,moveStepUp:P,moveStepDown:m,setSelectedStepId:A,reset:D}=Oe(),y=react.useCallback(async()=>{l(true),o&&await h(o);},[o,h]),I=react.useCallback(()=>{l(false),D(),t?.();},[D,t]),R=react.useCallback(async()=>{if(a)try{await E({}),r?.(a);}catch{}},[a,E,r]),x=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(Et,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,onClose:I,onSave:R,onPublish:x,onAddStep:U,onSelectStep:A,onUpdateStep:G,onDeleteStep:S,onMoveStepUp:P,onMoveStepDown:m,className:p})]}):s?jsxRuntime.jsx(Et,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,onClose:I,onSave:R,onPublish:x,onAddStep:U,onSelectStep:A,onUpdateStep:G,onDeleteStep:S,onMoveStepUp:P,onMoveStepDown:m,className:p}):null}function Et({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:p,onClose:d,onSave:l,onPublish:s,onAddStep:a,onSelectStep:c,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:C,className:T}){let[h,E]=react.useState(false),v={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},w=react.useCallback((G,S)=>{o&&g(o.id,{selectorStrategy:G}),E(false);},[o,g]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Rt,{isActive:h,onSelect:w,onCancel:()=>E(false),ignoreSelector:"[data-census-builder]"}),jsxRuntime.jsxs("div",{className:T,"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:d,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:[p&&jsxRuntime.jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:p.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((G,S)=>jsxRuntime.jsxs("div",{onClick:()=>c(G.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===G.id?"#eff6ff":"white",border:`1px solid ${r===G.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[G.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),u(G.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:P=>{P.stopPropagation(),C(G.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:P=>{P.stopPropagation(),confirm("Delete this step?")&&f(G.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:G.rich_content?.title||G.title||"Untitled"})]},G.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((G,S)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:G.style==="primary"?"#2563eb":"#f3f4f6",color:G.style==="primary"?"white":"#374151"},children:G.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(wt,{step:o,onUpdate:g,onSelectElement:()=>E(true),isSelectingElement:h}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Ye(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 Qe(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Xe(e,t,o,r,i){let n=Qe(),{scrollX:p,scrollY:d,width:l,height:s}=n;switch(r){case "top":return e.top-d-o-i>0&&e.left-p+e.width/2-t/2>0&&e.left-p+e.width/2+t/2<l;case "bottom":return e.bottom-d+o+i<s&&e.left-p+e.width/2-t/2>0&&e.left-p+e.width/2+t/2<l;case "left":return e.left-p-t-i>0&&e.top-d+e.height/2-o/2>0&&e.top-d+e.height/2+o/2<s;case "right":return e.right-p+t+i<l&&e.top-d+e.height/2-o/2>0&&e.top-d+e.height/2+o/2<s;default:return true}}function jo(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(Xe(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:p=10,arrowSize:d=8}=r,l=Ye(e),s=Qe(),a=i;if(i==="auto")a=jo(l,t,o,p);else if(!Xe(l,t,o,i,p)){let S={top:"bottom",bottom:"top",left:"right",right:"left"}[i];S&&Xe(l,t,o,S,p)&&(a=S);}let c=0,g=0,f={},u=d+4;switch(a){case "top":c=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-d/2,top:o,transform:"rotate(180deg)"};break;case "bottom":c=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-d/2,top:-d};break;case "left":c=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-d/2,left:t,transform:"rotate(-90deg)"};break;case "right":c=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-d/2,left:-d,transform:"rotate(90deg)"};break}let C=s.scrollX+p,T=s.scrollX+s.width-t-p,h=s.scrollY+p,E=s.scrollY+s.height-o-p,v=g;g=Math.max(C,Math.min(T,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(v-g));let w=c;return c=Math.max(h,Math.min(E,c)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(w-c)),{top:c,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=Qe(),i=o.top<t,n=o.bottom>r.height-t,p=o.left<t,d=o.right>r.width-t;(i||n||p||d)&&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 Pt(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 Do({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[p,d]=react.useState(t),[l,s]=react.useState(""),[a,c]=react.useState(null),[g,f]=react.useState(new Set),[u,C]=react.useState(null),[T,h]=react.useState(false),[E,v]=react.useState("feedback"),[w,G]=react.useState(""),S=react.useRef(null),[P,m]=react.useState(false);react.useEffect(()=>{if(n!=="auto")return;let k=()=>{let ct=document.documentElement;return ct.classList.contains("dark")||ct.getAttribute("data-theme")==="dark"?true: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 dt=new MutationObserver(()=>m(k()));return dt.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme"]}),()=>{N.removeEventListener("change",J),dt.disconnect();}},[n]);let A=n==="dark"||n==="auto"&&P,D=A?wt.dark:wt.light,y=react.useMemo(()=>Mo(D),[D]),I=react.useMemo(()=>qo(D),[D,A]),{isIdentified:R}=O(),{articles:x,isLoading:U}=ye({search:l||void 0}),{article:M,isLoading:Q}=xe(a?.slug||""),{requests:rt,isLoading:Wt,refetch:nt}=he({limit:50}),{featureGroups:it,isLoading:jt}=Ne(),{submitFeedback:st,isSubmitting:ge,isSuccess:Vt,reset:at}=be(),Kt={...Go,...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 Xt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},lt=react.useMemo(()=>x.filter(k=>!u||k.feature_id===u),[x,u]),Yt=react.useCallback(async k=>{if(k.preventDefault(),!(!w.trim()||ge))try{await st({type:E,message:w}),G(""),h(!1),setTimeout(()=>{nt(),at();},500);}catch{}},[E,w,ge,st,nt,at]),Qt=()=>Q||!M?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading article..."})]}):jsxRuntime.jsxs("div",{style:y.articleDetail,children:[jsxRuntime.jsxs("button",{onClick:()=>c(null),style:y.backButton,className:"census-back-btn",children:[jsxRuntime.jsx(Bo,{}),"Back to articles"]}),jsxRuntime.jsx("h1",{style:y.articleDetailTitle,children:M.title}),M.read_time_minutes&&jsxRuntime.jsxs("div",{style:y.articleDetailMeta,children:[jsxRuntime.jsx(Lo,{}),M.read_time_minutes," min read"]}),M.content_html?jsxRuntime.jsx("div",{style:y.articleDetailContent,dangerouslySetInnerHTML:{__html:M.content_html}}):jsxRuntime.jsx("p",{style:{...y.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),Jt=()=>a?Qt():U||jt?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading..."})]}):lt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(Ct,{})}),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:lt.map(k=>jsxRuntime.jsxs("button",{onClick:()=>c(k),style:y.articleCard,className:"census-article-card",children:[jsxRuntime.jsx("div",{style:y.articleIcon,className:"census-article-icon",children:jsxRuntime.jsx(Ct,{})}),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(St,{})})]},k.id))}),Zt=()=>Vt?jsxRuntime.jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):T?jsxRuntime.jsxs("form",{onSubmit:Yt,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:()=>h(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsxRuntime.jsx("div",{style:y.typeSelector,children:Po.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=>G(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:()=>h(true),style:y.newRequestButton,className:"census-new-request-btn",children:[jsxRuntime.jsx(Ao,{}),"New Request"]}),eo=()=>R?Wt?jsxRuntime.jsxs("div",{style:y.loading,children:[jsxRuntime.jsx(je,{}),jsxRuntime.jsx("span",{children:"Loading requests..."})]}):jsxRuntime.jsxs("div",{children:[Zt(),rt.length===0?jsxRuntime.jsxs("div",{style:y.emptyState,children:[jsxRuntime.jsx("div",{style:y.emptyIcon,children:jsxRuntime.jsx(zo,{})}),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:rt.map(k=>{let N=ht[k.feedback_type]||ht.feedback,J=vt[k.status]||vt.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:To(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:I}),e.length>1&&jsxRuntime.jsx("div",{style:y.tabs,children:e.map(k=>jsxRuntime.jsx("button",{onClick:()=>d(k),style:{...y.tab,...p===k?y.tabActive:{}},className:p!==k?"census-tab":void 0,children:Kt[k]},k))}),jsxRuntime.jsxs("div",{style:y.grid,children:[jsxRuntime.jsxs("aside",{style:y.sidebar,children:[r&&p==="articles"&&jsxRuntime.jsxs("div",{style:y.searchContainer,children:[jsxRuntime.jsx("div",{style:y.searchIcon,children:jsxRuntime.jsx(Io,{})}),jsxRuntime.jsx("input",{ref:S,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:y.searchInput,className:"census-search-input"})]}),p==="articles"&&it.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"})}),it.map(k=>jsxRuntime.jsxs("li",{children:[jsxRuntime.jsxs("button",{onClick:()=>Xt(k.id),style:y.navItem,className:"census-nav-item",children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx(Fo,{}),k.name]}),g.has(k.id)?jsxRuntime.jsx(_o,{}):jsxRuntime.jsx(St,{})]}),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:[p==="articles"&&Jt(),p==="requests"&&eo()]})]})]})}var kt={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},Oo={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"},$o=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],Uo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Rt({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=react.useState(false),[p,d]=react.useState(e.step_type),[l,s]=react.useState(e.rich_content?.title||e.title||""),[a,c]=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||""),[T,h]=react.useState(e.display_config?.backdrop!==false),[E,v]=react.useState(e.advance_config?.trigger||"button"),[w,G]=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:T},y={trigger:E,delay:E==="delay"?w:void 0};await t(e.id,{stepType:p,selectorStrategy:m,richContent:A,displayConfig:D,advanceConfig:y,tooltipPosition:g});}finally{n(false);}},[e.id,p,l,a,g,u,T,E,w,t]),P=p==="tooltip"||p==="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(kt).map(m=>jsxRuntime.jsxs("button",{onClick:()=>d(m),style:{padding:"10px",border:`2px solid ${p===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:p===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:kt[m]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:Oo[m]})]},m))})]}),P&&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=>c(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"}})]}),(p==="tooltip"||p==="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:$o.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),p==="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"})]})]}),p==="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"})]})]}),(p==="tooltip"||p==="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:T,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=>v(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Uo.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=>G(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function Wo(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,p=5;for(;i&&i!==document.body&&n<p;){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 c=r.join(" > ");try{if(document.querySelectorAll(c).length===1){t.css=c;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let d=e.textContent?.trim();return d&&d.length<100&&d.length>2&&(t.text=d.slice(0,50)),t}function jo(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,p]=react.useState(null),[d,l]=react.useState(null),[s,a]=react.useState(null),c=react.useRef(null),g=react.useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);react.useEffect(()=>{if(!e)return;let C=h=>{let v=document.elementsFromPoint(h.clientX,h.clientY).find(w=>!(c.current?.contains(w)||r&&w.closest(r)||w===document.body||w===document.documentElement));v!==n&&(p(v||null),a(v?Wo(v):null));},T=()=>{g();};return document.addEventListener("mousemove",C,true),window.addEventListener("scroll",T,true),window.addEventListener("resize",T),()=>{document.removeEventListener("mousemove",C,true),window.removeEventListener("scroll",T,true),window.removeEventListener("resize",T);}},[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=T=>{T.key==="Escape"&&o();};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,o]),!e)return null;let u=s?jo(s):null;return jsxRuntime.jsxs("div",{ref:c,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[d&&jsxRuntime.jsx("div",{style:{position:"fixed",top:d.top,left:d.left,width:d.width,height:d.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),d&&s&&jsxRuntime.jsxs("div",{style:{position:"fixed",top:Math.max(8,d.top-40),left:d.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 Vo({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:p}){let[d,l]=react.useState(false),s=e??d,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,loadGuide:h,updateGuide:E,publishGuide:v,addStep:w,updateStep:G,deleteStep:S,moveStepUp:P,moveStepDown:m,setSelectedStepId:A,reset:D}=Oe(),y=react.useCallback(async()=>{l(true),o&&await h(o);},[o,h]),I=react.useCallback(()=>{l(false),D(),t?.();},[D,t]),R=react.useCallback(async()=>{if(a)try{await E({}),r?.(a);}catch{}},[a,E,r]),x=react.useCallback(async()=>{if(a)try{let M=await v();i?.(M);}catch{}},[a,v,i]),U=react.useCallback(async(M="tooltip")=>{try{await w({stepType:M,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(Tt,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,onClose:I,onSave:R,onPublish:x,onAddStep:U,onSelectStep:A,onUpdateStep:G,onDeleteStep:S,onMoveStepUp:P,onMoveStepDown:m,className:p})]}):s?jsxRuntime.jsx(Tt,{guide:a,steps:c,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:T,onClose:I,onSave:R,onPublish:x,onAddStep:U,onSelectStep:A,onUpdateStep:G,onDeleteStep:S,onMoveStepUp:P,onMoveStepDown:m,className:p}):null}function Tt({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:p,onClose:d,onSave:l,onPublish:s,onAddStep:a,onSelectStep:c,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:C,className:T}){let[h,E]=react.useState(false),v={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},w=react.useCallback((G,S)=>{o&&g(o.id,{selectorStrategy:G}),E(false);},[o,g]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{isActive:h,onSelect:w,onCancel:()=>E(false),ignoreSelector:"[data-census-builder]"}),jsxRuntime.jsxs("div",{className:T,"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:d,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:[p&&jsxRuntime.jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:p.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((G,S)=>jsxRuntime.jsxs("div",{onClick:()=>c(G.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===G.id?"#eff6ff":"white",border:`1px solid ${r===G.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[G.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),u(G.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:P=>{P.stopPropagation(),C(G.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:P=>{P.stopPropagation(),confirm("Delete this step?")&&f(G.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:G.rich_content?.title||G.title||"Untitled"})]},G.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((G,S)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:G.style==="primary"?"#2563eb":"#f3f4f6",color:G.style==="primary"?"white":"#374151"},children:G.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(Rt,{step:o,onUpdate:g,onSelectElement:()=>E(true),isSelectingElement:h}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Ye(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 Qe(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Xe(e,t,o,r,i){let n=Qe(),{scrollX:p,scrollY:d,width:l,height:s}=n;switch(r){case "top":return e.top-d-o-i>0&&e.left-p+e.width/2-t/2>0&&e.left-p+e.width/2+t/2<l;case "bottom":return e.bottom-d+o+i<s&&e.left-p+e.width/2-t/2>0&&e.left-p+e.width/2+t/2<l;case "left":return e.left-p-t-i>0&&e.top-d+e.height/2-o/2>0&&e.top-d+e.height/2+o/2<s;case "right":return e.right-p+t+i<l&&e.top-d+e.height/2-o/2>0&&e.top-d+e.height/2+o/2<s;default:return true}}function Ko(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(Xe(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:p=10,arrowSize:d=8}=r,l=Ye(e),s=Qe(),a=i;if(i==="auto")a=Ko(l,t,o,p);else if(!Xe(l,t,o,i,p)){let S={top:"bottom",bottom:"top",left:"right",right:"left"}[i];S&&Xe(l,t,o,S,p)&&(a=S);}let c=0,g=0,f={},u=d+4;switch(a){case "top":c=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-d/2,top:o,transform:"rotate(180deg)"};break;case "bottom":c=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-d/2,top:-d};break;case "left":c=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-d/2,left:t,transform:"rotate(-90deg)"};break;case "right":c=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-d/2,left:-d,transform:"rotate(90deg)"};break}let C=s.scrollX+p,T=s.scrollX+s.width-t-p,h=s.scrollY+p,E=s.scrollY+s.height-o-p,v=g;g=Math.max(C,Math.min(T,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(v-g));let w=c;return c=Math.max(h,Math.min(E,c)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(w-c)),{top:c,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=Qe(),i=o.top<t,n=o.bottom>r.height-t,p=o.left<t,d=o.right>r.width-t;(i||n||p||d)&&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 _t(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(
55
54
  0 0,
56
55
  100% 0,
57
56
  100% 100%,
@@ -62,7 +61,7 @@
62
61
  ${r.right}px ${r.bottom}px,
63
62
  ${r.right}px ${r.top}px,
64
63
  ${r.left}px ${r.top}px
65
- )`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:p=.5}){let[d,l]=react.useState(),s=react.useCallback(()=>{l(t?Pt(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:c=>{i&&r&&r(),c.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${p})`,clipPath:d,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:p,accentColor:d="#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:d,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&&p&&p(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:d,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:d,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,c)=>jsxRuntime.jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},c))})}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:Jo(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 Jo(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 d=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(d,n);return}Array.from(n.attributes).forEach(d=>{let l=d.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(d.name),l==="href"||l==="src"){let a=d.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(d.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(d.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function Se({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[c,g]=react.useState(null),[f,u]=react.useState(null),[C,T]=react.useState(false),h={...l,...e.style_config},E=h.backgroundColor||"white",v=h.textColor||"#1f2937",w=h.accentColor||"#2563eb",G=h.borderRadius||8;react.useEffect(()=>{let P=ce(e.selector_strategy);g(P),P&&Pe(P,120);},[e.selector_strategy]);let S=react.useCallback(()=>{if(!c||!a.current)return;let P=a.current.getBoundingClientRect(),m=Te(c,P.width,P.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),T(true);},[c,e.tooltip_position,e.display_config]);return react.useEffect(()=>{let P=setTimeout(S,10);return window.addEventListener("scroll",S,true),window.addEventListener("resize",S),()=>{clearTimeout(P),window.removeEventListener("scroll",S,true),window.removeEventListener("resize",S);}},[S]),c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:c,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:G,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}),d&&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:p,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:G,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}),d&&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:p,accentColor:w})]})]})}function _e({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},c=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,C=e.display_config||{},T=C.width||480,h=C.position||"center",E=C.backdrop!==false;return react.useEffect(()=>{let w=G=>{G.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(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:T,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:c,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}),d&&o>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((w,G)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:G===t?f:"#e5e7eb",transition:"background-color 0.15s"}},G))}),jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:f})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let[a,c]=react.useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",C=g.accentColor||"#2563eb",T=g.borderRadius||0,h=e.display_config||{},E=h.width||400,v=h.position==="left"?"left":"right",w=h.backdrop!==false;return react.useEffect(()=>{let S=setTimeout(()=>c(false),50);return ()=>clearTimeout(S)},[]),react.useEffect(()=>{let S=P=>{P.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:T,borderBottomLeftRadius:T,transform:a?"translateX(100%)":"translateX(0)"}:{...S,left:0,borderTopRightRadius:T,borderBottomRightRadius:T,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}),d&&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:p,accentColor:C})})]})]})}function ze({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[c,g]=react.useState(null),[f,u]=react.useState(false),[C,T]=react.useState({top:0,left:0}),[h,E]=react.useState(null),v={...l,...e.style_config},w=v.backgroundColor||"white",G=v.textColor||"#1f2937",S=v.accentColor||"#2563eb",P=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(!c)return;let R=Ye(c);T({top:R.top-8,left:R.right-8});},[c]),y=react.useCallback(()=>{if(!c||!a.current||!f)return;let R=a.current.getBoundingClientRect(),x=Te(c,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(x);},[c,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=x=>{a.current&&!a.current.contains(x.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!c)return null;let I=`
64
+ )`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:p=.5}){let[d,l]=react.useState(),s=react.useCallback(()=>{l(t?_t(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:c=>{i&&r&&r(),c.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${p})`,clipPath:d,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:p,accentColor:d="#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:d,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&&p&&p(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:d,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:d,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,c)=>jsxRuntime.jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},c))})}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:er(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 er(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 d=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(d,n);return}Array.from(n.attributes).forEach(d=>{let l=d.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(d.name),l==="href"||l==="src"){let a=d.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(d.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(d.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function Se({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[c,g]=react.useState(null),[f,u]=react.useState(null),[C,T]=react.useState(false),h={...l,...e.style_config},E=h.backgroundColor||"white",v=h.textColor||"#1f2937",w=h.accentColor||"#2563eb",G=h.borderRadius||8;react.useEffect(()=>{let P=ce(e.selector_strategy);g(P),P&&Pe(P,120);},[e.selector_strategy]);let S=react.useCallback(()=>{if(!c||!a.current)return;let P=a.current.getBoundingClientRect(),m=Te(c,P.width,P.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),T(true);},[c,e.tooltip_position,e.display_config]);return react.useEffect(()=>{let P=setTimeout(S,10);return window.addEventListener("scroll",S,true),window.addEventListener("resize",S),()=>{clearTimeout(P),window.removeEventListener("scroll",S,true),window.removeEventListener("resize",S);}},[S]),c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:c,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:G,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}),d&&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:p,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:G,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}),d&&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:p,accentColor:w})]})]})}function _e({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},c=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,C=e.display_config||{},T=C.width||480,h=C.position||"center",E=C.backdrop!==false;return react.useEffect(()=>{let w=G=>{G.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(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:T,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:c,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}),d&&o>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((w,G)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:G===t?f:"#e5e7eb",transition:"background-color 0.15s"}},G))}),jsxRuntime.jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:f})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let[a,c]=react.useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",C=g.accentColor||"#2563eb",T=g.borderRadius||0,h=e.display_config||{},E=h.width||400,v=h.position==="left"?"left":"right",w=h.backdrop!==false;return react.useEffect(()=>{let S=setTimeout(()=>c(false),50);return ()=>clearTimeout(S)},[]),react.useEffect(()=>{let S=P=>{P.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:T,borderBottomLeftRadius:T,transform:a?"translateX(100%)":"translateX(0)"}:{...S,left:0,borderTopRightRadius:T,borderBottomRightRadius:T,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}),d&&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:p,accentColor:C})})]})]})}function Fe({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let a=react.useRef(null),[c,g]=react.useState(null),[f,u]=react.useState(false),[C,T]=react.useState({top:0,left:0}),[h,E]=react.useState(null),v={...l,...e.style_config},w=v.backgroundColor||"white",G=v.textColor||"#1f2937",S=v.accentColor||"#2563eb",P=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(!c)return;let R=Ye(c);T({top:R.top-8,left:R.right-8});},[c]),y=react.useCallback(()=>{if(!c||!a.current||!f)return;let R=a.current.getBoundingClientRect(),x=Te(c,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(x);},[c,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=x=>{a.current&&!a.current.contains(x.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!c)return null;let I=`
66
65
  @keyframes census-hotspot-pulse {
67
66
  0% {
68
67
  transform: scale(1);
@@ -77,5 +76,5 @@
77
76
  box-shadow: 0 0 0 0 ${S}00;
78
77
  }
79
78
  }
80
- `;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:I}}),jsxRuntime.jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:C.top,left:C.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:S,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||C.top+30,left:h?.left||C.left-140,zIndex:s+1,padding:"16px 20px",backgroundColor:w,color:G,borderRadius:P,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 ${w}`,top:h.arrowPosition.top,left:h.arrowPosition.left,transform:h.arrowPosition.transform}}),jsxRuntime.jsx(Y,{step:e,textColor:G}),d&&o>1&&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:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:p,accentColor:S})]})]})}var Fe={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 Ae({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let [a,c]=react.useState(true),[g,f]=react.useState(true),u={...l,...e.style_config},T=(e.display_config||{}).bannerPosition||"top",h="custom",E=u.backgroundColor||Fe[h].bg,v=u.textColor||Fe[h].text;react.useEffect(()=>{let D=setTimeout(()=>c(false),50);return ()=>clearTimeout(D)},[]);let G=()=>{c(true),setTimeout(()=>{f(false),n();},200);};if(!g)return null;let S=e.rich_content,P=S?.title||e.title,m=S?.body||e.content,A=S?.buttons&&S.buttons.length>0;return jsxRuntime.jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[T]:0,zIndex:s,padding:"12px 20px",backgroundColor:E,color:v,boxShadow:T==="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?T==="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:[Fe[h].icon,jsxRuntime.jsxs("div",{style:{flex:1},children:[P&&jsxRuntime.jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:P}),m&&jsxRuntime.jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),d&&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(X,{buttons:S.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:G,onCustomAction:p,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:v,cursor:"pointer"},children:"Next"}):jsxRuntime.jsx("button",{onClick:G,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:v,cursor:"pointer"},children:"Got it"})}),jsxRuntime.jsx("button",{onClick:G,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:v,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}var dr=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","canvas"];function cr(e){return !dr.includes(e.tagName.toLowerCase())}function ot({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l}){let[s,a]=react.useState(null),[c,g]=react.useState(false),f=react.useRef(null),u=react.useRef(null),C={...l,...e.style_config},h=(e.display_config||{}).embeddedPosition||"append",E=C.backgroundColor||"white",v=C.textColor||"#1f2937",w=C.accentColor||"#2563eb",G=C.borderRadius??8;if(react.useEffect(()=>{let P=ce(e.selector_strategy);P&&cr(P)?a(P):a(null);},[e.selector_strategy]),react.useEffect(()=>{if(!s)return;let P=document.createElement("div");return P.setAttribute("data-census-embedded","true"),f.current=P,h==="replace"?(u.current=s.innerHTML,s.innerHTML="",s.appendChild(P)):h==="prepend"?s.insertBefore(P,s.firstChild):s.appendChild(P),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||!c||!f.current)return null;let S=e.rich_content;return reactDom.createPortal(jsxRuntime.jsxs("div",{role:"region","aria-label":"Guide content",style:{position:"relative",padding:"16px",backgroundColor:E,color:v,borderRadius:`${G}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:v,opacity:.5,fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"\xD7"}),d&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:v,opacity:.6,marginBottom:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Y,{step:e,textColor:v}),jsxRuntime.jsx(X,{buttons:S?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:w})]}),f.current)}function ur({guide:e,onComplete:t,onDismiss:o,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:p=0,zIndex:d=9999}){let[l,s]=react.useState(p),[a,c]=react.useState(true),g=e.guide_steps||[],f=g.length,u=g[l];react.useEffect(()=>{r?.(l,f);},[l,f,r]);let C=react.useCallback(()=>{l<f-1?s(w=>w+1):(c(false),t?.(e));},[l,f,e,t]),T=react.useCallback(()=>{l>0&&s(w=>w-1);},[l]),h=react.useCallback(()=>{c(false),o?.(e,l);},[e,l,o]),E=react.useCallback(w=>{u&&i?.(w,u);},[u,i]);if(!a||!u||g.length===0)return null;let v={step:u,currentStep:l,totalSteps:f,onNext:C,onPrev:T,onDismiss:h,onCustomAction:E,showProgress:e.show_progress!==false,globalStyle:{...e.theme,...n},zIndex:d};switch(u.step_type){case "tooltip":return jsxRuntime.jsx(Se,{...v});case "modal":return jsxRuntime.jsx(_e,{...v});case "slideout":return jsxRuntime.jsx(Be,{...v});case "hotspot":return jsxRuntime.jsx(ze,{...v});case "banner":return jsxRuntime.jsx(Ae,{...v});case "embedded":return jsxRuntime.jsx(ot,{...v});default:return jsxRuntime.jsx(Se,{...v})}}exports.Backdrop=re;exports.BannerStep=Ae;exports.CensusProvider=oo;exports.FeedbackButton=mo;exports.GuideBuilder=Wo;exports.GuideRenderer=ur;exports.HelpCenter=qo;exports.HotspotStep=ze;exports.KnowledgeBase=xo;exports.ModalStep=_e;exports.Requests=So;exports.SlideoutStep=Be;exports.StepButtons=X;exports.StepContent=Y;exports.TooltipStep=Se;exports.useArticle=xe;exports.useArticles=ye;exports.useCensus=ro;exports.useCensusContext=O;exports.useFeatureGroups=Ne;exports.useFeedback=be;exports.useGuideBuilder=Oe;exports.useGuideRenderer=co;exports.useGuides=lo;exports.useIdentify=no;exports.useRequests=he;exports.useTrack=ao;//# sourceMappingURL=index.cjs.map
79
+ `;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:I}}),jsxRuntime.jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:C.top,left:C.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:S,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||C.top+30,left:h?.left||C.left-140,zIndex:s+1,padding:"16px 20px",backgroundColor:w,color:G,borderRadius:P,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 ${w}`,top:h.arrowPosition.top,left:h.arrowPosition.left,transform:h.arrowPosition.transform}}),jsxRuntime.jsx(Y,{step:e,textColor:G}),d&&o>1&&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:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:p,accentColor:S})]})]})}var ze={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 Ae({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l,zIndex:s=9999}){let [a,c]=react.useState(true),[g,f]=react.useState(true),u={...l,...e.style_config},T=(e.display_config||{}).bannerPosition||"top",h="custom",E=u.backgroundColor||ze[h].bg,v=u.textColor||ze[h].text;react.useEffect(()=>{let D=setTimeout(()=>c(false),50);return ()=>clearTimeout(D)},[]);let G=()=>{c(true),setTimeout(()=>{f(false),n();},200);};if(!g)return null;let S=e.rich_content,P=S?.title||e.title,m=S?.body||e.content,A=S?.buttons&&S.buttons.length>0;return jsxRuntime.jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[T]:0,zIndex:s,padding:"12px 20px",backgroundColor:E,color:v,boxShadow:T==="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?T==="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:[ze[h].icon,jsxRuntime.jsxs("div",{style:{flex:1},children:[P&&jsxRuntime.jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:P}),m&&jsxRuntime.jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),d&&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(X,{buttons:S.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:G,onCustomAction:p,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:v,cursor:"pointer"},children:"Next"}):jsxRuntime.jsx("button",{onClick:G,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:v,cursor:"pointer"},children:"Got it"})}),jsxRuntime.jsx("button",{onClick:G,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:v,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}var pr=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","canvas"];function ur(e){return !pr.includes(e.tagName.toLowerCase())}function ot({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:l}){let[s,a]=react.useState(null),[c,g]=react.useState(false),f=react.useRef(null),u=react.useRef(null),C={...l,...e.style_config},h=(e.display_config||{}).embeddedPosition||"append",E=C.backgroundColor||"white",v=C.textColor||"#1f2937",w=C.accentColor||"#2563eb",G=C.borderRadius??8;if(react.useEffect(()=>{let P=ce(e.selector_strategy);P&&ur(P)?a(P):a(null);},[e.selector_strategy]),react.useEffect(()=>{if(!s)return;let P=document.createElement("div");return P.setAttribute("data-census-embedded","true"),f.current=P,h==="replace"?(u.current=s.innerHTML,s.innerHTML="",s.appendChild(P)):h==="prepend"?s.insertBefore(P,s.firstChild):s.appendChild(P),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||!c||!f.current)return null;let S=e.rich_content;return reactDom.createPortal(jsxRuntime.jsxs("div",{role:"region","aria-label":"Guide content",style:{position:"relative",padding:"16px",backgroundColor:E,color:v,borderRadius:`${G}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:v,opacity:.5,fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"\xD7"}),d&&o>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:v,opacity:.6,marginBottom:"8px"},children:["Step ",t+1," of ",o]}),jsxRuntime.jsx(Y,{step:e,textColor:v}),jsxRuntime.jsx(X,{buttons:S?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:w})]}),f.current)}function gr({guide:e,onComplete:t,onDismiss:o,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:p=0,zIndex:d=9999}){let[l,s]=react.useState(p),[a,c]=react.useState(true),g=e.guide_steps||[],f=g.length,u=g[l];react.useEffect(()=>{r?.(l,f);},[l,f,r]);let C=react.useCallback(()=>{l<f-1?s(w=>w+1):(c(false),t?.(e));},[l,f,e,t]),T=react.useCallback(()=>{l>0&&s(w=>w-1);},[l]),h=react.useCallback(()=>{c(false),o?.(e,l);},[e,l,o]),E=react.useCallback(w=>{u&&i?.(w,u);},[u,i]);if(!a||!u||g.length===0)return null;let v={step:u,currentStep:l,totalSteps:f,onNext:C,onPrev:T,onDismiss:h,onCustomAction:E,showProgress:e.show_progress!==false,globalStyle:{...e.theme,...n},zIndex:d};switch(u.step_type){case "tooltip":return jsxRuntime.jsx(Se,{...v});case "modal":return jsxRuntime.jsx(_e,{...v});case "slideout":return jsxRuntime.jsx(Be,{...v});case "hotspot":return jsxRuntime.jsx(Fe,{...v});case "banner":return jsxRuntime.jsx(Ae,{...v});case "embedded":return jsxRuntime.jsx(ot,{...v});default:return jsxRuntime.jsx(Se,{...v})}}exports.Backdrop=re;exports.BannerStep=Ae;exports.CensusProvider=no;exports.FeedbackButton=yo;exports.GuideBuilder=Vo;exports.GuideRenderer=gr;exports.HelpCenter=Do;exports.HotspotStep=Fe;exports.KnowledgeBase=vo;exports.ModalStep=_e;exports.Requests=ko;exports.SlideoutStep=Be;exports.StepButtons=X;exports.StepContent=Y;exports.TooltipStep=Se;exports.useArticle=xe;exports.useArticles=ye;exports.useCensus=io;exports.useCensusContext=O;exports.useFeatureGroups=Ne;exports.useFeedback=be;exports.useGuideBuilder=Oe;exports.useGuideRenderer=uo;exports.useGuides=po;exports.useIdentify=so;exports.useRequests=he;exports.useTrack=co;//# sourceMappingURL=index.cjs.map
81
80
  //# sourceMappingURL=index.cjs.map