@census-ai/census-sdk 0.3.0 → 0.4.2

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,28 +1,28 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var mt="https://api.census.ai",Ee=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(n=>e.apiKey.startsWith(n))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||mt,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let n=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",n.feedbackId),{feedbackId:n.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let n=t.toString(),i=`/api/sdk/articles${n?`?${n}`:""}`,r=await this.request(i,"GET");return this.log("Fetched articles:",r.articles.length),r}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let n=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",n.requests.length),n}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.events.map(n=>({eventType:n.eventType,userId:this.currentUserId,articleId:n.articleId,featureId:n.featureId,properties:n.properties}));await this.request("/api/sdk/events","POST",{events:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let n=t.toString(),i=`/api/sdk/guides${n?`?${n}`:""}`,r=await this.request(i,"GET");return this.log("Fetched guides:",r.guides.length),r}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let n={};t.name!==void 0&&(n.name=t.name),t.slug!==void 0&&(n.slug=t.slug),t.description!==void 0&&(n.description=t.description),t.triggerType!==void 0&&(n.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(n.trigger_config=t.triggerConfig),t.theme!==void 0&&(n.theme=t.theme),t.allowSkip!==void 0&&(n.allow_skip=t.allowSkip),t.showProgress!==void 0&&(n.show_progress=t.showProgress),t.status!==void 0&&(n.status=t.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",n);return this.log("Guide updated:",e),i.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let n=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),n.step}async updateGuideStep(e,t,n){if(!e||!t)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let i={};n.stepType!==void 0&&(i.step_type=n.stepType),n.sortOrder!==void 0&&(i.sort_order=n.sortOrder),n.selectorStrategy!==void 0&&(i.selector_strategy=n.selectorStrategy),n.title!==void 0&&(i.title=n.title),n.content!==void 0&&(i.content=n.content),n.tooltipPosition!==void 0&&(i.tooltip_position=n.tooltipPosition),n.richContent!==void 0&&(i.rich_content=n.richContent),n.displayConfig!==void 0&&(i.display_config=n.displayConfig),n.advanceConfig!==void 0&&(i.advance_config=n.advanceConfig),n.styleConfig!==void 0&&(i.style_config=n.styleConfig);let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"PUT",i);return this.log("Step updated:",t),r.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let n=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),n.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,n){let i=`${this.baseUrl}${e}`,r={"X-Census-Key":this.apiKey};n&&(r["Content-Type"]="application/json"),this.log(`${t} ${e}`,n);let c=await fetch(i,{method:t,headers:r,body:n?JSON.stringify(n):void 0});if(!c.ok){let d=`Request failed with status ${c.status}`;try{d=(await c.json()).error||d;}catch{}throw {error:d,status:c.status}}return c.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function He(o){return new Ee(o)}var Re=react.createContext(null);function xt({apiKey:o,baseUrl:e,debug:t,user:n,theme:i={},children:r}){let[c,d]=react.useState(false),[a,l]=react.useState(false),s=react.useMemo(()=>He({apiKey:o,baseUrl:e,debug:t}),[o,e,t]);react.useEffect(()=>{n?s.identify(n).then(()=>{l(true),d(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),d(true);}):d(true);},[s,n]);let p=react.useMemo(()=>({client:s,theme:i,isReady:c,isIdentified:a}),[s,i,c,a]);return jsxRuntime.jsx(Re.Provider,{value:p,children:r})}function ht(){let o=react.useContext(Re);if(!o)throw new Error("useCensus must be used within a CensusProvider");return o.client}function U(){let o=react.useContext(Re);if(!o)throw new Error("useCensusContext must be used within a CensusProvider");return o}function vt(){let{client:o}=U(),[e,t]=react.useState(false),[n,i]=react.useState(null);return {identify:async d=>{t(true),i(null);try{await o.identify(d);}catch(a){throw i(a instanceof Error?a:new Error("Failed to identify user")),a}finally{t(false);}},reset:()=>{o.reset();},isIdentifying:e,isIdentified:o.isIdentified(),error:n}}function Te(){let{client:o}=U(),[e,t]=react.useState(false),[n,i]=react.useState(false),[r,c]=react.useState(null),[d,a]=react.useState(null),l=react.useCallback(async p=>{t(true),i(false),c(null),a(null);try{let f=await o.submitFeedback(p);return a(f.feedbackId),i(!0),f}catch(f){let m=f instanceof Error?f:new Error("Failed to submit feedback");throw c(m),m}finally{t(false);}},[o]),s=react.useCallback(()=>{i(false),c(null),a(null);},[]);return {submitFeedback:l,reset:s,isSubmitting:e,isSuccess:n,error:r,feedbackId:d}}function Ie(o){let{client:e,isReady:t}=U(),[n,i]=react.useState(null),[r,c]=react.useState(true),[d,a]=react.useState(null),l=react.useCallback(async()=>{c(true),a(null);try{let s=await e.getArticles(o);i(s);}catch(s){a(s instanceof Error?s:new Error("Failed to fetch articles"));}finally{c(false);}},[e,o?.category,o?.search,o?.limit,o?.offset]);return react.useEffect(()=>{t&&l();},[t,l]),{articles:n?.articles||[],pagination:n?.pagination,isLoading:r,error:d,refetch:l}}function _e(o){let{client:e,isReady:t}=U(),[n,i]=react.useState(null),[r,c]=react.useState(true),[d,a]=react.useState(null),l=react.useCallback(async()=>{if(!o){i(null),c(false);return}c(true),a(null);try{let s=await e.getArticle(o);i(s);}catch(s){a(s instanceof Error?s:new Error("Failed to fetch article"));}finally{c(false);}},[e,o]);return react.useEffect(()=>{t&&l();},[t,l]),{article:n,isLoading:r,error:d,refetch:l}}function Be(o){let{client:e,isReady:t,isIdentified:n}=U(),[i,r]=react.useState(null),[c,d]=react.useState(true),[a,l]=react.useState(null),s=react.useCallback(async()=>{if(!n){r(null),d(false);return}d(true),l(null);try{let p=await e.getRequests(o);r(p);}catch(p){l(p instanceof Error?p:new Error("Failed to fetch requests"));}finally{d(false);}},[e,n,o?.status,o?.type,o?.limit,o?.offset]);return react.useEffect(()=>{t&&n&&s();},[t,n,s]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:c,error:a,refetch:s}}function wt(){let{client:o}=U(),e=react.useCallback(async(n,i)=>{await o.track(n,i);},[o]),t=react.useCallback(async n=>{await o.trackBatch({events:n});},[o]);return {track:e,trackBatch:t}}function kt(o){let{client:e,isReady:t}=U(),[n,i]=react.useState(null),[r,c]=react.useState(true),[d,a]=react.useState(null),l=react.useCallback(async()=>{c(true),a(null);try{let s=await e.getGuides(o);i(s);}catch(s){a(s instanceof Error?s:new Error("Failed to fetch guides"));}finally{c(false);}},[e,o?.projectId,o?.url,o?.userId]);return react.useEffect(()=>{t&&l();},[t,l]),{guides:n?.guides||[],completedGuides:n?.completedGuides||[],isLoading:r,error:d,refetch:l}}function ze(){let{client:o,isReady:e}=U(),[t,n]=react.useState(null),[i,r]=react.useState([]),[c,d]=react.useState(false),[a,l]=react.useState(false),[s,p]=react.useState(null),[f,m]=react.useState(null),u=react.useRef(false),S=react.useCallback(async h=>{d(true),p(null);try{let b=await o.getGuide(h);return b&&(n(b),r(b.guide_steps||[]),m(b.guide_steps?.[0]?.id||null)),b}catch(b){return p(b instanceof Error?b:new Error("Failed to load guide")),null}finally{d(false);}},[o]),w=react.useCallback(async h=>{l(true),p(null);try{let b=await o.createGuide(h);return n(b),r([]),m(null),b}catch(b){throw p(b instanceof Error?b:new Error("Failed to create guide")),b}finally{l(false);}},[o]),y=react.useCallback(async h=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{let b=await o.updateGuide(t.id,h);return n(b),u.current=!1,b}catch(b){throw p(b instanceof Error?b:new Error("Failed to update guide")),b}finally{l(false);}},[o,t]),G=react.useCallback(async()=>y({status:"published"}),[y]),v=react.useCallback(async()=>y({status:"draft"}),[y]),C=react.useCallback(async()=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{await o.deleteGuide(t.id),n(null),r([]),m(null);}catch(h){throw p(h instanceof Error?h:new Error("Failed to delete guide")),h}finally{l(false);}},[o,t]),k=react.useCallback(async h=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{let b=await o.addGuideStep(t.id,h);return r(q=>[...q,b]),m(b.id),u.current=!0,b}catch(b){throw p(b instanceof Error?b:new Error("Failed to add step")),b}finally{l(false);}},[o,t]),x=react.useCallback(async(h,b)=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{let q=await o.updateGuideStep(t.id,h,b);return r(O=>O.map(K=>K.id===h?q:K)),u.current=!0,q}catch(q){throw p(q instanceof Error?q:new Error("Failed to update step")),q}finally{l(false);}},[o,t]),P=react.useCallback(async h=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{await o.deleteGuideStep(t.id,h),r(b=>b.filter(q=>q.id!==h)),f===h&&m(i[0]?.id||null),u.current=!0;}catch(b){throw p(b instanceof Error?b:new Error("Failed to delete step")),b}finally{l(false);}},[o,t,f,i]),g=react.useCallback(async h=>{if(!t)throw new Error("No guide loaded");l(true),p(null);try{let b=await o.reorderGuideSteps(t.id,h);return r(b),u.current=!0,b}catch(b){throw p(b instanceof Error?b:new Error("Failed to reorder steps")),b}finally{l(false);}},[o,t]),z=react.useCallback(async h=>{let b=i.findIndex(O=>O.id===h);if(b<=0)return;let q=i.map((O,K)=>K===b?{id:O.id,sort_order:b-1}:K===b-1?{id:O.id,sort_order:b}:{id:O.id,sort_order:K});return g(q)},[i,g]),L=react.useCallback(async h=>{let b=i.findIndex(O=>O.id===h);if(b<0||b>=i.length-1)return;let q=i.map((O,K)=>K===b?{id:O.id,sort_order:b+1}:K===b+1?{id:O.id,sort_order:b}:{id:O.id,sort_order:K});return g(q)},[i,g]),V=f&&i.find(h=>h.id===f)||null,E=react.useCallback(()=>{n(null),r([]),m(null),p(null),u.current=false;},[]);return {guide:t,steps:i,selectedStep:V,selectedStepId:f,isLoading:c,isSaving:a,error:s,isReady:e,hasUnsavedChanges:u.current,loadGuide:S,createGuide:w,updateGuide:y,publishGuide:G,unpublishGuide:v,deleteGuide:C,addStep:k,updateStep:x,deleteStep:P,reorderSteps:g,moveStepUp:z,moveStepDown:L,setSelectedStepId:m,reset:E}}function Gt(){let{client:o,isReady:e}=U(),[t,n]=react.useState(null),[i,r]=react.useState(0),[c,d]=react.useState(false),[a,l]=react.useState([]),[s,p]=react.useState([]),f=react.useCallback((E,h=0)=>{n(E),r(h),d(true);},[]),m=react.useCallback(()=>{if(!t)return;let E=t.guide_steps||[];i<E.length-1?r(h=>h+1):(l(h=>[...h,t.id]),d(false),n(null));},[t,i]),u=react.useCallback(()=>{i>0&&r(E=>E-1);},[i]),S=react.useCallback(E=>{if(!t)return;let h=t.guide_steps||[];E>=0&&E<h.length&&r(E);},[t]),w=react.useCallback(()=>{t&&p(E=>[...E,t.id]),d(false),n(null),r(0);},[t]),y=react.useCallback(()=>{d(false);},[]),G=react.useCallback(()=>{t&&d(true);},[t]),v=react.useCallback(async(E,h)=>{let b=E.guide_steps?.[h];if(b)try{await o.track("guide_step_viewed",{guide_id:E.id,guide_name:E.name,step_id:b.id,step_index:h,step_type:b.step_type});}catch{}},[o]),C=react.useCallback(async E=>{try{await o.track("guide_completed",{guide_id:E.id,guide_name:E.name,total_steps:E.guide_steps?.length||0});}catch{}},[o]),k=react.useCallback(async(E,h)=>{try{await o.track("guide_dismissed",{guide_id:E.id,guide_name:E.name,dismissed_at_step:h,total_steps:E.guide_steps?.length||0});}catch{}},[o]),x=t?.guide_steps?.[i]||null,P=t?.guide_steps?.length||0,g=i===P-1,z=i===0,L=react.useCallback(E=>a.includes(E),[a]),V=react.useCallback(E=>s.includes(E),[s]);return {activeGuide:t,currentStep:x,currentStepIndex:i,totalSteps:P,isPlaying:c,isFirstStep:z,isLastStep:g,isReady:e,startGuide:f,nextStep:m,prevStep:u,goToStep:S,dismiss:w,pause:y,resume:G,trackStepView:v,trackGuideComplete:C,trackGuideDismiss:k,completedGuideIds:a,dismissedGuideIds:s,isGuideCompleted:L,isGuideDismissed:V}}var Z={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"}},Pt={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},Et={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},Rt={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function Tt(o){return {primaryColor:o.primaryColor||"#000000",textColor:o.textColor||"#333333",backgroundColor:o.backgroundColor||"#ffffff",borderRadius:o.borderRadius||"8px",fontFamily:o.fontFamily||"system-ui, -apple-system, sans-serif"}}function It({position:o="bottom-right",text:e="Feedback",allowedTypes:t=["feedback","bug_report","feature_request"],theme:n,onSubmit:i,onError:r,children:c}){let{theme:d}=U(),{submitFeedback:a,isSubmitting:l,isSuccess:s,reset:p}=Te(),[f,m]=react.useState(false),[u,S]=react.useState(t[0]),[w,y]=react.useState(""),G={...d,...n},v=Tt(G),C=react.useCallback(()=>{m(true),p();},[p]),k=react.useCallback(()=>{m(false),y(""),S(t[0]);},[t]),x=react.useCallback(async P=>{P.preventDefault();let g={type:u,message:w};try{await a(g),i?.(g),setTimeout(k,1500);}catch(z){r?.(z instanceof Error?z:new Error("Failed to submit feedback"));}},[u,w,a,i,r,k]);return c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:C,style:{cursor:"pointer"},children:c}),f&&jsxRuntime.jsx(je,{isOpen:f,onClose:k,selectedType:u,onTypeChange:S,allowedTypes:t,message:w,onMessageChange:y,onSubmit:x,isSubmitting:l,isSuccess:s,themeStyles:v})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:C,style:{...Z.button,...Pt[o],backgroundColor:v.primaryColor,color:"white",borderRadius:v.borderRadius,fontFamily:v.fontFamily},"aria-label":"Open feedback form",children:e}),f&&jsxRuntime.jsx(je,{isOpen:f,onClose:k,selectedType:u,onTypeChange:S,allowedTypes:t,message:w,onMessageChange:y,onSubmit:x,isSubmitting:l,isSuccess:s,themeStyles:v})]})}function je({isOpen:o,onClose:e,selectedType:t,onTypeChange:n,allowedTypes:i,message:r,onMessageChange:c,onSubmit:d,isSubmitting:a,isSuccess:l,themeStyles:s}){return o?l?jsxRuntime.jsx("div",{style:Z.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Z.modalContent,textAlign:"center",fontFamily:s.fontFamily},onClick:p=>p.stopPropagation(),children:[jsxRuntime.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",color:s.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:Z.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...Z.modalContent,fontFamily:s.fontFamily},onClick:p=>p.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsxRuntime.jsx("h3",{style:{margin:0,color:s.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:e,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsxs("form",{onSubmit: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(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(p),style:{...Z.typeButton,backgroundColor:t===p?s.primaryColor:"white",color:t===p?"white":s.textColor,borderColor:t===p?s.primaryColor:"#e0e0e0"},children:[Rt[p]," ",Et[p]]},p))})]}),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:r,onChange:p=>c(p.target.value),placeholder:t==="bug_report"?"Describe the bug and steps to reproduce...":t==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:Z.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:a||!r.trim(),style:{...Z.submitButton,backgroundColor:s.primaryColor,color:"white",opacity:a||!r.trim()?.6:1,cursor:a||!r.trim()?"not-allowed":"pointer"},children:a?"Sending...":"Send Feedback"})]})]})}):null}var B={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 Bt(o){return {primaryColor:o.primaryColor||"#000000",textColor:o.textColor||"#333333",backgroundColor:o.backgroundColor||"#ffffff",borderRadius:o.borderRadius||"8px",fontFamily:o.fontFamily||"system-ui, -apple-system, sans-serif"}}function zt({showSearch:o=true,showCategories:e=true,defaultCategory:t,theme:n,className:i,onArticleView:r}){let{theme:c}=U(),[d,a]=react.useState(""),[l,s]=react.useState(t),[p,f]=react.useState(null),m={...c,...n},u=Bt(m),{articles:S,isLoading:w,error:y}=Ie({category:l,search:d||void 0}),{article:G,isLoading:v,error:C}=_e(p||""),k=react.useMemo(()=>{let g=new Set;return S.forEach(z=>{z.category&&g.add(z.category);}),Array.from(g).sort()},[S]),x=g=>{f(g.slug),r?.(g);},P=()=>{f(null);};return p?v?jsxRuntime.jsx("div",{style:{...B.container,fontFamily:u.fontFamily},className:i,children:jsxRuntime.jsx("div",{style:B.loading,children:"Loading article..."})}):C?jsxRuntime.jsxs("div",{style:{...B.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:B.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:B.error,children:"Failed to load article. Please try again."})]}):G?jsxRuntime.jsxs("div",{style:{...B.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:B.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 16px 0",color:u.textColor},children:G.title}),G.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[G.read_time_minutes," min read"]}),G.content_html?jsxRuntime.jsx("div",{style:{...B.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:G.content_html}}):jsxRuntime.jsx("div",{style:{...B.articleContent,color:u.textColor},children:typeof G.content=="string"?G.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...B.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:P,style:B.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:B.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{style:{...B.container,fontFamily:u.fontFamily},className:i,children:[o&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:d,onChange:g=>a(g.target.value),style:B.searchInput}),e&&k.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>s(void 0),style:{...B.categoryButton,backgroundColor:l?"white":u.primaryColor,color:l?u.textColor:"white",borderColor:l?"#e0e0e0":u.primaryColor},children:"All"}),k.map(g=>jsxRuntime.jsx("button",{onClick:()=>s(g),style:{...B.categoryButton,backgroundColor:l===g?u.primaryColor:"white",color:l===g?"white":u.textColor,borderColor:l===g?u.primaryColor:"#e0e0e0"},children:g},g))]}),w&&jsxRuntime.jsx("div",{style:B.loading,children:"Loading articles..."}),y&&jsxRuntime.jsx("div",{style:B.error,children:"Failed to load articles. Please try again."}),!w&&!y&&S.length===0&&jsxRuntime.jsx("div",{style:B.empty,children:d?`No articles found for "${d}"`:"No articles available yet."}),!w&&!y&&S.length>0&&jsxRuntime.jsx("div",{children:S.map(g=>jsxRuntime.jsxs("div",{onClick:()=>x(g),style:B.articleCard,role:"button",tabIndex:0,onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&x(g);},children:[jsxRuntime.jsx("h3",{style:{...B.articleTitle,color:u.textColor},children:g.title}),g.seo_description&&jsxRuntime.jsx("p",{style:B.articleDescription,children:g.seo_description}),jsxRuntime.jsxs("div",{style:B.articleMeta,children:[g.category&&jsxRuntime.jsx("span",{children:g.category}),g.read_time_minutes&&jsxRuntime.jsxs("span",{children:[g.read_time_minutes," min read"]})]})]},g.id))})]})}var $={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"}},Ye={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"}},Qe={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 Lt(o){return new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function qt({status:o,type:e,limit:t=50,className:n,showEmptyState:i=true,onRequestClick:r}){let{isIdentified:c}=U(),[d,a]=react.useState(null),{requests:l,isLoading:s,error:p,refetch:f}=Be({status:o,type:e,limit:t}),m=react.useCallback(u=>{r?.(u);},[r]);return c?s?jsxRuntime.jsx("div",{style:$.loading,children:jsxRuntime.jsx("p",{children:"Loading requests..."})}):p?jsxRuntime.jsx("div",{style:$.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests. ",jsxRuntime.jsx("button",{onClick:f,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):l.length===0&&i?jsxRuntime.jsxs("div",{style:$.empty,children:[jsxRuntime.jsx("svg",{style:$.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:$.container,className:n,children:jsxRuntime.jsx("ul",{style:$.list,children:l.map(u=>{let S=Ye[u.feedback_type]||Ye.feedback,w=Qe[u.status]||Qe.new,y=d===u.id;return jsxRuntime.jsxs("li",{style:{...$.card,...y?$.cardHover:{}},onMouseEnter:()=>a(u.id),onMouseLeave:()=>a(null),onClick:()=>m(u),role:"button",tabIndex:0,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&m(u);},children:[jsxRuntime.jsx("div",{style:$.header,children:jsxRuntime.jsxs("div",{style:$.badges,children:[jsxRuntime.jsx("span",{style:{...$.badge,color:S.color,backgroundColor:S.bg},children:S.label}),jsxRuntime.jsx("span",{style:{...$.badge,color:w.color,backgroundColor:w.bg},children:w.label})]})}),jsxRuntime.jsx("p",{style:$.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:$.meta,children:[jsxRuntime.jsx("span",{children:Lt(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:$.empty,children:jsxRuntime.jsx("p",{children:"Please sign in to view your requests."})}):null}var Je={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner"},Ut={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"},Dt=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],Nt=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Ze({step:o,onUpdate:e,onSelectElement:t,isSelectingElement:n}){let[i,r]=react.useState(false),[c,d]=react.useState(o.step_type),[a,l]=react.useState(o.rich_content?.title||o.title||""),[s,p]=react.useState(o.rich_content?.body||o.content||""),[f,m]=react.useState(o.tooltip_position||o.display_config?.position||"auto"),[u,S]=react.useState(o.selector_strategy?.css||""),[w,y]=react.useState(o.display_config?.backdrop!==false),[G,v]=react.useState(o.advance_config?.trigger||"button"),[C,k]=react.useState(o.advance_config?.delay||3e3),x=react.useCallback(async()=>{r(true);try{let g=u?{css:u}:void 0,z={title:a||void 0,body:s||void 0},L={position:f!=="auto"?f:void 0,backdrop:w},V={trigger:G,delay:G==="delay"?C:void 0};await e(o.id,{stepType:c,selectorStrategy:g,richContent:z,displayConfig:L,advanceConfig:V,tooltipPosition:f});}finally{r(false);}},[o.id,c,a,s,f,u,w,G,C,e]),P=c==="tooltip"||c==="hotspot";return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[jsxRuntime.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:"Edit Step"}),jsxRuntime.jsx("button",{onClick:x,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(Je).map(g=>jsxRuntime.jsxs("button",{onClick:()=>d(g),style:{padding:"10px",border:`2px solid ${c===g?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:c===g?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:Je[g]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:Ut[g]})]},g))})]}),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:g=>S(g.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:t,disabled:n,style:{padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:n?"#f3f4f6":"white",cursor:n?"wait":"pointer"},children:n?"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:a,onChange:g=>l(g.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:s,onChange:g=>p(g.target.value),placeholder:"Enter step content (HTML supported)",rows:4,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",resize:"vertical",fontFamily:"inherit"}})]}),(c==="tooltip"||c==="hotspot")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Position"}),jsxRuntime.jsx("select",{value:f,onChange:g=>m(g.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Dt.map(g=>jsxRuntime.jsx("option",{value:g.value,children:g.label},g.value))})]}),c==="banner"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Banner Position"}),jsxRuntime.jsxs("select",{value:f==="bottom"?"bottom":"top",onChange:g=>m(g.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"top",children:"Top"}),jsxRuntime.jsx("option",{value:"bottom",children:"Bottom"})]})]}),c==="slideout"&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Slideout Side"}),jsxRuntime.jsxs("select",{value:f==="left"?"left":"right",onChange:g=>m(g.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsxRuntime.jsx("option",{value:"right",children:"Right"}),jsxRuntime.jsx("option",{value:"left",children:"Left"})]})]}),(c==="tooltip"||c==="modal")&&jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:w,onChange:g=>y(g.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:G,onChange:g=>v(g.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Nt.map(g=>jsxRuntime.jsx("option",{value:g.value,children:g.label},g.value))})]}),G==="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:C/1e3,onChange:g=>k(Number(g.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function $t(o){let e={},t=o.getAttribute("data-testid");if(t)return e.testId=t,e.css=`[data-testid="${t}"]`,e;if(o.id)return e.css=`#${CSS.escape(o.id)}`,e;let n=[],i=o,r=0,c=5;for(;i&&i!==document.body&&r<c;){let a=i.tagName.toLowerCase(),l=Array.from(i.classList).filter(f=>!f.startsWith("hover")&&!f.startsWith("focus")&&!f.startsWith("active")).slice(0,2);l.length>0&&(a+="."+l.map(f=>CSS.escape(f)).join("."));let s=i.parentElement;if(s){let f=Array.from(s.children).filter(m=>m.tagName===i.tagName);if(f.length>1){let m=f.indexOf(i)+1;a+=`:nth-of-type(${m})`;}}n.unshift(a);let p=n.join(" > ");try{if(document.querySelectorAll(p).length===1){e.css=p;break}}catch{}i=i.parentElement,r++;}!e.css&&n.length>0&&(e.css=n.join(" > "));let d=o.textContent?.trim();return d&&d.length<100&&d.length>2&&(e.text=d.slice(0,50)),e}function Wt(o){let e=0;if(o.css)try{e=document.querySelectorAll(o.css).length;}catch{}return o.testId&&(e=document.querySelectorAll(`[data-testid="${o.testId}"]`).length),{isUnique:e===1,count:e}}function tt({isActive:o,onSelect:e,onCancel:t,ignoreSelector:n="[data-census-builder]",zIndex:i=99999}){let[r,c]=react.useState(null),[d,a]=react.useState(null),[l,s]=react.useState(null),p=react.useRef(null),f=react.useCallback(()=>{if(!r){a(null);return}a(r.getBoundingClientRect());},[r]);react.useEffect(()=>{if(!o)return;let S=y=>{let v=document.elementsFromPoint(y.clientX,y.clientY).find(C=>!(p.current?.contains(C)||n&&C.closest(n)||C===document.body||C===document.documentElement));v!==r&&(c(v||null),s(v?$t(v):null));},w=()=>{f();};return document.addEventListener("mousemove",S,true),window.addEventListener("scroll",w,true),window.addEventListener("resize",w),()=>{document.removeEventListener("mousemove",S,true),window.removeEventListener("scroll",w,true),window.removeEventListener("resize",w);}},[o,r,n,f]),react.useEffect(()=>{f();},[r,f]);let m=react.useCallback(S=>{S.preventDefault(),S.stopPropagation(),r&&l&&e(l,r);},[r,l,e]);if(react.useEffect(()=>{if(!o)return;let S=w=>{w.key==="Escape"&&t();};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[o,t]),!o)return null;let u=l?Wt(l):null;return jsxRuntime.jsxs("div",{ref:p,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:m,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&&l&&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:l.testId?"data-testid: ":""}),l.testId||l.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:S=>{S.stopPropagation(),t();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function Ht({isOpen:o,onClose:e,guideId:t,onSave:n,onPublish:i,trigger:r,className:c}){let[d,a]=react.useState(false),l=o??d,{guide:s,steps:p,selectedStep:f,selectedStepId:m,isLoading:u,isSaving:S,error:w,loadGuide:y,updateGuide:G,publishGuide:v,addStep:C,updateStep:k,deleteStep:x,moveStepUp:P,moveStepDown:g,setSelectedStepId:z,reset:L}=ze(),V=react.useCallback(async()=>{a(true),t&&await y(t);},[t,y]),E=react.useCallback(()=>{a(false),L(),e?.();},[L,e]),h=react.useCallback(async()=>{if(s)try{await G({}),n?.(s);}catch{}},[s,G,n]),b=react.useCallback(async()=>{if(s)try{let O=await v();i?.(O);}catch{}},[s,v,i]),q=react.useCallback(async(O="tooltip")=>{try{await C({stepType:O,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[C]);return r&&o===void 0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{onClick:V,children:r}),l&&jsxRuntime.jsx(ot,{guide:s,steps:p,selectedStep:f,selectedStepId:m,isLoading:u,isSaving:S,error:w,onClose:E,onSave:h,onPublish:b,onAddStep:q,onSelectStep:z,onUpdateStep:k,onDeleteStep:x,onMoveStepUp:P,onMoveStepDown:g,className:c})]}):l?jsxRuntime.jsx(ot,{guide:s,steps:p,selectedStep:f,selectedStepId:m,isLoading:u,isSaving:S,error:w,onClose:E,onSave:h,onPublish:b,onAddStep:q,onSelectStep:z,onUpdateStep:k,onDeleteStep:x,onMoveStepUp:P,onMoveStepDown:g,className:c}):null}function ot({guide:o,steps:e,selectedStep:t,selectedStepId:n,isLoading:i,isSaving:r,error:c,onClose:d,onSave:a,onPublish:l,onAddStep:s,onSelectStep:p,onUpdateStep:f,onDeleteStep:m,onMoveStepUp:u,onMoveStepDown:S,className:w}){let[y,G]=react.useState(false),v={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner"},C=react.useCallback((k,x)=>{t&&f(t.id,{selectorStrategy:k}),G(false);},[t,f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(tt,{isActive:y,onSelect:C,onCancel:()=>G(false),ignoreSelector:"[data-census-builder]"}),jsxRuntime.jsxs("div",{className:w,"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:o?o.name:"Guide Builder"}),o?.status&&jsxRuntime.jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:o.status==="published"?"#dcfce7":"#fef3c7",color:o.status==="published"?"#166534":"#92400e"},children:o.status})]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"8px"},children:[c&&jsxRuntime.jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:c.message}),jsxRuntime.jsx("button",{onClick:a,disabled:r||!o,style:{padding:"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:r?"wait":"pointer",opacity:r?.5:1},children:r?"Saving...":"Save"}),jsxRuntime.jsx("button",{onClick:l,disabled:r||!o||o.status==="published",style:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:r?"wait":"pointer",opacity:r||o?.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 (",e.length,")"]}),jsxRuntime.jsx("button",{onClick:()=>s("tooltip"),disabled:!o,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:o?"pointer":"not-allowed",opacity:o?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..."}):e.length===0?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):e.map((k,x)=>jsxRuntime.jsxs("div",{onClick:()=>p(k.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:n===k.id?"#eff6ff":"white",border:`1px solid ${n===k.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:[x+1,". ",v[k.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),u(k.id);},disabled:x===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:x===0?"not-allowed":"pointer",opacity:x===0?.3:1},children:"Up"}),jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),S(k.id);},disabled:x===e.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:x===e.length-1?"not-allowed":"pointer",opacity:x===e.length-1?.3:1},children:"Down"}),jsxRuntime.jsx("button",{onClick:P=>{P.stopPropagation(),confirm("Delete this step?")&&m(k.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:k.rich_content?.title||k.title||"Untitled"})]},k.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:t?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[t.step_type]})}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:t.rich_content?.title||t.title||"Step Preview"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#4b5563"},children:t.rich_content?.body||t.content||"No content"}),t.rich_content?.media&&jsxRuntime.jsx("div",{style:{marginTop:"12px"},children:t.rich_content.media.type==="image"&&jsxRuntime.jsx("img",{src:t.rich_content.media.url,alt:t.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),t.rich_content?.buttons&&t.rich_content.buttons.length>0&&jsxRuntime.jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:t.rich_content.buttons.map((k,x)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:k.style==="primary"?"#2563eb":"#f3f4f6",color:k.style==="primary"?"white":"#374151"},children:k.label},x))}),t.selector_strategy?.css&&jsxRuntime.jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",t.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:t?jsxRuntime.jsx(Ze,{step:t,onUpdate:f,onSelectElement:()=>G(true),isSelectingElement:y}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function De(o){let e=o.getBoundingClientRect();return {top:e.top+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX,bottom:e.bottom+window.scrollY,width:e.width,height:e.height}}function Ne(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ue(o,e,t,n,i){let r=Ne(),{scrollX:c,scrollY:d,width:a,height:l}=r;switch(n){case "top":return o.top-d-t-i>0&&o.left-c+o.width/2-e/2>0&&o.left-c+o.width/2+e/2<a;case "bottom":return o.bottom-d+t+i<l&&o.left-c+o.width/2-e/2>0&&o.left-c+o.width/2+e/2<a;case "left":return o.left-c-e-i>0&&o.top-d+o.height/2-t/2>0&&o.top-d+o.height/2+t/2<l;case "right":return o.right-c+e+i<a&&o.top-d+o.height/2-t/2>0&&o.top-d+o.height/2+t/2<l;default:return true}}function Vt(o,e,t,n){let i=["bottom","top","right","left"];for(let r of i)if(Ue(o,e,t,r,n))return r;return "bottom"}function be(o,e,t,n){let{preferredPosition:i,offset:r={x:0,y:0},containerPadding:c=10,arrowSize:d=8}=n,a=De(o),l=Ne(),s=i;if(i==="auto")s=Vt(a,e,t,c);else if(!Ue(a,e,t,i,c)){let x={top:"bottom",bottom:"top",left:"right",right:"left"}[i];x&&Ue(a,e,t,x,c)&&(s=x);}let p=0,f=0,m={},u=d+4;switch(s){case "top":p=a.top-t-u+r.y,f=a.left+a.width/2-e/2+r.x,m={left:e/2-d/2,top:t,transform:"rotate(180deg)"};break;case "bottom":p=a.bottom+u+r.y,f=a.left+a.width/2-e/2+r.x,m={left:e/2-d/2,top:-d};break;case "left":p=a.top+a.height/2-t/2+r.y,f=a.left-e-u+r.x,m={top:t/2-d/2,left:e,transform:"rotate(-90deg)"};break;case "right":p=a.top+a.height/2-t/2+r.y,f=a.right+u+r.x,m={top:t/2-d/2,left:-d,transform:"rotate(90deg)"};break}let S=l.scrollX+c,w=l.scrollX+l.width-e-c,y=l.scrollY+c,G=l.scrollY+l.height-t-c,v=f;f=Math.max(S,Math.min(w,f)),(s==="top"||s==="bottom")&&(m.left=(m.left||0)+(v-f));let C=p;return p=Math.max(y,Math.min(G,p)),(s==="left"||s==="right")&&(m.top=(m.top||0)+(C-p)),{top:p,left:f,placement:s,arrowPosition:m}}function ye(o,e=100){let t=o.getBoundingClientRect(),n=Ne(),i=t.top<e,r=t.bottom>n.height-e,c=t.left<e,d=t.right>n.width-e;(i||r||c||d)&&o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function xe(o){if(!o)return null;if(o.css)try{let e=document.querySelector(o.css);if(e)return e}catch{}if(o.testId){let e=document.querySelector(`[data-testid="${o.testId}"]`);if(e)return e}if(o.xpath)try{let e=document.evaluate(o.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(e.singleNodeValue)return e.singleNodeValue}catch{}if(o.text){let e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t;for(;t=e.nextNode();)if(t.textContent?.includes(o.text))return t.parentElement}return null}function it(o,e=8){let t=o.getBoundingClientRect(),n={top:t.top-e,left:t.left-e,right:t.right+e,bottom:t.bottom+e,width:t.width+e*2,height:t.height+e*2};return `polygon(
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var kt="https://api.census.ai",ze=class{constructor(e){this.currentUserId=null;if(!e.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(r=>e.apiKey.startsWith(r))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=e.apiKey,this.baseUrl=e.baseUrl||kt,this.debug=e.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(e){if(!e.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=e.userId,await this.request("/api/sdk/identify","POST",{userId:e.userId,email:e.email,name:e.name,avatarUrl:e.avatarUrl,metadata:e.metadata,organizationId:e.organizationId,organizationName:e.organizationName,organizationDomain:e.organizationDomain,organizationPlan:e.organizationPlan}),this.log("User identified:",e.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(e){let t=["feedback","bug_report","feature_request","article_rating"];if(!e.type||!t.includes(e.type))throw new Error(`Census: type must be one of: ${t.join(", ")}`);if(e.type==="article_rating"){if(e.rating===void 0&&e.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!e.message)throw new Error("Census: message is required for this feedback type");let r=await this.request("/api/sdk/feedback","POST",{type:e.type,message:e.message,rating:e.rating,helpful:e.helpful,userId:this.currentUserId,articleId:e.articleId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:e.metadata});return this.log("Feedback submitted:",r.feedbackId),{feedbackId:r.feedbackId}}async getArticles(e){let t=new URLSearchParams;e?.category&&t.set("category",e.category),e?.search&&t.set("search",e.search),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let r=t.toString(),i=`/api/sdk/articles${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched articles:",n.articles.length),n}async getArticle(e){try{let t=await this.request(`/api/sdk/articles/${encodeURIComponent(e)}`,"GET");return this.log("Fetched article:",e),t.article}catch(t){if(t.status===404)return null;throw t}}async getFeatureGroups(){let e=await this.request("/api/sdk/feature-groups","GET");return this.log("Fetched feature groups:",e.feature_groups.length),e}async getRequests(e){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let t=new URLSearchParams;t.set("userId",this.currentUserId),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let r=await this.request(`/api/sdk/requests?${t.toString()}`,"GET");return this.log("Fetched requests:",r.requests.length),r}async track(e,t){if(!e)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:e,userId:this.currentUserId,properties:t}),this.log("Event tracked:",e);}async trackBatch(e){if(!e.events||e.events.length===0)throw new Error("Census: at least one event is required");if(e.events.length>100)throw new Error("Census: maximum 100 events per batch");let t=e.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:t}),this.log("Batch events tracked:",e.events.length);}async getGuides(e){let t=new URLSearchParams;e?.projectId&&t.set("project_id",e.projectId),e?.url&&t.set("url",e.url),e?.userId&&t.set("user_id",e.userId);let r=t.toString(),i=`/api/sdk/guides${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched guides:",n.guides.length),n}async getGuide(e){try{let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"GET");return this.log("Fetched guide:",e),t.guide}catch(t){if(t.status===404)return null;throw t}}async createGuide(e){if(!e.name||!e.slug)throw new Error("Census: name and slug are required for createGuide()");let t=await this.request("/api/sdk/guides","POST",{name:e.name,slug:e.slug,description:e.description,project_id:e.projectId,trigger_type:e.triggerType||"manual",trigger_config:e.triggerConfig||{},theme:e.theme||{},allow_skip:e.allowSkip??true,show_progress:e.showProgress??true});return this.log("Guide created:",t.guide.id),t.guide}async updateGuide(e,t){if(!e)throw new Error("Census: guideId is required for updateGuide()");let r={};t.name!==void 0&&(r.name=t.name),t.slug!==void 0&&(r.slug=t.slug),t.description!==void 0&&(r.description=t.description),t.triggerType!==void 0&&(r.trigger_type=t.triggerType),t.triggerConfig!==void 0&&(r.trigger_config=t.triggerConfig),t.theme!==void 0&&(r.theme=t.theme),t.allowSkip!==void 0&&(r.allow_skip=t.allowSkip),t.showProgress!==void 0&&(r.show_progress=t.showProgress),t.status!==void 0&&(r.status=t.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"PUT",r);return this.log("Guide updated:",e),i.guide}async deleteGuide(e){if(!e)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}`,"DELETE"),this.log("Guide deleted:",e);}async getGuideSteps(e){let t=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"GET");return this.log("Fetched steps for guide:",e),t.steps}async addGuideStep(e,t){if(!e)throw new Error("Census: guideId is required for addGuideStep()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"POST",{step_type:t.stepType||"tooltip",sort_order:t.sortOrder,selector_strategy:t.selectorStrategy||{},title:t.title,content:t.content,tooltip_position:t.tooltipPosition||"auto",rich_content:t.richContent||{},display_config:t.displayConfig||{},advance_config:t.advanceConfig||{trigger:"button"},style_config:t.styleConfig||{}});return this.log("Step added to guide:",e),r.step}async updateGuideStep(e,t,r){if(!e||!t)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(e)}/steps/${encodeURIComponent(t)}`,"PUT",i);return this.log("Step updated:",t),n.step}async deleteGuideStep(e,t){if(!e||!t)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}`,"DELETE"),this.log("Step deleted:",t);}async reorderGuideSteps(e,t){if(!e)throw new Error("Census: guideId is required for reorderGuideSteps()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(e)}/steps`,"PUT",{steps:t});return this.log("Steps reordered for guide:",e),r.steps}async trackGuideEvent(e){if(!e.guideId||!e.eventType||!e.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:e.guideId,eventType:e.eventType,stepId:e.stepId,stepIndex:e.stepIndex,pageUrl:e.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:e.sessionId,userId:e.userId||this.currentUserId,metadata:e.metadata}),this.log("Guide event tracked:",e.eventType,e.guideId);}async markGuideCompleted(e){if(!e)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:e,userId:this.currentUserId}),this.log("Guide marked completed:",e);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(e,t,r){let i=`${this.baseUrl}${e}`,n={"X-Census-Key":this.apiKey};r&&(n["Content-Type"]="application/json"),this.log(`${t} ${e}`,r);let p=await fetch(i,{method:t,headers:n,body:r?JSON.stringify(r):void 0});if(!p.ok){let d=`Request failed with status ${p.status}`;try{d=(await p.json()).error||d;}catch{}throw {error:d,status:p.status}}return p.json()}log(...e){this.debug&&console.log("[Census]",...e);}};function Ye(o){return new ze(o)}var Ae=react.createContext(null);function Pt({apiKey:o,baseUrl:e,debug:t,user:r,theme:i={},children:n}){let[p,d]=react.useState(false),[s,a]=react.useState(false),l=react.useMemo(()=>Ye({apiKey:o,baseUrl:e,debug:t}),[o,e,t]);react.useEffect(()=>{r?l.identify(r).then(()=>{a(true),d(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),d(true);}):d(true);},[l,r]);let c=react.useMemo(()=>({client:l,theme:i,isReady:p,isIdentified:s}),[l,i,p,s]);return jsxRuntime.jsx(Ae.Provider,{value:c,children:n})}function Et(){let o=react.useContext(Ae);if(!o)throw new Error("useCensus must be used within a CensusProvider");return o.client}function O(){let o=react.useContext(Ae);if(!o)throw new Error("useCensusContext must be used within a CensusProvider");return o}function Tt(){let{client:o}=O(),[e,t]=react.useState(false),[r,i]=react.useState(null);return {identify:async d=>{t(true),i(null);try{await o.identify(d);}catch(s){throw i(s instanceof Error?s:new Error("Failed to identify user")),s}finally{t(false);}},reset:()=>{o.reset();},isIdentifying:e,isIdentified:o.isIdentified(),error:r}}function Le(){let{client:o}=O(),[e,t]=react.useState(false),[r,i]=react.useState(false),[n,p]=react.useState(null),[d,s]=react.useState(null),a=react.useCallback(async c=>{t(true),i(false),p(null),s(null);try{let f=await o.submitFeedback(c);return s(f.feedbackId),i(!0),f}catch(f){let g=f instanceof Error?f:new Error("Failed to submit feedback");throw p(g),g}finally{t(false);}},[o]),l=react.useCallback(()=>{i(false),p(null),s(null);},[]);return {submitFeedback:a,reset:l,isSubmitting:e,isSuccess:r,error:n,feedbackId:d}}function ue(o){let{client:e,isReady:t}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,s]=react.useState(null),a=react.useCallback(async()=>{p(true),s(null);try{let l=await e.getArticles(o);i(l);}catch(l){s(l instanceof Error?l:new Error("Failed to fetch articles"));}finally{p(false);}},[e,o?.category,o?.search,o?.limit,o?.offset]);return react.useEffect(()=>{t&&a();},[t,a]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:d,refetch:a}}function fe(o){let{client:e,isReady:t}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,s]=react.useState(null),a=react.useCallback(async()=>{if(!o){i(null),p(false);return}p(true),s(null);try{let l=await e.getArticle(o);i(l);}catch(l){s(l instanceof Error?l:new Error("Failed to fetch article"));}finally{p(false);}},[e,o]);return react.useEffect(()=>{t&&a();},[t,a]),{article:r,isLoading:n,error:d,refetch:a}}function qe(){let{client:o,isReady:e}=O(),[t,r]=react.useState([]),[i,n]=react.useState(true),[p,d]=react.useState(null),s=react.useCallback(async()=>{n(true),d(null);try{let a=await o.getFeatureGroups();r(a.feature_groups);}catch(a){d(a instanceof Error?a:new Error("Failed to fetch feature groups"));}finally{n(false);}},[o]);return react.useEffect(()=>{e&&s();},[e,s]),{featureGroups:t,isLoading:i,error:p,refetch:s}}function ne(o){let{client:e,isReady:t,isIdentified:r}=O(),[i,n]=react.useState(null),[p,d]=react.useState(true),[s,a]=react.useState(null),l=react.useCallback(async()=>{if(!r){n(null),d(false);return}d(true),a(null);try{let c=await e.getRequests(o);n(c);}catch(c){a(c instanceof Error?c:new Error("Failed to fetch requests"));}finally{d(false);}},[e,r,o?.status,o?.type,o?.limit,o?.offset]);return react.useEffect(()=>{t&&r&&l();},[t,r,l]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:p,error:s,refetch:l}}function Bt(){let{client:o}=O(),e=react.useCallback(async(r,i)=>{await o.track(r,i);},[o]),t=react.useCallback(async r=>{await o.trackBatch({events:r});},[o]);return {track:e,trackBatch:t}}function Ft(o){let{client:e,isReady:t}=O(),[r,i]=react.useState(null),[n,p]=react.useState(true),[d,s]=react.useState(null),a=react.useCallback(async()=>{p(true),s(null);try{let l=await e.getGuides(o);i(l);}catch(l){s(l instanceof Error?l:new Error("Failed to fetch guides"));}finally{p(false);}},[e,o?.projectId,o?.url,o?.userId]);return react.useEffect(()=>{t&&a();},[t,a]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:d,refetch:a}}function Oe(){let{client:o,isReady:e}=O(),[t,r]=react.useState(null),[i,n]=react.useState([]),[p,d]=react.useState(false),[s,a]=react.useState(false),[l,c]=react.useState(null),[f,g]=react.useState(null),u=react.useRef(false),R=react.useCallback(async G=>{d(true),c(null);try{let y=await o.getGuide(G);return y&&(r(y),n(y.guide_steps||[]),g(y.guide_steps?.[0]?.id||null)),y}catch(y){return c(y instanceof Error?y:new Error("Failed to load guide")),null}finally{d(false);}},[o]),S=react.useCallback(async G=>{a(true),c(null);try{let y=await o.createGuide(G);return r(y),n([]),g(null),y}catch(y){throw c(y instanceof Error?y:new Error("Failed to create guide")),y}finally{a(false);}},[o]),x=react.useCallback(async G=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{let y=await o.updateGuide(t.id,G);return r(y),u.current=!1,y}catch(y){throw c(y instanceof Error?y:new Error("Failed to update guide")),y}finally{a(false);}},[o,t]),w=react.useCallback(async()=>x({status:"published"}),[x]),b=react.useCallback(async()=>x({status:"draft"}),[x]),v=react.useCallback(async()=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{await o.deleteGuide(t.id),r(null),n([]),g(null);}catch(G){throw c(G instanceof Error?G:new Error("Failed to delete guide")),G}finally{a(false);}},[o,t]),E=react.useCallback(async G=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{let y=await o.addGuideStep(t.id,G);return n(N=>[...N,y]),g(y.id),u.current=!0,y}catch(y){throw c(y instanceof Error?y:new Error("Failed to add step")),y}finally{a(false);}},[o,t]),k=react.useCallback(async(G,y)=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{let N=await o.updateGuideStep(t.id,G,y);return n(P=>P.map(D=>D.id===G?N:D)),u.current=!0,N}catch(N){throw c(N instanceof Error?N:new Error("Failed to update step")),N}finally{a(false);}},[o,t]),T=react.useCallback(async G=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{await o.deleteGuideStep(t.id,G),n(y=>y.filter(N=>N.id!==G)),f===G&&g(i[0]?.id||null),u.current=!0;}catch(y){throw c(y instanceof Error?y:new Error("Failed to delete step")),y}finally{a(false);}},[o,t,f,i]),m=react.useCallback(async G=>{if(!t)throw new Error("No guide loaded");a(true),c(null);try{let y=await o.reorderGuideSteps(t.id,G);return n(y),u.current=!0,y}catch(y){throw c(y instanceof Error?y:new Error("Failed to reorder steps")),y}finally{a(false);}},[o,t]),L=react.useCallback(async G=>{let y=i.findIndex(P=>P.id===G);if(y<=0)return;let N=i.map((P,D)=>D===y?{id:P.id,sort_order:y-1}:D===y-1?{id:P.id,sort_order:y}:{id:P.id,sort_order:D});return m(N)},[i,m]),U=react.useCallback(async G=>{let y=i.findIndex(P=>P.id===G);if(y<0||y>=i.length-1)return;let N=i.map((P,D)=>D===y?{id:P.id,sort_order:y+1}:D===y+1?{id:P.id,sort_order:y}:{id:P.id,sort_order:D});return m(N)},[i,m]),j=f&&i.find(G=>G.id===f)||null,_=react.useCallback(()=>{r(null),n([]),g(null),c(null),u.current=false;},[]);return {guide:t,steps:i,selectedStep:j,selectedStepId:f,isLoading:p,isSaving:s,error:l,isReady:e,hasUnsavedChanges:u.current,loadGuide:R,createGuide:S,updateGuide:x,publishGuide:w,unpublishGuide:b,deleteGuide:v,addStep:E,updateStep:k,deleteStep:T,reorderSteps:m,moveStepUp:L,moveStepDown:U,setSelectedStepId:g,reset:_}}function zt(){let{client:o,isReady:e}=O(),[t,r]=react.useState(null),[i,n]=react.useState(0),[p,d]=react.useState(false),[s,a]=react.useState([]),[l,c]=react.useState([]),f=react.useCallback((_,G=0)=>{r(_),n(G),d(true);},[]),g=react.useCallback(()=>{if(!t)return;let _=t.guide_steps||[];i<_.length-1?n(G=>G+1):(a(G=>[...G,t.id]),d(false),r(null));},[t,i]),u=react.useCallback(()=>{i>0&&n(_=>_-1);},[i]),R=react.useCallback(_=>{if(!t)return;let G=t.guide_steps||[];_>=0&&_<G.length&&n(_);},[t]),S=react.useCallback(()=>{t&&c(_=>[..._,t.id]),d(false),r(null),n(0);},[t]),x=react.useCallback(()=>{d(false);},[]),w=react.useCallback(()=>{t&&d(true);},[t]),b=react.useCallback(async(_,G)=>{let y=_.guide_steps?.[G];if(y)try{await o.track("guide_step_viewed",{guide_id:_.id,guide_name:_.name,step_id:y.id,step_index:G,step_type:y.step_type});}catch{}},[o]),v=react.useCallback(async _=>{try{await o.track("guide_completed",{guide_id:_.id,guide_name:_.name,total_steps:_.guide_steps?.length||0});}catch{}},[o]),E=react.useCallback(async(_,G)=>{try{await o.track("guide_dismissed",{guide_id:_.id,guide_name:_.name,dismissed_at_step:G,total_steps:_.guide_steps?.length||0});}catch{}},[o]),k=t?.guide_steps?.[i]||null,T=t?.guide_steps?.length||0,m=i===T-1,L=i===0,U=react.useCallback(_=>s.includes(_),[s]),j=react.useCallback(_=>l.includes(_),[l]);return {activeGuide:t,currentStep:k,currentStepIndex:i,totalSteps:T,isPlaying:p,isFirstStep:L,isLastStep:m,isReady:e,startGuide:f,nextStep:g,prevStep:u,goToStep:R,dismiss:S,pause:x,resume:w,trackStepView:b,trackGuideComplete:v,trackGuideDismiss:E,completedGuideIds:s,dismissedGuideIds:l,isGuideCompleted:U,isGuideDismissed:j}}var oe={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"}},At={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},Lt={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},qt={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function Ot(o){return {primaryColor:o.primaryColor||"#000000",textColor:o.textColor||"#333333",backgroundColor:o.backgroundColor||"#ffffff",borderRadius:o.borderRadius||"8px",fontFamily:o.fontFamily||"system-ui, -apple-system, sans-serif"}}function Dt({position:o="bottom-right",text:e="Feedback",allowedTypes:t=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:p}){let{theme:d}=O(),{submitFeedback:s,isSubmitting:a,isSuccess:l,reset:c}=Le(),[f,g]=react.useState(false),[u,R]=react.useState(t[0]),[S,x]=react.useState(""),w={...d,...r},b=Ot(w),v=react.useCallback(()=>{g(true),c();},[c]),E=react.useCallback(()=>{g(false),x(""),R(t[0]);},[t]),k=react.useCallback(async T=>{T.preventDefault();let m={type:u,message:S};try{await s(m),i?.(m),setTimeout(E,1500);}catch(L){n?.(L instanceof Error?L:new Error("Failed to submit feedback"));}},[u,S,s,i,n,E]);return p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:v,style:{cursor:"pointer"},children:p}),f&&jsxRuntime.jsx(Ze,{isOpen:f,onClose:E,selectedType:u,onTypeChange:R,allowedTypes:t,message:S,onMessageChange:x,onSubmit:k,isSubmitting:a,isSuccess:l,themeStyles:b})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:v,style:{...oe.button,...At[o],backgroundColor:b.primaryColor,color:"white",borderRadius:b.borderRadius,fontFamily:b.fontFamily},"aria-label":"Open feedback form",children:e}),f&&jsxRuntime.jsx(Ze,{isOpen:f,onClose:E,selectedType:u,onTypeChange:R,allowedTypes:t,message:S,onMessageChange:x,onSubmit:k,isSubmitting:a,isSuccess:l,themeStyles:b})]})}function Ze({isOpen:o,onClose:e,selectedType:t,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:p,onSubmit:d,isSubmitting:s,isSuccess:a,themeStyles:l}){return o?a?jsxRuntime.jsx("div",{style:oe.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...oe.modalContent,textAlign:"center",fontFamily:l.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:l.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:oe.modal,onClick:e,children:jsxRuntime.jsxs("div",{style:{...oe.modalContent,fontFamily:l.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:l.textColor},children:"Send Feedback"}),jsxRuntime.jsx("button",{onClick:e,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsxs("form",{onSubmit: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:{...oe.typeButton,backgroundColor:t===c?l.primaryColor:"white",color:t===c?"white":l.textColor,borderColor:t===c?l.primaryColor:"#e0e0e0"},children:[qt[c]," ",Lt[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:t==="bug_report"?"Describe the bug and steps to reproduce...":t==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:oe.textarea,required:true})]}),jsxRuntime.jsx("button",{type:"submit",disabled:s||!n.trim(),style:{...oe.submitButton,backgroundColor:l.primaryColor,color:"white",opacity:s||!n.trim()?.6:1,cursor:s||!n.trim()?"not-allowed":"pointer"},children:s?"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:"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 Ut(o){return {primaryColor:o.primaryColor||"#000000",textColor:o.textColor||"#333333",backgroundColor:o.backgroundColor||"#ffffff",borderRadius:o.borderRadius||"8px",fontFamily:o.fontFamily||"system-ui, -apple-system, sans-serif"}}function Nt({showSearch:o=true,showCategories:e=true,defaultCategory:t,theme:r,className:i,onArticleView:n}){let{theme:p}=O(),[d,s]=react.useState(""),[a,l]=react.useState(t),[c,f]=react.useState(null),g={...p,...r},u=Ut(g),{articles:R,isLoading:S,error:x}=ue({category:a,search:d||void 0}),{article:w,isLoading:b,error:v}=fe(c||""),E=react.useMemo(()=>{let m=new Set;return R.forEach(L=>{L.category&&m.add(L.category);}),Array.from(m).sort()},[R]),k=m=>{f(m.slug),n?.(m);},T=()=>{f(null);};return c?b?jsxRuntime.jsx("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:jsxRuntime.jsx("div",{style:q.loading,children:"Loading article..."})}):v?jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:T,style:q.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:q.error,children:"Failed to load article. Please try again."})]}):w?jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:T,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:w.title}),w.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[w.read_time_minutes," min read"]}),w.content_html?jsxRuntime.jsx("div",{style:{...q.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:w.content_html}}):jsxRuntime.jsx("div",{style:{...q.articleContent,color:u.textColor},children:typeof w.content=="string"?w.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{style:{...q.container,fontFamily:u.fontFamily},className:i,children:[jsxRuntime.jsx("button",{onClick:T,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:[o&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:d,onChange:m=>s(m.target.value),style:q.searchInput}),e&&E.length>0&&jsxRuntime.jsxs("div",{style:{marginBottom:"24px"},children:[jsxRuntime.jsx("button",{onClick:()=>l(void 0),style:{...q.categoryButton,backgroundColor:a?"white":u.primaryColor,color:a?u.textColor:"white",borderColor:a?"#e0e0e0":u.primaryColor},children:"All"}),E.map(m=>jsxRuntime.jsx("button",{onClick:()=>l(m),style:{...q.categoryButton,backgroundColor:a===m?u.primaryColor:"white",color:a===m?"white":u.textColor,borderColor:a===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),S&&jsxRuntime.jsx("div",{style:q.loading,children:"Loading articles..."}),x&&jsxRuntime.jsx("div",{style:q.error,children:"Failed to load articles. Please try again."}),!S&&!x&&R.length===0&&jsxRuntime.jsx("div",{style:q.empty,children:d?`No articles found for "${d}"`:"No articles available yet."}),!S&&!x&&R.length>0&&jsxRuntime.jsx("div",{children:R.map(m=>jsxRuntime.jsxs("div",{onClick:()=>k(m),style:q.articleCard,role:"button",tabIndex:0,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&k(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, 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"}},tt={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"}},ot={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 $t(o){return new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Vt({status:o,type:e,limit:t=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:p}=O(),[d,s]=react.useState(null),{requests:a,isLoading:l,error:c,refetch:f}=ne({status:o,type:e,limit:t}),g=react.useCallback(u=>{n?.(u);},[n]);return p?l?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:f,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):a.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:a.map(u=>{let R=tt[u.feedback_type]||tt.feedback,S=ot[u.status]||ot.new,x=d===u.id;return jsxRuntime.jsxs("li",{style:{...K.card,...x?K.cardHover:{}},onMouseEnter:()=>s(u.id),onMouseLeave:()=>s(null),onClick:()=>g(u),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&g(u);},children:[jsxRuntime.jsx("div",{style:K.header,children:jsxRuntime.jsxs("div",{style:K.badges,children:[jsxRuntime.jsx("span",{style:{...K.badge,color:R.color,backgroundColor:R.bg},children:R.label}),jsxRuntime.jsx("span",{style:{...K.badge,color:S.color,backgroundColor:S.bg},children:S.label})]})}),jsxRuntime.jsx("p",{style:K.message,children:u.message||"No message provided"}),jsxRuntime.jsxs("div",{style:K.meta,children:[jsxRuntime.jsx("span",{children:$t(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 h={container:{fontFamily:"system-ui, -apple-system, sans-serif",display:"flex",minHeight:"400px"},sidebar:{width:"240px",flexShrink:0,borderRight:"1px solid #e5e7eb",paddingRight:"16px",marginRight:"24px"},sidebarSection:{marginBottom:"24px"},sidebarLabel:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"#6b7280",marginBottom:"8px",paddingLeft:"8px"},sidebarItem:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"6px",cursor:"pointer",fontSize:"14px",color:"#374151",transition:"background-color 0.15s, color 0.15s",border:"none",background:"none",width:"100%",textAlign:"left"},sidebarItemActive:{backgroundColor:"#f3f4f6",color:"#111827",fontWeight:500},sidebarFeature:{padding:"6px 12px 6px 32px",fontSize:"13px"},sidebarBadge:{marginLeft:"auto",padding:"2px 6px",borderRadius:"9999px",fontSize:"11px",fontWeight:500,backgroundColor:"#e5e7eb",color:"#374151"},main:{flex:1,minWidth:0},tabs:{display:"flex",gap:"4px",marginBottom:"24px",borderBottom:"1px solid #e5e7eb"},tab:{padding:"12px 20px",border:"none",background:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,color:"#6b7280",borderBottom:"2px solid transparent",marginBottom:"-1px",transition:"color 0.15s, border-color 0.15s"},tabActive:{color:"#111827",borderBottomColor:"#111827"},tabBadge:{marginLeft:"6px",padding:"2px 6px",borderRadius:"9999px",fontSize:"11px",fontWeight:600,backgroundColor:"#e5e7eb",color:"#374151"},groupCardsGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px",marginBottom:"24px"},groupCard:{padding:"20px",border:"1px solid #e5e7eb",borderRadius:"12px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",backgroundColor:"white"},groupCardName:{fontSize:"16px",fontWeight:600,color:"#111827",margin:0},groupCardMeta:{fontSize:"13px",color:"#6b7280",marginTop:"4px"},searchInput:{width:"100%",padding:"10px 14px",border:"1px solid #e5e7eb",borderRadius:"8px",fontSize:"14px",marginBottom:"20px",boxSizing:"border-box"},articleCard:{padding:"16px",border:"1px solid #e5e7eb",borderRadius:"10px",marginBottom:"12px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",backgroundColor:"white"},articleTitle:{margin:"0 0 6px 0",fontSize:"15px",fontWeight:600},articleDescription:{margin:0,fontSize:"14px",color:"#6b7280",lineHeight:1.5},articleMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:"#9ca3af"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#6b7280",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},requestCard:{border:"1px solid #e5e7eb",borderRadius:"10px",padding:"16px",backgroundColor:"#ffffff",marginBottom:"12px",transition:"border-color 0.15s"},requestHeader:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},badge:{display:"inline-flex",alignItems:"center",padding:"3px 10px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},requestMessage:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:"#9ca3af"},sectionHeader:{marginBottom:"16px"},sectionTitle:{fontSize:"18px",fontWeight:600,color:"#111827",margin:"0 0 4px 0"},sectionDescription:{fontSize:"14px",color:"#6b7280",margin:0},loading:{textAlign:"center",padding:"40px",color:"#6b7280"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"10px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"48px 24px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 16px",color:"#d1d5db"}},rt={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Rating",color:"#7c3aed",bg:"#ede9fe"}},nt={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 Kt(o){return new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function jt(o){return {primaryColor:o.primaryColor||"#111827",textColor:o.textColor||"#111827",backgroundColor:o.backgroundColor||"#ffffff",borderRadius:o.borderRadius||"10px",fontFamily:o.fontFamily||"system-ui, -apple-system, sans-serif"}}var Xt={articles:"Articles",requests:"My Requests"};function Yt({group:o,onClick:e}){return jsxRuntime.jsxs("div",{style:h.groupCard,onClick:e,role:"button",tabIndex:0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&e();},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:h.groupCardName,children:o.name}),jsxRuntime.jsxs("p",{style:h.groupCardMeta,children:[o.feature_count," feature",o.feature_count!==1?"s":""," \xB7 ",o.article_count," article",o.article_count!==1?"s":""]})]}),o.description&&jsxRuntime.jsx("p",{style:{...h.articleDescription,marginTop:"8px"},children:o.description})]})}function it({featureId:o,featureName:e,showSearch:t,themeStyles:r,onArticleView:i,onBack:n}){let[p,d]=react.useState(""),[s,a]=react.useState(null),{articles:l,isLoading:c,error:f}=ue({search:p||void 0}),{article:g,isLoading:u,error:R}=fe(s||""),S=react.useMemo(()=>o?l.filter(b=>b.features?.id===o):l,[l,o]),x=b=>{a(b.slug),i?.(b);},w=()=>{a(null);};return s?u?jsxRuntime.jsx("div",{style:h.loading,children:"Loading article..."}):R?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{onClick:w,style:h.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:h.error,children:"Failed to load article."})]}):g?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{onClick:w,style:h.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsxs("article",{children:[jsxRuntime.jsx("h1",{style:{margin:"0 0 12px 0",fontSize:"24px",color:r.textColor},children:g.title}),g.read_time_minutes&&jsxRuntime.jsxs("div",{style:{fontSize:"14px",color:"#6b7280",marginBottom:"24px"},children:[g.read_time_minutes," min read"]}),g.content_html?jsxRuntime.jsx("div",{style:{...h.articleContent,color:r.textColor},dangerouslySetInnerHTML:{__html:g.content_html}}):jsxRuntime.jsx("div",{style:{...h.articleContent,color:r.textColor},children:typeof g.content=="string"?g.content:"No content available."})]})]}):jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{onClick:w,style:h.backButton,children:"\u2190 Back to articles"}),jsxRuntime.jsx("div",{style:h.empty,children:"Article not found."})]}):jsxRuntime.jsxs("div",{children:[e&&n&&jsxRuntime.jsxs("div",{style:h.sectionHeader,children:[jsxRuntime.jsx("button",{onClick:n,style:h.backButton,children:"\u2190 Back to features"}),jsxRuntime.jsx("h2",{style:h.sectionTitle,children:e}),jsxRuntime.jsx("p",{style:h.sectionDescription,children:"Documentation and guides for this feature"})]}),t&&jsxRuntime.jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:b=>d(b.target.value),style:h.searchInput}),c&&jsxRuntime.jsx("div",{style:h.loading,children:"Loading articles..."}),f&&jsxRuntime.jsx("div",{style:h.error,children:"Failed to load articles. Please try again."}),!c&&!f&&S.length===0&&jsxRuntime.jsxs("div",{style:h.empty,children:[jsxRuntime.jsx("svg",{style:h.emptyIcon,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"})}),jsxRuntime.jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:p?`No articles found for "${p}"`:"No articles yet"}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:"Check back soon for helpful content."})]}),!c&&!f&&S.length>0&&jsxRuntime.jsx("div",{children:S.map(b=>jsxRuntime.jsxs("div",{onClick:()=>x(b),style:h.articleCard,role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&x(b);},children:[jsxRuntime.jsx("h3",{style:{...h.articleTitle,color:r.textColor},children:b.title}),b.seo_description&&jsxRuntime.jsx("p",{style:h.articleDescription,children:b.seo_description}),jsxRuntime.jsxs("div",{style:h.articleMeta,children:[b.category&&jsxRuntime.jsx("span",{children:b.category}),b.read_time_minutes&&jsxRuntime.jsxs("span",{children:[b.read_time_minutes," min read"]})]})]},b.id))})]})}function Qt({onRequestClick:o}){let{isIdentified:e}=O(),{requests:t,isLoading:r,error:i,refetch:n}=ne({limit:50});return e?r?jsxRuntime.jsx("div",{style:h.loading,children:"Loading requests..."}):i?jsxRuntime.jsx("div",{style:h.error,children:jsxRuntime.jsxs("p",{children:["Failed to load requests."," ",jsxRuntime.jsx("button",{onClick:n,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):t.length===0?jsxRuntime.jsxs("div",{style:h.empty,children:[jsxRuntime.jsx("svg",{style:h.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",{children:t.map(p=>{let d=rt[p.feedback_type]||rt.feedback,s=nt[p.status]||nt.new;return jsxRuntime.jsxs("div",{style:h.requestCard,onClick:()=>o?.(p),role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:o?a=>{(a.key==="Enter"||a.key===" ")&&o(p);}:void 0,children:[jsxRuntime.jsxs("div",{style:h.requestHeader,children:[jsxRuntime.jsx("span",{style:{...h.badge,color:d.color,backgroundColor:d.bg},children:d.label}),jsxRuntime.jsx("span",{style:{...h.badge,color:s.color,backgroundColor:s.bg},children:s.label})]}),jsxRuntime.jsx("p",{style:h.requestMessage,children:p.message||"No message provided"}),jsxRuntime.jsxs("div",{style:h.requestMeta,children:[jsxRuntime.jsx("span",{children:Kt(p.created_at)}),p.page_url&&jsxRuntime.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",p.page_url]})]})]},p.id)})}):jsxRuntime.jsxs("div",{style:h.empty,children:[jsxRuntime.jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:"Sign in required"}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:"Please sign in to view your requests."})]})}function Jt({tabs:o=["articles","requests"],defaultTab:e,tabLabels:t,showSearch:r=true,showCategories:i=true,theme:n,className:p,onArticleView:d,onRequestClick:s,onTabChange:a}){let{theme:l}=O(),c={...l,...n},f=jt(c),g=e&&o.includes(e)?e:o[0],[u,R]=react.useState(g),[S,x]=react.useState(null),[w,b]=react.useState(null),{featureGroups:v,isLoading:E}=qe(),{requests:k}=ne({limit:100}),T=k.filter(P=>["new","reviewed","in_progress"].includes(P.status)).length,m={...Xt,...t},L=react.useMemo(()=>v.find(P=>P.id===S)||null,[v,S]),U=P=>{R(P),x(null),b(null),a?.(P);},j=P=>{x(P.id),b(null);},_=P=>{b(P);},G=()=>{x(null),b(null);},y=()=>{b(null);},N=o.length>1;return jsxRuntime.jsxs("div",{style:{...h.container,fontFamily:f.fontFamily},className:p,children:[u==="articles"&&v.length>0&&jsxRuntime.jsxs("div",{style:h.sidebar,children:[jsxRuntime.jsxs("div",{style:h.sidebarSection,children:[jsxRuntime.jsx("div",{style:h.sidebarLabel,children:"Resources"}),jsxRuntime.jsxs("button",{style:{...h.sidebarItem,...S?{}:h.sidebarItemActive},onClick:G,children:[jsxRuntime.jsx("span",{children:"\u{1F3E0}"}),jsxRuntime.jsx("span",{children:"All Features"})]})]}),jsxRuntime.jsxs("div",{style:h.sidebarSection,children:[jsxRuntime.jsx("div",{style:h.sidebarLabel,children:"Features"}),E?jsxRuntime.jsx("div",{style:{padding:"8px 12px",fontSize:"13px",color:"#6b7280"},children:"Loading..."}):v.map(P=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{style:{...h.sidebarItem,...S===P.id?h.sidebarItemActive:{}},onClick:()=>j(P),children:[jsxRuntime.jsx("span",{style:{flex:1},children:P.name}),jsxRuntime.jsx("span",{style:h.sidebarBadge,children:P.feature_count})]}),S===P.id&&jsxRuntime.jsx("div",{children:P.features.map(D=>jsxRuntime.jsxs("button",{style:{...h.sidebarItem,...h.sidebarFeature,...w?.id===D.id?h.sidebarItemActive:{}},onClick:()=>_(D),children:[D.name,D.article_count>0&&jsxRuntime.jsx("span",{style:h.sidebarBadge,children:D.article_count})]},D.id))})]},P.id))]})]}),jsxRuntime.jsxs("div",{style:h.main,children:[N&&jsxRuntime.jsx("div",{style:h.tabs,children:o.map(P=>jsxRuntime.jsxs("button",{onClick:()=>U(P),style:{...h.tab,...u===P?h.tabActive:{},...u===P?{borderBottomColor:f.primaryColor,color:f.primaryColor}:{}},children:[m[P],P==="requests"&&T>0&&jsxRuntime.jsx("span",{style:h.tabBadge,children:T})]},P))}),u==="articles"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!S&&!w&&v.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{style:h.sectionHeader,children:[jsxRuntime.jsx("h2",{style:h.sectionTitle,children:"Browse by Feature"}),jsxRuntime.jsx("p",{style:h.sectionDescription,children:"Select a feature group to find relevant documentation"})]}),jsxRuntime.jsx("div",{style:h.groupCardsGrid,children:v.map(P=>jsxRuntime.jsx(Yt,{group:P,onClick:()=>j(P)},P.id))})]}),L&&!w&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{style:h.sectionHeader,children:[jsxRuntime.jsx("button",{onClick:G,style:h.backButton,children:"\u2190 Back to all features"}),jsxRuntime.jsx("h2",{style:h.sectionTitle,children:L.name}),L.description&&jsxRuntime.jsx("p",{style:h.sectionDescription,children:L.description})]}),jsxRuntime.jsx("div",{style:h.groupCardsGrid,children:L.features.map(P=>jsxRuntime.jsxs("div",{style:h.groupCard,onClick:()=>_(P),role:"button",tabIndex:0,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&_(P);},children:[jsxRuntime.jsx("h3",{style:h.groupCardName,children:P.name}),jsxRuntime.jsxs("p",{style:h.groupCardMeta,children:[P.article_count," article",P.article_count!==1?"s":""]}),P.description&&jsxRuntime.jsx("p",{style:{...h.articleDescription,marginTop:"8px"},children:P.description})]},P.id))})]}),w&&jsxRuntime.jsx(it,{featureId:w.id,featureName:w.name,showSearch:r,themeStyles:f,onArticleView:d,onBack:y}),v.length===0&&jsxRuntime.jsx(it,{showSearch:r,themeStyles:f,onArticleView:d})]}),u==="requests"&&jsxRuntime.jsx(Qt,{onRequestClick:s})]})]})}var at={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner"},to={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"},oo=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],ro=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function lt({step:o,onUpdate:e,onSelectElement:t,isSelectingElement:r}){let[i,n]=react.useState(false),[p,d]=react.useState(o.step_type),[s,a]=react.useState(o.rich_content?.title||o.title||""),[l,c]=react.useState(o.rich_content?.body||o.content||""),[f,g]=react.useState(o.tooltip_position||o.display_config?.position||"auto"),[u,R]=react.useState(o.selector_strategy?.css||""),[S,x]=react.useState(o.display_config?.backdrop!==false),[w,b]=react.useState(o.advance_config?.trigger||"button"),[v,E]=react.useState(o.advance_config?.delay||3e3),k=react.useCallback(async()=>{n(true);try{let m=u?{css:u}:void 0,L={title:s||void 0,body:l||void 0},U={position:f!=="auto"?f:void 0,backdrop:S},j={trigger:w,delay:w==="delay"?v:void 0};await e(o.id,{stepType:p,selectorStrategy:m,richContent:L,displayConfig:U,advanceConfig:j,tooltipPosition:f});}finally{n(false);}},[o.id,p,s,l,f,u,S,w,v,e]),T=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:k,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(at).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:at[m]}),jsxRuntime.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:to[m]})]},m))})]}),T&&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=>R(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:t,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:s,onChange:m=>a(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:l,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:f,onChange:m=>g(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))})]}),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:f==="bottom"?"bottom":"top",onChange:m=>g(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:f==="left"?"left":"right",onChange:m=>g(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:S,onChange:m=>x(m.target.checked),style:{width:"16px",height:"16px"}}),jsxRuntime.jsx("span",{style:{fontSize:"13px",fontWeight:500},children:"Show backdrop overlay"})]}),jsxRuntime.jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px",marginLeft:"24px"},children:"Dims the background to focus attention on the step"})]}),jsxRuntime.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntime.jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Advance When"}),jsxRuntime.jsx("select",{value:w,onChange:m=>b(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:ro.map(m=>jsxRuntime.jsx("option",{value:m.value,children:m.label},m.value))})]}),w==="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:v/1e3,onChange:m=>E(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function io(o){let e={},t=o.getAttribute("data-testid");if(t)return e.testId=t,e.css=`[data-testid="${t}"]`,e;if(o.id)return e.css=`#${CSS.escape(o.id)}`,e;let r=[],i=o,n=0,p=5;for(;i&&i!==document.body&&n<p;){let s=i.tagName.toLowerCase(),a=Array.from(i.classList).filter(f=>!f.startsWith("hover")&&!f.startsWith("focus")&&!f.startsWith("active")).slice(0,2);a.length>0&&(s+="."+a.map(f=>CSS.escape(f)).join("."));let l=i.parentElement;if(l){let f=Array.from(l.children).filter(g=>g.tagName===i.tagName);if(f.length>1){let g=f.indexOf(i)+1;s+=`:nth-of-type(${g})`;}}r.unshift(s);let c=r.join(" > ");try{if(document.querySelectorAll(c).length===1){e.css=c;break}}catch{}i=i.parentElement,n++;}!e.css&&r.length>0&&(e.css=r.join(" > "));let d=o.textContent?.trim();return d&&d.length<100&&d.length>2&&(e.text=d.slice(0,50)),e}function so(o){let e=0;if(o.css)try{e=document.querySelectorAll(o.css).length;}catch{}return o.testId&&(e=document.querySelectorAll(`[data-testid="${o.testId}"]`).length),{isUnique:e===1,count:e}}function pt({isActive:o,onSelect:e,onCancel:t,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,p]=react.useState(null),[d,s]=react.useState(null),[a,l]=react.useState(null),c=react.useRef(null),f=react.useCallback(()=>{if(!n){s(null);return}s(n.getBoundingClientRect());},[n]);react.useEffect(()=>{if(!o)return;let R=x=>{let b=document.elementsFromPoint(x.clientX,x.clientY).find(v=>!(c.current?.contains(v)||r&&v.closest(r)||v===document.body||v===document.documentElement));b!==n&&(p(b||null),l(b?io(b):null));},S=()=>{f();};return document.addEventListener("mousemove",R,true),window.addEventListener("scroll",S,true),window.addEventListener("resize",S),()=>{document.removeEventListener("mousemove",R,true),window.removeEventListener("scroll",S,true),window.removeEventListener("resize",S);}},[o,n,r,f]),react.useEffect(()=>{f();},[n,f]);let g=react.useCallback(R=>{R.preventDefault(),R.stopPropagation(),n&&a&&e(a,n);},[n,a,e]);if(react.useEffect(()=>{if(!o)return;let R=S=>{S.key==="Escape"&&t();};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[o,t]),!o)return null;let u=a?so(a):null;return jsxRuntime.jsxs("div",{ref:c,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:g,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&&a&&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:a.testId?"data-testid: ":""}),a.testId||a.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:R=>{R.stopPropagation(),t();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function ao({isOpen:o,onClose:e,guideId:t,onSave:r,onPublish:i,trigger:n,className:p}){let[d,s]=react.useState(false),a=o??d,{guide:l,steps:c,selectedStep:f,selectedStepId:g,isLoading:u,isSaving:R,error:S,loadGuide:x,updateGuide:w,publishGuide:b,addStep:v,updateStep:E,deleteStep:k,moveStepUp:T,moveStepDown:m,setSelectedStepId:L,reset:U}=Oe(),j=react.useCallback(async()=>{s(true),t&&await x(t);},[t,x]),_=react.useCallback(()=>{s(false),U(),e?.();},[U,e]),G=react.useCallback(async()=>{if(l)try{await w({}),r?.(l);}catch{}},[l,w,r]),y=react.useCallback(async()=>{if(l)try{let P=await b();i?.(P);}catch{}},[l,b,i]),N=react.useCallback(async(P="tooltip")=>{try{await v({stepType:P,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[v]);return n&&o===void 0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{onClick:j,children:n}),a&&jsxRuntime.jsx(ct,{guide:l,steps:c,selectedStep:f,selectedStepId:g,isLoading:u,isSaving:R,error:S,onClose:_,onSave:G,onPublish:y,onAddStep:N,onSelectStep:L,onUpdateStep:E,onDeleteStep:k,onMoveStepUp:T,onMoveStepDown:m,className:p})]}):a?jsxRuntime.jsx(ct,{guide:l,steps:c,selectedStep:f,selectedStepId:g,isLoading:u,isSaving:R,error:S,onClose:_,onSave:G,onPublish:y,onAddStep:N,onSelectStep:L,onUpdateStep:E,onDeleteStep:k,onMoveStepUp:T,onMoveStepDown:m,className:p}):null}function ct({guide:o,steps:e,selectedStep:t,selectedStepId:r,isLoading:i,isSaving:n,error:p,onClose:d,onSave:s,onPublish:a,onAddStep:l,onSelectStep:c,onUpdateStep:f,onDeleteStep:g,onMoveStepUp:u,onMoveStepDown:R,className:S}){let[x,w]=react.useState(false),b={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner"},v=react.useCallback((E,k)=>{t&&f(t.id,{selectorStrategy:E}),w(false);},[t,f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(pt,{isActive:x,onSelect:v,onCancel:()=>w(false),ignoreSelector:"[data-census-builder]"}),jsxRuntime.jsxs("div",{className:S,"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:o?o.name:"Guide Builder"}),o?.status&&jsxRuntime.jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:o.status==="published"?"#dcfce7":"#fef3c7",color:o.status==="published"?"#166534":"#92400e"},children:o.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:s,disabled:n||!o,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:a,disabled:n||!o||o.status==="published",style:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:n?"wait":"pointer",opacity:n||o?.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 (",e.length,")"]}),jsxRuntime.jsx("button",{onClick:()=>l("tooltip"),disabled:!o,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:o?"pointer":"not-allowed",opacity:o?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..."}):e.length===0?jsxRuntime.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):e.map((E,k)=>jsxRuntime.jsxs("div",{onClick:()=>c(E.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===E.id?"#eff6ff":"white",border:`1px solid ${r===E.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:[k+1,". ",b[E.step_type]]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsxRuntime.jsx("button",{onClick:T=>{T.stopPropagation(),u(E.id);},disabled:k===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:k===0?"not-allowed":"pointer",opacity:k===0?.3:1},children:"Up"}),jsxRuntime.jsx("button",{onClick:T=>{T.stopPropagation(),R(E.id);},disabled:k===e.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:k===e.length-1?"not-allowed":"pointer",opacity:k===e.length-1?.3:1},children:"Down"}),jsxRuntime.jsx("button",{onClick:T=>{T.stopPropagation(),confirm("Delete this step?")&&g(E.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:E.rich_content?.title||E.title||"Untitled"})]},E.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:t?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:b[t.step_type]})}),jsxRuntime.jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:t.rich_content?.title||t.title||"Step Preview"}),jsxRuntime.jsx("p",{style:{margin:0,color:"#4b5563"},children:t.rich_content?.body||t.content||"No content"}),t.rich_content?.media&&jsxRuntime.jsx("div",{style:{marginTop:"12px"},children:t.rich_content.media.type==="image"&&jsxRuntime.jsx("img",{src:t.rich_content.media.url,alt:t.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),t.rich_content?.buttons&&t.rich_content.buttons.length>0&&jsxRuntime.jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:t.rich_content.buttons.map((E,k)=>jsxRuntime.jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:E.style==="primary"?"#2563eb":"#f3f4f6",color:E.style==="primary"?"white":"#374151"},children:E.label},k))}),t.selector_strategy?.css&&jsxRuntime.jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",t.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:t?jsxRuntime.jsx(lt,{step:t,onUpdate:f,onSelectElement:()=>w(true),isSelectingElement:x}):jsxRuntime.jsx("div",{style:{padding:"16px"},children:jsxRuntime.jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function $e(o){let e=o.getBoundingClientRect();return {top:e.top+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX,bottom:e.bottom+window.scrollY,width:e.width,height:e.height}}function Ve(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function He(o,e,t,r,i){let n=Ve(),{scrollX:p,scrollY:d,width:s,height:a}=n;switch(r){case "top":return o.top-d-t-i>0&&o.left-p+o.width/2-e/2>0&&o.left-p+o.width/2+e/2<s;case "bottom":return o.bottom-d+t+i<a&&o.left-p+o.width/2-e/2>0&&o.left-p+o.width/2+e/2<s;case "left":return o.left-p-e-i>0&&o.top-d+o.height/2-t/2>0&&o.top-d+o.height/2+t/2<a;case "right":return o.right-p+e+i<s&&o.top-d+o.height/2-t/2>0&&o.top-d+o.height/2+t/2<a;default:return true}}function lo(o,e,t,r){let i=["bottom","top","right","left"];for(let n of i)if(He(o,e,t,n,r))return n;return "bottom"}function we(o,e,t,r){let{preferredPosition:i,offset:n={x:0,y:0},containerPadding:p=10,arrowSize:d=8}=r,s=$e(o),a=Ve(),l=i;if(i==="auto")l=lo(s,e,t,p);else if(!He(s,e,t,i,p)){let k={top:"bottom",bottom:"top",left:"right",right:"left"}[i];k&&He(s,e,t,k,p)&&(l=k);}let c=0,f=0,g={},u=d+4;switch(l){case "top":c=s.top-t-u+n.y,f=s.left+s.width/2-e/2+n.x,g={left:e/2-d/2,top:t,transform:"rotate(180deg)"};break;case "bottom":c=s.bottom+u+n.y,f=s.left+s.width/2-e/2+n.x,g={left:e/2-d/2,top:-d};break;case "left":c=s.top+s.height/2-t/2+n.y,f=s.left-e-u+n.x,g={top:t/2-d/2,left:e,transform:"rotate(-90deg)"};break;case "right":c=s.top+s.height/2-t/2+n.y,f=s.right+u+n.x,g={top:t/2-d/2,left:-d,transform:"rotate(90deg)"};break}let R=a.scrollX+p,S=a.scrollX+a.width-e-p,x=a.scrollY+p,w=a.scrollY+a.height-t-p,b=f;f=Math.max(R,Math.min(S,f)),(l==="top"||l==="bottom")&&(g.left=(g.left||0)+(b-f));let v=c;return c=Math.max(x,Math.min(w,c)),(l==="left"||l==="right")&&(g.top=(g.top||0)+(v-c)),{top:c,left:f,placement:l,arrowPosition:g}}function ke(o,e=100){let t=o.getBoundingClientRect(),r=Ve(),i=t.top<e,n=t.bottom>r.height-e,p=t.left<e,d=t.right>r.width-e;(i||n||p||d)&&o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function Ge(o){if(!o)return null;if(o.css)try{let e=document.querySelector(o.css);if(e)return e}catch{}if(o.testId){let e=document.querySelector(`[data-testid="${o.testId}"]`);if(e)return e}if(o.xpath)try{let e=document.evaluate(o.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(e.singleNodeValue)return e.singleNodeValue}catch{}if(o.text){let e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t;for(;t=e.nextNode();)if(t.textContent?.includes(o.text))return t.parentElement}return null}function gt(o,e=8){let t=o.getBoundingClientRect(),r={top:t.top-e,left:t.left-e,right:t.right+e,bottom:t.bottom+e,width:t.width+e*2,height:t.height+e*2};return `polygon(
2
2
  0 0,
3
3
  100% 0,
4
4
  100% 100%,
5
5
  0 100%,
6
6
  0 0,
7
- ${n.left}px ${n.top}px,
8
- ${n.left}px ${n.bottom}px,
9
- ${n.right}px ${n.bottom}px,
10
- ${n.right}px ${n.top}px,
11
- ${n.left}px ${n.top}px
12
- )`}function Q({visible:o,spotlightElement:e,spotlightPadding:t=8,onClick:n,dismissOnClick:i=false,zIndex:r=9998,opacity:c=.5}){let[d,a]=react.useState(),l=react.useCallback(()=>{a(e?it(e,t):void 0);},[e,t]);return react.useEffect(()=>{if(o)return l(),window.addEventListener("scroll",l,true),window.addEventListener("resize",l),()=>{window.removeEventListener("scroll",l,true),window.removeEventListener("resize",l);}},[o,l]),o?jsxRuntime.jsx("div",{onClick:p=>{i&&n&&n(),p.stopPropagation();},style:{position:"fixed",inset:0,zIndex:r,backgroundColor:`rgba(0, 0, 0, ${c})`,clipPath:d,transition:"clip-path 0.2s ease-out",cursor:i?"pointer":"default",pointerEvents:"auto"},"aria-hidden":"true"}):null}function W({buttons:o,currentStep:e,isLastStep:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,accentColor:d="#2563eb"}){if(!o||o.length===0)return jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsxRuntime.jsx("div",{children:e>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:t?r:n,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:d,color:"white",cursor:"pointer"},children:t?"Done":"Next"})]});let a=s=>{switch(s.action){case "next":n();break;case "prev":i();break;case "dismiss":r();break;case "url":s.url&&window.open(s.url,"_blank","noopener,noreferrer");break;case "custom":s.customAction&&c&&c(s.customAction);break}},l=s=>{switch(s){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:o.map((s,p)=>jsxRuntime.jsx("button",{onClick:()=>a(s),style:l(s.style),children:s.label},p))})}function H({step:o,textColor:e="#1f2937",showTitle:t=true}){let n=o.rich_content,i=n?.title||o.title,r=n?.body||o.content;return jsxRuntime.jsxs("div",{children:[t&&i&&jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:e,lineHeight:1.4},children:i}),r&&jsxRuntime.jsx("div",{style:{fontSize:"14px",color:e,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:r.includes("<")?{__html:Jt(r)}:void 0,children:r.includes("<")?null:r}),n?.media&&jsxRuntime.jsxs("div",{style:{marginTop:"12px"},children:[n.media.type==="image"&&jsxRuntime.jsx("img",{src:n.media.url,alt:n.media.alt||"",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}),n.media.type==="video"&&jsxRuntime.jsx("video",{src:n.media.url,controls:true,style:{maxWidth:"100%",height:"auto",borderRadius:"4px"},children:"Your browser does not support the video tag."})]})]})}function Jt(o){let e=["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 o.replace(/<[^>]*>/g,"");let t=document.createElement("div");return t.innerHTML=o,t.querySelectorAll("script").forEach(r=>r.remove()),t.querySelectorAll("*").forEach(r=>{if(!e.includes(r.tagName.toLowerCase())){let d=document.createTextNode(r.textContent||"");r.parentNode?.replaceChild(d,r);return}Array.from(r.attributes).forEach(d=>{let a=d.name.toLowerCase();if(a.startsWith("on")&&r.removeAttribute(d.name),a==="href"||a==="src"){let s=d.value.toLowerCase().trim();(s.startsWith("javascript:")||s.startsWith("data:"))&&r.removeAttribute(d.name);}["href","target","rel","class","style"].includes(a)||r.removeAttribute(d.name);}),r.tagName.toLowerCase()==="a"&&(r.setAttribute("rel","noopener noreferrer"),r.setAttribute("target","_blank"));}),t.innerHTML}function de({step:o,currentStep:e,totalSteps:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,showProgress:d=true,globalStyle:a,zIndex:l=9999}){let s=react.useRef(null),[p,f]=react.useState(null),[m,u]=react.useState(null),[S,w]=react.useState(false),y={...a,...o.style_config},G=y.backgroundColor||"white",v=y.textColor||"#1f2937",C=y.accentColor||"#2563eb",k=y.borderRadius||8;react.useEffect(()=>{let P=xe(o.selector_strategy);f(P),P&&ye(P,120);},[o.selector_strategy]);let x=react.useCallback(()=>{if(!p||!s.current)return;let P=s.current.getBoundingClientRect(),g=be(p,P.width,P.height,{preferredPosition:o.tooltip_position||o.display_config?.position||"auto",offset:o.display_config?.offset,arrowSize:8});u(g),w(true);},[p,o.tooltip_position,o.display_config]);return react.useEffect(()=>{let P=setTimeout(x,10);return window.addEventListener("scroll",x,true),window.addEventListener("resize",x),()=>{clearTimeout(P),window.removeEventListener("scroll",x,true),window.removeEventListener("resize",x);}},[x]),p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{visible:o.display_config?.backdrop!==false,spotlightElement:p,spotlightPadding:o.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxRuntime.jsxs("div",{ref:s,style:{position:"absolute",top:m?.top||0,left:m?.left||0,zIndex:l,padding:"16px 20px",backgroundColor:G,color:v,borderRadius:k,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:o.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:S?1:0,transition:"opacity 0.15s ease-out"},children:[m&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${G}`,top:m.arrowPosition.top,left:m.arrowPosition.left,transform:m.arrowPosition.transform}}),jsxRuntime.jsx(H,{step:o,textColor:v}),d&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(W,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,accentColor:C})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{visible:true}),jsxRuntime.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:l,padding:"24px",backgroundColor:G,color:v,borderRadius:k,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(H,{step:o,textColor:v}),d&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(W,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,accentColor:C})]})]})}function ve({step:o,currentStep:e,totalSteps:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,showProgress:d=true,globalStyle:a,zIndex:l=9999}){let s={...a,...o.style_config},p=s.backgroundColor||"white",f=s.textColor||"#1f2937",m=s.accentColor||"#2563eb",u=s.borderRadius||12,S=o.display_config||{},w=S.width||480,y=S.position||"center",G=S.backdrop!==false;return react.useEffect(()=>{let C=k=>{k.key==="Escape"&&r();};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r]),react.useEffect(()=>{let C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C;}},[]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{visible:true,onClick:G?r:void 0,dismissOnClick:G,opacity:.6}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(y){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:l,width:"90%",maxWidth:w,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:p,color:f,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:r,"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:C=>C.currentTarget.style.color="#6b7280",onMouseLeave:C=>C.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsxRuntime.jsx(H,{step:o,textColor:f}),d&&t>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:t}).map((C,k)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:k===e?m:"#e5e7eb",transition:"background-color 0.15s"}},k))}),jsxRuntime.jsx(W,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,accentColor:m})]})]})}function Se({step:o,currentStep:e,totalSteps:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,showProgress:d=true,globalStyle:a,zIndex:l=9999}){let[s,p]=react.useState(true),f={...a,...o.style_config},m=f.backgroundColor||"white",u=f.textColor||"#1f2937",S=f.accentColor||"#2563eb",w=f.borderRadius||0,y=o.display_config||{},G=y.width||400,v=y.position==="left"?"left":"right",C=y.backdrop!==false;return react.useEffect(()=>{let x=setTimeout(()=>p(false),50);return ()=>clearTimeout(x)},[]),react.useEffect(()=>{let x=P=>{P.key==="Escape"&&r();};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[r]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[C&&jsxRuntime.jsx(Q,{visible:true,onClick:r,dismissOnClick:true,opacity:.4}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let x={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:G,zIndex:l,backgroundColor:m,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"?{...x,right:0,borderTopLeftRadius:w,borderBottomLeftRadius:w,transform:s?"translateX(100%)":"translateX(0)"}:{...x,left:0,borderTopRightRadius:w,borderBottomRightRadius:w,transform:s?"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:m,zIndex:1},children:[jsxRuntime.jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:o.rich_content?.title||o.title||"Guide"}),jsxRuntime.jsx("button",{onClick:r,"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(H,{step:o,textColor:u,showTitle:false}),d&&t>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",e+1," of ",t]})]}),jsxRuntime.jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:m},children:jsxRuntime.jsx(W,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,accentColor:S})})]})]})}function we({step:o,currentStep:e,totalSteps:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,showProgress:d=true,globalStyle:a,zIndex:l=9999}){let s=react.useRef(null),[p,f]=react.useState(null),[m,u]=react.useState(false),[S,w]=react.useState({top:0,left:0}),[y,G]=react.useState(null),v={...a,...o.style_config},C=v.backgroundColor||"white",k=v.textColor||"#1f2937",x=v.accentColor||"#2563eb",P=v.borderRadius||8,g=o.display_config||{};react.useEffect(()=>{let h=xe(o.selector_strategy);f(h),h&&ye(h,120);},[o.selector_strategy]);let L=react.useCallback(()=>{if(!p)return;let h=De(p);w({top:h.top-8,left:h.right-8});},[p]),V=react.useCallback(()=>{if(!p||!s.current||!m)return;let h=s.current.getBoundingClientRect(),b=be(p,h.width,h.height,{preferredPosition:o.tooltip_position||"auto",offset:o.display_config?.offset,arrowSize:8});G(b);},[p,m,o.tooltip_position,o.display_config?.offset]);if(react.useEffect(()=>(L(),m&&setTimeout(V,10),window.addEventListener("scroll",L,true),window.addEventListener("resize",L),()=>{window.removeEventListener("scroll",L,true),window.removeEventListener("resize",L);}),[L,V,m]),react.useEffect(()=>{if(!m)return;let h=b=>{s.current&&!s.current.contains(b.target)&&u(false);};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[m]),!p)return null;let E=`
7
+ ${r.left}px ${r.top}px,
8
+ ${r.left}px ${r.bottom}px,
9
+ ${r.right}px ${r.bottom}px,
10
+ ${r.right}px ${r.top}px,
11
+ ${r.left}px ${r.top}px
12
+ )`}function ee({visible:o,spotlightElement:e,spotlightPadding:t=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:p=.5}){let[d,s]=react.useState(),a=react.useCallback(()=>{s(e?gt(e,t):void 0);},[e,t]);return react.useEffect(()=>{if(o)return a(),window.addEventListener("scroll",a,true),window.addEventListener("resize",a),()=>{window.removeEventListener("scroll",a,true),window.removeEventListener("resize",a);}},[o,a]),o?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:o,currentStep:e,isLastStep:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:d="#2563eb"}){if(!o||o.length===0)return jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsxRuntime.jsx("div",{children:e>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:t?n:r,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:d,color:"white",cursor:"pointer"},children:t?"Done":"Next"})]});let s=l=>{switch(l.action){case "next":r();break;case "prev":i();break;case "dismiss":n();break;case "url":l.url&&window.open(l.url,"_blank","noopener,noreferrer");break;case "custom":l.customAction&&p&&p(l.customAction);break}},a=l=>{switch(l){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:o.map((l,c)=>jsxRuntime.jsx("button",{onClick:()=>s(l),style:a(l.style),children:l.label},c))})}function Y({step:o,textColor:e="#1f2937",showTitle:t=true}){let r=o.rich_content,i=r?.title||o.title,n=r?.body||o.content;return jsxRuntime.jsxs("div",{children:[t&&i&&jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:e,lineHeight:1.4},children:i}),n&&jsxRuntime.jsx("div",{style:{fontSize:"14px",color:e,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:n.includes("<")?{__html:mo(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 mo(o){let e=["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 o.replace(/<[^>]*>/g,"");let t=document.createElement("div");return t.innerHTML=o,t.querySelectorAll("script").forEach(n=>n.remove()),t.querySelectorAll("*").forEach(n=>{if(!e.includes(n.tagName.toLowerCase())){let d=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(d,n);return}Array.from(n.attributes).forEach(d=>{let s=d.name.toLowerCase();if(s.startsWith("on")&&n.removeAttribute(d.name),s==="href"||s==="src"){let l=d.value.toLowerCase().trim();(l.startsWith("javascript:")||l.startsWith("data:"))&&n.removeAttribute(d.name);}["href","target","rel","class","style"].includes(s)||n.removeAttribute(d.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),t.innerHTML}function ye({step:o,currentStep:e,totalSteps:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:s,zIndex:a=9999}){let l=react.useRef(null),[c,f]=react.useState(null),[g,u]=react.useState(null),[R,S]=react.useState(false),x={...s,...o.style_config},w=x.backgroundColor||"white",b=x.textColor||"#1f2937",v=x.accentColor||"#2563eb",E=x.borderRadius||8;react.useEffect(()=>{let T=Ge(o.selector_strategy);f(T),T&&ke(T,120);},[o.selector_strategy]);let k=react.useCallback(()=>{if(!c||!l.current)return;let T=l.current.getBoundingClientRect(),m=we(c,T.width,T.height,{preferredPosition:o.tooltip_position||o.display_config?.position||"auto",offset:o.display_config?.offset,arrowSize:8});u(m),S(true);},[c,o.tooltip_position,o.display_config]);return react.useEffect(()=>{let T=setTimeout(k,10);return window.addEventListener("scroll",k,true),window.addEventListener("resize",k),()=>{clearTimeout(T),window.removeEventListener("scroll",k,true),window.removeEventListener("resize",k);}},[k]),c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ee,{visible:o.display_config?.backdrop!==false,spotlightElement:c,spotlightPadding:o.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxRuntime.jsxs("div",{ref:l,style:{position:"absolute",top:g?.top||0,left:g?.left||0,zIndex:a,padding:"16px 20px",backgroundColor:w,color:b,borderRadius:E,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:o.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:R?1:0,transition:"opacity 0.15s ease-out"},children:[g&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${w}`,top:g.arrowPosition.top,left:g.arrowPosition.left,transform:g.arrowPosition.transform}}),jsxRuntime.jsx(Y,{step:o,textColor:b}),d&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(X,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:v})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ee,{visible:true}),jsxRuntime.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:a,padding:"24px",backgroundColor:w,color:b,borderRadius:E,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:o,textColor:b}),d&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(X,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:v})]})]})}function Pe({step:o,currentStep:e,totalSteps:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:s,zIndex:a=9999}){let l={...s,...o.style_config},c=l.backgroundColor||"white",f=l.textColor||"#1f2937",g=l.accentColor||"#2563eb",u=l.borderRadius||12,R=o.display_config||{},S=R.width||480,x=R.position||"center",w=R.backdrop!==false;return react.useEffect(()=>{let v=E=>{E.key==="Escape"&&n();};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]),react.useEffect(()=>{let v=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=v;}},[]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ee,{visible:true,onClick:w?n:void 0,dismissOnClick:w,opacity:.6}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(x){case "top":return {top:"10%",left:"50%",transform:"translateX(-50%)"};case "bottom":return {bottom:"10%",left:"50%",transform:"translateX(-50%)"};default:return {top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}})(),zIndex:a,width:"90%",maxWidth:S,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:c,color:f,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:v=>v.currentTarget.style.color="#6b7280",onMouseLeave:v=>v.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsxRuntime.jsx(Y,{step:o,textColor:f}),d&&t>1&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:t}).map((v,E)=>jsxRuntime.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:E===e?g:"#e5e7eb",transition:"background-color 0.15s"}},E))}),jsxRuntime.jsx(X,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:g})]})]})}function Ee({step:o,currentStep:e,totalSteps:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:s,zIndex:a=9999}){let[l,c]=react.useState(true),f={...s,...o.style_config},g=f.backgroundColor||"white",u=f.textColor||"#1f2937",R=f.accentColor||"#2563eb",S=f.borderRadius||0,x=o.display_config||{},w=x.width||400,b=x.position==="left"?"left":"right",v=x.backdrop!==false;return react.useEffect(()=>{let k=setTimeout(()=>c(false),50);return ()=>clearTimeout(k)},[]),react.useEffect(()=>{let k=T=>{T.key==="Escape"&&n();};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[v&&jsxRuntime.jsx(ee,{visible:true,onClick:n,dismissOnClick:true,opacity:.4}),jsxRuntime.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let k={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:w,zIndex:a,backgroundColor:g,color:u,boxShadow:b==="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 b==="right"?{...k,right:0,borderTopLeftRadius:S,borderBottomLeftRadius:S,transform:l?"translateX(100%)":"translateX(0)"}:{...k,left:0,borderTopRightRadius:S,borderBottomRightRadius:S,transform:l?"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:g,zIndex:1},children:[jsxRuntime.jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:o.rich_content?.title||o.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:o,textColor:u,showTitle:false}),d&&t>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",e+1," of ",t]})]}),jsxRuntime.jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:g},children:jsxRuntime.jsx(X,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,accentColor:R})})]})]})}function _e({step:o,currentStep:e,totalSteps:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:s,zIndex:a=9999}){let l=react.useRef(null),[c,f]=react.useState(null),[g,u]=react.useState(false),[R,S]=react.useState({top:0,left:0}),[x,w]=react.useState(null),b={...s,...o.style_config},v=b.backgroundColor||"white",E=b.textColor||"#1f2937",k=b.accentColor||"#2563eb",T=b.borderRadius||8,m=o.display_config||{};react.useEffect(()=>{let G=Ge(o.selector_strategy);f(G),G&&ke(G,120);},[o.selector_strategy]);let U=react.useCallback(()=>{if(!c)return;let G=$e(c);S({top:G.top-8,left:G.right-8});},[c]),j=react.useCallback(()=>{if(!c||!l.current||!g)return;let G=l.current.getBoundingClientRect(),y=we(c,G.width,G.height,{preferredPosition:o.tooltip_position||"auto",offset:o.display_config?.offset,arrowSize:8});w(y);},[c,g,o.tooltip_position,o.display_config?.offset]);if(react.useEffect(()=>(U(),g&&setTimeout(j,10),window.addEventListener("scroll",U,true),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,true),window.removeEventListener("resize",U);}),[U,j,g]),react.useEffect(()=>{if(!g)return;let G=y=>{l.current&&!l.current.contains(y.target)&&u(false);};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[g]),!c)return null;let _=`
13
13
  @keyframes census-hotspot-pulse {
14
14
  0% {
15
15
  transform: scale(1);
16
- box-shadow: 0 0 0 0 ${x}66;
16
+ box-shadow: 0 0 0 0 ${k}66;
17
17
  }
18
18
  70% {
19
19
  transform: scale(1.1);
20
- box-shadow: 0 0 0 10px ${x}00;
20
+ box-shadow: 0 0 0 10px ${k}00;
21
21
  }
22
22
  100% {
23
23
  transform: scale(1);
24
- box-shadow: 0 0 0 0 ${x}00;
24
+ box-shadow: 0 0 0 0 ${k}00;
25
25
  }
26
26
  }
27
- `;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:E}}),jsxRuntime.jsx("button",{onClick:()=>u(!m),"aria-label":"Show more information","aria-expanded":m,style:{position:"absolute",top:S.top,left:S.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:x,color:"white",cursor:"pointer",zIndex:l,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,animation:!m?"census-hotspot-pulse 2s infinite":"none",transition:"transform 0.15s"},children:"?"}),m&&jsxRuntime.jsxs("div",{ref:s,style:{position:"absolute",top:y?.top||S.top+30,left:y?.left||S.left-140,zIndex:l+1,padding:"16px 20px",backgroundColor:C,color:k,borderRadius:P,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:g.width||300,fontFamily:"system-ui, -apple-system, sans-serif"},children:[y&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${C}`,top:y.arrowPosition.top,left:y.arrowPosition.left,transform:y.arrowPosition.transform}}),jsxRuntime.jsx(H,{step:o,textColor:k}),d&&t>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(W,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:()=>{u(false),n();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),r();},onCustomAction:c,accentColor:x})]})]})}var ke={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 Ge({step:o,currentStep:e,totalSteps:t,onNext:n,onPrev:i,onDismiss:r,onCustomAction:c,showProgress:d=true,globalStyle:a,zIndex:l=9999}){let [s,p]=react.useState(true),[f,m]=react.useState(true),u={...a,...o.style_config},w=(o.display_config||{}).bannerPosition||"top",y="custom",G=u.backgroundColor||ke[y].bg,v=u.textColor||ke[y].text;react.useEffect(()=>{let L=setTimeout(()=>p(false),50);return ()=>clearTimeout(L)},[]);let k=()=>{p(true),setTimeout(()=>{m(false),r();},200);};if(!f)return null;let x=o.rich_content,P=x?.title||o.title,g=x?.body||o.content,z=x?.buttons&&x.buttons.length>0;return jsxRuntime.jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[w]:0,zIndex:l,padding:"12px 20px",backgroundColor:G,color:v,boxShadow:w==="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:s?w==="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:[ke[y].icon,jsxRuntime.jsxs("div",{style:{flex:1},children:[P&&jsxRuntime.jsx("strong",{style:{display:"block",marginBottom:g?"2px":0},children:P}),g&&jsxRuntime.jsx("span",{style:{opacity:.9,fontSize:"14px"},children:g})]}),d&&t>1&&jsxRuntime.jsxs("span",{style:{fontSize:"12px",opacity:.7,flexShrink:0},children:[e+1,"/",t]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[z?jsxRuntime.jsx(W,{buttons:x.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:n,onPrev:i,onDismiss:k,onCustomAction:c,accentColor:"white"}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e<t-1?jsxRuntime.jsx("button",{onClick:n,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:k,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:k,"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"})]})]})})}function po({guide:o,onComplete:e,onDismiss:t,onStepChange:n,onCustomAction:i,globalStyle:r,startStep:c=0,zIndex:d=9999}){let[a,l]=react.useState(c),[s,p]=react.useState(true),f=o.guide_steps||[],m=f.length,u=f[a];react.useEffect(()=>{n?.(a,m);},[a,m,n]);let S=react.useCallback(()=>{a<m-1?l(C=>C+1):(p(false),e?.(o));},[a,m,o,e]),w=react.useCallback(()=>{a>0&&l(C=>C-1);},[a]),y=react.useCallback(()=>{p(false),t?.(o,a);},[o,a,t]),G=react.useCallback(C=>{u&&i?.(C,u);},[u,i]);if(!s||!u||f.length===0)return null;let v={step:u,currentStep:a,totalSteps:m,onNext:S,onPrev:w,onDismiss:y,onCustomAction:G,showProgress:o.show_progress!==false,globalStyle:{...o.theme,...r},zIndex:d};switch(u.step_type){case "tooltip":return jsxRuntime.jsx(de,{...v});case "modal":return jsxRuntime.jsx(ve,{...v});case "slideout":return jsxRuntime.jsx(Se,{...v});case "hotspot":return jsxRuntime.jsx(we,{...v});case "banner":return jsxRuntime.jsx(Ge,{...v});default:return jsxRuntime.jsx(de,{...v})}}exports.Backdrop=Q;exports.BannerStep=Ge;exports.CensusProvider=xt;exports.FeedbackButton=It;exports.GuideBuilder=Ht;exports.GuideRenderer=po;exports.HotspotStep=we;exports.KnowledgeBase=zt;exports.ModalStep=ve;exports.Requests=qt;exports.SlideoutStep=Se;exports.StepButtons=W;exports.StepContent=H;exports.TooltipStep=de;exports.useArticle=_e;exports.useArticles=Ie;exports.useCensus=ht;exports.useCensusContext=U;exports.useFeedback=Te;exports.useGuideBuilder=ze;exports.useGuideRenderer=Gt;exports.useGuides=kt;exports.useIdentify=vt;exports.useRequests=Be;exports.useTrack=wt;//# sourceMappingURL=index.cjs.map
27
+ `;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:_}}),jsxRuntime.jsx("button",{onClick:()=>u(!g),"aria-label":"Show more information","aria-expanded":g,style:{position:"absolute",top:R.top,left:R.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:k,color:"white",cursor:"pointer",zIndex:a,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,animation:!g?"census-hotspot-pulse 2s infinite":"none",transition:"transform 0.15s"},children:"?"}),g&&jsxRuntime.jsxs("div",{ref:l,style:{position:"absolute",top:x?.top||R.top+30,left:x?.left||R.left-140,zIndex:a+1,padding:"16px 20px",backgroundColor:v,color:E,borderRadius:T,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:[x&&jsxRuntime.jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${v}`,top:x.arrowPosition.top,left:x.arrowPosition.left,transform:x.arrowPosition.transform}}),jsxRuntime.jsx(Y,{step:o,textColor:E}),d&&t>1&&jsxRuntime.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",e+1," of ",t]}),jsxRuntime.jsx(X,{buttons:o.rich_content?.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:p,accentColor:k})]})]})}var Ie={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 Be({step:o,currentStep:e,totalSteps:t,onNext:r,onPrev:i,onDismiss:n,onCustomAction:p,showProgress:d=true,globalStyle:s,zIndex:a=9999}){let [l,c]=react.useState(true),[f,g]=react.useState(true),u={...s,...o.style_config},S=(o.display_config||{}).bannerPosition||"top",x="custom",w=u.backgroundColor||Ie[x].bg,b=u.textColor||Ie[x].text;react.useEffect(()=>{let U=setTimeout(()=>c(false),50);return ()=>clearTimeout(U)},[]);let E=()=>{c(true),setTimeout(()=>{g(false),n();},200);};if(!f)return null;let k=o.rich_content,T=k?.title||o.title,m=k?.body||o.content,L=k?.buttons&&k.buttons.length>0;return jsxRuntime.jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[S]:0,zIndex:a,padding:"12px 20px",backgroundColor:w,color:b,boxShadow:S==="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:l?S==="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:[Ie[x].icon,jsxRuntime.jsxs("div",{style:{flex:1},children:[T&&jsxRuntime.jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:T}),m&&jsxRuntime.jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),d&&t>1&&jsxRuntime.jsxs("span",{style:{fontSize:"12px",opacity:.7,flexShrink:0},children:[e+1,"/",t]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[L?jsxRuntime.jsx(X,{buttons:k.buttons,currentStep:e,totalSteps:t,isLastStep:e===t-1,onNext:r,onPrev:i,onDismiss:E,onCustomAction:p,accentColor:"white"}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e<t-1?jsxRuntime.jsx("button",{onClick:r,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:b,cursor:"pointer"},children:"Next"}):jsxRuntime.jsx("button",{onClick:E,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:b,cursor:"pointer"},children:"Got it"})}),jsxRuntime.jsx("button",{onClick:E,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:b,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}function Ro({guide:o,onComplete:e,onDismiss:t,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:p=0,zIndex:d=9999}){let[s,a]=react.useState(p),[l,c]=react.useState(true),f=o.guide_steps||[],g=f.length,u=f[s];react.useEffect(()=>{r?.(s,g);},[s,g,r]);let R=react.useCallback(()=>{s<g-1?a(v=>v+1):(c(false),e?.(o));},[s,g,o,e]),S=react.useCallback(()=>{s>0&&a(v=>v-1);},[s]),x=react.useCallback(()=>{c(false),t?.(o,s);},[o,s,t]),w=react.useCallback(v=>{u&&i?.(v,u);},[u,i]);if(!l||!u||f.length===0)return null;let b={step:u,currentStep:s,totalSteps:g,onNext:R,onPrev:S,onDismiss:x,onCustomAction:w,showProgress:o.show_progress!==false,globalStyle:{...o.theme,...n},zIndex:d};switch(u.step_type){case "tooltip":return jsxRuntime.jsx(ye,{...b});case "modal":return jsxRuntime.jsx(Pe,{...b});case "slideout":return jsxRuntime.jsx(Ee,{...b});case "hotspot":return jsxRuntime.jsx(_e,{...b});case "banner":return jsxRuntime.jsx(Be,{...b});default:return jsxRuntime.jsx(ye,{...b})}}exports.Backdrop=ee;exports.BannerStep=Be;exports.CensusProvider=Pt;exports.FeedbackButton=Dt;exports.GuideBuilder=ao;exports.GuideRenderer=Ro;exports.HelpCenter=Jt;exports.HotspotStep=_e;exports.KnowledgeBase=Nt;exports.ModalStep=Pe;exports.Requests=Vt;exports.SlideoutStep=Ee;exports.StepButtons=X;exports.StepContent=Y;exports.TooltipStep=ye;exports.useArticle=fe;exports.useArticles=ue;exports.useCensus=Et;exports.useCensusContext=O;exports.useFeatureGroups=qe;exports.useFeedback=Le;exports.useGuideBuilder=Oe;exports.useGuideRenderer=zt;exports.useGuides=Ft;exports.useIdentify=Tt;exports.useRequests=ne;exports.useTrack=Bt;//# sourceMappingURL=index.cjs.map
28
28
  //# sourceMappingURL=index.cjs.map