import{B as X,C as J,K,e as y,f as P,D as O,m as j,n as W,p as Z,r as F,g as G,c as U,o as x,b as e,t as D,h as r,k as p,v as Q,L as Y,d as S,y as tt,a as u,u as b,w,x as et,q as M,s as _,j as ot,T as st,F as nt,J as it}from"./app-CMIR6SQ7.js";import{d as lt}from"./sortBy-B8YjcpP2.js";import{a as at,b as rt,u as dt}from"./notifier-D0ifK1Rl.js";import{u as ut,_ as ft,T as ct}from"./TheBulkUpload-1HzoRCet.js";import{u as pt,d as mt,o as gt}from"./vue-contenteditable.es-Dtcp21g7.js";import"./_Uint8Array-BxbSsmXd.js";import"./get-DjLjuSKy.js";const vt={class:"mr:8 font:24 lh:32px"},yt={id:"poststuff"},bt={id:"post-body-content"},ht={id:"titlediv"},xt={id:"titlewrap"},wt=["placeholder"],_t={class:"postarea wp-editor-expand"},kt={id:"wp-content-wrap",class:"wp-core-ui mt:32"},St={class:"grid grid-cols:12 gap:16"},Vt={class:"grid-col-span:4 flex flex:col gap:6"},$t={class:"grid-col-span:2 flex flex:col gap:6"},Ft={class:"grid-col-span:4 flex flex:col gap:6"},Ut={class:"grid-col-span:2 flex flex:col gap:6"},zt={class:"flex:1|1|0% flex align-items:center"},Ct={for:"preload",class:"font:14 lh:20px"},Nt={class:"flex align-items:center {ml:8}>*+* mt:32 mb:12"},Tt={class:"flex:1|1|0%"},Bt={class:"font-files"},Pt={class:"grid gap:16"},jt={id:"postbox-container-1",class:"postbox-container"},Dt={id:"submitdiv",class:"postbox"},Mt={class:"inside"},Rt={class:"submitbox",id:"submitpost"},qt={id:"minor-publishing"},At={id:"misc-publishing-actions"},Et={class:"misc-pub-section"},Lt={class:"py:6 flex align-items:center"},Ht={id:"major-publishing-actions"},It={id:"publishing-action"},Xt=["disabled"],Jt={class:"flex flex:col {mt:8}>*+* py:8 px:8 b:1|solid|gray-30/.5"},Kt={class:"h:fit flex r:6 shadow-sm"},Ot=["min","max"],Wt=["min","max"],Zt={class:"h:fit flex r:6 shadow-sm"},Gt=["min","max"],Qt=["min","max"],Yt={class:"h:fit flex r:6 shadow-sm"},te={class:"h:fit flex align-items:stretch rel r:6 shadow-sm"},ee={id:"postbox-container-2",class:"postbox-container mt:12"},oe={key:0,class:"mt:16"},fe={__name:"Create",setup(se){const R=at(),q=X(),A=rt(),V=dt(),E=J(),$=ut(),{fontFaces:m}=K($),g=y(""),i=y(""),h=y("auto"),v=y(""),k=y(!1),f=y(!0);P(i,(o,t)=>{(g.value===""||g.value===t)&&(g.value=o)});const z=()=>{$.add()},n=O({text:"",fontSize:18,lineHeight:1.5,fontFamily:i,weight:{current:400,min:1,max:1e3},width:{current:100,min:25,max:200}});it("fontFamily",i);function L(){m.value.sort((o,t)=>o.weight===t.weight?o.style==="normal"?-1:1:o.weight-t.weight)}function H(o){switch(o){case"woff2":case"font/woff2":return"woff2";case"woff":case"font/woff":return"woff";case"ttf":case"font/ttf":return"truetype";case"otf":case"font/otf":return"opentype";case"eot":case"font/eot":return"embedded-opentype";default:return"woff2"}}const C=j(()=>{let o="";return i.value&&m.value.forEach(t=>{if(t.comment&&(o+=`/* ${t.comment} */
`),o+=`@font-face {
`,o+=`	font-family: '${i.value}';
`,o+=`	font-style: ${t.style};
`,t.weight!==""&&(o+=`	font-weight: ${t.weight};
`),t.width&&t.width!==""?o+=`	font-stretch: ${t.width};
`:o+=`	font-stretch: 100%;
`,o+=`	font-display: ${t.display||h.value};
`,t.files.length>0){o+="	src: ";let a=t.files.map(l=>{let d=l.attachment_url;try{d=new URL(l.attachment_url).pathname}catch{}return`url('${d}') format("${H(l.extension)}")`});o+=a.join(`,
		`),o+=`;
`}t.unicodeRange&&(o+=`	unicode-range: ${t.unicodeRange};
`),o+=`}

`}),o}),N=j(()=>{let o="";if(!i.value)return o;o+=`
`,o+=C.value;const t=i.value.replace(/[^a-zA-Z0-9\-_]+/g,"-").toLowerCase();let a="",l=[];return v.value&&(l=v.value.split("|").map(d=>d.trim())),l.length>1&&l[1]&&(a=`, ${l[1]}`),o+=`:root {
`,o+=`	--ywf--family-${t}: '${i.value}'${a};
`,o+=`}

`,l.length>0&&l[0]&&(o+=`${l[0]} {
	font-family: var(--ywf--family-${t});
}

`),m.value.forEach(d=>{d.selector&&(o+=`${d.selector} {
`,o+=`	font-family: var(--ywf--family-${t});
`,o+=`	font-style: ${d.style};
`,o+=`	font-weight: ${d.weight};
`,o+=`}

`)}),o=o.replace(/\t/g,"  "),o=o.replace(/<family>/g,i.value),o});let c;P(C,lt((o,t)=>{c&&(c.innerHTML=o.replace(/\t/g,"  "))},1e3));function T(){g.value="",i.value="",v.value="",h.value="auto",k.value=!1,$.reset(),z(),n.text="The quick brown fox jumps over a lazy dog",n.fontSize=18,n.weight={current:400,min:1,max:1e3},n.width={current:100,min:25,max:200}}W(()=>{T(),c=document.querySelector("#yabe-webfont-preview"),c||(c=document.createElement("style"),c.setAttribute("id","yabe-webfont-preview"),document.head.appendChild(c))}),Z(()=>{c&&document.head.removeChild(c)});function I(o){o.preventDefault(),V.add("fonts.create.custom:send-form");let t=R.request({method:"POST",url:"/fonts/custom/store",data:{title:g.value,family:i.value,status:f.value,font_faces:m.value,metadata:{preload:k.value,selector:v.value,display:h.value}}}).then(a=>{const l=q.resolve({name:"fonts.edit.custom",params:{id:a.data.id}}).href;E.add({type:"success",message:`<p>Font saved successfully. <a href="${l}">Edit Font</a></p>`}),T()}).finally(()=>{V.remove("fonts.create.custom:send-form")});A.async(t,"Font stored successfully.",void 0,"Storing font...")}return(o,t)=>{const a=F("Icon"),l=F("Draggable"),d=F("highlightjs"),B=G("ripple");return x(),U(nt,null,[e("span",vt,"» "+D(o.__("New","yabe-webfont")),1),e("div",yt,[e("form",{id:"post-body",onSubmit:I,class:"metabox-holder columns-2 cols:auto"},[e("div",bt,[e("div",ht,[e("div",xt,[t[13]||(t[13]=e("label",{class:"screen-reader-text",for:"title"},"Add title",-1)),r(e("input",{type:"text",name:"title",id:"title",size:"30",required:"","onUpdate:modelValue":t[0]||(t[0]=s=>g.value=s),placeholder:o.__("Title","yabe-webfont"),autocomplete:"off"},null,8,wt),[[p,g.value]])]),t[14]||(t[14]=e("div",{class:"inside"},null,-1))]),e("div",_t,[e("div",kt,[t[23]||(t[23]=e("h3",null,"Meta",-1)),e("div",St,[e("div",Vt,[t[15]||(t[15]=e("label",{for:"family",class:"font:14 lh:20px font:semibold"},"Font Family",-1)),r(e("input",{type:"text",name:"family",id:"family","onUpdate:modelValue":t[1]||(t[1]=s=>i.value=s),required:"",placeholder:"Font Family",autofocus:"",autocomplete:"off"},null,512),[[p,i.value]])]),e("div",$t,[t[17]||(t[17]=e("label",{for:"display",class:"font:14 lh:20px font:semibold"},"Font Display",-1)),r(e("select",{name:"display",id:"display","onUpdate:modelValue":t[2]||(t[2]=s=>h.value=s),class:"capitalize {capitalize}_option"},t[16]||(t[16]=[Y('<option value="auto">auto</option><option value="block">block</option><option value="swap">swap</option><option value="fallback">fallback</option><option value="optional">optional</option>',5)]),512),[[Q,h.value]])]),e("div",Ft,[t[18]||(t[18]=e("label",{for:"selector",class:"font:14 lh:20px font:semibold"},"CSS Selector | Fallback Font",-1)),r(e("input",{type:"text",name:"selector",id:"selector","onUpdate:modelValue":t[3]||(t[3]=s=>v.value=s),placeholder:"h1, .title, #lyric | Arial, Helvetica, sans-serif",autocomplete:"off"},null,512),[[p,v.value]])]),e("div",Ut,[t[20]||(t[20]=e("span",{class:"font:14 lh:20px font:semibold"},"Preload",-1)),e("div",zt,[e("label",Ct,[r(e("input",{type:"checkbox",name:"preload",id:"preload","onUpdate:modelValue":t[4]||(t[4]=s=>k.value=s)},null,512),[[tt,k.value]]),t[19]||(t[19]=S(" Preload files "))])])])]),e("div",Nt,[e("h3",Tt,[t[21]||(t[21]=S(" Variants ")),u(a,{icon:"fa6-solid:arrow-up-1-9",onClick:L,title:"Sort variants",class:"w:16 h:16 ml:4 cursor:pointer"})]),u(ft,{"font-faces":b(m),family:i.value},null,8,["font-faces","family"]),r((x(),U("button",{type:"button",onClick:z,class:"button my:16"},t[22]||(t[22]=[S("Add variant")]))),[[B]])]),e("div",Bt,[e("div",Pt,[u(l,{modelValue:b(m),"onUpdate:modelValue":t[5]||(t[5]=s=>et(m)?m.value=s:null),tag:"transition-group","item-key":"id","component-data":{name:"font-face"},"ghost-class":"dragged-placeholder",animation:"200"},{item:w(({element:s})=>[e("div",null,[u(ct,{item:s,preview:n,"font-family":i.value},null,8,["item","preview","font-family"])])]),_:1},8,["modelValue"])])])])])]),e("div",jt,[e("div",null,[e("div",Dt,[t[27]||(t[27]=e("div",{class:"postbox-header"},[e("h2",{class:""},"Publish")],-1)),e("div",Mt,[e("div",Rt,[e("div",qt,[e("div",At,[e("div",Et,[e("div",Lt,[f.value?(x(),M(a,{key:0,icon:"fa6-solid:rocket",class:"h:16 w:16 flex-shrink:0 fg:gray-90"})):(x(),M(a,{key:1,icon:"fa6-solid:rocket",class:"h:16 w:16 flex-shrink:0 fg:gray-40"})),t[24]||(t[24]=e("span",{class:"pl:10 pr:8"},"Status:",-1)),u(b(gt),{as:"div",class:"flex align-items:center"},{default:w(()=>[u(b(pt),{modelValue:f.value,"onUpdate:modelValue":t[6]||(t[6]=s=>f.value=s),class:_([[f.value?"bg:sky-60":"opacity:.5 bg:gray-85"],"rel inline-flex p:0 h:24 w:44 flex-shrink:0 cursor:pointer rounded b:2 b:transparent transition-property:color,background-color,border-color,text-decoration-color,fill,stroke transition-duration:200 transition-timing-function:cubic-bezier(0.4,0,0.2,1) box-shadow:rgb(255,255,255)|0|0|0|2,rgb(14,165,233)|0|0|0|4,rgba(0,0,0,0)|0|0|0|0:focus outline:2|solid|transparent:focus"])},{default:w(()=>[e("span",{class:_([[f.value?"translateX(20)":"translateX(0)"],"pointer-events:none rel inline-block font:12 h:20 w:20 rounded bg:white transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter transition-duration:200 transition-timing-function:cubic-bezier(0.4,0,0.2,1) box-shadow:rgb(255,255,255)|0|0|0|0,rgba(59,130,246,0.5)|0|0|0|0,rgba(0,0,0,0.1)|0|1|3|0,rgba(0,0,0,0.1)|0|1|2|-1"])},[e("span",{"aria-hidden":"true",class:_([[f.value?"opacity:0 transition-timing-function:ease-out transition-duration:100":"opacity:1 transition-timing-function:ease-in transition-duration:200"],"abs inset:0 flex h:full w:full align-items:center justify-content:center tw-transition-opacity"])},[u(a,{icon:"fa6-solid:xmark",class:"fg:gray-60"})],2),e("span",{"aria-hidden":"true",class:_([[f.value?"opacity:1 transition-timing-function:ease-in transition-duration:200":"opacity:0 transition-timing-function:ease-out transition-duration:100"],"abs inset:0 flex h:full w:full align-items:center justify-content:center tw-transition-opacity"])},[u(a,{icon:"fa6-solid:check",class:"fg:sky-60"})],2)],2)]),_:1},8,["modelValue","class"]),u(b(mt),{as:"span",class:_([[f.value?"fg:black":"fg:gray-60"],"ml:8 font:medium tw-cursor-pointer"])},{default:w(()=>[S(D(f.value?"published":"draft"),1)]),_:1},8,["class"])]),_:1})])])]),t[25]||(t[25]=e("div",{class:"clear"},null,-1))]),e("div",Ht,[e("div",It,[e("button",{type:"submit",name:"save",id:"save",disabled:b(V).isBusy,class:"button button-primary button-large",value:"save"},"Save",8,Xt)]),t[26]||(t[26]=e("div",{class:"clear"},null,-1))])])])])]),e("div",null,[e("div",Jt,[t[32]||(t[32]=e("div",{class:"font:semibold font:16 lh:24px"},"Preview :",-1)),e("div",Kt,[t[28]||(t[28]=e("span",{class:"inline-flex align-items:center rl:6 b:1|solid|gray-30/.5 br:0 bg:gray-5 px:12 fg:gray-60 font:12 lh:16px"},"width",-1)),r(e("input",{type:"number","onUpdate:modelValue":t[7]||(t[7]=s=>n.width.current=s),min:n.width.min,max:n.width.max,class:"block min-w:0 w:64 min-h:0 h:24 mx:0 py:0 px:8 r:0 rr:6 b:1|solid|gray-30/.5 font:12 lh:16px"},null,8,Ot),[[p,n.width.current]]),r(e("input",{type:"range","onUpdate:modelValue":t[8]||(t[8]=s=>n.width.current=s),min:n.width.min,max:n.width.max,class:"flex:1|1|0% appearance:none accent:#0050FF h:4 align-self:center"},null,8,Wt),[[p,n.width.current]])]),e("div",Zt,[t[29]||(t[29]=e("span",{class:"inline-flex align-items:center rl:6 b:1|solid|gray-30/.5 br:0 bg:gray-5 px:12 fg:gray-60 font:12 lh:16px"},"weight",-1)),r(e("input",{type:"number","onUpdate:modelValue":t[9]||(t[9]=s=>n.weight.current=s),min:n.weight.min,max:n.weight.max,class:"block min-w:0 w:64 min-h:0 h:24 mx:0 py:0 px:8 r:0 rr:6 b:1|solid|gray-30/.5 font:12 lh:16px"},null,8,Gt),[[p,n.weight.current]]),r(e("input",{type:"range","onUpdate:modelValue":t[10]||(t[10]=s=>n.weight.current=s),min:n.weight.min,max:n.weight.max,class:"flex:1|1|0% appearance:none accent:#0050FF h:4 align-self:center"},null,8,Qt),[[p,n.weight.current]])]),e("div",Yt,[t[31]||(t[31]=e("span",{class:"inline-flex align-items:center rl:6 b:1|solid|gray-30/.5 br:0 bg:gray-5 px:12 fg:gray-60 font:12 lh:16px"},"size",-1)),e("div",te,[r(e("input",{type:"number","onUpdate:modelValue":t[11]||(t[11]=s=>n.fontSize=s),class:"block min-w:0 w:64 min-h:0 h:24 mx:0 py:0 px:8 r:0 rr:6 b:1|solid|gray-30/.5 font:12 lh:16px"},null,512),[[p,n.fontSize]]),t[30]||(t[30]=e("div",{class:"abs top:0 bottom:0 right:0 flex py:4 pr:6"},[e("kbd",{class:"inline-flex align-items:center r:4 b:1|solid|gray-20 px:4 fg:gray-60"},"px")],-1))]),r(e("input",{type:"range","onUpdate:modelValue":t[12]||(t[12]=s=>n.fontSize=s),max:"200",class:"flex:1|1|0% appearance:none accent:#0050FF h:4 align-self:center"},null,512),[[p,n.fontSize]])])])])]),e("div",ee,[u(st,{name:"css-preview"},{default:w(()=>[N.value?(x(),U("div",oe,[t[33]||(t[33]=e("h3",{class:"mt:20"},"CSS Preview",-1)),u(d,{language:"css",code:N.value},null,8,["code"])])):ot("",!0)]),_:1})])],32)])],64)}}};export{fe as default};
