$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback] from "@iosevka/util"

glyph-module

glyph-block Symbol-Arrow-Stacked : for-width-kinds WideWidth1
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Symbol-Arrow-Shared : ArrowDims ArrowT MkArrowT

	define dims : ArrowDims MosaicWidth MosaicWidthScalar
	define Arrow : ArrowT dims
	define MkArrow : MkArrowT dims

	define {
		.arrowWidth arrowWidth
		.arrowTop arrowTop
		.arrowBot arrowBot
		.arrowMidX arrowMidX
		.arrowSB arrowSB
		.arrowRSB arrowRSB
		.arrowSw arrowSw
		.arrowHeadSize arrowHeadSize

		.compactHeadSize compactHeadSize
		.halfArrowSw halfArrowSw
	} dims

	MkArrow.single Arrow.shape [MangleName 'arrowRightCompact']  null arrowSB SymbolMid arrowRSB SymbolMid nothing compactHeadSize
	MkArrow.single Arrow.shape [MangleName 'arrowLeftCompact']   null arrowRSB SymbolMid arrowSB SymbolMid nothing compactHeadSize

	define hcDist : Math.max (halfArrowSw * 5) (arrowWidth / 2)
	define vcDist2  arrowHeadSize
	define vcDist : arrowHeadSize * 1.75

	VCombine [MangleName 'uni21C4'] [MangleUnicode 0x21C4] [MangleName 'arrowRight'] [MangleName 'arrowLeft'] vcDist
	HCombine [MangleName 'uni21C5'] [MangleUnicode 0x21C5] [MangleName 'arrowUp'] [MangleName 'arrowDown'] hcDist
	VCombine [MangleName 'uni21C6'] [MangleUnicode 0x21C6] [MangleName 'arrowLeft'] [MangleName 'arrowRight'] vcDist
	VCombine [MangleName 'uni21C7'] [MangleUnicode 0x21C7] [MangleName 'arrowLeft'] [MangleName 'arrowLeft'] vcDist
	HCombine [MangleName 'uni21C8'] [MangleUnicode 0x21C8] [MangleName 'arrowUp'] [MangleName 'arrowUp'] hcDist
	VCombine [MangleName 'uni21C9'] [MangleUnicode 0x21C9] [MangleName 'arrowRight'] [MangleName 'arrowRight'] vcDist
	HCombine [MangleName 'uni21CA'] [MangleUnicode 0x21CA] [MangleName 'arrowDown'] [MangleName 'arrowDown'] hcDist
	HCombine [MangleName 'uni21F5'] [MangleUnicode 0x21F5] [MangleName 'arrowDown'] [MangleName 'arrowUp'] hcDist
	VCombine [MangleName 'uni21CB'] [MangleUnicode 0x21CB] [MangleName 'arrowLeftHR'] [MangleName 'arrowRightHR'] vcDist2
	VCombine [MangleName 'uni21CC'] [MangleUnicode 0x21CC] [MangleName 'arrowRightHL'] [MangleName 'arrowLeftHL'] vcDist2
	VCombine [MangleName 'uni21B9'] [MangleUnicode 0x21B9] [MangleName 'arrowBarLeft'] [MangleName 'arrowBarRight'] vcDist
	VCombine [MangleName 'uni2962'] [MangleUnicode 0x2962] [MangleName 'arrowLeftHR'] [MangleName 'arrowLeftHL'] vcDist2
	HCombine [MangleName 'uni2963'] [MangleUnicode 0x2963] [MangleName 'arrowUpHL'] [MangleName 'arrowUpHR'] vcDist2
	VCombine [MangleName 'uni2964'] [MangleUnicode 0x2964] [MangleName 'arrowRightHL'] [MangleName 'arrowRightHR'] vcDist2
	HCombine [MangleName 'uni2965'] [MangleUnicode 0x2965] [MangleName 'arrowDownHR'] [MangleName 'arrowDownHL'] vcDist2
	HCombine [MangleName 'uni296E'] [MangleUnicode 0x296E] [MangleName 'arrowUpHL'] [MangleName 'arrowDownHL'] vcDist2
	HCombine [MangleName 'uni296F'] [MangleUnicode 0x296F] [MangleName 'arrowDownHR'] [MangleName 'arrowUpHR'] vcDist2

	VCombine [MangleName 'uni2B80'] [MangleUnicode 0x2B80] [MangleName 'trigArrowLeft'] [MangleName 'trigArrowRight'] vcDist
	HCombine [MangleName 'uni2B81'] [MangleUnicode 0x2B81] [MangleName 'trigArrowUp'] [MangleName 'trigArrowDown'] hcDist
	VCombine [MangleName 'uni2B82'] [MangleUnicode 0x2B82] [MangleName 'trigArrowRight'] [MangleName 'trigArrowLeft'] vcDist
	HCombine [MangleName 'uni2B83'] [MangleUnicode 0x2B83] [MangleName 'trigArrowDown'] [MangleName 'trigArrowUp'] hcDist
	VCombine [MangleName 'uni2B84'] [MangleUnicode 0x2B84] [MangleName 'trigArrowLeft'] [MangleName 'trigArrowLeft'] vcDist
	HCombine [MangleName 'uni2B85'] [MangleUnicode 0x2B85] [MangleName 'trigArrowUp'] [MangleName 'trigArrowUp'] hcDist
	VCombine [MangleName 'uni2B86'] [MangleUnicode 0x2B86] [MangleName 'trigArrowRight'] [MangleName 'trigArrowRight'] vcDist
	HCombine [MangleName 'uni2B87'] [MangleUnicode 0x2B87] [MangleName 'trigArrowDown'] [MangleName 'trigArrowDown'] hcDist
	VCombine [MangleName 'uni2B7E'] [MangleUnicode 0x2B7E] [MangleName 'trigArrowBarLeft'] [MangleName 'trigArrowBarRight'] vcDist
	HCombine [MangleName 'uni2B7F'] [MangleUnicode 0x2B7F] [MangleName 'trigArrowBarDown'] [MangleName 'trigArrowBarUp'] hcDist

	create-glyph [MangleName 'uni21F6'] [MangleUnicode 0x21F6] : glyph-proc
		set-width MosaicWidth
		local distance : compactHeadSize * 2 - arrowSw
		include : with-transform [ApparentTranslate 0 (+distance)] : refer-glyph : MangleName 'arrowRightCompact'
		include : refer-glyph : MangleName 'arrowRightCompact'
		include : with-transform [ApparentTranslate 0 (-distance)] : refer-glyph : MangleName 'arrowRightCompact'
	create-glyph [MangleName 'uni2B31'] [MangleUnicode 0x2B31] : glyph-proc
		set-width MosaicWidth
		local distance : compactHeadSize * 2 - arrowSw
		include : with-transform [ApparentTranslate 0 (+distance)] : refer-glyph : MangleName 'arrowLeftCompact'
		include : refer-glyph : MangleName 'arrowLeftCompact'
		include : with-transform [ApparentTranslate 0 (-distance)] : refer-glyph : MangleName 'arrowLeftCompact'
