import { ShareEnterPassword } from '@/components/auth/share-enter-password';
import { FullPageEmptyState } from '@/components/full-page-empty-state';
import FullPageLoadingState from '@/components/full-page-loading-state';
import { OverviewFiltersButtons } from '@/components/overview/filters/overview-filters-buttons';
import { LiveCounter } from '@/components/overview/live-counter';
import OverviewMetrics from '@/components/overview/overview-metrics';
import { OverviewRange } from '@/components/overview/overview-range';
import OverviewTopDevices from '@/components/overview/overview-top-devices';
import OverviewTopEvents from '@/components/overview/overview-top-events';
import OverviewTopGeo from '@/components/overview/overview-top-geo';
import OverviewTopPages from '@/components/overview/overview-top-pages';
import OverviewTopSources from '@/components/overview/overview-top-sources';
import { useTRPC } from '@/integrations/trpc/react';
import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
import {
ScriptOnce,
createFileRoute,
notFound,
useSearch,
} from '@tanstack/react-router';
import { EyeClosedIcon, FrownIcon } from 'lucide-react';
import { z } from 'zod';
import '@iframe-resizer/child';
const shareSearchSchema = z.object({
header: z.optional(z.number().or(z.string().or(z.boolean()))),
});
const iframeResizerScript = `
(function() {
if (typeof window !== 'undefined' && window.iFrameResizer) {
window.iFrameResizer.onMessage = function(message) {
if (message && message.type === 'load-custom-styles') {
var css = (message.opts && message.opts.styles) || '';
if (!css) return;
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);
}
};
}
})();
`;
export const Route = createFileRoute('/share/overview/$shareId')({
component: RouteComponent,
validateSearch: shareSearchSchema,
loader: async ({ context, params }) => {
await context.queryClient.prefetchQuery(
context.trpc.share.overview.queryOptions({
shareId: params.shareId,
}),
);
},
pendingComponent: FullPageLoadingState,
errorComponent: () => (