import{d as K,u as Q,c as P,r as y,z as Y,o as Z,e as n,f as i,h as g,w as D,j as d,F as b,H as F,X as ee,l as se,n as c,q as te,B as $,g as C,t as x,C as oe,k as ae}from"./index-a0da86f0.js";import{I as N}from"./iconify-56cbf3ff.js";import{getWorkspace as ne}from"./common-fa44b7a0.js";import{p as R}from"./slug-3db6ff8f.js";import{_ as ce}from"./_plugin-vue_export-helper-c27b6911.js";const re={class:"workspace"},le={class:"workspace-header"},ie={key:0,class:"loading"},pe={key:1,class:"content"},ue={class:"grid-12"},de={class:"card-header"},_e={class:"card-title"},fe={class:"card-body"},he={class:"card-links"},ke=["onClick"],ye={class:"link-text"},ge=["onClick"],ve={class:"shortcut-text"},me=["innerHTML"],be={key:3,class:"spacer span-12"};function $e(o){try{return typeof o=="string"?JSON.parse(o):Array.isArray(o)?o:[]}catch{return[]}}function V(o){const u=["span-12"];return o<=12&&o>=7||(o===6||o===5?u.push("sm-span-6"):o===4?u.push("sm-span-6","md-span-4"):(o===3||o===2)&&u.push("sm-span-6","md-span-4",`lg-span-${o}`)),u}const Ce=K({__name:"WorkspacePage",setup(o){const u=ee(),v=se(),q=Q(),z=P(()=>String(u.params.name||"Build")),B=P(()=>decodeURIComponent(z.value)),h=y(!0),J=y("Workspace"),O=y(!0),S=y([]);async function m(){var L,T,I,M,W,A,H;h.value=!0;const{success:a,data:e,message:s}=await ne(B.value);if(!a){q.error(s||"Failed to load workspace"),h.value=!1;return}J.value=(e==null?void 0:e.title)||B.value,O.value=!!((e==null?void 0:e.public)??!0);const _=$e(e==null?void 0:e.content),w=Array.isArray(e==null?void 0:e.links)?e.links:[],k={};let f="";for(const t of w)t.type==="Card Break"?(f=t.label||"Untitled",k[f]||(k[f]=[])):t.type==="Link"&&f&&k[f].push({label:t.label,link_type:t.link_type,link_to:t.link_to});const p=[];for(const t of _||[])if(t.type==="card"){const r=((L=t.data)==null?void 0:L.card_name)||"Section",l=Number(((T=t.data)==null?void 0:T.col)||6);p.push({key:`card-${r}-${l}-${p.length}`,type:"card",title:r,col:l,links:k[r]||[],classes:V(l)})}else if(t.type==="shortcut"){const r=((I=t.data)==null?void 0:I.shortcut_name)||"Shortcut",l=Number(((M=t.data)==null?void 0:M.col)||3),X=(W=e==null?void 0:e.shortcuts)==null?void 0:W.find(G=>G.label===r);p.push({key:`shortcut-${r}-${l}-${p.length}`,type:"shortcut",title:r,col:l,shortcutData:X,classes:V(l)})}else if(t.type==="header"){const r=((A=t.data)==null?void 0:A.text)||"Header",l=Number(((H=t.data)==null?void 0:H.col)||12);p.push({key:`header-${r}-${l}-${p.length}`,type:"header",text:r,col:l,classes:["span-12"]})}else t.type==="spacer"&&p.push({key:`spacer-${p.length}`,type:"spacer"});S.value=p,h.value=!1}function U(){m()}function j(a){if(!a)return;const e=(a.link_type||"").toLowerCase();if(e==="pagetype"||e==="report"){const s=R(a.link_to);v.push(`/app/${s}`)}else e==="page"&&v.push(`/${a.link_to}`)}function E(a){if(a){if(a.url)window.open(a.url,"_blank");else if(a.link_to){const e=R(a.link_to);v.push(`/app/${e}`)}}}return Y(()=>u.params.name,m),Z(m),(a,e)=>(c(),n("div",re,[i("div",le,[g(d(te),{quaternary:"",circle:"",onClick:U,style:{"margin-left":"auto"}},{icon:D(()=>[g(d(N),{icon:"tabler:refresh"})]),_:1})]),h.value?(c(),n("div",ie)):(c(),n("div",pe,[i("div",ue,[(c(!0),n(b,null,F(S.value,s=>(c(),n(b,{key:s.key},[s.type==="card"?(c(),n("div",{key:0,class:$(["card",s.classes])},[i("div",de,[i("div",_e,C(d(x)(s.title)),1)]),i("div",fe,[i("div",he,[(c(!0),n(b,null,F(s.links,_=>(c(),n("a",{key:_.label,class:"link",onClick:oe(w=>j(_),["prevent"])},[i("span",ye,C(d(x)(_.label)),1),g(d(N),{class:"link-icon",icon:"tabler:arrow-up-right"})],8,ke))),128))])])],2)):s.type==="shortcut"?(c(),n("div",{key:1,class:$(["shortcut",s.classes])},[i("div",{class:"shortcut-content",onClick:_=>E(s.shortcutData)},[i("span",ve,C(d(x)(s.title)),1),g(d(N),{class:"shortcut-icon",icon:"tabler:arrow-up-right"})],8,ge)],2)):s.type==="header"?(c(),n("div",{key:2,class:$(["header",s.classes])},[i("div",{class:"header-content",innerHTML:s.text},null,8,me)],2)):s.type==="spacer"?(c(),n("div",be)):ae("",!0)],64))),128))])]))]))}});const Le=ce(Ce,[["__scopeId","data-v-06f47be1"]]);export{Le as default,V as mapColToClasses,$e as parseJSON};
