1import{r as _,x as L,C as q,j as A,c as i,a as d,k as o,u as a,Z as B,l as h,f as t,D as j,g as S,e as E,h as g,v as f,d as F,F as T,q as O,t as w,E as $,s as P}from"./app-B3q2SnoA.js";import R from"./Layout-DJc98_Vc.js";import{_ as p}from"./InputError-C0zZ9OuN.js";import{_ as K}from"./PrimaryButton-HBIzXExn.js";import{Q as X}from"./vue-quill.snow-Cr9JEAqn.js";import{_ as I}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./AuthenticationCardLogo-BtSjXMhD.js";const H={class:"max-w-4xl mx-auto"},J={class:"flex justify-between items-center mb-8 pb-6 border-b"},Q={class:"grid grid-cols-2 gap-6"},z={key:0,class:"flex flex-wrap gap-1.5 mb-3"},W=["onClick"],Z={key:1,class:"space-y-2"},G={class:"border border-gray-300 rounded-md p-3 max-h-40 overflow-y-auto space-y-2"},Y=["value","checked","onChange"],ee={class:"text-sm text-gray-700"},te=["onClick"],se={key:0,class:"text-sm text-gray-400 text-center py-2"},re={key:2,class:"flex gap-2"},ae={class:"grid grid-cols-1 md:grid-cols-3 gap-6"},oe={key:0,class:"col-span-1 md:col-span-3 mt-4 p-4 bg-gray-50 rounded border"},le=["src"],ne={class:"bg-gray-50 p-6 rounded border"},ie={class:"space-y-4"},de={class:"text-xs text-gray-500 mt-1"},ue={class:"text-xs text-gray-500 mt-1"},me={class:"flex items-center justify-end space-x-3 pt-6 border-t"},ce={key:0},pe={key:1},ge={__name:"Edit",props:{article:Object,categories:{type:Array,default:()=>[]}},setup(U){const l=U,b=_([]),v=_(!1),y=_(""),x=L(()=>r.category?r.category.split(",").map(n=>n.trim()).filter(Boolean):[]),k=n=>{const e=x.value.slice(),m=e.indexOf(n);m===-1?e.push(n):e.splice(m,1),r.category=e.join(",")},C=async()=>{const e=await(await fetch("/api/categories?type=article")).json(),m=e.data.map(s=>s.name),u=l.categories.filter(s=>s&&s.trim()&&!m.includes(s));if(l.article.category){const s=l.article.category.split(",").map(c=>c.trim()).filter(Boolean);for(const c of s)!m.includes(c)&&!u.includes(c)&&u.push(c)}for(const s of u)await fetch("/api/categories",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({name:s,type:"article"})});if(u.length>0){const c=await(await fetch("/api/categories?type=article")).json();b.value=c.data}else b.value=e.data},N=async()=>{const n=y.value.trim();n&&(await fetch("/api/categories",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({name:n,type:"article"})}),await C(),k(n),y.value="",v.value=!1)},V=async n=>{const e=b.value.find(u=>u.name===n);if(!e||!e.id||!confirm(`Delete category "${e.name}"?`))return;await fetch(`/api/categories/${e.id}`,{method:"DELETE",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]').content,"X-Requested-With":"XMLHttpRequest"}});const m=x.value.filter(u=>u!==n);r.category=m.join(","),await C()},D=()=>{y.value="",v.value=!1},r=q({title:l.article.title,excerpt:l.article.excerpt||"",content:l.article.content,category:l.article.category,author:l.article.author,featured_image:l.article.featured_image||"",meta_description:l.article.meta_description||"",meta_title:l.article.meta_title||"",status:l.article.status,published_at:l.article.published_at?new Date(new Date(l.article.published_at).getTime()-new Date().getTimezoneOffset()*6e4).toISOString().slice(0,16):""}),M=()=>{r.put(route("admin.article.update",l.article.id),{preserveScroll:!0})};return A(()=>{C()}),(n,e)=>(d(),i(T,null,[o(a(B),{title:`Edit: ${a(r).title}`},null,8,["title"]),o(R,null,{default:h(()=>{var m,u;return[t("div",H,[t("div",J,[e[12]||(e[12]=t("div",null,[t("h1",{class:"text-2xl font-bold text-gray-900"},"Edit Article"),t("p",{class:"text-gray-600 mt-2"},"Update your article content and metadata")],-1)),o(a(j),{href:n.route("admin.articles"),class:"px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300"},{default:h(()=>[...e[11]||(e[11]=[S(" Back to Articles ",-1)])]),_:1},8,["href"])]),t("form",{onSubmit:E(M,["prevent"]),class:"bg-white rounded border p-8 space-y-6"},[t("div",null,[e[13]||(e[13]=t("label",{for:"title",class:"block text-sm font-medium text-gray-700 mb-2"},"Title",-1)),g(t("input",{id:"title","onUpdate:modelValue":e[0]||(e[0]=s=>a(r).title=s),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focu
1s:border-transparent",required:""},null,512),[[f,a(r).title]]),o(p,{message:a(r).errors.title,class:"mt-2"},null,8,["message"])]),t("div",Q,[t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Categories",-1)),x.value.length>0?(d(),i("div",z,[(d(!0),i(T,null,O(x.value,s=>(d(),i("span",{key:s,class:"inline-flex items-center gap-1 px-2.5 py-1 bg-[#00403F] text-white text-xs font-medium rounded-full"},[S(w(s)+" ",1),t("button",{type:"button",onClick:c=>k(s),class:"hover:text-red-200 transition-colors"},[...e[14]||(e[14]=[t("svg",{class:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,W)]))),128))])):F("",!0),v.value?(d(),i("div",re,[g(t("input",{id:"category-new","onUpdate:modelValue":e[2]||(e[2]=s=>y.value=s),type:"text",class:"flex-1 px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",placeholder:"Type new category name",onKeyup:$(N,["enter"])},null,544),[[f,y.value]]),t("button",{type:"button",onClick:N,class:"px-3 py-2 bg-[#00403F] text-white rounded-md hover:bg-[#002d2c] text-sm"},"Add"),t("button",{type:"button",onClick:D,class:"px-3 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 text-sm"},"Cancel")])):(d(),i("div",Z,[t("div",G,[(d(!0),i(T,null,O(b.value,s=>(d(),i("label",{key:s.id||s.name,class:"flex items-center gap-2 cursor-pointer hover:bg-gray-50 rounded px-1 py-0.5"},[t("input",{type:"checkbox",value:s.name,checked:x.value.includes(s.name),onChange:c=>k(s.name),class:"rounded border-gray-300 text-[#00403F] focus:ring-[#00403F]"},null,40,Y),t("span",ee,w(s.name),1),t("button",{type:"button",onClick:E(c=>V(s.name),["prevent"]),class:"ml-auto text-red-400 hover:text-red-600 transition-colors",title:"Delete category"},[...e[15]||(e[15]=[t("svg",{class:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,te)]))),128)),b.value.length===0?(d(),i("p",se,"No categories yet")):F("",!0)]),t("button",{type:"button",onClick:e[1]||(e[1]=s=>{v.value=!0,y.value=""}),class:"text-xs text-[#00403F] hover:underline font-medium"},"+ Add New Category")])),o(p,{message:a(r).errors.category,class:"mt-2"},null,8,["message"])]),t("div",null,[e[17]||(e[17]=t("label",{for:"author",class:"block text-sm font-medium text-gray-700 mb-2"},"Author",-1)),g(t("input",{id:"author","onUpdate:modelValue":e[3]||(e[3]=s=>a(r).author=s),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",required:""},null,512),[[f,a(r).author]]),o(p,{message:a(r).errors.author,class:"mt-2"},null,8,["message"])])]),t("div",ae,[t("div",null,[e[19]||(e[19]=t("label",{for:"status",class:"block text-sm font-medium text-gray-700 mb-2"},"Status",-1)),g(t("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=s=>a(r).status=s),class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",required:""},[...e[18]||(e[18]=[t("option",{value:"draft"},"Draft",-1),t("option",{value:"published"},"Published",-1),t("option",{value:"archived"},"Archived",-1)])],512),[[P,a(r).status]]),o(p,{message:a(r).errors.status,class:"mt-2"},null,8,["message"])]),t("div",null,[e[20]||(e[20]=t("label",{for:"published_at",class:"block text-sm font-medium text-gray-700 mb-2"},"Publish Date (Optional)",-1)),g(t("input",{id:"published_at","onUpdate:modelValue":e[5]||(e[5]=s=>a(r).published_at=s),type:"datetime-local",step:"any",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent"},null,512),[[f,a(r).published_at]]),e[21]||(e[21]=t("p",{class:"text-xs text-gray-500 mt-1"},"Updates current publish time if filled",-1)),o(p,{message:a(r).errors.published_at,class:"mt-2"},null,8,["message"])]),t("div",null,[e[23]||(e[23]=t("label",{for:"featured_image",class:"block text-sm font-medium text-gray-700 mb-2"},"Featured Image URL",-1)),g(t("input",{id:"featured_image","onUpdate:modelValue":e[6]||(e[6]=s=>a(r).featured_image=s),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focu
1s:border-transparent",placeholder:"https://..."},null,512),[[f,a(r).featured_image]]),e[24]||(e[24]=t("p",{class:"text-xs text-gray-500 mt-1"},"Paste the image URL from the Media Library",-1)),o(p,{message:a(r).errors.featured_image,class:"mt-2"},null,8,["message"]),a(r).featured_image?(d(),i("div",oe,[e[22]||(e[22]=t("p",{class:"text-sm font-medium text-gray-700 mb-2"},"Image Preview",-1)),t("img",{src:a(r).featured_image,alt:"Preview",class:"h-24 w-24 object-cover rounded"},null,8,le)])):F("",!0)])]),t("div",null,[e[25]||(e[25]=t("label",{for:"excerpt",class:"block text-sm font-medium text-gray-700 mb-2"},"Excerpt",-1)),g(t("textarea",{id:"excerpt","onUpdate:modelValue":e[7]||(e[7]=s=>a(r).excerpt=s),rows:"3",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",placeholder:"Short summary of the article..."},null,512),[[f,a(r).excerpt]]),o(p,{message:a(r).errors.excerpt,class:"mt-2"},null,8,["message"])]),t("div",null,[e[26]||(e[26]=t("label",{for:"content",class:"block text-sm font-medium text-gray-700 mb-2"},"Content",-1)),o(a(X),{content:a(r).content,"onUpdate:content":e[8]||(e[8]=s=>a(r).content=s),theme:"snow",contentType:"html",style:{"min-height":"300px",background:"white"}},null,8,["content"]),o(p,{message:a(r).errors.content,class:"mt-2"},null,8,["message"])]),t("div",ne,[e[29]||(e[29]=t("h3",{class:"text-lg font-semibold text-gray-900 mb-4"},"SEO Settings",-1)),t("div",ie,[t("div",null,[e[27]||(e[27]=t("label",{for:"meta_title",class:"block text-sm font-medium text-gray-700 mb-2"},"Meta Title",-1)),g(t("input",{id:"meta_title","onUpdate:modelValue":e[9]||(e[9]=s=>a(r).meta_title=s),type:"text",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",maxlength:"60"},null,512),[[f,a(r).meta_title]]),t("p",de,w(((m=a(r).meta_title)==null?void 0:m.length)||0)+"/60 characters",1),o(p,{message:a(r).errors.meta_title,class:"mt-2"},null,8,["message"])]),t("div",null,[e[28]||(e[28]=t("label",{for:"meta_description",class:"block text-sm font-medium text-gray-700 mb-2"},"Meta Description",-1)),g(t("textarea",{id:"meta_description","onUpdate:modelValue":e[10]||(e[10]=s=>a(r).meta_description=s),rows:"3",class:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#00403F] focus:border-transparent",maxlength:"160"},null,512),[[f,a(r).meta_description]]),t("p",ue,w(((u=a(r).meta_description)==null?void 0:u.length)||0)+"/160 characters",1),o(p,{message:a(r).errors.meta_description,class:"mt-2"},null,8,["message"])])])]),t("div",me,[o(a(j),{href:n.route("admin.articles"),class:"px-6 py-2 text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300"},{default:h(()=>[...e[30]||(e[30]=[S(" Cancel ",-1)])]),_:1},8,["href"]),o(K,{disabled:a(r).processing,class:"!gap-2"},{default:h(()=>[a(r).processing?(d(),i("span",ce,"Saving...")):(d(),i("span",pe,"Save Changes"))]),_:1},8,["disabled"])])],32)])]}),_:1})],64))}},ke=I(ge,[["__scopeId","data-v-e6ddc57c"]]);export{ke 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.