import{J as P,K as j,b7 as C,r as b,aK as k,aV as O,b8 as U,Q as K,B as h,d as $,a9 as D,T as N,C as T,ai as L,aa as B,af as p,y as M,a5 as F,a4 as x}from"#entry";import{u as z}from"./DIRTgmGz.js";import{u as H}from"./vRc2BJuY.js";const Q=j({...K(),...U()},"VForm"),J=P()({name:"VForm",props:Q(),emits:{"update:modelValue":e=>!0,submit:e=>!0},setup(e,t){let{slots:r,emit:o}=t;const l=C(e),i=b();function c(n){n.preventDefault(),l.reset()}function u(n){const a=n,f=l.validate();a.then=f.then.bind(f),a.catch=f.catch.bind(f),a.finally=f.finally.bind(f),o("submit",a),a.defaultPrevented||f.then(y=>{let{valid:g}=y;g&&i.value?.submit()}),a.preventDefault()}return k(()=>h("form",{ref:i,class:["v-form",e.class],style:e.style,novalidate:!0,onReset:c,onSubmit:u},[r.default?.(l)])),O(l,i)}});function A(e){"@babel/helpers - typeof";return A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(e)}function V(e){var t=typeof e=="string"||e instanceof String;if(!t){var r=A(e);throw e===null?r="null":r==="object"&&(r=e.constructor.name),new TypeError("Expected a string but received a ".concat(r))}}function I(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var r in t)typeof e[r]>"u"&&(e[r]=t[r]);return e}var W={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function Z(e,t){V(e),t=I(t,W),t.allow_trailing_dot&&e[e.length-1]==="."&&(e=e.substring(0,e.length-1)),t.allow_wildcard===!0&&e.indexOf("*.")===0&&(e=e.substring(2));var r=e.split("."),o=r[r.length-1];return t.require_tld&&(r.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(o)||/\s/.test(o))||!t.allow_numeric_tld&&/^\d+$/.test(o)?!1:r.every(function(l){return!(l.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(l)||/[\uff01-\uff5e]/.test(l)||/^-|-$/.test(l)||!t.allow_underscores&&/_/.test(l))})}var q="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",_="(".concat(q,"[.]){3}").concat(q),G=new RegExp("^".concat(_,"$")),s="(?:[0-9a-fA-F]{1,4})",X=new RegExp("^("+"(?:".concat(s,":){7}(?:").concat(s,"|:)|")+"(?:".concat(s,":){6}(?:").concat(_,"|:").concat(s,"|:)|")+"(?:".concat(s,":){5}(?::").concat(_,"|(:").concat(s,"){1,2}|:)|")+"(?:".concat(s,":){4}(?:(:").concat(s,"){0,1}:").concat(_,"|(:").concat(s,"){1,3}|:)|")+"(?:".concat(s,":){3}(?:(:").concat(s,"){0,2}:").concat(_,"|(:").concat(s,"){1,4}|:)|")+"(?:".concat(s,":){2}(?:(:").concat(s,"){0,3}:").concat(_,"|(:").concat(s,"){1,5}|:)|")+"(?:".concat(s,":){1}(?:(:").concat(s,"){0,4}:").concat(_,"|(:").concat(s,"){1,6}|:)|")+"(?::((?::".concat(s,"){0,5}:").concat(_,"|(?::").concat(s,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function w(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return V(e),t=String(t),t?t==="4"?G.test(e):t==="6"?X.test(e):!1:w(e,4)||w(e,6)}function Y(e,t){return ne(e)||re(e,t)||te(e,t)||ee()}function ee(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function te(e,t){if(e){if(typeof e=="string")return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}}function E(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function re(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,l,i,c,u=[],n=!0,a=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(n=(o=i.call(r)).done)&&(u.push(o.value),u.length!==t);n=!0);}catch(f){a=!0,l=f}finally{try{if(!n&&r.return!=null&&(c=r.return(),Object(c)!==c))return}finally{if(a)throw l}}return u}}function ne(e){if(Array.isArray(e))return e}var ae={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0},le=/^\[([^\]]+)\](?::([0-9]+))?$/;function oe(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function R(e,t){for(var r=0;r<t.length;r++){var o=t[r];if(e===o||oe(o)&&o.test(e))return!0}return!1}function se(e,t){if(V(e),!e||/[\s<>]/.test(e)||e.indexOf("mailto:")===0||(t=I(t,ae),t.validate_length&&e.length>=2083)||!t.allow_fragments&&e.includes("#")||!t.allow_query_components&&(e.includes("?")||e.includes("&")))return!1;var r,o,l,i,c,u,n,a;if(n=e.split("#"),e=n.shift(),n=e.split("?"),e=n.shift(),n=e.split("://"),n.length>1){if(r=n.shift().toLowerCase(),t.require_valid_protocol&&t.protocols.indexOf(r)===-1)return!1}else{if(t.require_protocol)return!1;if(e.slice(0,2)==="//"){if(!t.allow_protocol_relative_urls)return!1;n[0]=e.slice(2)}}if(e=n.join("://"),e==="")return!1;if(n=e.split("/"),e=n.shift(),e===""&&!t.require_host)return!0;if(n=e.split("@"),n.length>1){if(t.disallow_auth||n[0]===""||(o=n.shift(),o.indexOf(":")>=0&&o.split(":").length>2))return!1;var f=o.split(":"),y=Y(f,2),g=y[0],S=y[1];if(g===""&&S==="")return!1}i=n.join("@"),u=null,a=null;var d=i.match(le);if(d?(l="",a=d[1],u=d[2]||null):(n=i.split(":"),l=n.shift(),n.length&&(u=n.join(":"))),u!==null&&u.length>0){if(c=parseInt(u,10),!/^[0-9]+$/.test(u)||c<=0||c>65535)return!1}else if(t.require_port)return!1;return t.host_whitelist?R(l,t.host_whitelist):l===""&&!t.require_host?!0:!(!w(l)&&!Z(l,t)&&(!a||!w(a,6))||(l=l||a,t.host_blacklist&&R(l,t.host_blacklist)))}const ce=$({__name:"ScannerForm",props:{scanner:{type:Object,default:()=>({endpoint:"",apiKey:"",name:""})},isEditMode:{type:Boolean,defualt:!1}},emits:["close-form"],setup(e,{emit:t}){const r={endpoint:"",apiKey:"",name:""},o=e,l=b(),i=b(!1),c=t,u=z(),n=H(),a=b(r),f={required:d=>d.trim()!==""||"This field is required",url:d=>se(d)||"Must be a valid URL"};D(o.scanner,d=>{a.value={...d}},{immediate:!0,deep:!0});const y=async()=>{if(i.value===!0&&a.value!==null)try{u.addOrUpdateScanner(a.value),g(),c("close-form"),n.reportSuccess("Scanner saved successfully.")}catch{n.reportError("Failed to save scanner information. Please try again.")}},g=()=>{a.value=r},S=()=>{g(),c("close-form")};return(d,m)=>(M(),N(J,{ref_key:"form",ref:l,modelValue:p(i),"onUpdate:modelValue":m[3]||(m[3]=v=>B(i)?i.value=v:null),onSubmit:L(y,["prevent"])},{default:T(()=>[h(F,{modelValue:p(a).endpoint,"onUpdate:modelValue":m[0]||(m[0]=v=>p(a).endpoint=v),variant:"outlined",density:"compact",label:"Scanner Endpoint",placeholder:"https://api.example.com/graphql",disabled:e.isEditMode===!0,rules:[f.required,f.url]},null,8,["modelValue","disabled","rules"]),h(F,{modelValue:p(a).name,"onUpdate:modelValue":m[1]||(m[1]=v=>p(a).name=v),variant:"outlined",density:"compact",label:"Scanner Name",placeholder:"Scanner Name"},null,8,["modelValue"]),h(F,{modelValue:p(a).apiKey,"onUpdate:modelValue":m[2]||(m[2]=v=>p(a).apiKey=v),variant:"outlined",density:"compact",label:"API Key",placeholder:"Enter API Key",rules:[f.required]},null,8,["modelValue","rules"]),h(x,{class:"me-2",type:"submit",color:"success",text:"Save","prepend-icon":"mdi-check",disabled:!p(i)},null,8,["disabled"]),h(x,{text:"Cancel","prepend-icon":"mdi-close",onClick:S})]),_:1},8,["modelValue"]))}});export{J as V,ce as _};
