// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '../../../ui/kit/kit.js';
import * as i18n from '../../../core/i18n/i18n.js';
import * as Platform from '../../../core/platform/platform.js';
import type * as SDK from '../../../core/sdk/sdk.js';
import * as UI from '../../../ui/legacy/legacy.js';
import * as Lit from '../../../ui/lit/lit.js';
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
import * as NetworkForward from '../forward/forward.js';
import {EditingAllowedStatus, type HeaderDescriptor} from './HeaderSectionRow.js';
import requestHeaderSectionStyles from './RequestHeaderSection.css.js';
import requestHeadersViewStyles from './RequestHeadersView.css.js';
export {requestHeadersViewStyles};
const {render, html} = Lit;
const UIStrings = {
/**
* @description Text that is usually a hyperlink to more documentation
*/
learnMore: 'Learn more',
/**
* @description Message to explain lack of raw headers for a particular network request
*/
provisionalHeadersAreShownDisableCache: 'Provisional headers are shown. Disable cache to see full headers.',
/**
* @description Tooltip to explain lack of raw headers for a particular network request
*/
onlyProvisionalHeadersAre:
'Only provisional headers are available because this request was not sent over the network and instead was served from a local cache, which doesn’t store the original request headers. Disable cache to see full request headers.',
/**
* @description Message to explain lack of raw headers for a particular network request
*/
provisionalHeadersAreShown: 'Provisional headers are shown.',
} as const;
const str_ = i18n.i18n.registerUIStrings('panels/network/components/RequestHeaderSection.ts', UIStrings);
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
export interface ViewInput {
headers: HeaderDescriptor[];
isProvisionalHeaders: boolean;
isRequestCached: boolean;
}
export type View = (input: ViewInput, output: undefined, target: HTMLElement|ShadowRoot) => void;
export const DEFAULT_VIEW: View = (input, output, target) => {
const headers = input.headers;
// Disabled until https://crbug.com/1079231 is fixed.
// clang-format off
render(html`
${input.isProvisionalHeaders ? renderProvisionalHeadersWarning(input.isRequestCached) : Lit.nothing}
${headers.map(header => html`