function r(p){return Math.ceil(p.length*3/4)}function n(p){const a=[];for(const t of p)switch(t.type){case"text":t.text?.trim()&&a.push({type:"paragraph",content:[{type:"text",text:t.text}]});break;case"image":case"audio":t.data&&t.mimeType&&a.push({type:"paragraph",content:[{type:"file",attrs:{id:crypto.randomUUID(),name:`${t.type}.${t.mimeType.split("/")[1]??"bin"}`,mimeType:t.mimeType,size:r(t.data),data:t.data}}]});break;case"resource":{const e=t.resource;"text"in e&&e.text?a.push({type:"paragraph",content:[{type:"text",text:e.text}]}):"blob"in e&&e.blob&&a.push({type:"paragraph",content:[{type:"file",attrs:{id:crypto.randomUUID(),name:String(e.uri),mimeType:e.mimeType??"application/octet-stream",size:r(e.blob),data:e.blob}}]});break}case"resource_link":a.push({type:"paragraph",content:[{type:"text",text:t.name??t.uri}]});break}return{type:"doc",content:a}}export{n as c};
