<script setup lang="ts">
import type { KbxAsyncState, KbxProblem, KbxScreenDefinition, KbxSummaryItem, KbxTemplateContext, KbxWorkQueueCounter } from '@kbx/contracts'
import KbxQueuePage from './KbxQueuePage.vue'

withDefaults(defineProps<{
  screen:KbxScreenDefinition
  selectionCount?:number
  can?:(permission:string)=>boolean
  breadcrumb?:string
  context?:KbxTemplateContext|null
  contentState?:KbxAsyncState
  refreshing?:boolean
  errorRetryable?:boolean
  summaryItems?:KbxSummaryItem[]
  exceptionCounters?:KbxWorkQueueCounter[]
  activeExceptionKey?:string|null
  problem?:KbxProblem|null
  problemActionAllowlist?:readonly string[]
  queueTitle?:string
  queueDescription?:string
  queueCount?:number
  queueCountUnit?:string
  emptyTitle?:string
  emptyDetail?:string
  emptyActionLabel?:string
}>(), {
  context:null,
  contentState:'ready',
  refreshing:false,
  errorRetryable:true,
  summaryItems:()=>[],
  exceptionCounters:()=>[],
  activeExceptionKey:null,
  problem:null,
  problemActionAllowlist:()=>[],
  queueTitle:'작업 Queue',
  queueDescription:'',
  queueCountUnit:'건',
  emptyTitle:'',
  emptyDetail:'',
  emptyActionLabel:'',
})
const emit=defineEmits<{ command:[string]; exceptionFilter:[string|null]; problemAction:[string]; retryProblem:[]; dismissProblem:[]; emptyAction:[] }>()
</script>

<template>
  <KbxQueuePage
    :screen="screen"
    :selection-count="selectionCount"
    :can="can"
    :breadcrumb="breadcrumb"
    :context="context"
    :content-state="contentState"
    :refreshing="refreshing"
    :error-retryable="errorRetryable"
    :summary-items="summaryItems"
    :exception-counters="exceptionCounters"
    :active-exception-key="activeExceptionKey"
    :problem="problem"
    :problem-action-allowlist="problemActionAllowlist"
    :queue-title="queueTitle"
    :queue-description="queueDescription"
    :queue-count="queueCount"
    :queue-count-unit="queueCountUnit"
    :empty-title="emptyTitle"
    :empty-detail="emptyDetail"
    :empty-action-label="emptyActionLabel"
    @command="emit('command',$event)"
    @exception-filter="emit('exceptionFilter',$event)"
    @problem-action="emit('problemAction',$event)"
    @retry-problem="emit('retryProblem')"
    @dismiss-problem="emit('dismissProblem')"
    @empty-action="emit('emptyAction')"
  >
    <template v-if="$slots.utility" #utility><slot name="utility" /></template>
    <template v-if="$slots.notice" #notice><slot name="notice" /></template>
    <template v-if="$slots.search" #search><slot name="search" /></template>
    <template v-if="$slots['queue-summary'] || $slots.summary" #summary><slot name="queue-summary"><slot name="summary" /></slot></template>
    <template v-if="$slots.exceptions" #exceptions><slot name="exceptions" /></template>
    <template v-if="$slots.contextual" #contextual><slot name="contextual" /></template>
    <template v-if="$slots['queue-heading']" #queue-heading><slot name="queue-heading" /></template>
    <template v-if="$slots['queue-actions']" #queue-actions><slot name="queue-actions" /></template>
    <template #content><slot name="content" /></template>
    <template v-if="$slots.footer" #footer><slot name="footer" /></template>
    <template v-if="$slots.detail" #detail><slot name="detail" /></template>
  </KbxQueuePage>
</template>
