import { jsx as _jsx } from "react/jsx-runtime";
import { CloudDeploymentProvider, CloudDeploymentStatus, } from '../../../../../../packages/core/src/domain/generated/output.js';
import { DeployPanel } from './deploy-panel.js';
function makeCloudApi(overrides = {}) {
    return {
        state: {
            provider: CloudDeploymentProvider.CloudflarePages,
            status: CloudDeploymentStatus.NotDeployed,
            url: null,
            error: null,
            deploymentId: null,
            lastDeployedAt: null,
            isWorking: false,
            ...overrides,
        },
        refresh: async () => undefined,
        selectProvider: async () => undefined,
        initiate: async () => undefined,
        connect: async () => undefined,
    };
}
const cleanRemoteStatus = {
    branch: 'main',
    uncommittedCount: 0,
    unpushedCount: 0,
    hasRemote: true,
    remoteUrl: 'https://github.com/blackpc/landing-page-hero',
};
const noop = () => undefined;
const meta = {
    title: 'ApplicationPage/DeployPanel',
    component: DeployPanel,
    parameters: { layout: 'centered' },
    decorators: [
        (Story) => (_jsx("div", { className: "bg-background border-border w-[360px] rounded-md border shadow-md", children: _jsx(Story, {}) })),
    ],
};
export default meta;
const sharedHandlers = {
    onSaveChanges: noop,
    onPublishToWeb: noop,
    onRedeploy: noop,
    onSetUpCodeStorage: noop,
    onConnectCloud: noop,
    onSwitchProvider: noop,
    onOpenLogs: noop,
    onOpenInGitHub: noop,
};
const baseSmart = (overrides = {}) => ({
    kind: 'deploy',
    changeCount: 0,
    hasCloud: true,
    hasRemote: true,
    liveUrl: null,
    errorMessage: null,
    failedSource: null,
    workingSource: null,
    cloudProviderName: null,
    ...overrides,
});
export const FirstTimeNothingSetUp = {
    args: {
        state: baseSmart({ kind: 'getOnline', hasRemote: false, hasCloud: false }),
        gitStatus: {
            branch: null,
            uncommittedCount: 0,
            unpushedCount: 0,
            hasRemote: false,
            remoteUrl: null,
        },
        cloudDeploy: makeCloudApi(),
        cloudProviderName: null,
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const HasRemoteNotConnectedToCloud = {
    args: {
        state: baseSmart({ kind: 'deploy', hasCloud: false }),
        gitStatus: cleanRemoteStatus,
        cloudDeploy: makeCloudApi(),
        cloudProviderName: null,
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const HasRemoteCleanReadyToDeploy = {
    args: {
        state: baseSmart({ kind: 'deploy' }),
        gitStatus: cleanRemoteStatus,
        cloudDeploy: makeCloudApi(),
        cloudProviderName: 'Cloudflare Pages',
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const DirtyHasRemoteHasCloud = {
    args: {
        state: baseSmart({ kind: 'pushAndDeploy', changeCount: 5 }),
        gitStatus: { ...cleanRemoteStatus, uncommittedCount: 5 },
        cloudDeploy: makeCloudApi(),
        cloudProviderName: 'Cloudflare Pages',
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const DirtyOnlyNoCloud = {
    args: {
        state: baseSmart({ kind: 'save', changeCount: 3, hasCloud: false }),
        gitStatus: { ...cleanRemoteStatus, uncommittedCount: 3 },
        cloudDeploy: makeCloudApi(),
        cloudProviderName: null,
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const Live = {
    args: {
        state: baseSmart({
            kind: 'live',
            liveUrl: 'https://landing-page-hero-features-pricing-85f4e3.pages.dev',
        }),
        gitStatus: cleanRemoteStatus,
        cloudDeploy: makeCloudApi({
            status: CloudDeploymentStatus.Deployed,
            url: 'https://landing-page-hero-features-pricing-85f4e3.pages.dev',
            lastDeployedAt: new Date(Date.now() - 2 * 60 * 1000),
        }),
        cloudProviderName: 'Cloudflare Pages',
        lastDeployedAgo: '2 minutes ago',
        ...sharedHandlers,
    },
};
export const DeployFailed = {
    args: {
        state: baseSmart({
            kind: 'failed',
            errorMessage: 'Cloudflare API GET /accounts/.../deployments returned a non-JSON response (HTTP 502).',
            failedSource: 'deploy',
        }),
        gitStatus: cleanRemoteStatus,
        cloudDeploy: makeCloudApi({
            status: CloudDeploymentStatus.Failed,
            error: 'Cloudflare API returned 502',
        }),
        cloudProviderName: 'Cloudflare Pages',
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
export const SaveFailed = {
    args: {
        state: baseSmart({
            kind: 'failed',
            errorMessage: 'git push failed: remote rejected (permission denied)',
            failedSource: 'sync',
            changeCount: 3,
        }),
        gitStatus: { ...cleanRemoteStatus, uncommittedCount: 3 },
        cloudDeploy: makeCloudApi(),
        cloudProviderName: 'Cloudflare Pages',
        lastDeployedAgo: null,
        ...sharedHandlers,
    },
};
