{
  "version": 3,
  "sources": ["../../src/attached_to/view.tsx"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { MediaItem } from '../types';\nimport { getRenderedContent } from '../utils/get-rendered-content';\n\nexport default function MediaAttachedToView( {\n\titem,\n}: DataViewRenderFieldProps< MediaItem > ) {\n\t// Store the displayed title in state, as the embedded post may be loaded\n\t// asynchronously. This ensures that the title remains stable after it\n\t// is updated by the user, and while it is re-fetched from the server.\n\tconst [ attachedPostTitle, setAttachedPostTitle ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst parentId = item.post;\n\tconst embeddedPostId = item._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.id;\n\tconst embeddedPostTitle =\n\t\titem._embedded?.[ 'wp:attached-to' ]?.[ 0 ]?.title;\n\n\tuseEffect( () => {\n\t\tif ( !! parentId && parentId === embeddedPostId ) {\n\t\t\tsetAttachedPostTitle(\n\t\t\t\tgetRenderedContent( embeddedPostTitle ) || __( '(no title)' )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! parentId ) {\n\t\t\tsetAttachedPostTitle( __( '(Unattached)' ) );\n\t\t}\n\t}, [ parentId, embeddedPostId, embeddedPostTitle ] );\n\n\treturn <>{ attachedPostTitle }</>;\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoC;AACpC,kBAAmB;AAMnB,kCAAmC;AA6B3B;AA3BO,SAAR,oBAAsC;AAAA,EAC5C;AACD,GAA2C;AAI1C,QAAM,CAAE,mBAAmB,oBAAqB,QAAI,yBAEjD,IAAK;AAER,QAAM,WAAW,KAAK;AACtB,QAAM,iBAAiB,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AACpE,QAAM,oBACL,KAAK,YAAa,gBAAiB,IAAK,CAAE,GAAG;AAE9C,gCAAW,MAAM;AAChB,QAAK,CAAC,CAAE,YAAY,aAAa,gBAAiB;AACjD;AAAA,YACC,gDAAoB,iBAAkB,SAAK,gBAAI,YAAa;AAAA,MAC7D;AAAA,IACD;AAEA,QAAK,CAAE,UAAW;AACjB,+BAAsB,gBAAI,cAAe,CAAE;AAAA,IAC5C;AAAA,EACD,GAAG,CAAE,UAAU,gBAAgB,iBAAkB,CAAE;AAEnD,SAAO,2EAAI,6BAAmB;AAC/B;",
  "names": []
}
