1import{r as b,w as S,i as l,e as d,f,k as L,A as H,j as t,t as i,p as c,l as p,D as s,c as h,b as w}from"./index-CQF_Jfas.js";import{_ as V}from"./BlockEditor-D7bzkRsR.js";import"./index-Bu5VyALz.js";const N={class:"min-h-screen bg-gray-50 dark:bg-gray-900"},R={class:"sticky top-0 z-40 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm"},T={class:"max-w-5xl mx-auto px-4 py-3"},D={class:"flex items-center justify-between gap-4"},U={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},z={class:"flex-1 text-lg font-medium text-gray-900 dark:text-gray-100 truncate"},P={class:"flex items-center gap-3 text-sm"},q={key:0,class:"text-red-500"},I={key:1,class:"text-gray-400"},F={key:2,class:"text-green-500"},O={key:3,class:"px-2 py-1 text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded"},Q={class:"mt-3 flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-gray-400"},X={class:"text-gray-700 dark:text-gray-300"},G={key:0},J={class:"text-gray-700 dark:text-gray-300"},K={key:1},W={class:"text-gray-700 dark:text-gray-300"},Y={key:0,class:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 flex flex-wrap items-center gap-1"},Z=["disabled"],_=["disabled"],ee={class:"max-w-5xl mx-auto"},te={class:"fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 py-2 px-4 text-center text-xs text-gray-400"},ne={__name:"SharedEditor",props:{document:{type:Object,required:!0},canEdit:{type:Boolean,default:!1},companyName:{type:String,default:""}},setup(a){const C=(n,e)=>{let o;return(...E)=>{clearTimeout(o),o=setTimeout(()=>n(...E),e)}},u=a,m=b(null),r=h(()=>{var n;return(n=m.value)==null?void 0:n.editor}),v=b(u.document.content||""),y=b(!1),x=b(null),g=b(null),k=h(()=>u.document.share_token),M=C(async()=>{if(!(!u.canEdit||!k.value)){y.value=!0,g.value=null;try{(await w.patch(`/api/share/document/${k.value}/content`,{content:v.value})).data.success&&(x.value=new Date)}catch(n){console.error("Auto-save failed:",n),g.value="Failed to save changes"}finally{y.value=!1}}},2e3);S(v,()=>{u.canEdit&&M()});const B=async()=>{if(!(!u.canEdit||!k.value)){y.value=!0,g.value=null;try{(await w.patch(`/api/share/document/${k.value}/content`,{content:v.value})).data.success&&(x.value=new Date)}catch(n){console.error("Save failed:",n),g.value="Failed to save changes"}finally{y.value=!1}}},j=()=>{window.open(`/api/share/document/${k.value}/pdf/preview`,"_blank")},$=()=>{if(!r.value||!u.canEdit)return;const n=r.value.getAttributes("link").href,e=window.prompt("URL",n);if(e!==null){if(e===""){r.value.chain().focus().extendMarkRange("link").unsetLink().run();return}r.value.chain().focus().extendMarkRange("link").setLink({href:e}).run()}},A={document:"Document",quote:"Quote",letter:"Letter"};return(n,e)=>(l(),d("div",N,[f(L(H),{title:a.document.name},null,8,["title"]),t("div",R,[t("div",T,[t("div",D,[t("div",U,i(a.companyName),1),t("h1",z,i(a.document.name),1),t("div",P,[g.value?(l(),d("span",q,i(g.value),1)):y.value?(l(),d("span",I," Saving... ")):x.value?(l(),d("span",F," Saved ")):c("",!0),a.canEdit?c("",!0):(l(),d("span",O," Read-only ")),t("button",{onClick:j,class:"px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600"}," Preview PDF ")])]),t("div",Q,[t("span",null,[e[14]||(e[14]=p(" Type: ",-1)),t("strong",X,i(A[a.document.document_type]||a.document.document_type),1)]),a.document.customer?(l(),d("span",G,[e[15]||(e[15]=p(" Customer: ",-1)),t("strong",J,i(a.document.customer.name),1)])):c("",!0),a.document.project?(l(),d("span",K,[e[16]||(e[16]=p(" Project: ",-1)),t("strong",W,i(a.document.project.name),1)])):c("",!0)]),r.value&&a.canEdit?(l(),d("div",Y,[t("button",{type:"button",onClick:e[0]||(e[0]=o=>r.value.chain().focus().toggleBold().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("bold")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Bold"},[...e[17]||(e[17]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6z M6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"})],-1)])],2),t("button",{type:"button",onClick:e[1]||(e[1]=o=>r.value.chain().focus().toggleItalic().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("italic")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Italic"},[...e[18]||(e[18]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 4h4m-2 0v16m-4 0h8",transform:"skewX(-10)"})],-1)])],2),t("button",{type:"button",onClick:e[2]||(e[2]=o=>r.value.chain().focus().toggleUnderline().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("underline")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Underline"},[...e[19]||(e[19]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 8v4a5 5 0 0010 0V8M5 20h14"})],-1)])],2),t("button",{type:"button",onClick:e[3]||(e[3]=o=>r.value.chain().focus().toggleStrike().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("strike")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Str
1ikethrough"},[...e[20]||(e[20]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v4m0 4v8m-6-8h12"})],-1)])],2),t("button",{type:"button",onClick:e[4]||(e[4]=o=>r.value.chain().focus().toggleCode().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("code")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Inline Code"},[...e[21]||(e[21]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})],-1)])],2),e[28]||(e[28]=t("div",{class:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},null,-1)),t("button",{type:"button",onClick:e[5]||(e[5]=o=>r.value.chain().focus().toggleHeading({level:1}).run()),class:s(["px-1.5 py-0.5 rounded text-xs font-semibold hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("heading",{level:1})?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"])},"H1",2),t("button",{type:"button",onClick:e[6]||(e[6]=o=>r.value.chain().focus().toggleHeading({level:2}).run()),class:s(["px-1.5 py-0.5 rounded text-xs font-semibold hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("heading",{level:2})?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"])},"H2",2),t("button",{type:"button",onClick:e[7]||(e[7]=o=>r.value.chain().focus().toggleHeading({level:3}).run()),class:s(["px-1.5 py-0.5 rounded text-xs font-semibold hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("heading",{level:3})?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"])},"H3",2),e[29]||(e[29]=t("div",{class:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},null,-1)),t("button",{type:"button",onClick:e[8]||(e[8]=o=>r.value.chain().focus().toggleBulletList().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("bulletList")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Bullet List"},[...e[22]||(e[22]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h16M4 18h16M2 6h.01M2 12h.01M2 18h.01"})],-1)])],2),t("button",{type:"button",onClick:e[9]||(e[9]=o=>r.value.chain().focus().toggleOrderedList().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("orderedList")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Numbered List"},[...e[23]||(e[23]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 6h13M7 12h13M7 18h13M3 6v.01M3 12v.01M3 18v.01"})],-1)])],2),e[30]||(e[30]=t("div",{class:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},null,-1)),t("button",{type:"button",onClick:e[10]||(e[10]=o=>r.value.chain().focus().toggleBlockquote().run()),class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("blockquote")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Quote"},[...e[24]||(e[24]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-4l-4 4z"})],-1)])],2),t("button",{type:"button",onClick:$,class:s(["p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700",r.value.isActive("link")?"bg-gray-200 dark:bg-gray-600 text-reflex-500":"text-gray-600 dark:text-gray-400"]),title:"Link"},[...e[25]||(e[25]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})],-1)])],2),e[31]||(e[31]=t("div",{class:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},null,-1)),t("button",{type:"button",onClick:e[11]||(e[11]=o=>
1r.value.chain().focus().undo().run()),disabled:!r.value.can().undo(),class:"p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 disabled:opacity-30",title:"Undo"},[...e[26]||(e[26]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})],-1)])],8,Z),t("button",{type:"button",onClick:e[12]||(e[12]=o=>r.value.chain().focus().redo().run()),disabled:!r.value.can().redo(),class:"p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 disabled:opacity-30",title:"Redo"},[...e[27]||(e[27]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 10h-10a8 8 0 00-8 8v2M21 10l-6 6m6-6l-6-6"})],-1)])],8,_),e[32]||(e[32]=t("span",{class:"ml-auto text-xs text-gray-400"},"Type / for blocks",-1))])):c("",!0)])]),t("div",ee,[f(V,{ref_key:"blockEditorRef",ref:m,modelValue:v.value,"onUpdate:modelValue":e[13]||(e[13]=o=>v.value=o),placeholder:a.canEdit?"Start typing or press '/' for commands...":"","show-toolbar":!1,class:s({"pointer-events-none":!a.canEdit}),onSave:B},null,8,["modelValue","placeholder","class"])]),t("div",te," Powered by "+i(a.companyName),1)]))}};export{ne 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.