<script setup>

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

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

const valueInputRef = ref()
const {cond} = (function () {
	let cond = {
		isRequest: true,
		param: "${requestPath}",
		operator: "not regexp",
		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"><strong>不要</strong>匹配URL的正则表达式，意即只要匹配成功则排除此条件，比如
			<CodeLabel>^/static/(.*).js$</CodeLabel>
			，不需要带域名。
		</p>
	</div>
</template>

<style scoped>
</style>
