<script setup>
const props = defineProps({
  settingData: {
    type: Array,
    default: () => [],
  },
  settingName: {
    type: String,
    default: '',
  },
})
const emit = defineEmits(['update:settingData'])

watch(() => props.settingData, () => {
  emit('update:settingData', props.settingData)
}, {
  deep: true,
})

const handleChange = () => {

}

const { t } = useI18n()
</script>

<template>
  <div>
    <div class="setting-title text-left text-2xl ml-10">
      {{ t(props.settingName) }}：
    </div>
    <div class="setting-items my-3 py-2 border mx-5 rounded-md">
      <div v-for="item in props.settingData" :key="item" class="setting-item my-1">
        <div v-if="Array.isArray(item.status)" class="flex justify-between  mx-8">
          <div class="setting-item-title self-center flex justify-center items-center" :data-tip="item.description" :class="!!item.description ? 'tooltip tooltip-primary tooltip-right' : ''">
            {{ t(item.name) }}<div v-if="!!item.description" i-carbon-information class="ml-1 " />
          </div>
          <!-- <select class="select select-sm  max-w-xs">
            <option v-for="item_ in item.status" :key="item_" :selected="item_.status">
              {{ item_.name }}
            </option>
          </select> -->
          <d-select v-model:options="item.status" class="select select-sm  max-w-xs" />
        </div>
        <div v-else class="flex justify-between mx-8 items-center">
          <div class="setting-item-title self-center flex justify-center items-center " :data-tip="item.description" :class="!!item.description ? 'tooltip tooltip-primary tooltip-right' : ''">
            {{ t(item.name) }}<div v-if="!!item.description" i-carbon-information class="ml-1 " />
          </div>
          <div class="tooltip tooltip-primary tooltip-left" :data-tip="item.status">
            <input v-model="item.status" type="range" min="0" max="1" class="range range-xs" step="0.05">
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style  scoped>
.input-group > *,
  .input-group > .input,
  .input-group > .select {
  border-radius: 0px;
}
.select {
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  appearance: none;
  height: 3rem/* 48px */;
  padding-left: 1rem/* 16px */;
  padding-right: 2.5rem/* 40px */;
  padding-right: 2.5rem/* 40px */;
  font-size: 0.875rem/* 14px */;
  line-height: 1.25rem/* 20px */;
  line-height: 2;
  min-height: 3rem/* 48px */;
  border-width: 1px;
  border-color: hsl(var(--bc) / var(--tw-border-opacity));
  --tw-border-opacity: 0;
  --tw-bg-opacity: 1;
  background-color: hsl(var(--b1) / var(--tw-bg-opacity));
  font-weight: 600;
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--rounded-btn, 0.5rem);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(1px + 50%), calc(100% - 16px) calc(1px + 50%);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.select[multiple] {
  height: auto;
}
.select:focus {
  outline: 0px solid hsla(var(--bc) / 0.2);
  outline-offset: 2px;
}
.select-disabled,
  .select[disabled] {
  cursor: not-allowed;
  --tw-border-opacity: 1;
  border-color: hsl(var(--b2, var(--b1)) / var(--tw-border-opacity));
  --tw-bg-opacity: 1;
  background-color: hsl(var(--b2, var(--b1)) / var(--tw-bg-opacity));
  --tw-text-opacity: 0.2;
}
.select-disabled::placeholder,
  .select[disabled]::placeholder {
  color: hsl(var(--bc) / var(--tw-placeholder-opacity));
  --tw-placeholder-opacity: 0.2;
}
.select-multiple,
  .select[multiple],
  .select[size].select:not([size="1"]) {
  background-image: none;
  padding-right: 1rem/* 16px */;
}
.select-multiple,
  .select[multiple],
  .select[size].select:not([size="1"]) {
  background-image: none;
  padding-right: 1rem/* 16px */;
}
.select-multiple,
  .select[multiple],
  .select[size].select:not([size="1"]) {
  background-image: none;
  padding-right: 1rem/* 16px */;
}

.select-sm {
  height: 2rem/* 32px */;
  padding-left: 0.75rem/* 12px */;
  padding-right: 2rem/* 32px */;
  font-size: 0.875rem/* 14px */;
  line-height: 2rem/* 32px */;
  min-height: 2rem/* 32px */;
}
[dir="rtl"] .select-sm {
  padding-right: 0.75rem/* 12px */;
  padding-left: 2rem/* 32px */;
}

.range {
  height: 1.5rem/* 24px */;
  width: 8rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  --range-shdw: var(--bc);
  overflow: hidden;
  background-color: transparent;
  border-radius: var(--rounded-box, 1rem);
}
.range:focus {
  outline: none;
}
.range:focus-visible::-webkit-slider-thumb {
  --focus-shadow: 0 0 0 6px hsl(var(--b1)) inset, 0 0 0 2rem hsl(var(--range-shdw)) inset;
}
.range:focus-visible::-moz-range-thumb {
  --focus-shadow: 0 0 0 6px hsl(var(--b1)) inset, 0 0 0 2rem hsl(var(--range-shdw)) inset;
}
.range::-webkit-slider-runnable-track {
  height: 0.5rem/* 8px */;
  width: 100%;
  border-radius: var(--rounded-box, 1rem);
  background-color: hsla(var(--bc) / 0.1);
}
.range::-moz-range-track {
  height: 0.5rem/* 8px */;
  width: 100%;
  border-radius: var(--rounded-box, 1rem);
  background-color: hsla(var(--bc) / 0.1);
}
.range::-webkit-slider-thumb {
  background-color: hsl(var(--b1));
  position: relative;
  height: 1.5rem/* 24px */;
  width: 1.5rem/* 24px */;
  border-style: none;
  border-radius: var(--rounded-box, 1rem);
  appearance: none;
  -webkit-appearance: none;
  top: 50%;
  color: hsl(var(--range-shdw));
  transform: translateY(-50%);
  --filler-size: 100rem/* 1600px */;
  --filler-offset: 0.6rem/* 9.6px */;
  box-shadow: 0 0 0 3px hsl(var(--range-shdw)) inset, var(--focus-shadow, 0 0), calc(var(--filler-size) * -1 - var(--filler-offset)) 0 0 var(--filler-size);
}
.range::-moz-range-thumb {
  background-color: hsl(var(--b1));
  position: relative;
  height: 1.5rem/* 24px */;
  width: 1.5rem/* 24px */;
  border-style: none;
  border-radius: var(--rounded-box, 1rem);
  top: 50%;
  color: hsl(var(--range-shdw));
  --filler-size: 100rem/* 1600px */;
  --filler-offset: 0.5rem/* 8px */;
  box-shadow: 0 0 0 3px hsl(var(--range-shdw)) inset, var(--focus-shadow, 0 0), calc(var(--filler-size) * -1 - var(--filler-offset)) 0 0 var(--filler-size);
}

.range-xs {
  height: .5rem/* 16px */;
}
.range-xs::-webkit-slider-runnable-track {
  height: 0.125rem/* 4px */;
}
.range-xs::-moz-range-track {
  height: 0.125rem/* 4px */;
}
.range-xs::-webkit-slider-thumb {
  height: .5rem/* 16px */;
  width: .5rem/* 16px */;
  --filler-offset: 0.2rem/* 6.4px */;
}
.range-xs::-moz-range-thumb {
  height: .5rem/* 16px */;
  width: .5rem/* 16px */;
  --filler-offset: 0.2rem/* 6.4px */;
}
</style>
