import{r as p,J as q,o as u,g as m,d as b,e as k,u as t,a as l,F as E,D as J,c as V,w as d,t as U,f as o,i as v,n as B,b as r,L as M,a_ as R,h as _}from"./app-BYcXwl4U.js";import{u as W}from"./app-a6cKceqE.js";import{a as g,_ as G}from"./app-DxbU-QrX.js";import{_ as H}from"./app-Ufpj4Ll4.js";import{T as Q}from"./app-CrjU8lgK.js";import{_ as T}from"./app-Wy4FFEmL.js";import{T as X}from"./app-D2Wz0BUQ.js";import{P as Y}from"./app-0YmIdYYs.js";const Z={class:"label-group"},ee={class:"grey",style:{"font-weight":"normal"}},te=["onClick"],ae=l("i",{class:"pi pi-pencil tiny"},null,-1),le=[ae],se=["onClick"],ne=l("i",{class:"pi pi-remove small"},null,-1),ie=[ne],oe={style:{"margin-top":"0.5em"}},re={class:"ui fields inline"},ue={class:"ui field"},de={class:"ui field"},ce={key:0,class:"comment"},pe={class:"red",style:{"font-weight":"normal"}},fe={key:0},me={key:1},ve={class:"ui field",style:{"padding-left":"0"}},_e={class:"ui field"},he=l("i",{class:"pi pi-remove small"},null,-1),ye=[he],ge={key:0,style:{"margin-top":"0.5em"}},Ue={__name:"URLPatternsBox",props:["modelValue"],emits:["input","update:modelValue"],setup(P,{emit:N}){const z=W(),C=P,h=p(),I=N,{patterns:i,isAdding:f,addingPattern:e,editingIndex:c,patternIsInvalid:y,windowIsSmall:we}=function(){let a=[];return C.modelValue!=null&&(a=C.modelValue),{patterns:p(a),isAdding:p(!1),addingPattern:p({type:"wildcard",pattern:""}),editingIndex:p(-1),patternIsInvalid:p(!1),windowIsSmall:p(window.innerWidth)}}(),K=function(){f.value=!0,setTimeout(function(){h.value.focus()})},S=function(a){f.value=!0,c.value=a,e.value={type:i.value[a].type,pattern:i.value[a].pattern}},$=function(){if(O(e.value.type)&&e.value.pattern.trim().length==0){z.warn("请输入URL",function(){h.value.focus()});return}c.value<0?i.value.push({type:e.value.type,pattern:e.value.pattern}):(i.value[c.value].type=e.value.type,i.value[c.value].pattern=e.value.pattern),L(),x()},D=function(a){i.value.$remove(a),x(),L()},x=function(){f.value=!1,e.value={type:"wildcard",pattern:""},c.value=-1},A=function(a){switch(a){case"wildcard":return"通配符";case"regexp":return"正则";case"images":return"常见图片文件";case"audios":return"常见音频文件";case"videos":return"常见视频文件"}return""},L=function(){I("input",i.value),I("update:modelValue",i.value)},F=function(){y.value=!1;let a=e.value.pattern;switch(e.value.type){case"wildcard":a.indexOf("?")>=0&&(y.value=!0);break;case"regexp":if(a.indexOf("?")>=0){let n=a.split("?");for(let s=0;s<n.length-1;s++)(n[s].length==0||n[s][n[s].length-1]!="\\")&&(y.value=!0)}break}},O=function(a){return a=="wildcard"||a=="regexp"};return q(()=>e.value.type,()=>{h.value!=null&&setTimeout(()=>{h.value.focus()})}),(a,n)=>(u(),m("div",null,[b(l("div",Z,[(u(!0),m(E,null,J(t(i),(s,w)=>(u(),V(X,{outlined:"",class:B({blue:w==t(c),disabled:t(f)&&w!=t(c)})},{default:d(()=>[l("span",ee,"["+U(A(s.type))+"]",1),l("span",null,U(s.pattern),1),o("   "),l("a",{href:"",title:"修改",onClick:v(j=>S(w),["prevent"])},le,8,te),o("   "),l("a",{href:"",title:"删除",onClick:v(j=>D(w),["prevent"])},ie,8,se)]),_:2},1032,["class"]))),256)),r(M)],512),[[k,t(i).length>0]]),b(l("div",oe,[l("div",re,[l("div",ue,[r(G,{modelValue:t(e).type,"onUpdate:modelValue":n[0]||(n[0]=s=>t(e).type=s)},{default:d(()=>[r(g,{value:"wildcard"},{default:d(()=>[o("通配符")]),_:1}),r(g,{value:"regexp"},{default:d(()=>[o("正则表达式")]),_:1}),r(g,{value:"images"},{default:d(()=>[o("常见图片")]),_:1}),r(g,{value:"audios"},{default:d(()=>[o("常见音频")]),_:1}),r(g,{value:"videos"},{default:d(()=>[o("常见视频")]),_:1})]),_:1},8,["modelValue"])]),b(l("div",de,[r(H,{type:"text",placeholder:t(e).type=="wildcard"?"可以使用星号（*）通配符，不区分大小写":"可以使用正则表达式，不区分大小写",modelValue:t(e).pattern,"onUpdate:modelValue":n[1]||(n[1]=s=>t(e).pattern=s),onInput:F,size:"36",ref_key:"patternInputRef",ref:h,onKeyup:n[2]||(n[2]=R(s=>$(),["enter"])),onKeypress:R(v(s=>1,["prevent"]),["enter"]),spellcheck:"false"},null,8,["placeholder","modelValue","onKeypress"]),t(y)?(u(),m("p",ce,[l("span",pe,[t(e).type=="wildcard"?(u(),m("span",fe,"通配符")):_("",!0),t(e).type=="regexp"?(u(),m("span",me,"正则表达式")):_("",!0),o("中不能包含问号（?）及问号以后的内容。")])])):_("",!0)],512),[[k,t(e).type=="wildcard"||t(e).type=="regexp"]]),b(l("div",ve,[t(e).type=="wildcard"?(u(),V(T,{key:0,content:"通配符示例：<br/>单个路径开头：/hello/world/*<br/>单个路径结尾：*/hello/world<br/>包含某个路径：*/article/*<br/>某个域名下的所有URL：*example.com/*<br/>忽略某个扩展名：*.js"})):_("",!0),t(e).type=="regexp"?(u(),V(T,{key:1,content:"正则表达式示例：<br/>单个路径开头：^/hello/world<br/>单个路径结尾：/hello/world$<br/>包含某个路径：/article/<br/>匹配某个数字路径：/article/(\\\\d+)<br/>某个域名下的所有URL：^(http|https)://example.com/"})):_("",!0)],512),[[k,t(e).type=="wildcard"||t(e).type=="regexp"]]),l("div",_e,[r(Q,{secondary:"",size:"small",class:B({disabled:t(y)}),type:"button",onClick:v($,["prevent"])},{default:d(()=>[o("确定")]),_:1},8,["class"]),o("   "),l("a",{href:"",title:"取消",onClick:v(x,["prevent"])},ye)])])],512),[[k,t(f)]]),t(f)?_("",!0):(u(),m("div",ge,[r(Y,{size:"small",type:"button",onClick:v(K,["prevent"])})]))]))}};export{Ue as _};
