<script setup>

import {onMounted, ref} from "vue"
import TInputText from "@/components/ui/TInputText.vue";
import CodeLabel from "@/components/common/CodeLabel.vue";

const props = defineProps(["v-cond"])

const valueInputRef = ref()
const {cond} = (function () {
	let cond = {
		isRequest: true,
		param: "${requestPath}",
		operator: "wildcard match",
		value: "",
		isCaseInsensitive: false
	}
	if (props.vCond != null && typeof props.vCond.value == "string") {
		cond.value = props.vCond.value
	}
	return {
		cond: ref(cond)
	}
})()

const changeCaseInsensitive = function (isCaseInsensitive) {
	cond.value.isCaseInsensitive = isCaseInsensitive
}

onMounted(() => {
	valueInputRef.value.focus()
})

defineExpose({
	changeCaseInsensitive
})

</script>

<template>
	<div>
		<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
		<TInputText type="text" v-model="cond.value" ref="valueInputRef" class="w-full"/>
		<p class="comment">匹配URL的通配符，用星号（
			<CodeLabel>*</CodeLabel>
			）表示任意字符，比如（
			<CodeLabel>/images/*.png</CodeLabel>
			、
			<CodeLabel>/static/*</CodeLabel>
			，不需要带域名。
		</p>
	</div>
</template>

<style scoped>
</style>
