1import{r as f,_ as E}from"./azure-b7f4c004.js";import{J as b,u as h,m as w,D as u,j as r,L as y,_ as v,l as g,s as _,a0 as N,o as P,e as I,d as L,N as S,B as A,v as D,a as T,F as O}from"./registration-0c84e8c2.js";import{t as R,T as F}from"./trackingService-c35d4468.js";import{E as $}from"./RegisterLinks-92c41860.js";import"./analytics-99e053f8.js";import"./iconsax-fa9e39a7.js";import"./sentry-e70f6bf5.js";import"./TemplateGroup-d4b0ada9.js";import"./PrivateRouter-adcfebb1.js";import"./ErrorFallback-9f0f33dd.js";import"./index-59e96616.js";import"./TemplateCustomizationWalkthrough-069a85f8.js";import"./HelpContainer-ea92176d.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="22c0ebb6-d73c-4fd2-bbb4-821ff8c1215f",a._sentryDebugIdIdentifier="sentry-dbid-22c0ebb6-d73c-4fd2-bbb4-821ff8c1215f")}catch{}})();const k=g(()=>E(()=>import("./DefaultLayout-6cfd98b7.js"),["assets/css/registration-8b20d1d3.css","assets/css/ErrorFallback-46853439.css","assets/css/index-412759e9.css","assets/css/PrivateRouter-4e1c1a6f.css"]));function Q(){const{templateId:a}=b(),{isTreatmentPlanTester:e}=h();f.useEffect(()=>{R.trackEvent("visitsTemplateBuilderPage",{source:"edit-template"})},[]);const{data:t,isLoading:p,error:n}=w(a&&`template/${a}`,()=>u.GET_NOTE_TEMPLATE(a),{revalidateOnFocus:!1}),d=t?!1:p,o=async(l,i)=>{let s=u.SAVE_NOTE_TEMPLATE(a,l).then(()=>i?.()).catch(m=>{throw _(m,`Problem saving final template ${m.message}`,{templateId:a,payload:l}),i?.(m),m});N(s,{pending:"Saving template",success:"Template saved successfully!",error:"We could not save the template right now. Try again or contact support for help."})},c=async(l,i)=>{try{let{data:s}=await u.CREATE_NEW_TEMPLATE(l);if(P(`The template â${s.name}â was created and saved as new successfully.`),s){i?.();let m=s.template_id;window.open(`/note-templates/${m}?expand=true`,"_blank")}else throw new Error("clone service returned a 200 status but didn't return template")}catch(s){let m={template_id:t.template_id,is_system:t.is_system,template_name:l.name};i?.(s),I("We could not save the template right now. Try again or contact support for help."),_(s,`Problem cloning template ${t.template_id} ${s.message}`,{templateId:a,params:m})}};return r(f.Suspense,{fallback:r(y,{}),children:r(k,{beforeHeader:null,children:d||t?r(F,{templateId:a,isLoading:d,defaultTemplateName:t?.name,defaultTemplateFormat:t?.template_format,defaultClientType:t?.client_type,isDefaultTemplate:t?.is_default,defaultNoteType:t?.note_type,defaultTemplateStructure:t?.template_structure,defaultTemplateVersion:t?.template_version,defaultRecommendedFor:t?.recommended_for??v(null,!1,t?.note_type),isSystemTemplate:t?.is_system,isEditable:t?.is_editable,onSave:o,onSaveAsNew:c,isTreatmentPlanTester:e||!1}):r("div",{children:r(x,{err:n,templateId:a})})})})}function x(a){const e=L.c(8),{err:t,templateId:p}=a;let n="";if(t){const i=t?.response?.status;if(i===404){let s;e[0]!==p?(s=T(O,{children:["No such template: ",r("span",{className:"tw-font-bold",children:p})]}),e[0]=p,e[1]=s):s=e[1],n=s}else i>=500&&(n="Internal server error")}n=n||"Unknown Error, please contact customer service";let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r("div",{className:"tw-mb-2",children:r($,{className:"tw-w-12 tw-h-12"})}),e[2]=d):d=e[2];let o;e[3]!==n?(o=r("div",{className:"tw-mb-3 tw-font-medium",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r(S,{to:"/note-templates",children:r(A,{variant:D.OUTLINED,children:"View all templates"})}),e[5]=c):c=e[5];let l;return e[6]!==o?(l=T("div",{className:"tw-py-20 tw-text-center",children:[d,o,c]}),e[6]=o,e[7]=l):l=e[7],l}export{Q as default}; 2//# sourceMappingURL=EditTemplate-efd5bcc1.js.map
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.