1import{w as M,l as o,m as l,B as u,q as t,z as D,u as m,K as g,p as x,Y as Q,J as d,aa as n,ac as i,F as w,v as h,ab as L,ag as G,a6 as H,e as c,b as J,r as S,a9 as O,_ as X,af as Y}from"./vue-vendor-c0W5WEtO.js";import{u as W,b as R}from"./query-vendor-BMwEzNLN.js";import{i as Z,u as ee,k as te,j as re,l as ae}from"./knox-D0ix4KvO.js";import{a as se}from"./swal-roE_GOvf.js";import{t as _}from"./index-B2Yag7Gu.js";import{_ as oe}from"./KnoxAdminTabs-DLrE-PA8.js";import{ac as le,al as N,a6 as ne,X as ie}from"./ui-vendor-B7SopUXd.js";import"./date-vendor-HBGOQ70J.js";import"./twilio-DAuME2Y9.js";import"./charts-BVdrK9wF.js";import"./socket-Kk_l3rvZ.js";const de={class:"flex h-full flex-col"},ue={class:"flex items-center gap-3 border-b border-gray-200 bg-white px-6 py-4 dark:border-gray-700 dark:bg-gray-800"},ge={class:"min-w-0"},pe={class:"text-xl font-bold text-gray-900 dark:text-white"},ye={key:0,class:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400"},me={key:0,class:"flex flex-1 items-center justify-center py-20"},xe={class:"rounded-lg border border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-800"},be={class:"grid gap-5 sm:grid-cols-2"},ce={id:"page-feature-areas"},fe=["value"],ke={key:0,class:"mt-1 text-xs text-teal-600 dark:text-teal-400"},ve={class:"mb-1.5 flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300"},we={class:"sm:col-span-2"},he={class:"rounded-lg border border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-800"},_e={class:"grid gap-5 sm:grid-cols-2"},Se={key:0,class:"mt-2 flex flex-wrap gap-1"},Ue={key:0,class:"mt-2 flex flex-wrap gap-1"},Pe={class:"rounded-lg border border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-800"},Ae={class:"mb-4 flex items-center justify-between"},Ve={key:0,class:"text-sm text-gray-400 dark:text-gray-500"},qe={key:1,class:"space-y-3"},Ce=["onUpdate:modelValue"],Ee=["onUpdate:modelValue"],Ke=["onUpdate:modelValue"],De=["onClick"],Le={key:0,class:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-600 dark:border-red-800 dark:bg-red-950 dark:text-red-400"},Re={class:"flex flex-wrap items-center gap-3"},Ne=["disabled"],Te=["disabled"],Xe={__name:"Edit",setup(Fe){const b=O(),U=X(),P=W(),p=c(()=>!!b.params.id),T=["dashboard","chat","voice","visitors","settings","integrations","widget","analytics","billing","api","knox","onboarding"],{data:F}=R({queryKey:["admin","knox","pages"],queryFn:re,staleTime:6e4}),A=c(()=>{const s=(F.value||[]).map(e=>e.feature_area).filter(e=>typeof e=="string"&&e.trim().length>0);return Array.from(new Set([...T,...s])).sort()}),r=J({url_pattern:"",page_title:"",feature_area:"",section_path:"",description:"",parent_url:"",requires_role:"admin",is_active:!0,ui_elements:[],keywords:[],aliases:[]}),{data:I,isLoading:B}=R({queryKey:["admin","knox","pages",c(()=>b.params.id)],queryFn:()=>ae(b.params.id),enabled:p});M(I,s=>{s&&Object.assign(r,{url_pattern:s.url_pattern||"",page_title:s.page_title||"",feature_area:s.feature_area||"",section_path:s.section_path||"",description:s.description||"",parent_url:s.parent_url||"",requires_role:s.requires_role||"admin",is_active:s.is_active!==!1,ui_elements:Array.isArray(s.ui_elements)?s.ui_elements.map(e=>({...e})):[],keywords:Array.isArray(s.keywords)?[...s.keywords]:[],aliases:Array.isArray(s.aliases)?[...s.aliases]:[]})},{immediate:!0});const V=c({get:()=>r.keywords.join(", "),set:s=>{r.keywords=C(s)}}),q=c({get:()=>r.aliases.join(", "),set:s=>{r.aliases=C(s)}});function C(s){return String(s||"").split(",").map(e=>e.trim()).filter(Boolean)}const f=S(null),k=S(!1),v=S(!1);async function j(){if((await se(`page "${r.page_title}" (${r.url_pattern})`,{text:"This removes it from the registry so Nox can no longer navigate to it or surface knowledge tied to it."})).isConfirmed){v.value=!0;try{await Z(b.params.id),_.success("Page deleted"),P.invalidateQueries({queryKey:["admin","knox","pages"]}),U.push("/admin/knox/pages")}catch(e){_.error(e?.response?.data?.message||e.message||"Failed to delete page")}finally{v.value=!1}}}function z(){r.ui_elements.push({id:"",label:"",type:"input"})}async function $(){f.value=null,k.value=!0;try{const s={...r,ui_elements:r.ui_elements.filter(e=>e.id&&e.label)};p.value?(await ee(b.params.id,s),_.success("Page updated")):(await te(s),_.success("Page created")),P.invalidateQueries({queryKey:["admin","knox","pages"]}),U.push("/admin/knox/pages")}catch(s){f.value=s?.response?.data?.message||s.message||"Failed to save page"}finally{k.value=!1}}return(s,e)=>{const E=H("router-link");return o(),l("div",de,[u(oe),t("div",ue,[u(E,{to:"/admin/knox/pages",class:"inline-flex items-center gap-1 rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300","aria-label":"Back to Pages"},{default:D(()=>[u(m(le),{size:18})]),_:1}),t("div",ge,[t("h1",pe,g(p.value?"Edit Page":"Register New Page"),1),r.url_pattern?(o(),l("p",ye,g(r.url_pattern),1)):x("",!0)])]),p.value&&m(B)?(o(),l("div",me,[...e[10]||(e[10]=[t("div",{class:"h-10 w-10 animate-spin rounded-full border-4 border-teal-200 border-t-teal-600"},null,-1)])])):(o(),l("form",{key:1,onSubmit:Q($,["prevent"]),class:"flex-1 space-y-6 overflow-y-auto p-6"},[t("div",xe,[e[23]||(e[23]=t("h2",{class:"mb-4 text-lg font-semibold text-gray-900 dark:text-white"},"Page Information",-1)),t("div",be,[t("div",null,[e[11]||(e[11]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},[d(" URL Pattern "),t("span",{class:"text-red-500"},"*")],-1)),n(t("input",{"onUpdate:modelValue":e[0]||(e[0]=a=>r.url_pattern=a),type:"text",placeholder:"/settings/integrations/shopify",required:"",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.url_pattern]]),e[12]||(e[12]=t("p",{class:"mt-1 text-xs text-gray-400"},"The portal URL path this page matches",-1))]),t("div",null,[e[13]||(e[13]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},[d(" Page Title "),t("span",{class:"text-red-500"},"*")],-1)),n(t("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>r.page_title=a),type:"text",placeholder:"Shopify Integration Settings",required:"",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.page_title]])]),t("div",null,[e[14]||(e[14]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},[d(" Feature Area "),t("span",{class:"text-red-500"},"*")],-1)),n(t("input",{"onUpdate:modelValue":e[2]||(e[2]=a=>r.feature_area=a),type:"text",list:"page-feature-areas",required:"",placeholder:"Pick or type a new oneâ¦",autocomplete:"off",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.feature_area]]),t("datalist",ce,[(o(!0),l(w,null,h(A.value,a=>(o(),l("option",{key:a,value:a},null,8,fe))),128))]),r.feature_area&&!A.value.includes(r.feature_area)?(o(),l("p",ke,[u(m(N),{size:11,class:"-mt-0.5 inline"}),d(' New area "'+g(r.feature_area)+'" will be created on save. ',1)])):x("",!0)]),t("div",null,[e[15]||(e[15]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},[d(" Section Path "),t("span",{class:"text-red-500"},"*")],-1)),n(t("input",{"onUpdate:modelValue":e[3]||(e[3]=a=>r.section_path=a),type:"text",placeholder:"Settings > Integrations > Shopify",required:"",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.section_path]])]),t("div",null,[e[16]||(e[16]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"}," Parent URL ",-1)),n(t("input",{"onUpdate:modelValue":e[4]||(e[4]=a=>r.parent_url=a),type:"text",placeholder:"/settings/integrations",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.parent_url]]),e[17]||(e[17]=t("p",{class:"mt-1 text-xs text-gray-400"},"Parent page for breadcrumb navigation",-1))]),t("div",null,[e[19]||(e[19]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"}," Required Role ",-1)),n(t("select",{"onUpdate:modelValue":e[5]||(e[5]=a=>r.requires_role=a),class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},[...e[18]||(e[18]=[t("option",{value:"public"},"Public (no auth)",-1),t("option",{value:"user"},"User (any signed-in workspace user)",-1),t("option",{value:"admin"},"Admin (super-admin only)",-1),t("option",{value:"agency"},"Agency (agency owner/staff)",-1)])],512),[[L,r.requires_role]])]),t("div",null,[t("label",ve,[n(t("input",{"onUpdate:modelValue":e[6]||(e[6]=a=>
1r.is_active=a),type:"checkbox",class:"h-4 w-4 rounded border-gray-300 text-teal-600 focus:ring-teal-500 dark:border-gray-600 dark:bg-gray-700"},null,512),[[G,r.is_active]]),e[20]||(e[20]=d(" Active ",-1))]),e[21]||(e[21]=t("p",{class:"mt-1 text-xs text-gray-400"}," Inactive rows are hidden from the navigation allowlist. Removing a page from the registry soft-deletes it (sets this to false) so historical references degrade gracefully. ",-1))]),t("div",we,[e[22]||(e[22]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"}," Description ",-1)),n(t("textarea",{"onUpdate:modelValue":e[7]||(e[7]=a=>r.description=a),rows:"3",placeholder:"Brief description of what this page does and what the admin can configure here...",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,r.description]])])])]),t("div",he,[e[28]||(e[28]=t("h2",{class:"mb-1 text-lg font-semibold text-gray-900 dark:text-white"},"Keywords & Aliases",-1)),e[29]||(e[29]=t("p",{class:"mb-4 text-xs text-gray-500 dark:text-gray-400"}," Extra phrasings the navigation lookup matches against, in addition to page title and section path. Comma-separated. ",-1)),t("div",_e,[t("div",null,[e[24]||(e[24]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"}," Keywords ",-1)),n(t("textarea",{"onUpdate:modelValue":e[8]||(e[8]=a=>V.value=a),rows:"3",placeholder:"slack, messaging, notifications, chat, alerts",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,V.value]]),e[25]||(e[25]=t("p",{class:"mt-1 text-xs text-gray-400"}," Lowercase, no punctuation. Single-word concepts users would search by. ",-1)),r.keywords.length?(o(),l("div",Se,[(o(!0),l(w,null,h(r.keywords,a=>(o(),l("span",{key:`k-${a}`,class:"rounded-full bg-teal-50 px-2 py-0.5 text-[10px] font-medium text-teal-700 dark:bg-teal-900/30 dark:text-teal-400"},g(a),1))),128))])):x("",!0)]),t("div",null,[e[26]||(e[26]=t("label",{class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"}," Aliases ",-1)),n(t("textarea",{"onUpdate:modelValue":e[9]||(e[9]=a=>q.value=a),rows:"3",placeholder:"connect Slack, set up Slack, link Slack, Slack app, hook up Slack",class:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:ring-2 focus:ring-teal-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white"},null,512),[[i,q.value]]),e[27]||(e[27]=t("p",{class:"mt-1 text-xs text-gray-400"},' Verb / brand variants ("connect Slack", "set up Stripe", "GHL integration"). ',-1)),r.aliases.length?(o(),l("div",Ue,[(o(!0),l(w,null,h(r.aliases,a=>(o(),l("span",{key:`a-${a}`,class:"rounded-full bg-violet-50 px-2 py-0.5 text-[10px] font-medium text-violet-700 dark:bg-violet-900/30 dark:text-violet-400"},g(a),1))),128))])):x("",!0)])])]),t("div",Pe,[t("div",Ae,[e[31]||(e[31]=t("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white"},"UI Elements",-1)),t("button",{type:"button",onClick:z,class:"text-sm font-medium text-teal-600 hover:text-teal-700 dark:text-teal-400"},[u(m(N),{size:14,class:"mr-1 inline"}),e[30]||(e[30]=d(" Add Element ",-1))])]),r.ui_elements.length?(o(),l("div",qe,[(o(!0),l(w,null,h(r.ui_elements,(a,K)=>(o(),l("div",{key:K,class:"flex items-start gap-3 rounded-lg border border-gray-100 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},[n(t("input",{"onUpdate:modelValue":y=>a.id=y,placeholder:"Element ID (e.g. api-key-input)",class:"flex-1 rounded border border-gray-300 px-2.5 py-1.5 text-xs dark:border-gray-600 dark:bg-gray-800 dark:text-white"},null,8,Ce),[[i,a.id]]),n(t("input",{"onUpdate:modelValue":y=>a.label=y,placeholder:"Label (e.g. API Key)",class:"flex-1 rounded border border-gray-300 px-2.5 py-1.5 text-xs dark:border-gray-600 dark:bg-gray-800 dark:text-white"},null,8,Ee),[[i,a.label]]),n(t("select",{"onUpdate:modelValue":y=>a.type=y,class:"rounded border border-gray-300 px-2.5 py-1.5 text-xs dar
1k:border-gray-600 dark:bg-gray-800 dark:text-white"},[...e[32]||(e[32]=[Y('<option value="input">Input</option><option value="button">Button</option><option value="toggle">Toggle</option><option value="select">Select</option><option value="link">Link</option><option value="section">Section</option>',6)])],8,Ke),[[L,a.type]]),t("button",{type:"button",onClick:y=>r.ui_elements.splice(K,1),class:"p-1 text-gray-400 hover:text-red-500"},[u(m(ie),{size:14})],8,De)]))),128))])):(o(),l("p",Ve," No UI elements defined. Add buttons, inputs, toggles, etc. that Nox should know about. "))]),f.value?(o(),l("div",Le,g(f.value),1)):x("",!0),t("div",Re,[t("button",{type:"submit",disabled:k.value,class:"rounded-lg bg-teal-600 px-6 py-2.5 text-sm font-medium text-white transition-colors hover:bg-teal-700 disabled:opacity-50"},g(k.value?"Saving...":p.value?"Update Page":"Create Page"),9,Ne),u(E,{to:"/admin/knox/pages",class:"rounded-lg border border-gray-300 px-6 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800"},{default:D(()=>[...e[33]||(e[33]=[d(" Cancel ",-1)])]),_:1}),p.value?(o(),l("button",{key:0,type:"button",onClick:j,disabled:v.value,class:"ml-auto inline-flex items-center gap-1.5 rounded-lg border border-red-300 bg-white px-6 py-2.5 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50 dark:border-red-800 dark:bg-gray-800 dark:text-red-400 dark:hover:bg-red-950"},[u(m(ne),{size:14}),d(" "+g(v.value?"Deleting...":"Delete"),1)],8,Te)):x("",!0)])],32))])}}};export{Xe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.