{{- $jsonViewer := .Attributes | merge (dict "Page" .Page "Key" "json_viewer" | partial "function/param.html") -}}
{{- if $jsonViewer.enable | and (ne hugo.Context.MarkupScope "home") -}}
  {{- /* Deprecated camelCase attribute support: Hugo lowercases Markdown attributes, so expandDepth → expanddepth */ -}}
  {{- if isset .Attributes "expanddepth" | and (not (isset .Attributes "expand_depth")) -}}
    {{- warnidf "v1-deprecated-json-viewer-attr" "The attribute `expandDepth` is deprecated since v1.0.0, use `expand_depth` instead. See %s" .Position -}}
    {{- $jsonViewer = dict "expand_depth" .Attributes.expanddepth | merge $jsonViewer -}}
  {{- end -}}
  {{- $attrs := printf `expand-depth="%v"` $jsonViewer.expand_depth -}}
  {{- $copyable := false -}}
  {{- with $jsonViewer.copyable -}}
    {{- $copyable = dict "copyText" (T "assets.copyText") "copiedText" (T "assets.copiedText") -}}
  {{- end -}}
  {{- with $jsonViewer.sort -}}
    {{- $attrs = " sort" | add $attrs -}}
  {{- end -}}
  {{- with $jsonViewer.boxed -}}
    {{- $attrs = " boxed" | add $attrs -}}
  {{- end -}}
  <json-viewer value="{{ .Inner | jsonify }}" {{ $attrs | safeHTMLAttr }}{{ with $copyable}} copyable="{{ . | jsonify }}"{{ end }}></json-viewer>
  {{- .Page.Store.Set "hasJsonViewer" true -}}
{{- else -}}
  {{- partial "plugin/code-block-wrapper.html" . -}}
{{- end -}}
