@burdenoff/microfe-support 2026.1031.2 → 2026.1109.1

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.
Files changed (147) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +6 -0
  2. package/dist/dev/main.d.ts +0 -0
  3. package/dist/generated/global-operations.d.ts +60 -60
  4. package/dist/node_modules/@tiptap/core/dist/index.js +949 -674
  5. package/dist/node_modules/@tiptap/core/dist/index.js.map +1 -1
  6. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +1 -1
  7. package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +1 -1
  8. package/dist/node_modules/@tiptap/extension-code/dist/index.js +14 -3
  9. package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +1 -1
  10. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +1 -3
  11. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +1 -1
  12. package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +1 -1
  13. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +1 -1
  14. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +4 -1
  15. package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +1 -1
  16. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +1 -1
  17. package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +1 -1
  18. package/dist/node_modules/@tiptap/extension-link/dist/index.js +76 -51
  19. package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +1 -1
  20. package/dist/node_modules/@tiptap/extension-list/dist/index.js +143 -127
  21. package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +1 -1
  22. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +3 -2
  23. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +1 -1
  24. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +1 -1
  25. package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +1 -1
  26. package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +1 -1
  27. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +21 -11
  28. package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +1 -1
  29. package/dist/node_modules/@tiptap/extensions/dist/index.js +8 -9
  30. package/dist/node_modules/@tiptap/extensions/dist/index.js.map +1 -1
  31. package/dist/node_modules/@tiptap/react/dist/index.js +70 -49
  32. package/dist/node_modules/@tiptap/react/dist/index.js.map +1 -1
  33. package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +1 -1
  34. package/dist/node_modules/fast-equals/dist/es/index.js +108 -76
  35. package/dist/node_modules/fast-equals/dist/es/index.js.map +1 -1
  36. package/dist/node_modules/linkifyjs/dist/linkify.js +127 -113
  37. package/dist/node_modules/linkifyjs/dist/linkify.js.map +1 -1
  38. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +1 -1
  39. package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +1 -1
  40. package/dist/node_modules/prosemirror-history/dist/index.js +21 -14
  41. package/dist/node_modules/prosemirror-history/dist/index.js.map +1 -1
  42. package/dist/node_modules/prosemirror-model/dist/index.js +98 -105
  43. package/dist/node_modules/prosemirror-model/dist/index.js.map +1 -1
  44. package/dist/node_modules/prosemirror-schema-list/dist/index.js +37 -34
  45. package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +1 -1
  46. package/dist/node_modules/prosemirror-transform/dist/index.js +153 -101
  47. package/dist/node_modules/prosemirror-transform/dist/index.js.map +1 -1
  48. package/dist/node_modules/prosemirror-view/dist/index.js +742 -693
  49. package/dist/node_modules/prosemirror-view/dist/index.js.map +1 -1
  50. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +96 -17
  51. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
  52. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +55 -0
  53. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
  54. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +53 -0
  55. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +1 -0
  56. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +53 -0
  57. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  58. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +45 -0
  59. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
  60. package/dist/node_modules/use-sync-external-store/shim/index.js +11 -0
  61. package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  62. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +11 -0
  63. package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
  64. package/dist/support/SupportAdminRoot.d.ts +2 -2
  65. package/dist/support/SupportAdminRoutes.d.ts +1 -1
  66. package/dist/support/SupportUserRoot.d.ts +2 -2
  67. package/dist/support/SupportUserRoutes.d.ts +1 -1
  68. package/dist/support/components/NotificationToast.d.ts +2 -2
  69. package/dist/support/components/PageLayout.d.ts +4 -4
  70. package/dist/support/components/RouteHelpers.d.ts +1 -1
  71. package/dist/support/components/analytics/CategoryBreakdown.d.ts +1 -1
  72. package/dist/support/components/analytics/MetricCard.d.ts +1 -1
  73. package/dist/support/components/analytics/PriorityBreakdown.d.ts +1 -1
  74. package/dist/support/components/analytics/SLAReport.d.ts +1 -1
  75. package/dist/support/components/analytics/SatisfactionDistribution.d.ts +1 -1
  76. package/dist/support/components/analytics/TopAgents.d.ts +1 -1
  77. package/dist/support/components/analytics/TrendChart.d.ts +1 -1
  78. package/dist/support/components/careers/BulkCandidateActionGuidance.d.ts +1 -1
  79. package/dist/support/components/careers/BulkCandidateDialogs.d.ts +7 -7
  80. package/dist/support/components/careers/BulkOperationFeedback.d.ts +8 -8
  81. package/dist/support/components/careers/BulkSelectionSummary.d.ts +2 -2
  82. package/dist/support/components/careers/RichTextEditor.d.ts +1 -2
  83. package/dist/support/components/careers/RichTextEditor.js.map +1 -1
  84. package/dist/support/components/kb/ArticleForm.d.ts +1 -1
  85. package/dist/support/components/settings/CannedResponsesSettings.d.ts +1 -1
  86. package/dist/support/components/settings/SLAPoliciesSettings.d.ts +1 -1
  87. package/dist/support/components/settings/TicketCategoriesSettings.d.ts +1 -1
  88. package/dist/support/components/tickets/AttachmentList.d.ts +1 -1
  89. package/dist/support/components/tickets/MarkdownContent.d.ts +1 -1
  90. package/dist/support/components/tickets/MessageComposer.d.ts +1 -1
  91. package/dist/support/components/tickets/MessageThread.d.ts +2 -2
  92. package/dist/support/components/tickets/TicketDetailHeader.d.ts +2 -2
  93. package/dist/support/components/tickets/TicketHeader.d.ts +2 -2
  94. package/dist/support/components/tickets/TicketSidebar.d.ts +2 -2
  95. package/dist/support/components/tickets/TriagePanel.d.ts +2 -2
  96. package/dist/support/constants/pipeline.d.ts +0 -6
  97. package/dist/support/events/rybbit.d.ts +1 -1
  98. package/dist/support/hooks/useAnalyticsOperations.d.ts +10 -25
  99. package/dist/support/hooks/useAnalyticsOperations.js +40 -39
  100. package/dist/support/hooks/useAnalyticsOperations.js.map +1 -1
  101. package/dist/support/hooks/useAttachmentsFailedToast.d.ts +1 -1
  102. package/dist/support/hooks/useChatOperations.d.ts +2 -2
  103. package/dist/support/hooks/useKnowledgeBaseOperations.d.ts +7 -13
  104. package/dist/support/hooks/useKnowledgeBaseOperations.js +84 -83
  105. package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
  106. package/dist/support/hooks/useRegisterFooter.d.ts +1 -1
  107. package/dist/support/hooks/useSettingsOperations.d.ts +7 -16
  108. package/dist/support/hooks/useSupportAttachments.d.ts +1 -1
  109. package/dist/support/hooks/useTicketListOperations.d.ts +3 -6
  110. package/dist/support/hooks/useTicketOperations.d.ts +5 -11
  111. package/dist/support/hooks/useTicketOperations.js +80 -79
  112. package/dist/support/hooks/useTicketOperations.js.map +1 -1
  113. package/dist/support/pages/AnalyticsPage.d.ts +1 -1
  114. package/dist/support/pages/ArticleDetailAdminPage.d.ts +1 -1
  115. package/dist/support/pages/ArticleDetailUserPage.d.ts +1 -1
  116. package/dist/support/pages/ContactInquiriesPage.d.ts +1 -1
  117. package/dist/support/pages/ContactInquiryDetailPage.d.ts +1 -1
  118. package/dist/support/pages/CreateArticlePage.d.ts +1 -1
  119. package/dist/support/pages/CreateTicketPage.d.ts +1 -1
  120. package/dist/support/pages/EditArticlePage.d.ts +1 -1
  121. package/dist/support/pages/InterviewersPage.d.ts +1 -1
  122. package/dist/support/pages/JobApplicationDetailPage.d.ts +1 -2
  123. package/dist/support/pages/JobApplicationsPage.d.ts +1 -1
  124. package/dist/support/pages/JobPostingDetailPage.d.ts +1 -1
  125. package/dist/support/pages/JobPostingsPage.d.ts +1 -1
  126. package/dist/support/pages/KnowledgeBaseAdminPage.d.ts +1 -1
  127. package/dist/support/pages/KnowledgeBaseUserPage.d.ts +1 -1
  128. package/dist/support/pages/SettingsPage.d.ts +1 -1
  129. package/dist/support/pages/SettingsPage.js.map +1 -1
  130. package/dist/support/pages/TicketDetailAdminPage.d.ts +1 -1
  131. package/dist/support/pages/TicketDetailUserPage.d.ts +1 -1
  132. package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
  133. package/dist/support/pages/TicketListPage.d.ts +1 -1
  134. package/dist/support/providers/SupportProvider.d.ts +2 -2
  135. package/dist/support/store/supportStore.d.ts +2 -2
  136. package/dist/support/utils/bulkCandidateTargetQuery.d.ts +1 -1
  137. package/dist/support/utils/cn.d.ts +1 -1
  138. package/dist/support/utils/index.d.ts +1 -1
  139. package/dist/support/utils/markdown.d.ts +0 -1
  140. package/dist/support/utils/refetch.d.ts +12 -0
  141. package/dist/support/utils/refetch.js +7 -0
  142. package/dist/support/utils/refetch.js.map +1 -0
  143. package/dist/support/utils/ticketFilters.d.ts +2 -2
  144. package/dist/support/utils/uiTokens.d.ts +1 -1
  145. package/dist/test/dom.d.ts +1 -0
  146. package/dist/test/setup.d.ts +1 -0
  147. package/package.json +65 -54
@@ -1 +1 @@
1
- {"version":3,"file":"useKnowledgeBaseOperations.js","names":["useKnowledgeBaseOperations","useSupportStore","eventBus","useEventBus","articlesData","articlesLoading","articlesError","fetchMoreArticles","refetchArticles","useGetArticlesQuery","kbSearch","articleIdFromSlug","articleSlug","article","popularData","popularLoading","useGetPopularArticlesQuery","categoriesData","categoriesLoading","useGetTicketCategoriesQuery","searchData","searchLoading","searchError","useSearchKnowledgeBaseQuery","articles","setKbResults","articleData","articleLoading","articleError","refetchArticle","useGetArticleQuery","selectedArticle","rateArticleMutation","ratingArticle","useRateArticleMutation","error","recordViewMutation","useRecordArticleViewMutation","createArticleMutation","creatingArticle","useCreateKnowledgeBaseArticleMutation","updateArticleMutation","updatingArticle","useUpdateKnowledgeBaseArticleMutation","deleteArticleMutation","deletingArticle","useDeleteKnowledgeBaseArticleMutation","publishArticleMutation","publishingArticle","usePublishKnowledgeBaseArticleMutation","unpublishArticleMutation","unpublishingArticle","useUnpublishKnowledgeBaseArticleMutation","archiveArticleMutation","archivingArticle","useArchiveKnowledgeBaseArticleMutation","searchArticles","query","filters","filterArticles","loadMoreArticles","currentCount","fetchMoreResult","prev","voteArticle","articleId","emitSupportKbArticleRated","helpful","recordView","useCallback"],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { emitSupportKbArticleRated } from '../events/rybbit';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n useGetArticlesQuery,\n useGetArticleQuery,\n useGetPopularArticlesQuery,\n useGetTicketCategoriesQuery,\n useSearchKnowledgeBaseQuery,\n useRateArticleMutation,\n useRecordArticleViewMutation,\n useCreateKnowledgeBaseArticleMutation,\n useUpdateKnowledgeBaseArticleMutation,\n useDeleteKnowledgeBaseArticleMutation,\n usePublishKnowledgeBaseArticleMutation,\n useUnpublishKnowledgeBaseArticleMutation,\n useArchiveKnowledgeBaseArticleMutation,\n} from '../../generated/global-operations';\nimport type {\n KnowledgeBaseArticle,\n KnowledgeBaseArticleFilterInput,\n CreateKnowledgeBaseArticleInput,\n UpdateKnowledgeBaseArticleInput,\n} from '../../generated/global-types';\nimport type { KnowledgeBaseArticleState } from '../store/supportStore';\n\n// Input types for article operations (re-export for consumers)\nexport type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };\n\nexport function useKnowledgeBaseOperations(articleSlug?: string) {\n const { kbSearch, selectedArticle, updateKbSearch, setKbResults, setSelectedArticle } =\n useSupportStore();\n const eventBus = useEventBus();\n\n // Query: Get articles list (show all statuses - admins can see drafts)\n const {\n data: articlesData,\n loading: articlesLoading,\n error: articlesError,\n fetchMore: fetchMoreArticles,\n refetch: refetchArticles,\n } = useGetArticlesQuery({\n variables: {\n limit: 20,\n offset: 0,\n filter: {\n // Don't filter by status - show all articles including drafts\n categoryId: kbSearch.filters.categoryId || undefined,\n tags: kbSearch.filters.tags.length > 0 ? kbSearch.filters.tags : undefined,\n } as KnowledgeBaseArticleFilterInput,\n },\n });\n\n const articleIdFromSlug = articleSlug\n ? articlesData?.knowledgeBaseArticles?.nodes?.find(\n (article: { slug: string; id: string }) => article.slug === articleSlug\n )?.id\n : undefined;\n\n // Query: Get popular articles\n const { data: popularData, loading: popularLoading } = useGetPopularArticlesQuery({\n variables: { limit: 10 },\n });\n\n // Query: Get categories\n const { data: categoriesData, loading: categoriesLoading } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Search articles\n const {\n data: searchData,\n loading: searchLoading,\n error: searchError,\n } = useSearchKnowledgeBaseQuery({\n variables: {\n query: kbSearch.query || '',\n limit: 20,\n categoryId: kbSearch.filters.categoryId || undefined,\n },\n skip: !kbSearch.query,\n });\n\n // Update kbResults when search data changes\n useEffect(() => {\n if (searchData?.searchKnowledgeBase) {\n const articles = searchData.searchKnowledgeBase;\n setKbResults(articles as KnowledgeBaseArticleState[]);\n }\n }, [searchData, setKbResults]);\n\n // Query: Get article detail\n const {\n data: articleData,\n loading: articleLoading,\n error: articleError,\n refetch: refetchArticle,\n } = useGetArticleQuery({\n variables: { id: selectedArticle?.id || articleIdFromSlug || '' },\n skip: !selectedArticle?.id && !articleIdFromSlug,\n });\n\n // Mutation: Rate article\n const [rateArticleMutation, { loading: ratingArticle }] = useRateArticleMutation({\n onCompleted: () => {\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to rate article:', error);\n },\n });\n\n // Mutation: Record article view\n const [recordViewMutation] = useRecordArticleViewMutation({\n onError: (error) => {\n console.error('Failed to record view:', error);\n },\n });\n\n // Mutation: Create article\n const [createArticleMutation, { loading: creatingArticle }] =\n useCreateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to create article:', error);\n },\n });\n\n // Mutation: Update article\n const [updateArticleMutation, { loading: updatingArticle }] =\n useUpdateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to update article:', error);\n },\n });\n\n // Mutation: Delete article\n const [deleteArticleMutation, { loading: deletingArticle }] =\n useDeleteKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to delete article:', error);\n },\n });\n\n // Mutation: Publish article\n const [publishArticleMutation, { loading: publishingArticle }] =\n usePublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to publish article:', error);\n },\n });\n\n // Mutation: Unpublish article\n const [unpublishArticleMutation, { loading: unpublishingArticle }] =\n useUnpublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to unpublish article:', error);\n },\n });\n\n // Mutation: Archive article\n const [archiveArticleMutation, { loading: archivingArticle }] =\n useArchiveKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to archive article:', error);\n },\n });\n\n // Helper: Search articles\n const searchArticles = (query: string, filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(query.trim(), filters);\n };\n\n const filterArticles = (filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(kbSearch.query, filters);\n };\n\n // Helper: Load more articles (offset-based pagination)\n const loadMoreArticles = () => {\n const currentCount = articlesData?.knowledgeBaseArticles?.nodes?.length || 0;\n if (articlesData?.knowledgeBaseArticles?.hasMore) {\n fetchMoreArticles({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n knowledgeBaseArticles: {\n ...fetchMoreResult.knowledgeBaseArticles,\n nodes: [\n ...(prev.knowledgeBaseArticles?.nodes || []),\n ...(fetchMoreResult.knowledgeBaseArticles?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Helper: Vote on article helpfulness\n const voteArticle = async (articleId: string, helpful: boolean) => {\n try {\n await rateArticleMutation({\n variables: { id: articleId, helpful },\n });\n emitSupportKbArticleRated(eventBus, articleId, helpful);\n } catch (error) {\n console.error('Failed to vote on article:', error);\n throw error;\n }\n };\n\n // Helper: Record article view (memoized to prevent multiple calls)\n const recordView = useCallback(\n async (articleId: string) => {\n try {\n await recordViewMutation({\n variables: { id: articleId },\n });\n eventBus.emit('support.kb.article_viewed', {\n articleId,\n });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [eventBus, recordViewMutation]\n );\n\n // Helper: Create article\n const createArticle = async (input: CreateKnowledgeBaseArticleInput) => {\n try {\n const result = await createArticleMutation({\n variables: { input },\n });\n return result.data?.createKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to create article:', error);\n throw error;\n }\n };\n\n // Helper: Update article\n const updateArticle = async (id: string, input: UpdateKnowledgeBaseArticleInput) => {\n try {\n const result = await updateArticleMutation({\n variables: { id, input },\n });\n return result.data?.updateKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to update article:', error);\n throw error;\n }\n };\n\n // Helper: Delete article\n const deleteArticle = async (id: string) => {\n try {\n const result = await deleteArticleMutation({\n variables: { id },\n });\n return result.data?.deleteKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to delete article:', error);\n throw error;\n }\n };\n\n // Helper: Publish article\n const publishArticle = async (id: string) => {\n try {\n const result = await publishArticleMutation({\n variables: { id },\n });\n return result.data?.publishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to publish article:', error);\n throw error;\n }\n };\n\n // Helper: Unpublish article\n const unpublishArticle = async (id: string) => {\n try {\n const result = await unpublishArticleMutation({\n variables: { id },\n });\n return result.data?.unpublishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to unpublish article:', error);\n throw error;\n }\n };\n\n // Helper: Archive article\n const archiveArticle = async (id: string) => {\n try {\n const result = await archiveArticleMutation({\n variables: { id },\n });\n return result.data?.archiveKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to archive article:', error);\n throw error;\n }\n };\n\n return {\n // Data\n articles: (articlesData?.knowledgeBaseArticles?.nodes || []) as KnowledgeBaseArticle[],\n popularArticles: (popularData?.popularArticles || []) as KnowledgeBaseArticle[],\n categories: categoriesData?.ticketCategories?.nodes || [],\n searchResults: kbSearch.results,\n articleDetail: articleData?.knowledgeBaseArticle || null,\n totalArticles: articlesData?.knowledgeBaseArticles?.totalCount || 0,\n totalResults: searchData?.searchKnowledgeBase?.length || 0,\n hasMoreArticles: articlesData?.knowledgeBaseArticles?.hasMore || false,\n hasMoreResults: false, // searchKnowledgeBase returns array, no pagination\n\n // Loading states\n articlesLoading,\n popularLoading,\n categoriesLoading,\n searchLoading,\n articleLoading,\n ratingArticle,\n creatingArticle,\n updatingArticle,\n deletingArticle,\n publishingArticle,\n unpublishingArticle,\n archivingArticle,\n\n // Errors\n articlesError,\n searchError,\n articleError,\n\n // Read Operations\n searchArticles,\n filterArticles,\n loadMoreArticles,\n voteArticle,\n recordView,\n refetchArticles,\n refetchArticle,\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;;AA8BA,SAAgBA,EAA2B,GAAsB;CAC/D,IAAM,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/DC,EAAgB,GACZC,IAAWC,EAAY,GAGvB,EACJ,MAAMC,GACN,SAASC,GACT,OAAOC,GACP,WAAWC,GACX,SAASC,MACPC,EAAoB,EACtB,WAAW;EACT,OAAO;EACP,QAAQ;EACR,QAAQ;GAEN,YAAYC,EAAS,QAAQ,cAAc,KAAA;GAC3C,MAAMA,EAAS,QAAQ,KAAK,SAAS,IAAIA,EAAS,QAAQ,OAAO,KAAA;EACnE;CACF,EACF,CAAC,GAEKC,IAAoBC,IACtBR,GAAc,uBAAuB,OAAO,MACzC,MAA0CS,EAAQ,SAASD,CAC9D,CAAC,EAAE,KACH,KAAA,GAGE,EAAE,MAAME,GAAa,SAASC,MAAmBC,EAA2B,EAChF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EAAE,MAAMC,GAAgB,SAASC,MAAsBC,EAA4B,EACvF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EACJ,MAAMC,GACN,SAASC,IACT,OAAOC,MACLC,EAA4B;EAC9B,WAAW;GACT,OAAOb,EAAS,SAAS;GACzB,OAAO;GACP,YAAYA,EAAS,QAAQ,cAAc,KAAA;EAC7C;EACA,MAAM,CAACA,EAAS;CAClB,CAAC;CAGD,QAAgB;EACd,IAAIU,GAAY,qBAAqB;GACnC,IAAMI,IAAWJ,EAAW;GAC5B,EAAaI,CAAuC;EACtD;CACF,GAAG,CAACJ,GAAYK,CAAY,CAAC;CAG7B,IAAM,EAC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AAO;IAEd,MADA,QAAQ,MAAM,gCAAgCA,CAAK,GAC7CA;GACR;EACF;EA8DE,uBA3D4B,MAAe;GAC3C,IAAI;IAIF,QAAO,MAHckB,GAAuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASlB,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;CAkDA;AACF"}
1
+ {"version":3,"file":"useKnowledgeBaseOperations.js","names":["useKnowledgeBaseOperations","useSupportStore","eventBus","useEventBus","articlesData","articlesLoading","articlesError","fetchMoreArticles","refetchArticles","useGetArticlesQuery","kbSearch","articleIdFromSlug","articleSlug","article","popularData","popularLoading","useGetPopularArticlesQuery","categoriesData","categoriesLoading","useGetTicketCategoriesQuery","searchData","searchLoading","searchError","useSearchKnowledgeBaseQuery","articles","setKbResults","articleData","articleLoading","articleError","refetchArticle","useGetArticleQuery","selectedArticle","rateArticleMutation","ratingArticle","useRateArticleMutation","error","recordViewMutation","useRecordArticleViewMutation","createArticleMutation","creatingArticle","useCreateKnowledgeBaseArticleMutation","updateArticleMutation","updatingArticle","useUpdateKnowledgeBaseArticleMutation","deleteArticleMutation","deletingArticle","useDeleteKnowledgeBaseArticleMutation","publishArticleMutation","publishingArticle","usePublishKnowledgeBaseArticleMutation","unpublishArticleMutation","unpublishingArticle","useUnpublishKnowledgeBaseArticleMutation","archiveArticleMutation","archivingArticle","useArchiveKnowledgeBaseArticleMutation","searchArticles","query","filters","filterArticles","loadMoreArticles","currentCount","fetchMoreResult","prev","voteArticle","articleId","emitSupportKbArticleRated","helpful","recordView","useCallback","asRefetch"],"sources":["../../../src/support/hooks/useKnowledgeBaseOperations.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { emitSupportKbArticleRated } from '../events/rybbit';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n useGetArticlesQuery,\n useGetArticleQuery,\n useGetPopularArticlesQuery,\n useGetTicketCategoriesQuery,\n useSearchKnowledgeBaseQuery,\n useRateArticleMutation,\n useRecordArticleViewMutation,\n useCreateKnowledgeBaseArticleMutation,\n useUpdateKnowledgeBaseArticleMutation,\n useDeleteKnowledgeBaseArticleMutation,\n usePublishKnowledgeBaseArticleMutation,\n useUnpublishKnowledgeBaseArticleMutation,\n useArchiveKnowledgeBaseArticleMutation,\n} from '../../generated/global-operations';\nimport type {\n KnowledgeBaseArticle,\n KnowledgeBaseArticleFilterInput,\n CreateKnowledgeBaseArticleInput,\n UpdateKnowledgeBaseArticleInput,\n} from '../../generated/global-types';\nimport type { KnowledgeBaseArticleState } from '../store/supportStore';\nimport { asRefetch } from '../utils/refetch';\n\n// Input types for article operations (re-export for consumers)\nexport type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };\n\nexport function useKnowledgeBaseOperations(articleSlug?: string) {\n const { kbSearch, selectedArticle, updateKbSearch, setKbResults, setSelectedArticle } =\n useSupportStore();\n const eventBus = useEventBus();\n\n // Query: Get articles list (show all statuses - admins can see drafts)\n const {\n data: articlesData,\n loading: articlesLoading,\n error: articlesError,\n fetchMore: fetchMoreArticles,\n refetch: refetchArticles,\n } = useGetArticlesQuery({\n variables: {\n limit: 20,\n offset: 0,\n filter: {\n // Don't filter by status - show all articles including drafts\n categoryId: kbSearch.filters.categoryId || undefined,\n tags: kbSearch.filters.tags.length > 0 ? kbSearch.filters.tags : undefined,\n } as KnowledgeBaseArticleFilterInput,\n },\n });\n\n const articleIdFromSlug = articleSlug\n ? articlesData?.knowledgeBaseArticles?.nodes?.find(\n (article: { slug: string; id: string }) => article.slug === articleSlug\n )?.id\n : undefined;\n\n // Query: Get popular articles\n const { data: popularData, loading: popularLoading } = useGetPopularArticlesQuery({\n variables: { limit: 10 },\n });\n\n // Query: Get categories\n const { data: categoriesData, loading: categoriesLoading } = useGetTicketCategoriesQuery({\n variables: { limit: 50 },\n });\n\n // Query: Search articles\n const {\n data: searchData,\n loading: searchLoading,\n error: searchError,\n } = useSearchKnowledgeBaseQuery({\n variables: {\n query: kbSearch.query || '',\n limit: 20,\n categoryId: kbSearch.filters.categoryId || undefined,\n },\n skip: !kbSearch.query,\n });\n\n // Update kbResults when search data changes\n useEffect(() => {\n if (searchData?.searchKnowledgeBase) {\n const articles = searchData.searchKnowledgeBase;\n setKbResults(articles as KnowledgeBaseArticleState[]);\n }\n }, [searchData, setKbResults]);\n\n // Query: Get article detail\n const {\n data: articleData,\n loading: articleLoading,\n error: articleError,\n refetch: refetchArticle,\n } = useGetArticleQuery({\n variables: { id: selectedArticle?.id || articleIdFromSlug || '' },\n skip: !selectedArticle?.id && !articleIdFromSlug,\n });\n\n // Mutation: Rate article\n const [rateArticleMutation, { loading: ratingArticle }] = useRateArticleMutation({\n onCompleted: () => {\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to rate article:', error);\n },\n });\n\n // Mutation: Record article view\n const [recordViewMutation] = useRecordArticleViewMutation({\n onError: (error) => {\n console.error('Failed to record view:', error);\n },\n });\n\n // Mutation: Create article\n const [createArticleMutation, { loading: creatingArticle }] =\n useCreateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to create article:', error);\n },\n });\n\n // Mutation: Update article\n const [updateArticleMutation, { loading: updatingArticle }] =\n useUpdateKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to update article:', error);\n },\n });\n\n // Mutation: Delete article\n const [deleteArticleMutation, { loading: deletingArticle }] =\n useDeleteKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n },\n onError: (error) => {\n console.error('Failed to delete article:', error);\n },\n });\n\n // Mutation: Publish article\n const [publishArticleMutation, { loading: publishingArticle }] =\n usePublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to publish article:', error);\n },\n });\n\n // Mutation: Unpublish article\n const [unpublishArticleMutation, { loading: unpublishingArticle }] =\n useUnpublishKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to unpublish article:', error);\n },\n });\n\n // Mutation: Archive article\n const [archiveArticleMutation, { loading: archivingArticle }] =\n useArchiveKnowledgeBaseArticleMutation({\n onCompleted: () => {\n refetchArticles();\n refetchArticle();\n },\n onError: (error) => {\n console.error('Failed to archive article:', error);\n },\n });\n\n // Helper: Search articles\n const searchArticles = (query: string, filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(query.trim(), filters);\n };\n\n const filterArticles = (filters?: { categoryId?: string; tags?: string[] }) => {\n updateKbSearch(kbSearch.query, filters);\n };\n\n // Helper: Load more articles (offset-based pagination)\n const loadMoreArticles = () => {\n const currentCount = articlesData?.knowledgeBaseArticles?.nodes?.length || 0;\n if (articlesData?.knowledgeBaseArticles?.hasMore) {\n fetchMoreArticles({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n knowledgeBaseArticles: {\n ...fetchMoreResult.knowledgeBaseArticles,\n nodes: [\n ...(prev.knowledgeBaseArticles?.nodes || []),\n ...(fetchMoreResult.knowledgeBaseArticles?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Helper: Vote on article helpfulness\n const voteArticle = async (articleId: string, helpful: boolean) => {\n try {\n await rateArticleMutation({\n variables: { id: articleId, helpful },\n });\n emitSupportKbArticleRated(eventBus, articleId, helpful);\n } catch (error) {\n console.error('Failed to vote on article:', error);\n throw error;\n }\n };\n\n // Helper: Record article view (memoized to prevent multiple calls)\n const recordView = useCallback(\n async (articleId: string) => {\n try {\n await recordViewMutation({\n variables: { id: articleId },\n });\n eventBus.emit('support.kb.article_viewed', {\n articleId,\n });\n } catch (error) {\n console.error('Failed to record view:', error);\n }\n },\n [eventBus, recordViewMutation]\n );\n\n // Helper: Create article\n const createArticle = async (input: CreateKnowledgeBaseArticleInput) => {\n try {\n const result = await createArticleMutation({\n variables: { input },\n });\n return result.data?.createKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to create article:', error);\n throw error;\n }\n };\n\n // Helper: Update article\n const updateArticle = async (id: string, input: UpdateKnowledgeBaseArticleInput) => {\n try {\n const result = await updateArticleMutation({\n variables: { id, input },\n });\n return result.data?.updateKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to update article:', error);\n throw error;\n }\n };\n\n // Helper: Delete article\n const deleteArticle = async (id: string) => {\n try {\n const result = await deleteArticleMutation({\n variables: { id },\n });\n return result.data?.deleteKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to delete article:', error);\n throw error;\n }\n };\n\n // Helper: Publish article\n const publishArticle = async (id: string) => {\n try {\n const result = await publishArticleMutation({\n variables: { id },\n });\n return result.data?.publishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to publish article:', error);\n throw error;\n }\n };\n\n // Helper: Unpublish article\n const unpublishArticle = async (id: string) => {\n try {\n const result = await unpublishArticleMutation({\n variables: { id },\n });\n return result.data?.unpublishKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to unpublish article:', error);\n throw error;\n }\n };\n\n // Helper: Archive article\n const archiveArticle = async (id: string) => {\n try {\n const result = await archiveArticleMutation({\n variables: { id },\n });\n return result.data?.archiveKnowledgeBaseArticle;\n } catch (error) {\n console.error('Failed to archive article:', error);\n throw error;\n }\n };\n\n return {\n // Data\n articles: (articlesData?.knowledgeBaseArticles?.nodes || []) as KnowledgeBaseArticle[],\n popularArticles: (popularData?.popularArticles || []) as KnowledgeBaseArticle[],\n categories: categoriesData?.ticketCategories?.nodes || [],\n searchResults: kbSearch.results,\n articleDetail: articleData?.knowledgeBaseArticle || null,\n totalArticles: articlesData?.knowledgeBaseArticles?.totalCount || 0,\n totalResults: searchData?.searchKnowledgeBase?.length || 0,\n hasMoreArticles: articlesData?.knowledgeBaseArticles?.hasMore || false,\n hasMoreResults: false, // searchKnowledgeBase returns array, no pagination\n\n // Loading states\n articlesLoading,\n popularLoading,\n categoriesLoading,\n searchLoading,\n articleLoading,\n ratingArticle,\n creatingArticle,\n updatingArticle,\n deletingArticle,\n publishingArticle,\n unpublishingArticle,\n archivingArticle,\n\n // Errors\n articlesError,\n searchError,\n articleError,\n\n // Read Operations\n searchArticles,\n filterArticles,\n loadMoreArticles,\n voteArticle,\n recordView,\n refetchArticles: asRefetch(refetchArticles),\n refetchArticle: asRefetch(refetchArticle),\n setSelectedArticle,\n\n // CRUD Operations\n createArticle,\n updateArticle,\n deleteArticle,\n publishArticle,\n unpublishArticle,\n archiveArticle,\n };\n}\n"],"mappings":";;;;;;;AA+BA,SAAgBA,EAA2B,GAAsB;CAC/D,IAAM,EAAE,aAAU,oBAAiB,mBAAgB,iBAAc,0BAC/DC,EAAgB,GACZC,IAAWC,EAAY,GAGvB,EACJ,MAAMC,GACN,SAASC,GACT,OAAOC,GACP,WAAWC,GACX,SAASC,MACPC,EAAoB,EACtB,WAAW;EACT,OAAO;EACP,QAAQ;EACR,QAAQ;GAEN,YAAYC,EAAS,QAAQ,cAAc,KAAA;GAC3C,MAAMA,EAAS,QAAQ,KAAK,SAAS,IAAIA,EAAS,QAAQ,OAAO,KAAA;EACnE;CACF,EACF,CAAC,GAEKC,IAAoBC,IACtBR,GAAc,uBAAuB,OAAO,MACzC,MAA0CS,EAAQ,SAASD,CAC9D,CAAC,EAAE,KACH,KAAA,GAGE,EAAE,MAAME,GAAa,SAASC,MAAmBC,EAA2B,EAChF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EAAE,MAAMC,GAAgB,SAASC,MAAsBC,EAA4B,EACvF,WAAW,EAAE,OAAO,GAAG,EACzB,CAAC,GAGK,EACJ,MAAMC,GACN,SAASC,IACT,OAAOC,MACLC,EAA4B;EAC9B,WAAW;GACT,OAAOb,EAAS,SAAS;GACzB,OAAO;GACP,YAAYA,EAAS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AuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASZ,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;EA0EE,yBAvE8B,MAAe;GAC7C,IAAI;IAIF,QAAO,MAHce,EAAyB,EAC5C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASf,GAAO;IAEd,MADA,QAAQ,MAAM,gCAAgCA,CAAK,GAC7CA;GACR;EACF;EA8DE,uBA3D4B,MAAe;GAC3C,IAAI;IAIF,QAAO,MAHckB,GAAuB,EAC1C,WAAW,EAAE,MAAG,EAClB,CAAC,EAAA,CACa,MAAM;GACtB,SAASlB,GAAO;IAEd,MADA,QAAQ,MAAM,8BAA8BA,CAAK,GAC3CA;GACR;EACF;CAkDA;AACF"}
@@ -1,4 +1,4 @@
1
- import type { FooterItem } from '../types';
1
+ import { FooterItem } from '../types';
2
2
  /**
3
3
  * Shared hook for registering the support footer status indicator.
4
4
  * Used by SupportUserRoot, SupportAdminRoot, and SupportRoot.
@@ -1,4 +1,4 @@
1
- import type { CreateSlaPolicyInput, UpdateSlaPolicyInput, CreateCannedResponseInput, UpdateCannedResponseInput, CreateTicketCategoryInput, UpdateTicketCategoryInput } from '../../generated/global-types';
1
+ import { CreateSlaPolicyInput, UpdateSlaPolicyInput, CreateCannedResponseInput, UpdateCannedResponseInput, CreateTicketCategoryInput, UpdateTicketCategoryInput } from '../../generated/global-types';
2
2
  export type { CreateSlaPolicyInput, UpdateSlaPolicyInput, CreateCannedResponseInput, UpdateCannedResponseInput, CreateTicketCategoryInput, UpdateTicketCategoryInput, };
3
3
  export declare function useSettingsOperations(): {
4
4
  slaPolicies: any;
@@ -20,28 +20,19 @@ export declare function useSettingsOperations(): {
20
20
  updateCategoryLoading: boolean;
21
21
  deleteCategoryLoading: boolean;
22
22
  isLoading: boolean;
23
- slaPoliciesError: import("@apollo/client").ErrorLike | undefined;
24
- cannedResponsesError: import("@apollo/client").ErrorLike | undefined;
25
- categoriesError: import("@apollo/client").ErrorLike | undefined;
23
+ slaPoliciesError: import('@apollo/client').ErrorLike | undefined;
24
+ cannedResponsesError: import('@apollo/client').ErrorLike | undefined;
25
+ categoriesError: import('@apollo/client').ErrorLike | undefined;
26
26
  createSLAPolicy: (input: CreateSlaPolicyInput) => Promise<any>;
27
27
  updateSLAPolicy: (id: string, input: UpdateSlaPolicyInput) => Promise<any>;
28
28
  deleteSLAPolicy: (id: string) => Promise<any>;
29
- refetchSLAPolicies: (variables?: any) => Promise<{
30
- data: any;
31
- error?: import("@apollo/client").ErrorLike;
32
- }>;
29
+ refetchSLAPolicies: import('@apollo/client/react/internal').RefetchFunction<Types.GetSlaPoliciesQuery, Types.GetSlaPoliciesQueryVariables, undefined>;
33
30
  createCannedResponse: (input: CreateCannedResponseInput) => Promise<any>;
34
31
  updateCannedResponse: (id: string, input: UpdateCannedResponseInput) => Promise<any>;
35
32
  deleteCannedResponse: (id: string) => Promise<any>;
36
- refetchCannedResponses: (variables?: any) => Promise<{
37
- data: any;
38
- error?: import("@apollo/client").ErrorLike;
39
- }>;
33
+ refetchCannedResponses: import('@apollo/client/react/internal').RefetchFunction<Types.GetCannedResponsesQuery, Types.GetCannedResponsesQueryVariables, undefined>;
40
34
  createTicketCategory: (input: CreateTicketCategoryInput) => Promise<any>;
41
35
  updateTicketCategory: (id: string, input: UpdateTicketCategoryInput) => Promise<any>;
42
36
  deleteTicketCategory: (id: string) => Promise<any>;
43
- refetchCategories: (variables?: any) => Promise<{
44
- data: any;
45
- error?: import("@apollo/client").ErrorLike;
46
- }>;
37
+ refetchCategories: import('@apollo/client/react/internal').RefetchFunction<Types.GetTicketCategoriesQuery, Types.GetTicketCategoriesQueryVariables, undefined>;
47
38
  };
@@ -1,4 +1,4 @@
1
- import { type SupportAttachmentRecord } from '../utils/supportFiles';
1
+ import { SupportAttachmentRecord } from '../utils/supportFiles';
2
2
  interface UseSupportAttachmentsOptions {
3
3
  fileIds: string[];
4
4
  ticketId: string;
@@ -1,4 +1,4 @@
1
- import { type SupportTicket } from '../../generated/global-types';
1
+ import { SupportTicket } from '../../generated/global-types';
2
2
  /**
3
3
  * Drives the ticket list query for both the consumer ("my tickets") surface and
4
4
  * the admin triage surface.
@@ -18,14 +18,11 @@ import { type SupportTicket } from '../../generated/global-types';
18
18
  export declare function useTicketListOperations(adminView?: boolean): {
19
19
  tickets: SupportTicket[];
20
20
  ticketsLoading: boolean;
21
- ticketsError: import("@apollo/client").ErrorLike | undefined;
21
+ ticketsError: import('@apollo/client').ErrorLike | undefined;
22
22
  totalTickets: any;
23
23
  hasMoreTickets: boolean;
24
24
  isScopedLocalSearch: boolean;
25
25
  isMissingProductScope: boolean;
26
26
  loadMoreTickets: () => void;
27
- refetchTickets: (variables?: any) => Promise<{
28
- data: any;
29
- error?: import("@apollo/client").ErrorLike;
30
- }>;
27
+ refetchTickets: import('@apollo/client/react/internal').RefetchFunction<Types.GetMyTicketsQuery, Types.GetMyTicketsQueryVariables, undefined>;
31
28
  };
@@ -1,4 +1,4 @@
1
- import { SupportTicketStatus, type SupportTicket, type CreateSupportTicketInput, type UpdateSupportTicketInput, type CreateSupportMessageInput, type SubmitSatisfactionSurveyInput } from '../../generated/global-types';
1
+ import { SupportTicketStatus, SupportTicket, CreateSupportTicketInput, UpdateSupportTicketInput, CreateSupportMessageInput, SubmitSatisfactionSurveyInput } from '../../generated/global-types';
2
2
  interface UseTicketOperationsOptions {
3
3
  loadAgentProfiles?: boolean;
4
4
  /**
@@ -25,8 +25,8 @@ export declare function useTicketOperations(options?: UseTicketOperationsOptions
25
25
  changeStatusLoading: boolean;
26
26
  addMessageLoading: boolean;
27
27
  submitSurveyLoading: boolean;
28
- ticketsError: import("@apollo/client").ErrorLike | undefined;
29
- ticketDetailError: import("@apollo/client").ErrorLike | undefined;
28
+ ticketsError: import('@apollo/client').ErrorLike | undefined;
29
+ ticketDetailError: import('@apollo/client').ErrorLike | undefined;
30
30
  createTicket: (input: CreateSupportTicketInput) => Promise<any>;
31
31
  updateTicket: (id: string, input: UpdateSupportTicketInput) => Promise<any>;
32
32
  assignTicket: (ticketId: string, assignedTo: string) => Promise<any>;
@@ -34,14 +34,8 @@ export declare function useTicketOperations(options?: UseTicketOperationsOptions
34
34
  addTicketMessage: (input: CreateSupportMessageInput) => Promise<any>;
35
35
  submitSatisfactionSurvey: (input: SubmitSatisfactionSurveyInput) => Promise<any>;
36
36
  loadMoreTickets: () => void;
37
- refetchTickets: (variables?: any) => Promise<{
38
- data: any;
39
- error?: import("@apollo/client").ErrorLike;
40
- }>;
41
- refetchTicketDetail: (variables?: any) => Promise<{
42
- data: any;
43
- error?: import("@apollo/client").ErrorLike;
44
- }>;
37
+ refetchTickets: import('../utils/refetch').RefetchFn;
38
+ refetchTicketDetail: import('../utils/refetch').RefetchFn;
45
39
  setSelectedTicket: (ticket: SupportTicket | null) => void;
46
40
  };
47
41
  export {};
@@ -4,144 +4,145 @@ import { useAssignSupportTicketMutation as i, useCloseSupportTicketMutation as a
4
4
  import { SupportTicketStatus as g } from "../../generated/global-types.js";
5
5
  import { useSupport as _ } from "../providers/SupportProvider.js";
6
6
  import { buildTicketFilter as v, matchesTicketClientFilters as y } from "../utils/ticketFilters.js";
7
- import { useEffect as b, useMemo as ee, useState as te } from "react";
8
- import { useEventBus as x } from "@burdenoff/fe-libs/shared/events";
7
+ import { asRefetch as b } from "../utils/refetch.js";
8
+ import { useEffect as x, useMemo as ee, useState as te } from "react";
9
+ import { useEventBus as S } from "@burdenoff/fe-libs/shared/events";
9
10
  // src/support/hooks/useTicketOperations.ts
10
- function S(S = {}) {
11
- let { workspaceId: C, organizationId: w, productId: T, currentUser: E } = _(), { ticketFilter: D, selectedTicket: O, setSelectedTicket: k } = e(), A = S.ticketId || O?.id || void 0, j = x(), [M, N] = te(() => D.search.trim());
12
- b(() => {
11
+ function C(C = {}) {
12
+ let { workspaceId: w, organizationId: T, productId: E, currentUser: D } = _(), { ticketFilter: O, selectedTicket: k, setSelectedTicket: A } = e(), j = C.ticketId || k?.id || void 0, M = S(), [N, P] = te(() => O.search.trim());
13
+ x(() => {
13
14
  let e = setTimeout(() => {
14
- N(D.search.trim());
15
+ P(O.search.trim());
15
16
  }, 300);
16
17
  return () => clearTimeout(e);
17
- }, [D.search]);
18
- let P = ee(() => v(D), [D]), { data: F, loading: I, error: L, fetchMore: R, refetch: z } = u({
18
+ }, [O.search]);
19
+ let F = ee(() => v(O), [O]), { data: I, loading: L, error: R, fetchMore: z, refetch: B } = u({
19
20
  variables: {
20
- filter: P,
21
+ filter: F,
21
22
  limit: 10,
22
23
  offset: 0
23
24
  },
24
25
  notifyOnNetworkStatusChange: !0
25
- }), { data: B, loading: ne } = f({
26
+ }), { data: V, loading: ne } = f({
26
27
  variables: {
27
- query: M,
28
+ query: N,
28
29
  limit: 20
29
30
  },
30
- skip: M.length === 0,
31
+ skip: N.length === 0,
31
32
  notifyOnNetworkStatusChange: !0
32
- }), { data: V, loading: H } = c({
33
+ }), { data: H, loading: U } = c({
33
34
  variables: {
34
35
  filter: void 0,
35
36
  limit: 100,
36
37
  offset: 0
37
38
  },
38
- skip: !S.loadAgentProfiles
39
- }), { data: U, loading: W, error: G, refetch: K } = l({
40
- variables: { id: A ?? "" },
41
- skip: !A
42
- }), [q, { loading: J }] = s({
39
+ skip: !C.loadAgentProfiles
40
+ }), { data: W, loading: G, error: K, refetch: q } = l({
41
+ variables: { id: j ?? "" },
42
+ skip: !j
43
+ }), [J, { loading: Y }] = s({
43
44
  onCompleted: (e) => {
44
- e.createSupportTicket && z();
45
+ e.createSupportTicket && B();
45
46
  },
46
47
  onError: (e) => {
47
48
  console.error("Failed to create ticket:", e);
48
49
  }
49
- }), [Y, { loading: X }] = m({
50
+ }), [X, { loading: Z }] = m({
50
51
  onCompleted: (e) => {
51
- e.updateSupportTicket && (z(), A === e.updateSupportTicket.id && K());
52
+ e.updateSupportTicket && (B(), j === e.updateSupportTicket.id && q());
52
53
  },
53
54
  onError: (e) => {
54
55
  console.error("Failed to update ticket:", e);
55
56
  }
56
- }), [Z, { loading: re }] = i({
57
+ }), [re, { loading: ie }] = i({
57
58
  onCompleted: (e) => {
58
- e.assignSupportTicket && (z(), A === e.assignSupportTicket.id && K());
59
+ e.assignSupportTicket && (B(), j === e.assignSupportTicket.id && q());
59
60
  },
60
61
  onError: (e) => {
61
62
  console.error("Failed to assign ticket:", e);
62
63
  }
63
- }), [ie, { loading: ae }] = h({
64
+ }), [ae, { loading: oe }] = h({
64
65
  onCompleted: (e) => {
65
- e.updateSupportTicketStatus && (z(), A === e.updateSupportTicketStatus.id && K());
66
+ e.updateSupportTicketStatus && (B(), j === e.updateSupportTicketStatus.id && q());
66
67
  },
67
68
  onError: (e) => {
68
69
  console.error("Failed to change ticket status:", e);
69
70
  }
70
- }), [Q, { loading: oe }] = d({
71
+ }), [Q, { loading: $ }] = d({
71
72
  onCompleted: (e) => {
72
- e.resolveSupportTicket && (z(), A === e.resolveSupportTicket.id && K());
73
+ e.resolveSupportTicket && (B(), j === e.resolveSupportTicket.id && q());
73
74
  },
74
75
  onError: (e) => {
75
76
  console.error("Failed to resolve ticket:", e);
76
77
  }
77
- }), [$, { loading: se }] = a({
78
+ }), [se, { loading: ce }] = a({
78
79
  onCompleted: (e) => {
79
- e.closeSupportTicket && (z(), A === e.closeSupportTicket.id && K());
80
+ e.closeSupportTicket && (B(), j === e.closeSupportTicket.id && q());
80
81
  },
81
82
  onError: (e) => {
82
83
  console.error("Failed to close ticket:", e);
83
84
  }
84
- }), [ce, { loading: le }] = o({
85
+ }), [le, { loading: ue }] = o({
85
86
  onCompleted: () => {
86
- A && K();
87
+ j && q();
87
88
  },
88
89
  onError: (e) => {
89
90
  console.error("Failed to add ticket message:", e);
90
91
  }
91
- }), [ue, { loading: de }] = p({
92
+ }), [de, { loading: fe }] = p({
92
93
  onCompleted: () => {
93
- A && K();
94
+ j && q();
94
95
  },
95
96
  onError: (e) => {
96
97
  console.error("Failed to submit satisfaction survey:", e);
97
98
  }
98
99
  });
99
100
  return {
100
- tickets: M ? (B?.searchTickets || []).filter((e) => y(e, D)) : F?.supportTickets?.nodes || [],
101
- ticketDetail: U?.supportTicket || null,
102
- agentProfiles: V?.agentProfiles?.nodes || [],
103
- totalTickets: F?.supportTickets?.totalCount || 0,
104
- hasMoreTickets: F?.supportTickets?.hasMore || !1,
105
- ticketsLoading: M ? ne : I,
106
- ticketDetailLoading: W,
107
- agentProfilesLoading: H,
108
- createTicketLoading: J,
109
- updateTicketLoading: X,
110
- assignTicketLoading: re,
111
- changeStatusLoading: ae || oe || se,
112
- addMessageLoading: le,
113
- submitSurveyLoading: de,
114
- ticketsError: L,
115
- ticketDetailError: G,
101
+ tickets: N ? (V?.searchTickets || []).filter((e) => y(e, O)) : I?.supportTickets?.nodes || [],
102
+ ticketDetail: W?.supportTicket || null,
103
+ agentProfiles: H?.agentProfiles?.nodes || [],
104
+ totalTickets: I?.supportTickets?.totalCount || 0,
105
+ hasMoreTickets: I?.supportTickets?.hasMore || !1,
106
+ ticketsLoading: N ? ne : L,
107
+ ticketDetailLoading: G,
108
+ agentProfilesLoading: U,
109
+ createTicketLoading: Y,
110
+ updateTicketLoading: Z,
111
+ assignTicketLoading: ie,
112
+ changeStatusLoading: oe || $ || ce,
113
+ addMessageLoading: ue,
114
+ submitSurveyLoading: fe,
115
+ ticketsError: R,
116
+ ticketDetailError: K,
116
117
  createTicket: async (e) => {
117
118
  try {
118
119
  let t = {
119
120
  ...e.context ?? {},
120
- workspaceId: e.context?.workspaceId ?? C ?? void 0,
121
- organizationId: e.context?.organizationId ?? w ?? void 0,
122
- productId: e.context?.productId ?? T ?? void 0,
123
- userId: e.context?.userId ?? E?.id ?? void 0
124
- }, r = (await q({ variables: { input: {
121
+ workspaceId: e.context?.workspaceId ?? w ?? void 0,
122
+ organizationId: e.context?.organizationId ?? T ?? void 0,
123
+ productId: e.context?.productId ?? E ?? void 0,
124
+ userId: e.context?.userId ?? D?.id ?? void 0
125
+ }, r = (await J({ variables: { input: {
125
126
  ...e,
126
127
  context: t
127
128
  } } })).data?.createSupportTicket;
128
- return r && n(j, r, C), r;
129
+ return r && n(M, r, w), r;
129
130
  } catch (e) {
130
131
  throw console.error("Error creating ticket:", e), e;
131
132
  }
132
133
  },
133
134
  updateTicket: async (e, t) => {
134
135
  try {
135
- let n = (await Y({ variables: {
136
+ let n = (await X({ variables: {
136
137
  id: e,
137
138
  input: t
138
139
  } })).data?.updateSupportTicket;
139
- return n && j.emit("support.ticket.updated", {
140
+ return n && M.emit("support.ticket.updated", {
140
141
  ticketId: n.id,
141
142
  status: n.status,
142
143
  priority: n.priority,
143
144
  categoryId: n.categoryId ?? void 0,
144
- workspaceId: C ?? void 0
145
+ workspaceId: w ?? void 0
145
146
  }), n;
146
147
  } catch (e) {
147
148
  throw console.error("Error updating ticket:", e), e;
@@ -149,8 +150,8 @@ function S(S = {}) {
149
150
  },
150
151
  assignTicket: async (e, t) => {
151
152
  try {
152
- let n = (V?.agentProfiles?.nodes ?? []).find((e) => e.userId === t || e.id === t);
153
- return (await Z({ variables: {
153
+ let n = (H?.agentProfiles?.nodes ?? []).find((e) => e.userId === t || e.id === t);
154
+ return (await re({ variables: {
154
155
  id: e,
155
156
  assignedTo: n?.userId ?? t
156
157
  } })).data?.assignSupportTicket;
@@ -162,43 +163,43 @@ function S(S = {}) {
162
163
  try {
163
164
  if (n === g.Resolved) return (await Q({ variables: { id: e } })).data?.resolveSupportTicket;
164
165
  if (n === g.Closed) {
165
- let n = U?.supportTicket?.status ?? O?.status, r = n !== void 0 && n !== g.Resolved && n !== g.Closed;
166
+ let n = W?.supportTicket?.status ?? k?.status, r = n !== void 0 && n !== g.Resolved && n !== g.Closed;
166
167
  r && await Q({ variables: {
167
168
  id: e,
168
169
  resolution: "Closed by support."
169
170
  } });
170
171
  try {
171
- let n = (await $({ variables: { id: e } })).data?.closeSupportTicket;
172
- return n && t(j, n, C), n;
172
+ let n = (await se({ variables: { id: e } })).data?.closeSupportTicket;
173
+ return n && t(M, n, w), n;
173
174
  } catch (e) {
174
175
  throw r ? Error("Ticket was resolved, but closing it failed. Please try closing it again.") : e;
175
176
  }
176
177
  }
177
- let i = (await ie({ variables: {
178
+ let i = (await ae({ variables: {
178
179
  id: e,
179
180
  status: n
180
181
  } })).data?.updateSupportTicketStatus;
181
- return i && n === g.Reopened && r(j, i, C), i;
182
+ return i && n === g.Reopened && r(M, i, w), i;
182
183
  } catch (e) {
183
184
  throw console.error("Error changing ticket status:", e), e;
184
185
  }
185
186
  },
186
187
  addTicketMessage: async (e) => {
187
188
  try {
188
- let t = (await ce({ variables: { input: {
189
+ let t = (await le({ variables: { input: {
189
190
  ...e,
190
191
  context: {
191
192
  ...e.context ?? {},
192
- workspaceId: e.context?.workspaceId ?? C ?? O?.context?.workspaceId ?? void 0,
193
- organizationId: e.context?.organizationId ?? w ?? O?.context?.organizationId ?? void 0,
194
- productId: e.context?.productId ?? T ?? O?.context?.productId ?? void 0,
195
- userId: e.context?.userId ?? E?.id ?? void 0
193
+ workspaceId: e.context?.workspaceId ?? w ?? k?.context?.workspaceId ?? void 0,
194
+ organizationId: e.context?.organizationId ?? T ?? k?.context?.organizationId ?? void 0,
195
+ productId: e.context?.productId ?? E ?? k?.context?.productId ?? void 0,
196
+ userId: e.context?.userId ?? D?.id ?? void 0
196
197
  }
197
198
  } } })).data?.createSupportMessage;
198
- return t && j.emit("support.ticket.message_sent", {
199
+ return t && M.emit("support.ticket.message_sent", {
199
200
  messageId: t.id,
200
201
  ticketId: e.ticketId,
201
- workspaceId: C ?? void 0
202
+ workspaceId: w ?? void 0
202
203
  }), t;
203
204
  } catch (e) {
204
205
  throw console.error("Error adding ticket message:", e), e;
@@ -206,14 +207,14 @@ function S(S = {}) {
206
207
  },
207
208
  submitSatisfactionSurvey: async (e) => {
208
209
  try {
209
- return (await ue({ variables: { input: e } })).data?.submitSatisfactionSurvey;
210
+ return (await de({ variables: { input: e } })).data?.submitSatisfactionSurvey;
210
211
  } catch (e) {
211
212
  throw console.error("Error submitting satisfaction survey:", e), e;
212
213
  }
213
214
  },
214
215
  loadMoreTickets: () => {
215
- let e = F?.supportTickets?.nodes?.length || 0;
216
- F?.supportTickets?.hasMore && R({
216
+ let e = I?.supportTickets?.nodes?.length || 0;
217
+ I?.supportTickets?.hasMore && z({
217
218
  variables: { offset: e },
218
219
  updateQuery: (e, { fetchMoreResult: t }) => t ? { supportTickets: {
219
220
  ...t.supportTickets,
@@ -221,11 +222,11 @@ function S(S = {}) {
221
222
  } } : e
222
223
  });
223
224
  },
224
- refetchTickets: z,
225
- refetchTicketDetail: K,
226
- setSelectedTicket: k
225
+ refetchTickets: b(B),
226
+ refetchTicketDetail: b(q),
227
+ setSelectedTicket: A
227
228
  };
228
229
  }
229
- export { S as useTicketOperations };
230
+ export { C as useTicketOperations };
230
231
 
231
232
  //# sourceMappingURL=useTicketOperations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTicketOperations.js","names":["useTicketOperations","useSupport","useSupportStore","detailTicketId","options","selectedTicket","eventBus","useEventBus","debouncedSearch","setDebouncedSearch","useState","ticketFilter","timer","filter","useMemo","buildTicketFilter","ticketsData","ticketsLoading","ticketsError","fetchMoreTickets","refetchTickets","useGetTicketsQuery","searchedTicketsData","searchLoading","useSearchTicketsQuery","agentProfilesData","agentProfilesLoading","useGetAgentProfilesQuery","ticketDetailData","ticketDetailLoading","ticketDetailError","refetchTicketDetail","useGetTicketDetailQuery","createTicketMutation","createTicketLoading","useCreateSupportTicketMutation","data","error","updateTicketMutation","updateTicketLoading","useUpdateSupportTicketMutation","assignTicketMutation","assignTicketLoading","useAssignSupportTicketMutation","changeTicketStatusMutation","changeStatusLoading","useUpdateSupportTicketStatusMutation","resolveTicketMutation","resolveTicketLoading","useResolveSupportTicketMutation","closeTicketMutation","closeTicketLoading","useCloseSupportTicketMutation","addTicketMessageMutation","addMessageLoading","useCreateSupportMessageMutation","submitSatisfactionSurveyMutation","submitSurveyLoading","useSubmitSatisfactionSurveyMutation","matchesTicketClientFilters","ticket","mergedContext","input","workspaceId","organizationId","productId","currentUser","emitSupportTicketCreated","updated","selectedAgent","agent","assignedTo","ticketId","status","SupportTicketStatus","currentStatus","shouldResolveFirst","closedTicket","emitSupportTicketClosed","closeError","updatedTicket","emitSupportTicketReopened","message","currentCount","fetchMoreResult","prev"],"sources":["../../../src/support/hooks/useTicketOperations.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n emitSupportTicketClosed,\n emitSupportTicketCreated,\n emitSupportTicketReopened,\n} from '../events/rybbit';\nimport {\n useGetAgentProfilesQuery,\n useGetTicketsQuery,\n useGetTicketDetailQuery,\n useSearchTicketsQuery,\n useCreateSupportTicketMutation,\n useUpdateSupportTicketMutation,\n useAssignSupportTicketMutation,\n useUpdateSupportTicketStatusMutation,\n useResolveSupportTicketMutation,\n useCloseSupportTicketMutation,\n useCreateSupportMessageMutation,\n useSubmitSatisfactionSurveyMutation,\n} from '../../generated/global-operations';\nimport {\n SupportTicketStatus,\n type SupportTicket,\n type CreateSupportTicketInput,\n type UpdateSupportTicketInput,\n type CreateSupportMessageInput,\n type SubmitSatisfactionSurveyInput,\n} from '../../generated/global-types';\nimport { useSupport } from '../providers/SupportProvider';\nimport { buildTicketFilter, matchesTicketClientFilters } from '../utils/ticketFilters';\n\ninterface UseTicketOperationsOptions {\n loadAgentProfiles?: boolean;\n /**\n * The ticket a detail page shows, taken from its route. Preferred over the\n * store's `selectedTicket`, which `SupportAdminRoot`/`SupportUserRoot` reset\n * on mount and on every context change — the root's effect runs after the\n * page's, so a ticket opened by direct link (an email, a refresh, a shared\n * URL) was wiped before its query ran and the page showed \"Ticket not found\".\n */\n ticketId?: string;\n}\n\nexport function useTicketOperations(options: UseTicketOperationsOptions = {}) {\n const { workspaceId, organizationId, productId, currentUser } = useSupport();\n const { ticketFilter, selectedTicket, setSelectedTicket } = useSupportStore();\n const detailTicketId = options.ticketId || selectedTicket?.id || undefined;\n const eventBus = useEventBus();\n const [debouncedSearch, setDebouncedSearch] = useState(() => ticketFilter.search.trim());\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setDebouncedSearch(ticketFilter.search.trim());\n }, 300);\n\n return () => clearTimeout(timer);\n }, [ticketFilter.search]);\n\n const filter = useMemo(() => buildTicketFilter(ticketFilter), [ticketFilter]);\n\n // Query: Get tickets with filters\n const {\n data: ticketsData,\n loading: ticketsLoading,\n error: ticketsError,\n fetchMore: fetchMoreTickets,\n refetch: refetchTickets,\n } = useGetTicketsQuery({\n variables: {\n filter,\n limit: 10,\n offset: 0,\n },\n notifyOnNetworkStatusChange: true,\n });\n\n const { data: searchedTicketsData, loading: searchLoading } = useSearchTicketsQuery({\n variables: {\n query: debouncedSearch,\n limit: 20,\n },\n skip: debouncedSearch.length === 0,\n notifyOnNetworkStatusChange: true,\n });\n\n const { data: agentProfilesData, loading: agentProfilesLoading } = useGetAgentProfilesQuery({\n variables: {\n filter: undefined,\n limit: 100,\n offset: 0,\n },\n skip: !options.loadAgentProfiles,\n });\n\n // Query: Get ticket detail\n const {\n data: ticketDetailData,\n loading: ticketDetailLoading,\n error: ticketDetailError,\n refetch: refetchTicketDetail,\n } = useGetTicketDetailQuery({\n variables: { id: detailTicketId ?? '' },\n skip: !detailTicketId,\n });\n\n // Mutation: Create ticket\n const [createTicketMutation, { loading: createTicketLoading }] = useCreateSupportTicketMutation({\n onCompleted: (data) => {\n if (data.createSupportTicket) {\n refetchTickets();\n }\n },\n onError: (error) => {\n console.error('Failed to create ticket:', error);\n },\n });\n\n // Mutation: Update ticket\n const [updateTicketMutation, { loading: updateTicketLoading }] = useUpdateSupportTicketMutation({\n onCompleted: (data) => {\n if (data.updateSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.updateSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to update ticket:', error);\n },\n });\n\n // Mutation: Assign ticket\n const [assignTicketMutation, { loading: assignTicketLoading }] = useAssignSupportTicketMutation({\n onCompleted: (data) => {\n if (data.assignSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.assignSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to assign ticket:', error);\n },\n });\n\n // Mutation: Change ticket status\n const [changeTicketStatusMutation, { loading: changeStatusLoading }] =\n useUpdateSupportTicketStatusMutation({\n onCompleted: (data) => {\n if (data.updateSupportTicketStatus) {\n refetchTickets();\n if (detailTicketId === data.updateSupportTicketStatus.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to change ticket status:', error);\n },\n });\n\n const [resolveTicketMutation, { loading: resolveTicketLoading }] =\n useResolveSupportTicketMutation({\n onCompleted: (data) => {\n if (data.resolveSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.resolveSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to resolve ticket:', error);\n },\n });\n\n const [closeTicketMutation, { loading: closeTicketLoading }] = useCloseSupportTicketMutation({\n onCompleted: (data) => {\n if (data.closeSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.closeSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to close ticket:', error);\n },\n });\n\n // Mutation: Add ticket message\n const [addTicketMessageMutation, { loading: addMessageLoading }] =\n useCreateSupportMessageMutation({\n onCompleted: () => {\n if (detailTicketId) {\n refetchTicketDetail();\n }\n },\n onError: (error) => {\n console.error('Failed to add ticket message:', error);\n },\n });\n\n const [submitSatisfactionSurveyMutation, { loading: submitSurveyLoading }] =\n useSubmitSatisfactionSurveyMutation({\n onCompleted: () => {\n if (detailTicketId) {\n refetchTicketDetail();\n }\n },\n onError: (error) => {\n console.error('Failed to submit satisfaction survey:', error);\n },\n });\n\n // Helper: Create ticket\n const createTicket = async (input: CreateSupportTicketInput) => {\n try {\n const mergedContext = {\n ...(input.context ?? {}),\n workspaceId: input.context?.workspaceId ?? workspaceId ?? undefined,\n organizationId: input.context?.organizationId ?? organizationId ?? undefined,\n productId: input.context?.productId ?? productId ?? undefined,\n userId: input.context?.userId ?? currentUser?.id ?? undefined,\n };\n\n const result = await createTicketMutation({\n variables: {\n input: {\n ...input,\n context: mergedContext,\n },\n },\n });\n const ticket = result.data?.createSupportTicket;\n if (ticket) {\n emitSupportTicketCreated(eventBus, ticket, workspaceId);\n }\n return ticket;\n } catch (error) {\n console.error('Error creating ticket:', error);\n throw error;\n }\n };\n\n // Helper: Update ticket\n const updateTicket = async (id: string, input: UpdateSupportTicketInput) => {\n try {\n const result = await updateTicketMutation({\n variables: { id, input },\n });\n const updated = result.data?.updateSupportTicket;\n if (updated) {\n eventBus.emit('support.ticket.updated', {\n ticketId: updated.id,\n status: updated.status,\n priority: updated.priority,\n categoryId: updated.categoryId ?? undefined,\n workspaceId: workspaceId ?? undefined,\n });\n }\n return updated;\n } catch (error) {\n console.error('Error updating ticket:', error);\n throw error;\n }\n };\n\n // Helper: Assign ticket\n const assignTicket = async (ticketId: string, assignedTo: string) => {\n try {\n const assignableAgents = agentProfilesData?.agentProfiles?.nodes ?? [];\n const selectedAgent = assignableAgents.find(\n (agent: { id: string; userId: string }) =>\n agent.userId === assignedTo || agent.id === assignedTo\n );\n\n const result = await assignTicketMutation({\n variables: { id: ticketId, assignedTo: selectedAgent?.userId ?? assignedTo },\n });\n return result.data?.assignSupportTicket;\n } catch (error) {\n console.error('Error assigning ticket:', error);\n throw error;\n }\n };\n\n // Helper: Change ticket status\n const changeTicketStatus = async (ticketId: string, status: SupportTicketStatus) => {\n try {\n if (status === SupportTicketStatus.Resolved) {\n const result = await resolveTicketMutation({\n variables: { id: ticketId },\n });\n return result.data?.resolveSupportTicket;\n }\n\n if (status === SupportTicketStatus.Closed) {\n const currentStatus = ticketDetailData?.supportTicket?.status ?? selectedTicket?.status;\n const shouldResolveFirst =\n currentStatus !== undefined &&\n currentStatus !== SupportTicketStatus.Resolved &&\n currentStatus !== SupportTicketStatus.Closed;\n if (shouldResolveFirst) {\n await resolveTicketMutation({\n variables: { id: ticketId, resolution: 'Closed by support.' },\n });\n }\n\n try {\n const result = await closeTicketMutation({\n variables: { id: ticketId },\n });\n const closedTicket = result.data?.closeSupportTicket;\n if (closedTicket) {\n emitSupportTicketClosed(eventBus, closedTicket, workspaceId);\n }\n return closedTicket;\n } catch (closeError) {\n if (shouldResolveFirst) {\n throw new Error(\n 'Ticket was resolved, but closing it failed. Please try closing it again.'\n );\n }\n throw closeError;\n }\n }\n\n const result = await changeTicketStatusMutation({\n variables: { id: ticketId, status },\n });\n const updatedTicket = result.data?.updateSupportTicketStatus;\n if (updatedTicket && status === SupportTicketStatus.Reopened) {\n emitSupportTicketReopened(eventBus, updatedTicket, workspaceId);\n }\n return updatedTicket;\n } catch (error) {\n console.error('Error changing ticket status:', error);\n throw error;\n }\n };\n\n // Helper: Add message to ticket\n const addTicketMessage = async (input: CreateSupportMessageInput) => {\n try {\n const result = await addTicketMessageMutation({\n variables: {\n input: {\n ...input,\n context: {\n ...(input.context ?? {}),\n workspaceId:\n input.context?.workspaceId ??\n workspaceId ??\n selectedTicket?.context?.workspaceId ??\n undefined,\n organizationId:\n input.context?.organizationId ??\n organizationId ??\n selectedTicket?.context?.organizationId ??\n undefined,\n productId:\n input.context?.productId ??\n productId ??\n selectedTicket?.context?.productId ??\n undefined,\n userId: input.context?.userId ?? currentUser?.id ?? undefined,\n },\n },\n },\n });\n const message = result.data?.createSupportMessage;\n if (message) {\n eventBus.emit('support.ticket.message_sent', {\n messageId: message.id,\n ticketId: input.ticketId,\n workspaceId: workspaceId ?? undefined,\n });\n }\n return message;\n } catch (error) {\n console.error('Error adding ticket message:', error);\n throw error;\n }\n };\n\n const submitSatisfactionSurvey = async (input: SubmitSatisfactionSurveyInput) => {\n try {\n const result = await submitSatisfactionSurveyMutation({\n variables: { input },\n });\n return result.data?.submitSatisfactionSurvey;\n } catch (error) {\n console.error('Error submitting satisfaction survey:', error);\n throw error;\n }\n };\n\n // Helper: Load more tickets (offset-based pagination)\n const loadMoreTickets = () => {\n const currentCount = ticketsData?.supportTickets?.nodes?.length || 0;\n if (ticketsData?.supportTickets?.hasMore) {\n fetchMoreTickets({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n supportTickets: {\n ...fetchMoreResult.supportTickets,\n nodes: [\n ...(prev.supportTickets?.nodes || []),\n ...(fetchMoreResult.supportTickets?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Extract tickets from nodes\n const baseTickets: SupportTicket[] = debouncedSearch\n ? (searchedTicketsData?.searchTickets || []).filter((ticket: SupportTicket) =>\n matchesTicketClientFilters(ticket, ticketFilter)\n )\n : ticketsData?.supportTickets?.nodes || [];\n\n const tickets: SupportTicket[] = baseTickets;\n\n return {\n // Data\n tickets,\n ticketDetail: ticketDetailData?.supportTicket || null,\n agentProfiles: agentProfilesData?.agentProfiles?.nodes || [],\n totalTickets: ticketsData?.supportTickets?.totalCount || 0,\n hasMoreTickets: ticketsData?.supportTickets?.hasMore || false,\n\n // Loading states\n ticketsLoading: debouncedSearch ? searchLoading : ticketsLoading,\n ticketDetailLoading,\n agentProfilesLoading,\n createTicketLoading,\n updateTicketLoading,\n assignTicketLoading,\n changeStatusLoading: changeStatusLoading || resolveTicketLoading || closeTicketLoading,\n addMessageLoading,\n submitSurveyLoading,\n\n // Errors\n ticketsError,\n ticketDetailError,\n\n // Operations\n createTicket,\n updateTicket,\n assignTicket,\n changeTicketStatus,\n addTicketMessage,\n submitSatisfactionSurvey,\n loadMoreTickets,\n refetchTickets,\n refetchTicketDetail,\n setSelectedTicket,\n };\n}\n"],"mappings":";;;;;;;;;AA6CA,SAAgBA,EAAoB,IAAsC,CAAC,GAAG;CAC5E,IAAM,EAAE,gBAAa,mBAAgB,cAAW,mBAAgBC,EAAW,GACrE,EAAE,iBAAc,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EACV;IACA,cAAc,GAAM,EAAE,yBACfC,IACE,EACL,gBAAgB;KACd,GAAGA,EAAgB;KACnB,OAAO,CACL,GAAIC,EAAK,gBAAgB,SAAS,CAAC,GACnC,GAAID,EAAgB,gBAAgB,SAAS,CAAC,CAChD;IACF,EACF,IAT6BC;GAWjC,CAAC;EAEL;EA0CE;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useTicketOperations.js","names":["useTicketOperations","useSupport","useSupportStore","detailTicketId","options","selectedTicket","eventBus","useEventBus","debouncedSearch","setDebouncedSearch","useState","ticketFilter","timer","filter","useMemo","buildTicketFilter","ticketsData","ticketsLoading","ticketsError","fetchMoreTickets","refetchTickets","useGetTicketsQuery","searchedTicketsData","searchLoading","useSearchTicketsQuery","agentProfilesData","agentProfilesLoading","useGetAgentProfilesQuery","ticketDetailData","ticketDetailLoading","ticketDetailError","refetchTicketDetail","useGetTicketDetailQuery","createTicketMutation","createTicketLoading","useCreateSupportTicketMutation","data","error","updateTicketMutation","updateTicketLoading","useUpdateSupportTicketMutation","assignTicketMutation","assignTicketLoading","useAssignSupportTicketMutation","changeTicketStatusMutation","changeStatusLoading","useUpdateSupportTicketStatusMutation","resolveTicketMutation","resolveTicketLoading","useResolveSupportTicketMutation","closeTicketMutation","closeTicketLoading","useCloseSupportTicketMutation","addTicketMessageMutation","addMessageLoading","useCreateSupportMessageMutation","submitSatisfactionSurveyMutation","submitSurveyLoading","useSubmitSatisfactionSurveyMutation","matchesTicketClientFilters","ticket","mergedContext","input","workspaceId","organizationId","productId","currentUser","emitSupportTicketCreated","updated","selectedAgent","agent","assignedTo","ticketId","status","SupportTicketStatus","currentStatus","shouldResolveFirst","closedTicket","emitSupportTicketClosed","closeError","updatedTicket","emitSupportTicketReopened","message","currentCount","fetchMoreResult","prev","asRefetch"],"sources":["../../../src/support/hooks/useTicketOperations.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport { useSupportStore } from '../store/supportStore';\nimport {\n emitSupportTicketClosed,\n emitSupportTicketCreated,\n emitSupportTicketReopened,\n} from '../events/rybbit';\nimport {\n useGetAgentProfilesQuery,\n useGetTicketsQuery,\n useGetTicketDetailQuery,\n useSearchTicketsQuery,\n useCreateSupportTicketMutation,\n useUpdateSupportTicketMutation,\n useAssignSupportTicketMutation,\n useUpdateSupportTicketStatusMutation,\n useResolveSupportTicketMutation,\n useCloseSupportTicketMutation,\n useCreateSupportMessageMutation,\n useSubmitSatisfactionSurveyMutation,\n} from '../../generated/global-operations';\nimport {\n SupportTicketStatus,\n type SupportTicket,\n type CreateSupportTicketInput,\n type UpdateSupportTicketInput,\n type CreateSupportMessageInput,\n type SubmitSatisfactionSurveyInput,\n} from '../../generated/global-types';\nimport { useSupport } from '../providers/SupportProvider';\nimport { buildTicketFilter, matchesTicketClientFilters } from '../utils/ticketFilters';\nimport { asRefetch } from '../utils/refetch';\n\ninterface UseTicketOperationsOptions {\n loadAgentProfiles?: boolean;\n /**\n * The ticket a detail page shows, taken from its route. Preferred over the\n * store's `selectedTicket`, which `SupportAdminRoot`/`SupportUserRoot` reset\n * on mount and on every context change — the root's effect runs after the\n * page's, so a ticket opened by direct link (an email, a refresh, a shared\n * URL) was wiped before its query ran and the page showed \"Ticket not found\".\n */\n ticketId?: string;\n}\n\nexport function useTicketOperations(options: UseTicketOperationsOptions = {}) {\n const { workspaceId, organizationId, productId, currentUser } = useSupport();\n const { ticketFilter, selectedTicket, setSelectedTicket } = useSupportStore();\n const detailTicketId = options.ticketId || selectedTicket?.id || undefined;\n const eventBus = useEventBus();\n const [debouncedSearch, setDebouncedSearch] = useState(() => ticketFilter.search.trim());\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setDebouncedSearch(ticketFilter.search.trim());\n }, 300);\n\n return () => clearTimeout(timer);\n }, [ticketFilter.search]);\n\n const filter = useMemo(() => buildTicketFilter(ticketFilter), [ticketFilter]);\n\n // Query: Get tickets with filters\n const {\n data: ticketsData,\n loading: ticketsLoading,\n error: ticketsError,\n fetchMore: fetchMoreTickets,\n refetch: refetchTickets,\n } = useGetTicketsQuery({\n variables: {\n filter,\n limit: 10,\n offset: 0,\n },\n notifyOnNetworkStatusChange: true,\n });\n\n const { data: searchedTicketsData, loading: searchLoading } = useSearchTicketsQuery({\n variables: {\n query: debouncedSearch,\n limit: 20,\n },\n skip: debouncedSearch.length === 0,\n notifyOnNetworkStatusChange: true,\n });\n\n const { data: agentProfilesData, loading: agentProfilesLoading } = useGetAgentProfilesQuery({\n variables: {\n filter: undefined,\n limit: 100,\n offset: 0,\n },\n skip: !options.loadAgentProfiles,\n });\n\n // Query: Get ticket detail\n const {\n data: ticketDetailData,\n loading: ticketDetailLoading,\n error: ticketDetailError,\n refetch: refetchTicketDetail,\n } = useGetTicketDetailQuery({\n variables: { id: detailTicketId ?? '' },\n skip: !detailTicketId,\n });\n\n // Mutation: Create ticket\n const [createTicketMutation, { loading: createTicketLoading }] = useCreateSupportTicketMutation({\n onCompleted: (data) => {\n if (data.createSupportTicket) {\n refetchTickets();\n }\n },\n onError: (error) => {\n console.error('Failed to create ticket:', error);\n },\n });\n\n // Mutation: Update ticket\n const [updateTicketMutation, { loading: updateTicketLoading }] = useUpdateSupportTicketMutation({\n onCompleted: (data) => {\n if (data.updateSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.updateSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to update ticket:', error);\n },\n });\n\n // Mutation: Assign ticket\n const [assignTicketMutation, { loading: assignTicketLoading }] = useAssignSupportTicketMutation({\n onCompleted: (data) => {\n if (data.assignSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.assignSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to assign ticket:', error);\n },\n });\n\n // Mutation: Change ticket status\n const [changeTicketStatusMutation, { loading: changeStatusLoading }] =\n useUpdateSupportTicketStatusMutation({\n onCompleted: (data) => {\n if (data.updateSupportTicketStatus) {\n refetchTickets();\n if (detailTicketId === data.updateSupportTicketStatus.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to change ticket status:', error);\n },\n });\n\n const [resolveTicketMutation, { loading: resolveTicketLoading }] =\n useResolveSupportTicketMutation({\n onCompleted: (data) => {\n if (data.resolveSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.resolveSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to resolve ticket:', error);\n },\n });\n\n const [closeTicketMutation, { loading: closeTicketLoading }] = useCloseSupportTicketMutation({\n onCompleted: (data) => {\n if (data.closeSupportTicket) {\n refetchTickets();\n if (detailTicketId === data.closeSupportTicket.id) {\n refetchTicketDetail();\n }\n }\n },\n onError: (error) => {\n console.error('Failed to close ticket:', error);\n },\n });\n\n // Mutation: Add ticket message\n const [addTicketMessageMutation, { loading: addMessageLoading }] =\n useCreateSupportMessageMutation({\n onCompleted: () => {\n if (detailTicketId) {\n refetchTicketDetail();\n }\n },\n onError: (error) => {\n console.error('Failed to add ticket message:', error);\n },\n });\n\n const [submitSatisfactionSurveyMutation, { loading: submitSurveyLoading }] =\n useSubmitSatisfactionSurveyMutation({\n onCompleted: () => {\n if (detailTicketId) {\n refetchTicketDetail();\n }\n },\n onError: (error) => {\n console.error('Failed to submit satisfaction survey:', error);\n },\n });\n\n // Helper: Create ticket\n const createTicket = async (input: CreateSupportTicketInput) => {\n try {\n const mergedContext = {\n ...(input.context ?? {}),\n workspaceId: input.context?.workspaceId ?? workspaceId ?? undefined,\n organizationId: input.context?.organizationId ?? organizationId ?? undefined,\n productId: input.context?.productId ?? productId ?? undefined,\n userId: input.context?.userId ?? currentUser?.id ?? undefined,\n };\n\n const result = await createTicketMutation({\n variables: {\n input: {\n ...input,\n context: mergedContext,\n },\n },\n });\n const ticket = result.data?.createSupportTicket;\n if (ticket) {\n emitSupportTicketCreated(eventBus, ticket, workspaceId);\n }\n return ticket;\n } catch (error) {\n console.error('Error creating ticket:', error);\n throw error;\n }\n };\n\n // Helper: Update ticket\n const updateTicket = async (id: string, input: UpdateSupportTicketInput) => {\n try {\n const result = await updateTicketMutation({\n variables: { id, input },\n });\n const updated = result.data?.updateSupportTicket;\n if (updated) {\n eventBus.emit('support.ticket.updated', {\n ticketId: updated.id,\n status: updated.status,\n priority: updated.priority,\n categoryId: updated.categoryId ?? undefined,\n workspaceId: workspaceId ?? undefined,\n });\n }\n return updated;\n } catch (error) {\n console.error('Error updating ticket:', error);\n throw error;\n }\n };\n\n // Helper: Assign ticket\n const assignTicket = async (ticketId: string, assignedTo: string) => {\n try {\n const assignableAgents = agentProfilesData?.agentProfiles?.nodes ?? [];\n const selectedAgent = assignableAgents.find(\n (agent: { id: string; userId: string }) =>\n agent.userId === assignedTo || agent.id === assignedTo\n );\n\n const result = await assignTicketMutation({\n variables: { id: ticketId, assignedTo: selectedAgent?.userId ?? assignedTo },\n });\n return result.data?.assignSupportTicket;\n } catch (error) {\n console.error('Error assigning ticket:', error);\n throw error;\n }\n };\n\n // Helper: Change ticket status\n const changeTicketStatus = async (ticketId: string, status: SupportTicketStatus) => {\n try {\n if (status === SupportTicketStatus.Resolved) {\n const result = await resolveTicketMutation({\n variables: { id: ticketId },\n });\n return result.data?.resolveSupportTicket;\n }\n\n if (status === SupportTicketStatus.Closed) {\n const currentStatus = ticketDetailData?.supportTicket?.status ?? selectedTicket?.status;\n const shouldResolveFirst =\n currentStatus !== undefined &&\n currentStatus !== SupportTicketStatus.Resolved &&\n currentStatus !== SupportTicketStatus.Closed;\n if (shouldResolveFirst) {\n await resolveTicketMutation({\n variables: { id: ticketId, resolution: 'Closed by support.' },\n });\n }\n\n try {\n const result = await closeTicketMutation({\n variables: { id: ticketId },\n });\n const closedTicket = result.data?.closeSupportTicket;\n if (closedTicket) {\n emitSupportTicketClosed(eventBus, closedTicket, workspaceId);\n }\n return closedTicket;\n } catch (closeError) {\n if (shouldResolveFirst) {\n throw new Error(\n 'Ticket was resolved, but closing it failed. Please try closing it again.'\n );\n }\n throw closeError;\n }\n }\n\n const result = await changeTicketStatusMutation({\n variables: { id: ticketId, status },\n });\n const updatedTicket = result.data?.updateSupportTicketStatus;\n if (updatedTicket && status === SupportTicketStatus.Reopened) {\n emitSupportTicketReopened(eventBus, updatedTicket, workspaceId);\n }\n return updatedTicket;\n } catch (error) {\n console.error('Error changing ticket status:', error);\n throw error;\n }\n };\n\n // Helper: Add message to ticket\n const addTicketMessage = async (input: CreateSupportMessageInput) => {\n try {\n const result = await addTicketMessageMutation({\n variables: {\n input: {\n ...input,\n context: {\n ...(input.context ?? {}),\n workspaceId:\n input.context?.workspaceId ??\n workspaceId ??\n selectedTicket?.context?.workspaceId ??\n undefined,\n organizationId:\n input.context?.organizationId ??\n organizationId ??\n selectedTicket?.context?.organizationId ??\n undefined,\n productId:\n input.context?.productId ??\n productId ??\n selectedTicket?.context?.productId ??\n undefined,\n userId: input.context?.userId ?? currentUser?.id ?? undefined,\n },\n },\n },\n });\n const message = result.data?.createSupportMessage;\n if (message) {\n eventBus.emit('support.ticket.message_sent', {\n messageId: message.id,\n ticketId: input.ticketId,\n workspaceId: workspaceId ?? undefined,\n });\n }\n return message;\n } catch (error) {\n console.error('Error adding ticket message:', error);\n throw error;\n }\n };\n\n const submitSatisfactionSurvey = async (input: SubmitSatisfactionSurveyInput) => {\n try {\n const result = await submitSatisfactionSurveyMutation({\n variables: { input },\n });\n return result.data?.submitSatisfactionSurvey;\n } catch (error) {\n console.error('Error submitting satisfaction survey:', error);\n throw error;\n }\n };\n\n // Helper: Load more tickets (offset-based pagination)\n const loadMoreTickets = () => {\n const currentCount = ticketsData?.supportTickets?.nodes?.length || 0;\n if (ticketsData?.supportTickets?.hasMore) {\n fetchMoreTickets({\n variables: {\n offset: currentCount,\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n supportTickets: {\n ...fetchMoreResult.supportTickets,\n nodes: [\n ...(prev.supportTickets?.nodes || []),\n ...(fetchMoreResult.supportTickets?.nodes || []),\n ],\n },\n };\n },\n });\n }\n };\n\n // Extract tickets from nodes\n const baseTickets: SupportTicket[] = debouncedSearch\n ? (searchedTicketsData?.searchTickets || []).filter((ticket: SupportTicket) =>\n matchesTicketClientFilters(ticket, ticketFilter)\n )\n : ticketsData?.supportTickets?.nodes || [];\n\n const tickets: SupportTicket[] = baseTickets;\n\n return {\n // Data\n tickets,\n ticketDetail: ticketDetailData?.supportTicket || null,\n agentProfiles: agentProfilesData?.agentProfiles?.nodes || [],\n totalTickets: ticketsData?.supportTickets?.totalCount || 0,\n hasMoreTickets: ticketsData?.supportTickets?.hasMore || false,\n\n // Loading states\n ticketsLoading: debouncedSearch ? searchLoading : ticketsLoading,\n ticketDetailLoading,\n agentProfilesLoading,\n createTicketLoading,\n updateTicketLoading,\n assignTicketLoading,\n changeStatusLoading: changeStatusLoading || resolveTicketLoading || closeTicketLoading,\n addMessageLoading,\n submitSurveyLoading,\n\n // Errors\n ticketsError,\n ticketDetailError,\n\n // Operations\n createTicket,\n updateTicket,\n assignTicket,\n changeTicketStatus,\n addTicketMessage,\n submitSatisfactionSurvey,\n loadMoreTickets,\n refetchTickets: asRefetch(refetchTickets),\n refetchTicketDetail: asRefetch(refetchTicketDetail),\n setSelectedTicket,\n };\n}\n"],"mappings":";;;;;;;;;;AA8CA,SAAgBA,EAAoB,IAAsC,CAAC,GAAG;CAC5E,IAAM,EAAE,gBAAa,mBAAgB,cAAW,mBAAgBC,EAAW,GACrE,EAAE,iBAAc,mBAAgB,yBAAsBC,EAAgB,GACtEC,IAAiBC,EAAQ,YAAYC,GAAgB,MAAM,KAAA,GAC3DC,IAAWC,EAAY,GACvB,CAACC,GAAiBC,KAAsBC,SAAeC,EAAa,OAAO,KAAK,CAAC;CAEvF,QAAgB;EACd,IAAMC,IAAQ,iBAAiB;GAC7B,EAAmBD,EAAa,OAAO,KAAK,CAAC;EAC/C,GAAG,GAAG;EAEN,aAAa,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EAClD;CACF;AACF"}
@@ -1 +1 @@
1
- export declare function AnalyticsPage(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function AnalyticsPage(): import('react').JSX.Element;